akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef long double ld;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll exp(ll x,ll y){if(y==0) return 1;if(y%2 == 1) return x*exp(x,y/2)*exp(x,y/2);return exp(x,y/2) * exp(x,y/2);}
ll exp(ll x,ll y,ll modd) {if(y==0) return 1;ll t=exp(x,y/2,modd);t = t%modd;t=t*t;t=t%modd;if(y % 2 == 1) return (x*t)%modd ;return t%modd;}
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target ("sse4")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define emp empty()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0ll, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define revn(i,a,b) for(ll i=a;i>=b;--i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vs vector<string>
#define vsi vector<pair<string,int>>
#define vll vector<pair<ll,ll> >
#define vlll vector<pair<ll,pair<ll,ll>>>
#define vlvl vector<pair<pair<ll,ll>,ll>>>
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

ll vis[3005][3005],dp[3005][3005], a[3005];

int n;

ll solve(int i, int j)
{
	if(vis[i][j]!=0)return dp[i][j];
	vis[i][j]=1;
	if(i==j)return dp[i][j] = a[i];
	
	return dp[i][j] = max(a[i] - solve(i+1,j), a[j]-solve(i,j-1));
}

int main()
{
    ios;
    cin>>n;
	
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	memset(vis, 0, sizeof(vis));
	
	cout<<solve(0,n-1);
	return 0;
}

Measured memory_bytes: 141568
n = int(input())
a = list(map(int,input().split()))
dic = {}
ans = 0
for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1
for i in dic:
    x = dic[i]
    ans += x*(x-1)//2
for i in range(n):
    x = a[i]
    y = dic[x]
    print(ans-(y-1))

Measured memory_bytes: 26140
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int gcount=s.size();
    int pcount=0;
    int b=0;
    int ans=0;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i]=='p'){
            pcount++;
        }
    }
    cout << s.size()/2-pcount << "\n";
}


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

int main(){
    int n; cin >> n;
    ll a[n+1],b[n];
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans = 0;
    rep(i,n){
        if(b[i] > a[i]){
            b[i] -= a[i];
            ans += a[i] + min(a[i+1],b[i]);
            a[i] = 0;
            a[i+1] -= min(b[i],a[i+1]);
        }else{
            a[i] -= b[i];
            ans += b[i];
        }
    }
    cout << ans << endl;
}

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

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

int main(void) {
	int n, m, i,c=0;
	cin >> n >> m;
	vector<int> x(m),v(m-1);
	rep(i, m) {
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	rep(i, m - 1) {
		v[i] = x[i + 1] - x[i];
	}
	sort(v.begin(),v.end());

	rep(i, x.size() - n) {
		c += v[i];
	}
	cout << c << endl;
	return 0;
}
























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

int main(){
  string O, E;
  cin >> O >> E;
  for(int i=0;i<E.size();i++){
    cout << O.at(i) <<E.at(i);
  }
  if(O.size()!=E.size()){
    cout << O.at(O.size()-1);
  }
  cout << endl;
}
  


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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int N, M;
    cin >> N;
    vector<pair<int, string>> diagram;
    for(int i = 0; i < N; i++){
        string h, m;
        cin >> h >> m;
        if(m.size() == 1){
            diagram.push_back({stoi(h) * 60 + stoi(m), h + ":0" + m});
        }else{
            diagram.push_back({stoi(h) * 60 + stoi(m), h + ":" + m});
        }
    }
    cin >> M;
    for(int i = 0; i < M; i++){
        string h, m;
        cin >> h >> m;
        if(m.size() == 1){
            diagram.push_back({stoi(h) * 60 + stoi(m), h + ":0" + m});
        }else{
            diagram.push_back({stoi(h) * 60 + stoi(m), h + ":" + m});
        }
    }
    sort(all(diagram));
    diagram.erase(unique(all(diagram)), diagram.end());
    nint_output(all(diagram), [](auto x){ return x.second; });
}



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

const int N=100005;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        string s,t;
        cin>>s>>t;
        int cnt=0;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]!=t[i])
                cnt++;
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3804
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
        public static void main(String[] arg) throws IOException {
                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                String is; 
                String[] ia; 

                while((is = in.readLine()) != null){
                        ia = is.split(" ");
                        int n = Integer.parseInt(ia[0]);
                        int r = Integer.parseInt(ia[1]);
                        LinkedList<Integer> a,b,d;
                        d = new LinkedList<Integer>();
                        for(int i = 0;i < n; ++i){
                                d.addFirst(i);
                        }   
                        ia = in.readLine().split(" ");
                        for(int j = 0;j < r; ++j){
                                int c = Integer.parseInt(ia[j]);
                                a = new LinkedList<Integer>();
                                int x = d.size();
                                for(int i = 0;i < x/2.0; ++i){
                                        a.addLast(d.removeFirst());
                                }   
                                b = d;
                                d = new LinkedList<Integer>();
                                while(a.size() > 0 || b.size() > 0){ 
                                        for(int i = 0;i < c && a.size() > 0; ++i){
                                                d.addFirst(a.removeLast());
                                        }   
                                        for(int i = 0;i < c && b.size() > 0; ++i){
                                                d.addFirst(b.removeLast());
                                        }   
                                }   
                        }   
                        System.out.println(d.getFirst());
                }
        }
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    string s;
    cin >> s;
    int count = 0;
    rep(i, s.size()) {
        if(s[i] != s[s.size()-1-i]) count++;
    }
    cout << count/2 << endl;
    // cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 3616
n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
m = map(int, raw_input().split())
 
def solve(i, m):
    if m == 0:
        return 1
    if i  >= n or m > sum(A):
        return 0
    res = solve(i + 1, m) or solve(i + 1, m - A[i])
    return res
         
for j in range(0, q):
    if solve(0, m[j]):
        print "yes"
    else:
        print "no"

Measured memory_bytes: 6452
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
int a[4545];
signed main(){
	ic(n) ic(m)
	if(n==1){
		c(m)
		return 0;
	}
	int sum=0;
	for(int i=1;i<sqrt(m)+1;i++){
		if(m%i==0){
			a[sum*2]=i;
			a[sum*2+1]=m/i;
			sum++;
		}	
	}
	sort(a,a+sum*2);
	reverse(a,a+sum*2);
	rep(0,i,sum*2){
		if(m%a[i]==0&&m/a[i]>=n){
			c(a[i])
			return 0;
		}
	}		
}			
				

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

int main() {
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> ans;
    if (n % 2) {
        for ( int a = 1, b = n; a < b; a++, b-- ) {
            ans.emplace_back(a, b);
        }
    } else {
        for ( int a = 1, b = n / 2; a < b; a++, b-- ) {
            ans.emplace_back(a, b);
        }
        for ( int a = n / 2 + 1, b = n - 1; a < b; a++, b-- ) {
            ans.emplace_back(a, b);
        }
    }
    for ( int i=0; i<m; i++ ) {
        cout << ans[i].first << ' ' << ans[i].second << '\n';
    }
    return 0;
}

Measured memory_bytes: 4188
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
int main(void){
set<long long> s;
int n,k;
cin>>n>>k;

char kc= '0'+k;
char nc= '0' +n;

string a(n,kc);
string b(k,nc);
if(a<b)
    cout<<a;
else
    cout<<b;
}



Measured memory_bytes: 3104
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    CBoxesAndCandies solver = new CBoxesAndCandies();
    solver.solve(1, in, out);
    out.close();
  }

  static class CBoxesAndCandies {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
    /*
      解法
      a[0],a[1]について,まずa[1]から減らすべきであることは分かっている.
      a[1]でも足りなければさかのぼって減らせばいいことがわかる.
      a b a....みたいな形になっていきそうだけど...
      サンプルはどうだろう
      1   1 6 1 2 0 4なら1,6->1,0にして0,1->1,2(1,0)にして0,4->0,1で6,2,3の11個
      多分問題は無さそう...?
      なんかキラーケースがあるような気がするんだけど…
     */
      int n = in.nextInt();
      int x = in.nextInt();
      int[] a = new int[n];
      long sum = 0;
      for (int i = 0; i < n; i++) {
        a[i] = in.nextInt();
      }
      for (int i = 1; i < n; i++) {
        int niko = a[i] + a[i - 1];
        if (a[i - 1] > x) {
          sum += (niko - x);
          a[i] = 0;
          a[i - 1] = x;
        } else if (niko > x) {
          sum += (niko - x);
          a[i] = x - a[i - 1];
        }
      }
      out.println(sum);

      // マジで直感的だけど通らなさそうな不安にさせるやつヤメロ
      // オーバーフローじゃん、キレました
    }

  }
}



Measured memory_bytes: 52496
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking 
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1<<29)
using namespace std;
const int N=100005;
int a[N],b[N],n,tot;
int sum[N],val[N];
ll ans1,ans2,ans3;
pii q[N*2];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	ans1=0,ans2=0,ans3=0;
	for (int i=1;i<=n;i++) ans1+=a[i],ans2+=b[i];
	for (int i=1;i<=n;i++) q[++tot]=pii(a[i],i),q[++tot]=pii(b[i],-i);
	sort(q+1,q+tot+1); int ok=0;
	for (int i=1;i<=n;i++){
		ok+=(sum[abs(q[i].se)]!=0);
		ans3+=q[i].fi;
		sum[abs(q[i].se)]+=q[i].se;
		val[abs(q[i].se)]=q[i].fi;
	}
	if (!ok){
		int del=1<<30;
		for (int i=n+1;i<=tot;i++)
			del=min(del,q[i].fi-(val[abs(q[i].se)]==q[n].fi?q[n-1].fi:q[n].fi));
		ans3+=del;
	}
	printf("%lld\n",min(min(ans1,ans2),ans3));
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;
typedef long long ll;

int P, Q;
bool p[1000000];
vector<int> v;

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

bool prime(int n) {
  REP(i, 0, v.size()) if(n % v[i] == 0) return false;
  return true;
}

ll solve() {
  ll ans = 1;
  REP(i, 0, v.size()) if(Q % v[i] == 0) {
    ans *= v[i];
    while(Q % v[i] == 0) Q /= v[i];
  }
  if(prime(Q)) ans *= Q;
  return ans;
}

int main(void) {
  REP(i, 0, 1000000) p[i] = true;
  p[0] = p[1] = false;
  REP(i, 0, 1000000) if(p[i]) for(int j = i * 2; j < 1000000; j += i) p[j] = false;
  REP(i, 0, 1000000) if(p[i]) v.push_back(i);

  cin >> P >> Q;
  Q = Q / gcd(P, Q);
  cout << solve() << endl;
  return 0;
}

Measured memory_bytes: 4324
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
	fast;
	ll n,k,val,cnt=0;
	cin>>n>>k;
	int arr[k],snack[n]={0};
	for(int i=0;i<k;i++){
		cin>>arr[i];
		for(int j=0;j<arr[i];j++){
			cin>>val;
			snack[val-1]++;
		}
	}
	for(int i=0;i<n;i++)
		if(snack[i]==0)
			cnt++;
	cout<<cnt;
    return 0;
}

Measured memory_bytes: 3656
n = int(input())

address = list(map(int, input().split()))

sum = []
i_sum = 0


for i in range(100):
    
    for j in range(n):
        i_sum += ((address[j] - (i + 1)) ** 2)

    sum.append(i_sum)
    i_sum = 0

print(min(sum))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int n, ts, ans;
int t[105];
int v[105];
int a[40005], b[40005];

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &t[i]), t[i] *= 2, ts += t[i];
    for(int i = 1; i <= n; i++) scanf("%d", &v[i]), v[i] *= 2;
    int j = 0;
    int to = 0;
    for(int i = 1; i <= n; i++)
    {
        to += t[i];
        a[j] = min(a[j], v[i]);
        for(j = j + 1; j <= to; j++)
        {
            a[j] = min(v[i], a[j-1] + 1);
        }
        j--;
    }
    a[j] = 0;
    for(int i = j - 1; i >= 0; i--)
    {
        a[i] = min(a[i + 1] + 1, a[i]);
        ans += a[i];
    }
    printf("%f", (double)ans / 4);
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        
        int[] a = new int[N];
        int min = 1000;
        int max = 0;
        for(int i=0; i<N; i++){
            a[i] = Integer.parseInt(sc.next());
            min = Math.min(min, a[i]);
            max = Math.max(max, a[i]);
        }
        System.out.println(max - min);
    }
}

Measured memory_bytes: 21716
n = int(input())
b = list(map(int, input().split()))
tmp = 0
for i in range(n-2): 
    if b[i] < b[i+1]:
        tmp += b[i]
    else:
        tmp += b[i+1]
tmp += b[n-2] + b[0]
 
print(tmp)

Measured memory_bytes: 3060
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

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

using namespace std;

typedef long long ll;

int group(int n){
    if(n==2)
        return 2;
    else if(n==4 || n==6 || n==9 || n==11)
        return 1;
    else
        return 0;

}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int W,H,N;
    cin >> W >> H >> N;
    bool rect[110][110];
    repeat(w, W){
        repeat(h, H){
            rect[w][h]=false;
        }
    }
    int x[110],y[110],a[110];
    repeat(i, N){
        cin >> x[i] >> y[i] >> a[i];
        if(a[i]==1){
            for(int w=0;w<x[i];w++){
                repeat(h, H){
                    rect[w][h] |= true;
                }
            }
        }
        else if(a[i]==2){
            for(int w=x[i];w<W;w++){
                repeat(h, H){
                    rect[w][h] |= true;
                }
            }
        }
        else if(a[i]==3){
            repeat(w, W){
                for(int h=0;h<y[i];h++){
                    rect[w][h] |= true;
                }
            }
        }
        else{
            repeat(w, W){
                for(int h=y[i];h<H;h++){
                    rect[w][h] |= true;
                }
            }
        }
    }
    int ans=0;
    repeat(w, W){
        repeat(h, H){
            if(!rect[w][h])
                ans++;
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> v;
	for(int i=0;i<n;i++)
	{
		int cur1; 
		cin>>cur1;
		if(i<n-2)
		{
			int cur2;
			cin>>cur2;
			v.push_back(cur1);
			v.insert(v.begin(),cur2); 
			i++;
		}
		else
		{
			v.push_back(cur1);
			reverse(v.begin(),v.end());
		}
	}
	for(int i=0;i<v.size();i++)
		cout<<v[i]<<' ';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3188
D, G = map(int, input().split()) 
S = [[int(x) for x in input().split()]for i in range(D)]
Minimum_can = []
for i in range(2**D):
    binary = str(format(i,'b'))
    binary_zero = binary.zfill(D)
    SUM = 0
    Number = 0
    for j in range(D):
        if binary_zero[j]=='1':
            SUM += S[j][0]*100*(j+1)+S[j][1]
            Number += S[j][0]
    if SUM >= G: Minimum_can.append(Number)        
    elif SUM < G:
        Biggest_0_number = 0
        for k in range(D):
            if binary_zero[D-k-1]=='0':
                Biggest_0_number = D-k-1
                break
        for k in range(S[Biggest_0_number][0]):
            if SUM+100*(Biggest_0_number+1)*(k+1) >= G:
                Minimum_can.append(Number+k+1)
                break 
print(min(Minimum_can))

Measured memory_bytes: 40816
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;


int main() {
    int a,b,c;
    cin >> a >> b >> c;
    
    if(a - b > c){
        cout << 0 << endl;
    }
    else {
        cout << c - (a - b) << endl;
    }
}


Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
colors = list(map(int, input().split()))
cmap = [(i+1,a) for i,a in enumerate(colors)]
campus=[0]*(h*w)

def printmtrx(campus):
    ts=""
    for idx,i in enumerate(campus):
        if((idx+1)%w==1):
            if idx==0:
                ts += str(i) + " "
            else:
                ts+="\n"+str(i)+" "
        else:
            if (idx+1)%w==0:
                ts += str(i)
            else:
                ts+=str(i)+" "
    print(ts)

def printmtrx2(campus):
    cnt=0
    for i in range(h):
        ts=""
        for j in range(w):
            if not j==0:
                ts+=" "
            ts+=str(campus[cnt])
            cnt+=1
        print(ts)

#print(cmap)
#print(campus)

cnt=cmap[0][1]
idx=0
campusidx=0
direct=0
while cnt:
    #print(campusidx)
    #printmtrx(campus)
    #print("")
    campus[campusidx]=cmap[idx][0]
    cnt-=1
    if(cnt<1):
        idx+=1
        if(idx>=len(cmap)):
            break
        cnt=cmap[idx][1]
    campusidx+=1-2*direct
    if campusidx%w==0 and direct==0:
        campusidx+=w-1
        direct=1
    elif campusidx%w==w-1 and direct==1:
        campusidx+=w+1
        direct=0
printmtrx2(campus)

Measured memory_bytes: 4212
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i=0; i<6; i++){
        if (s[i] == '1')ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
a=[]
xy=[]
for i in range(n):
    tmp=int(input())
    a.append(tmp)
    tmp2=[list(map(int,input().split())) for i in range(tmp)]
    xy.append(tmp2)
bit=2**n
ans=0
# print(a)
for i in range(bit):
    flag=1
    for j in range(n):
        if i&(1<<j)!=0:
            for k in range(a[j]):
                if (i>>xy[j][k][0]-1)&1!=xy[j][k][1]:
                    flag=0
    # print(i,flag)
    if flag==1:
        tmp=0
        for j in range(n):
            if i&(1<<j)!=0:
                tmp+=1
        ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 42604
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  pp=1e9+7; 
double pi=3.141592653589793238;
  
 int main() {
        ff;
        ll n;
        cin>>n;
        ll cnt=0;
        ll s=0;
        for(ll i=1;i<=n;i++){
            for(ll j=1;j<=n && i*j<=n;j++){
                if(n-i*j<=n && n-i*j>0){
                    cnt++;
                }
            }
        }
        cout<<cnt<<endl;
		
    return 0;
}

            
		
        
           
  

Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
using namespace std;

inline int read()
{
    int x=0,f=1; char ch=getchar();
    while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
    while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
#define LL long long


struct matrix{
	bool operator < (const matrix & A) const {
		return a[0][0]<A.a[0][0];
	}
	int a[3][3];
}mat[100010*9];

struct Point{
	bool operator < (const Point & A) const {
		return h<A.h;
	}
	int h,w;
}b[100010];
map<matrix,int>mmp;
map<Point,int>mp;

int d1[9]={0,-1,-2,0,-1,-2,0,-1,-2};
int d2[9]={2,1,0,2,1,0,2,1,0};
int d3[9]={0,0,0,-1,-1,-1,-2,-2,-2};
int d4[9]={2,2,2,1,1,1,0,0,0};
LL ans[10];
int cnt=0;
//inline void calc(int x,int d) {
//	int num=0;
//	++cnt;
//	for (int i=b[x].h+d1[d],x=0; i<=b[x].h+d2[d]; i++,x++)
//		for (int j=b[x].w+d3[d],y=0; j<=b[x].w+d4[d]; j++,y++) {
//			Point t; t.h=i,t.w=j;
//			mat[cnt].a[x][y]=mp[t];
//			if (mp[t]) num++;
//		}
//	if (!mmp[mat[cnt]]) mmp[mat[cnt]]=1,ans[num]++;
//}

int H,W,N;

int dx[9]={-1,-1,-1,0,0,0,1,1,1},dy[9]={-1,0,1,-1,0,1,-1,0,1};
LL matr[10000010];
int main() {
	H=read(),W=read(),N=read();
	for (int i=1; i<=N; i++) {
		b[i].h=read(),b[i].w=read();
		for (int j=0; j<=8; j++) {
			int x=b[i].h+dx[j],y=b[i].w+dy[j];
			if (x<=1 || x>=H || y<=1 || y>=W) continue;
			matr[cnt++]=(LL)x*W+y;
		}
	}
	sort(matr,matr+cnt);
	ans[0]=(LL)(H-3+1)*(W-3+1);
	for (int l=0,r; l<cnt; l=r+1) {
		for (r=l; r+1<cnt && matr[r+1]==matr[l]; r++);
		ans[0]--; ans[r-l+1]++;
	}
	for (int i=0; i<=9; i++) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  cout << min(C,B/A) << endl;
  return 0;
}


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

signed main () {
    int n, m;
    cin >> n >> m;
    vector < int > cnt(n + 1, 0);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        ++cnt[a];
        ++cnt[b];
    }
    bool works = 1;
    for (int i = 0; i <= n; ++i) 
        works = works & !(cnt[i] & 1);
    if (works)
        cout << "YES\n";
    else
        cout << "NO\n";
}


Measured memory_bytes: 640
n, m, x, y = gets.chomp.split(" ").map(&:to_i)
xMax = gets.chomp.split(" ").map(&:to_i).max
yMin = gets.chomp.split(" ").map(&:to_i).min
xy = x < yMin && y >= yMin
isLessThanY = xMax < yMin
if xy && isLessThanY then
    puts "No War"
else
    puts "War"
end

Measured memory_bytes: 1788
import java.util.*;
import java.text.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int a = scn.nextInt(), b = scn.nextInt();
        DecimalFormat df = new DecimalFormat("#.#####");
        System.out.println(a / b + " " + a % b + " " + df.format((double)a / b));
    }
}

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

const int N = 3e4+100;

int n,h;
ll a[N],b[N],dp[N];

int main() {
    ios::sync_with_stdio(0);
    memset(dp,0x3f,sizeof(dp));
    dp[0] = 0;
    cin>>h>>n;
    ll ans = 1e18;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    for(int i=0;i<=h+10;i++) {
        for(int j=1;j<=n;j++) {
            dp[i+a[j]] = min(dp[i+a[j]],dp[i]+b[j]);
            if(i+a[j]>=h) ans = min(ans,dp[i+a[j]]);
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 640
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;

P f(int x){
	int a=x%10;
	int b=0;
	while(x){
		b=x%10;
		x/=10;
	}
	return mp(a,b);
}

map<P,int> freq;

int main(){
	int n;
	cin >> n;
	int num=1;
	ll ans=0;
	rep2(i,n){
		P p=f(i);
		freq[p]++;
	}
	rep2(i,n){
		P p=f(i);
		P q(p.se,p.fi);
		ans+=freq[q];
	}
	cout<<ans<<endl;
	return 0;
}

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


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)
    {
        int p;
        cin >> p;
        p--;
        a[p] = i;
    }
    int ans = 0, cnt = 1;
    a.push_back(-1); //rep(i,n+1) cout << a[i] << " "; cout << endl;
    rep(i,n)
    {
        if(a[i+1] > a[i]) cnt++;
        else
        {
            ans = max(ans, cnt);
            cnt = 1;
        }
    }
    cout << n - ans << endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = k; i < n; i++)
//#define sum(start, end) accumulate(start, end, 0)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

using namespace std;
template <class T = ll> T in() { T _in; cin >> _in; return (_in); }

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

    // 答え：累積和をとる
    ll N = in();
    ll S[200001];
    S[0] = 0;
    S[1] = in();
    REP(i, 2, N+1)
        S[i] = S[i-1] + in();

    // rep(i, N+1)
    //     cout << S[i] << endl;

    sort(S, S+N+1);

    // rep(i, N+1)
    //     cout << S[i] << endl;

    // 同じ数ごとに，2つ選ぶ組み合わせを数える
    ll res = 0;
    rep(i, N+1) {
        ll count = 1;
        REP(j, i+1, N+1) {
            if (S[j] == S[i])
                count++;
            else
                break;
        }

        if(count > 1) { // 組み合わせ数を追加
            res += count * (count - 1) / 2;
            // cout << "P" << i;
        }

        i += count - 1; // 同じところは見なくていい
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>

int main(){
    int i,j,h,w;
    bool flag,FALG,tmp,TMP;

    while(scanf("%d %d",&h,&w)&&(h||w)){
        for(i=1;i<h+1;i++){
            for(j=1;j<w+1;j++){
                if((i+j)%2)
                    putchar('.');
                else
                    putchar('#');

            }
            putchar('\n');
        }
        putchar('\n');
    }
}


Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(void){
	int n, m;

	cin >> n >> m;

	set<int> st1;
	vector<int> st2(0);

	int a, b;
	for (int i = 0; i < m; i++){
		cin >> a >> b;
		if (a == 1)
			st1.insert(b);
		if (b == n)
			st2.push_back(a);
	}

	int ok = 0;
	for (int i = 0; i < st2.size(); i++){
		if (st1.find(st2[i]) != st1.end()){
			ok = 1;
		}

	}

	if (ok)
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 5368
#include <stdio.h>
#include <string.h>
#define N 36

typedef struct {
  char mark;
  int value;
} Card;

void BubbleSort(Card *, int);
void SelectionSort(Card *, int);
void disply(Card *, int);
int isStable(Card *, Card *, int);

int main(){
  Card c1[N+1], c2[N+1];
  int i, n;

  scanf("%d", &n);

//文字列と数字でそれぞれ格納
  for( i = 0 ; i < n ; i++ ){
    scanf(" %c%d", &c1[i].mark, &c1[i].value);
  }

//BubbleSortとSelectionSortで比較するためにもう一つの配列に格納する
  for( i = 0 ; i < n ; i++ ) c2[i] = c1[i];

  BubbleSort(c1, n);
  disply(c1, n);
  //BubbleSortは常に安定なソートとなるため比較不要
  printf("Stable\n");

  SelectionSort(c2, n);
  disply(c2, n);

//c1に安定ソートされた文字列数字が格納されているためそれと比較し、同じでなければNot Stable
  if( isStable(c1, c2, n) == 0 ) {
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  
  return 0;
}
void BubbleSort(Card c1[], int n)
{
  int i, j;
  Card t;

  for( i = 0 ; i < n ; i++ ){
    for( j = n-1 ; j > i ; j-- ){
      if( c1[j].value < c1[j-1].value ){
        t = c1[j];
        c1[j] = c1[j-1];
        c1[j-1] = t;
      }
    }
  }
}

void SelectionSort(Card c2[], int n)
{
  int i, j, minj;
  Card t;

 for( i = 0 ; i < n ; i++ ){
    minj = i;
    for( j = i ; j < n ; j++ ){
      if( c2[j].value < c2[minj].value ) minj = j;
    }
    t = c2[i];
    c2[i] = c2[minj];
    c2[minj] = t;
  }
}

void disply(Card c[], int n)
{
  int i;

  for( i = 0 ; i < n ; i++ ){
    if( i > 0 ) printf(" ");
    printf("%c%d", c[i].mark, c[i].value);
  }
  printf("\n");
}

int isStable(Card c1[], Card c2[], int n){
  int i;

  for( i = 0 ; i < n ; i++ )
  if( c1[i].mark != c2[i].mark ) return 1;

  return 0;
}




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

int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main(void){
     long int n,i,c=0,k=0,j,m[100100]={0};
    long long int a[100090];

   scanf("%ld",&n);

    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }

    qsort(a, n, sizeof(long long int), cmpfunc);

    a[n]=-5;

    for(i=0;i<n;i++){
        if(a[i]==a[i+1]){
            m[k]++;
        }
        else{
            k++;
        }
    }

    for(i=0;i<k;i++){
        if(m[i]%2==0){c++;}
        else if(k==n){c=k;break;}
    }

    printf("%ld",c);

    return 0;
}

Measured memory_bytes: 3888
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    ll n,a,b; cin >> n >> a >> b;
    ll z=a+b;
    ll x=n/z; /*the number of set */
    ll y=x*z;
    ll ans=a*x; 
    cout << ans+min(n-y,a) <<endl;
    return 0;
}

Measured memory_bytes: 256
#Aの入力

D=int(input())

c = list(map(int, input().split()))

s = []#Dx26の行列
for i in range(D):
    s += [list(map(int, input().split()))]

t = [int(input()) for i in range(D)]#Aの出力 (コンテスト名　0~25) len = D

last = [0 for i in range(len(c))]#最後に行われた日

value = 0

v = []#len = 26

for i in range(D):
    value += s[i][t[i]-1]
    last[t[i]-1] = i+1
    for j in range(26):
        value -= c[j]*(i+1 - last[j])
    v += [value] 


#Bの出力
for i in range(D):
    print(v[i])

Measured memory_bytes: 9504
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int a[N] , n;

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


Measured memory_bytes: 640
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

int main(){
    int n;
    cin >> n;
    ll a[n];
    ll X = 0;
    for(int i=0;i<n;++i){
        cin >> a[i];
        X ^= a[i];
    }
    for(int i=0;i<n;++i){
        cout << (X^a[i]) << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string s;
    cin>>s;
    int sz=(int)s.size()-2;
    cout<<s[0]<<sz<<s[s.size()-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, A, B;
    cin >> N >> A >> B;

    if (A + B >= N) {
        cout << min(A, B)  << " " << A + B - N << endl;
    }
    else {
        cout << min(A, B)  << " " << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdint>
#include <algorithm>
#include <cmath>
using namespace std;

#define N 3000

int n;
int a[N];

int main() {
	int ans = 0;

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

	for( int i = 0; i < n; i++ ) {
		ans += a[i] - 1;
	}

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


Measured memory_bytes: 256
import Control.Applicative

main = do hws <- (map read) . (concatMap words) . lines <$> getContents
          putStr . unlines $ map unlines (solve hws)

solve :: [Int] -> [[String]]
solve (h:w:res) | h == 0 && w == 0 = []
                | otherwise = makeFrame h w : solve res

makeFrame :: Int -> Int -> [String]
makeFrame h w = sand fr . replicate (h-2) . concat . sand "#" $ replicate (w-2) "."
                where fr = concat $ replicate w "#"

sand :: a -> [a] -> [a]
sand ele xs = reverse ( ele : (reverse $ ele : xs)) 

Measured memory_bytes: 4412
from math import ceil


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    ng = 0
    ok = a[-1]
    while ok - ng > 1:
        mid = (ok + ng) // 2
        cnt = 0
        for i in range(n):
            cnt += (a[i] - 1) // mid
        if cnt <= k:
            ok = mid
        else:
            ng = mid
    print(ceil(ok) if k > 0 else a[-1])


if __name__ == '__main__':
    main()



Measured memory_bytes: 31056
#include <bits/stdc++.h>
using namespace std;
string s;
char a;
int n,cnt;
int main(){
	cin>>n>>s;
	a=s[0];
	for(int i=1;i<n;i++){
		if(s[i]!=a){
			cnt++;
			a=s[i];
		}
	}
	cout<<cnt+1<<endl;
	return 0;
}

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

int n, m, k;
vector<int> G[100000];
vector<int> H[100000];
bool used[100000];
int ans[100000];

void rec(int from, set<int>& st){
  if (used[from]) return;
  used[from] = true;
  st.insert(from);
  for (int to : G[from]) {
    rec(to, st);
  }
}

int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 0; i < k; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    H[a].push_back(b);
    H[b].push_back(a);
  }
  
  for (int i = 0; i < n; ++i) {
    if (used[i]) continue;
    set<int> st;
    rec(i, st);
    
    for (int from : st) {
      ans[from] = (int)st.size() - 1;
      for (int to : G[from]) {
        if (st.count(to)) {
          --ans[from];
        }
      }
      for (int to : H[from]) {
        if (st.count(to)) {
          --ans[from];
        }
      }
    }
  }
  
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << ' ';
  }
  cout << endl;
  
}


Measured memory_bytes: 17016
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
#define int long long
const int INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (int i = (int)((b)-1); i >= (int)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T>
inline void chmax(T &a, const T &b) {
    if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
    if ((a) > (b)) (a) = (b);
}

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x)    \
    sort(all(x)); \
    x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, int> pii;
typedef tuple<int, int, int> iii;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
    }
} fast;
void check_input() {
    assert(cin.eof() == 0);
    int tmp;
    cin >> tmp;
    assert(cin.eof() == 1);
}

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"

signed main() {
    //input
    string s;cin>>s;
    check_input();

    //solve
    cout << (s=="ABC" ? "ARC" : "ABC") << endl;

    return 0; 
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
     
int main() {
    string B;
    cin >> B;
    if(B=="A"){
      cout << "T" << endl;
    }
    else if (B=="T"){
      cout << "A" << endl;
    }
    else if (B=="G"){
      cout << "C" << endl;
    }    
    else {
      cout << "G" << endl;
    }  
}

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


int main() {
  int k, x;
  cin >> k >> x;
  for(int i = x - k + 1; i < x + k; i++){
    cout << i << " ";
  }
  return 0;
}

Measured memory_bytes: 3660