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

using namespace std;
char s[21][21];
int u[21][21];
int ans = 0;

void bfs(int i , int j) {
    u[i][j] = 0;
    queue<pair<int , int> > q;
    q.push({i , j});
    while(q.size() > 0) {
        int x = q.front().first , y = q.front().second;
        q.pop();
        ans = max(ans , u[x][y]);
        if(s[x + 1][y] == '.' && u[x + 1][y] > u[x][y] + 1) {
            q.push({x + 1 , y});
            u[x+1][y] = u[x][y] + 1;
        }
        if(s[x - 1][y] == '.' && u[x - 1][y] > u[x][y] + 1) {
            q.push({x - 1 , y});
            u[x-1][y] = u[x][y] + 1;
        }
        if(s[x][y+1] == '.' && u[x][y+1] > u[x][y] + 1) {
            q.push({x , y+1});
            u[x][y+1] = u[x][y] + 1;
        }
        if(s[x][y-1] == '.' && u[x][y-1] > u[x][y] + 1) {
            q.push({x , y-1});
            u[x][y-1] = u[x][y] + 1;
        }
    }
}

int main()
{
    int h,w;
    cin >> h >> w;
    for(int i = 1; i <= h; i ++) {
        for(int j = 1; j <= w; j ++) {
            cin >> s[i][j];
        }
    }

    for(int i = 1; i <= h; i ++) {
        for(int j = 1; j <= w; j ++) {
            if(s[i][j] == '.') {
                for(int ii = 1; ii <= h; ii ++) {
                    for(int jj = 1; jj <= w; jj ++) {
                        u[ii][jj] = 1e9;
                    }
                }
                bfs(i,j);
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int a,h,w,d,y[90001],x[90001],s[90001];
int main() {
	cin >> h >> w >> d;
	REP(i,h) REP(j,w) {
    cin >> a;
    y[a]=i,x[a]=j;
  }
	for(int i=d+1;i<=h*w;i++)
		s[i] = s[i-d] + abs(x[i-d]-x[i]) + abs(y[i-d]-y[i]);
	cin >> d;
	REP(i,d){
    int l,r;
		cin >> l >> r;
		cout << s[r]-s[l] << endl;
	}

  return 0;
}

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

int main() {
  int R,G; cin >>R >>G;
  int ans=2*G-R;
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 256
N_MAX = 10**6
MOD = 10**9 + 7
fac, finv, inv = [0]*N_MAX ,[0]*N_MAX, [0]*N_MAX
def com_init():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, N_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

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


n,k = map(int, input().split())
al = list(map(int, input().split()))
com_init()
al.sort()

ans_max = 0
ans_min = 0
for i,a in enumerate(al):
    ans_max += a*com(i,k-1)
    ans_max%=MOD
    ans_min += a*com(n-1-i,k-1)
    ans_min%=MOD


print((ans_max-ans_min)%MOD)

Measured memory_bytes: 109976
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
//#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


//namespace mp = boost::multiprecision;

//using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int size(int n) {
	int count = 0;
	while (n > 0) {
		n /= 10;
		count++;
	}
	return count;
}

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}
int main() {
	int N, M;
	cin >> N >> M;
	int ma = 1e9;
	map<int,int>Y_Cnt;
	vector<pair<int, int>>Pref_Year(M);
	vector<pair<int, int>>PYC(M);

	rep(i, M) {
		cin >> Pref_Year[i].first >> Pref_Year[i].second;
	}
	PYC = Pref_Year;
	sort(all(Pref_Year), ps3);

	vector<int>cnt(N+1);
	FOR(i,0 ,M) {
		cnt[Pref_Year[i].F]++;
		Y_Cnt[Pref_Year[i].S] = cnt[Pref_Year[i].F];
	}

	rep(i, M) {
		int sizep = size(PYC[i].F);
		int sizea = size(Y_Cnt[PYC[i].S]);
		rep(i, 6 - sizep) {
			printf("0");
		}
		printf("%d", PYC[i].F);
		rep(i, 6 - sizea) {
		printf("0");
		}
		printf("%d\n", Y_Cnt[PYC[i].S]);

	}




}


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

int h, w, d;
char s[] = { 'R', 'Y', 'G', 'B' }, c[500][500];

int main() {
	cin >> h >> w >> d;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int y = i + j;
			int x = i - j + (h + w);
			int color = y / d % 2 * 2 + x / d % 2;
			c[i][j] = s[color];
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << c[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 768
S = list(input())
ans = [0]*len(S)

i = 0
while i < len(S):
    Rcount=0
    while S[i]=="R":
        Rcount += 1
        i += 1
    ans[i]+=Rcount//2
    ans[i-1]+=Rcount//2+Rcount%2

    terminal = i
    Lcount=0
    while i < len(S) and S[i]=="L":
        Lcount+=1
        i += 1
    ans[terminal]+=Lcount//2+Lcount%2
    ans[terminal-1]+=Lcount//2

print(" ".join(map(str,ans)))


Measured memory_bytes: 11180
from itertools import permutations

n = int(input())
v = [list(map(int,input().split())) for i in range(n)]
ans = 0
c = 0
for p in permutations(range(n)):
    c += 1
    arr = [i for i in p]
    for i in range(n-1):
        ans += ((v[arr[i]][0]-v[arr[i+1]][0])**2 + (v[arr[i]][1]-v[arr[i+1]][1])**2)**0.5
ans /= c
print(ans)

Measured memory_bytes: 74504
#include <stdio.h>

int main() {
	int i, N, M, L, R, l = 0, r = 9999999;

	scanf("%d %d", &N, &M);

	for (i = 0; i < M; i++) {
		scanf("%d %d", &L, &R);
		if (L > l) l = L;
		if (R < r) r = R;
	}

	printf("%d\n", r - l >= 0 ? r - l + 1 : 0);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
using namespace std;
int n;
int a[100001];
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	int maxi=0;
	for(int i=1; i<=n ;i++){
		cin >> a[i];
		maxi=max(maxi,a[i]);
	}
	int max2=0;
	for(int i=1; i<=n ;i++){
		if(abs(a[i]*2-maxi)<abs(max2*2-maxi)) max2=a[i];
	}
	cout << maxi << ' ' << max2 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m%MOD*COM(m-1,n)%MOD*modinv(m-n,MOD)%MOD;
}
 

int main()
{
  string s;
  cin >> s;
  if(s.length()==2)cout << s;
  else cout << s[2] << s[1] << s[0];
}

Measured memory_bytes: 256
package main

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

func main() {
	H, W, N := ReadInt(), ReadInt(), ReadInt()
	if H < W {
		H = W
	}
	fmt.Println((N + H - 1) / H)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

using ll = long long;
const ll mod = 998244353;


ll dp[3030][3030][3];
int a[3030];
int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0;i<n;i++)cin >> a[i];
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
            (dp[i+1][j][0] += dp[i][j][0]) %= mod;
            (dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
            (dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]) %= mod;
            if(j + a[i] <= k){
                (dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]) %= mod;
                (dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]) %= mod;
            }
        }
    }
    cout << dp[n][k][2] << endl;
}

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

ll n, k;
ll a[200005];
vector<ll> pos, neg, zero;

ll numneg(ll x) {
	ll ret = 0;
	for(ll p1 = 0; p1 < pos.size(); p1++) {
		ll l = 0, r = neg.size();
		while(l < r) {
			ll mid = (l+r)/2;
			if(pos[p1] * neg[mid] <= x) l = mid+1;
			else r = mid;
		}
		ret += l;
	}
	return ret;
}

ll numpos(ll x) {
	ll ret = 0;
	for(ll p1 = 0; p1 < (int)pos.size()-1; p1++) {
		ll l = p1+1, r = pos.size();
		while(l < r) {
			ll mid = (l+r)/2;
			if(pos[p1] * pos[mid] <= x) l = mid+1;
			else r = mid;
		}
		ret += l-p1-1;
	}

	for(ll p2 = 0; p2 < (int)neg.size()-1; p2++) {
		ll l = p2+1, r = neg.size();
		while(l < r) {
			ll mid = (l+r)/2;
			if(neg[p2] * neg[mid] <= x) l = mid+1;
			else r = mid;
		}
		ret += l-p2-1;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++) {
		ll x; cin >> x;
		if(x < 0) neg.push_back(x);
		else if(x == 0) zero.push_back(x);
		else pos.push_back(x);
	}

	sort(pos.begin(), pos.end());

	ll cntneg = 1ll * neg.size() * pos.size();
	ll cntzero = 1ll * zero.size() * (n-1+n-zero.size()) / 2;

	ll ans;
	if(k <= cntneg) {
		//ans is neg
		sort(neg.begin(), neg.end());
		ll l = -1e18, r = -1;
		while(l < r) {
			ll mid = (l+r)/2;
			if(numneg(mid) >= k) r = mid-1;
			else l = mid;
		}
		ans = l+1;
	} else if(k <= cntneg + cntzero) {
		ans = 0;
	} else {
		//ans is pos
		k -= cntneg;
		k -= cntzero;
		sort(neg.begin(), neg.end(), greater<ll>());
		ll l = 1, r = 1e18;
		while(l < r) {
			ll mid = (l+r)/2;
			if(numpos(mid) < k) l = mid+1;
			else r = mid;
		}
		ans = l;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 2548
N=int(input())
S=list(map(int,input().split()))
Q=int(input())
T=list(map(int,input().split()))
ans=0
for t in T:
    L,U=-1,N
    while U-L>1:
        mid=(L+U)//2
        if S[mid]>=t:
            U=mid
        else:
            L=mid
    if S[U]==t:
        ans+=1
print(ans)


Measured memory_bytes: 16708
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<cassert>
#include<set>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(c)   (c).begin(),(c).end()
#define pb push_back

typedef long long ll;

bool vis[10][10];
char m[10][10];
int check[10][10];

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

bool isout(int ney,int nex,int r,int c){
  return nex==-1||ney==-1||nex==c||ney==r;
}

bool isok(int y,int x,int r,int c){
  int all=0,cnt=0;
  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (isout(ney,nex,r,c))continue;
    all++;
    if (m[ney][nex] == '0')cnt++;
  }
  if (cnt <= 1)return false;
  return true;
}

bool vis2[10][10];
void canvisitall(int r,int c,int y,int x,
		 int &tmp){
  if (vis2[y][x])return;
  //  cout << y <<" "  << x << endl;
  vis2[y][x]=true;
  tmp--;
  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (isout(ney,nex,r,c)||
	m[ney][nex] == '1')continue;
    canvisitall(r,c,ney,nex,tmp);
  }
}

ll geta(int r,int c){
  ll ret=0;
  rep(i,r){
    rep(j,c)ret=ret*2+vis[i][j];
  }
  return ret;
}

set<ll> S;
int ini;
bool search(int r,int c,int y,int x,int cnt,
	    int sy,int sx,int py,int px){
  if (cnt==0){
    /*
    if (x==sx && y == sy){
      rep(i,r){
	rep(j,c){
	  if (m[i][j] == '1')cout << -1 <<" ";
	  else cout<<check[i][j] <<" ";
	}
	cout << endl;
      }
    }
    */
    return x==sx && y == sy;
  }
  if (vis[y][x])return false;
  check[y][x]=cnt;

  int tmp=cnt+1;
  rep(i,r)rep(j,c)vis2[i][j]=vis[i][j];
  vis2[sy][sx]=false;

  canvisitall(r,c,y,x,tmp);
  if ((x!=sx||y!=sy) && tmp != 0){
    return false;
  }

  vis[y][x]=true;

  ll tmp2=geta(r,c);
  if (S.find(tmp2) != S.end()){
    vis[y][x]=false;
    return false;
  }
  S.insert(tmp2);



  rep(i,4){
    int nex=x+dx[i],ney=y+dy[i];
    if (isout(ney,nex,r,c)||
	m[ney][nex] == '1')continue;
    if (nex == px && ney == py)continue;
    if (search(r,c,ney,nex,cnt-1,sy,sx,y,x))return true;
  }
  vis[y][x]=false;
  return false;
}

main(){
  int r,c;
  while(cin>>c>>r && r){
    S.clear();
    int sx=0,sy=0;
    int cnt=0;
    bool haveans=true;
    rep(i,r){
      rep(j,c){
	cin>>m[i][j];
	if (m[i][j] == '0')sx=j,sy=i,cnt++;
	vis[i][j]=false;
      }
    }

    rep(i,r){
      rep(j,c){
	//if (m[i][j]=='0'&&!isok(i,j,r,c))haveans=false;
      }
    }

    if (r==7 && c==7 && cnt == 49){
      //haveans=false;
      //cout <<"Yes"<<endl;
      //continue;
    }
    ini=cnt;
    if (ini == 1||ini == 0){
      //cout <<"Yes" << endl;
      cout <<"No" << endl;
      continue;
    }
    if (ini > 1 && haveans && search(r,c,sy,sx,cnt,sy,sx,-1,-1))
      cout << "Yes" << endl;
    else cout <<"No" << endl;
  }
  return false;
}

Measured memory_bytes: 16000
import sys
import bisect
input = sys.stdin.readline

def main():
    n, q = map(int, input().split())
    a = list(map(int, input().split()))
    
    s = [0]*(n+1)
    odd = [0]*(n+1)
    even = [0]*(n+1)
    for i in range(n):
        s[i+1] += s[i]+a[i]
        odd[i+1] += odd[i]
        even[i+1] += even[i]
        if i%2:
            odd[i+1] += a[i]
        else:
            even[i+1] += a[i]
    
    key = []
    value = dict()
    v = 0
    for i in range(n):
        if i == n-1:
            k = pow(10, 9)
            key.append(k)
            value[k] = v
            continue
            
        k = (a[i+(n-i)//2]+a[i])//2
        v = s[i+(n-i)//2]-s[i]
        if (n-i)%2:
            if i%2:
                v += even[max(0, i)]
            else:
                v += odd[max(0, i)]
        else:
            if i%2:
                v += odd[max(0, i-1)]
            else:
                v += even[max(0, i-1)]
        
        key.append(k)
        value[k] = v
    
    sum_a = s[n]
    
    for i in range(q):
        x = int(input())
        k = key[bisect.bisect_left(key, x)]
        ans = sum_a-value[k]
        print(ans)
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 109088
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#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> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int H, W, K;
int num;
vector<string> b;
vector<vector<int>> s;
vector<vector<int>> a;

int getcount(int h1, int h2, int w1, int w2)
{
	return s[h2][w2] - s[h1][w2] - s[h2][w1] + s[h1][w1];
}

void rec(int h1, int h2, int w1, int w2, int cnt)
{
	//苺が1つしかない場合はこれ以上分割しない
	if (cnt == 1)
	{
		num++;

		repl(i, h1, h2)
		{
			repl(j, w1, w2)
			{
				a[i][j] = num;
			}
		}

		return;
	}

	//横方向にスライス
	repl(i, h1, h2)
	{
		int cnt1 = getcount(h1, i + 1, w1, w2);

		if (cnt1 == 0) continue;

		int rem = cnt - cnt1;

		//下半分に苺がない場合は分割不可。
		if (rem <= 0) break;

		//上半分
		rec(h1, i + 1, w1, w2, cnt1);

		//下半分
		rec(i + 1, h2, w1, w2, rem);

		return;
	}

	//縦方向にスライス
	//横方向にスライスできない場合は、こちらは必ずできる。
	repl(i, w1, w2)
	{
		int cnt1 = getcount(h1, h2, w1, i + 1);

		if (cnt1 == 0) continue;

		int rem = cnt - cnt1;

		//下半分に苺がない場合は分割不可。
		if (rem <= 0) break;

		//左半分
		rec(h1, h2, w1, i + 1, cnt1);

		//左半分
		rec(h1, h2, i + 1, w2, rem);

		return;
	}

	return;
}

int main()
{
	cin >> H >> W >> K;

	num = 0;

	b.resize(H);
	rep(i, H) cin >> b[i];

	a.resize(H, vector<int>(W));

	//2次元累積和で苺の数を管理
	s.resize(H + 1, vector<int>(W + 1, 0));

	rep(i, H)
	{
		rep(j, W)
		{
			s[i + 1][j + 1] = s[i][j + 1] + s[i + 1][j] - s[i][j];
			if (b[i][j] == '#') s[i + 1][j + 1]++;
		}
	}

	//再帰
	rec(0, H, 0, W, K);

	rep(i, H)
	{
		rep(j, W)
		{
			cout << a[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}

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

int main() {
  string X, Y;
  cin >> X >> Y;
  if (X < Y) {
    cout << "<" << endl;
  } else if (X > Y) {
    cout << ">" << endl;
  } else {
    cout << "=" << endl;
  }
}


Measured memory_bytes: 256
import itertools
n = input()
if len(n) <= 2:
    print(0)
    exit()
#n = str(n)[len(n)-3:]
#print(n)
k = int(n[:len(n)-2])
l = int(n[len(n)-2:])
#print(k,l)
if l <= 5*k:
    print(1)
else:
    print(0)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

struct St{
    int num,arrived;
};


int main(){
    int n;
    cin >> n;
    St data[n];
    for(int i = 0; i < n; i++){
        St tmp;
        tmp.num = i + 1;
        scanf("%d",&tmp.arrived);
        data[i] = tmp;
    }


    sort(data,data+SIZE_OF_ARRAY(data),[](const St& x, const St&y){return x.arrived < y.arrived;});

    
    for(int i = 0; i < n; i++){
        printf("%d ",data[i].num);
    }

}


Measured memory_bytes: 1536
import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    String t = sc.next();
    int count = 0;
    sc.close();
    
	for (int i=0; i<s.length(); i++) {
	  if (s.charAt(i) !=  t.charAt(i))
	    count++;
	}
    
    System.out.println(count);
  }
}

Measured memory_bytes: 41224
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;

int D, G;
int p[11], c[11];

//戻り値はGをこえるのにひつような最小の問題数
//index
int solve(int index, int score, bool incomp)
{
    if (score >= G)
    {
        return 0;
    }
    else if (index == D)
    {
        //どうがんばっても無理だった時
        return INF;
    }
    else
    {
        //indexをすべて説くか、中途半端に説くか、まったく解かないかの三種類
        //すでに中途半端に説かれた奴がある->まったくとかないか、すべてとくか
        if (incomp)
        {
            return min(p[index] + solve(index + 1, (index + 1) * p[index] * 100 + c[index] + score, incomp),
                       solve(index + 1, score, incomp));
        }
        else
        {
            int minimum = min(p[index] + solve(index + 1, (index + 1) * p[index] * 100 + c[index] + score, incomp),
                              solve(index + 1, score, incomp));
            int tmp;
            for (int i = 1; i < p[index]; i++)
            {
                tmp = i + solve(index + 1, (index + 1) * i * 100 + score, true);
                if (tmp < minimum)
                    minimum = tmp;
            }
            return minimum;
        }
    }
}

int main()
{
    cin >> D >> G;
    for (int i = 0; i < D; i++)
    {
        cin >> p[i] >> c[i];
    }
    cout << solve(0, 0, false) << endl;
}

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

int main() {

	string s;
	int N;
    cin >> N;
	vector<string> titles(N);
	vector<int> times(N);
	for(int i=0;i<N;i++){
		cin >> s;
		titles.at(i) = s;
		cin >> times.at(i);
	}
	string x;
	cin >> x;
	int total = 0;
	bool start = false;
	for(int i=0;i<N;i++){
		if (start){
			total += times.at(i);
		}
		if (x == titles.at(i)){
			start = true;
		}
	}
	cout << total << endl;
	return 0;
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

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

    return gcd(b, a%b);
}

const ll L = 10+5;

ll pts[L][L];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N, D;
    cin >> N >> D;

    for(ll i=0; i<N; i++)
    {
        for(ll j=0; j<D; j++)
        {
            cin >> pts[i][j];
        }
    }

    ll ans = 0;

    for(ll i=0; i<N; i++)
    {
        for(ll j=i+1; j<N; j++)
        {
            ll dis = 0;

            for(ll k=0; k<D; k++)
            {
                dis+=((pts[i][k]-pts[j][k])*(pts[i][k]-pts[j][k]));
            }

            ll root = sqrt(dis);

            if(root*root == dis)
            {
                ans++;
            }
        }
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int l=1,r=n;
	while(l<=r)
	{
		int mid=l+r>>1;
		if(a[mid]<n-mid+1)l=mid+1;
		else r=mid-1;
	}
	int j=l-1;
	while(n-l+1==a[j])j--;
	j++;
	if(j!=l)
	{
		if(l-j&1)
		{
			printf("First\n");
			return 0;
		}
	}
	if(a[l]-(n-l+1)&1)printf("First\n");
	else printf("Second\n");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define Rep(i, N) for(int i = 0; i < N; i++)
#define pb push_back
#define LLINF 1LL << 60
#define INF 1 << 28
#define F first
#define S second
typedef pair<int, int> Pi;
typedef vector<int> vint;

inline void chmax(int &a, int b) { a = max(a, b); }
inline void chmin(int &a, int b) { a = min(a, b); }

int N, M;
int val[100005];
int A, B, X;
vint bs, D;
int dfs(int v) {
  if(v < N) {
    if(val[v] == LLINF) {
      return 1;
    } else {
      if(val[v] >= X) return 0;
      else return LLINF;
    }
  }
  
  vint s; 
  int maxv = 0;
  for(int i = (v - N) * 3; i < (v - N) * 3 + 3; i++) s.pb(dfs(i));
  Rep(i, 3) chmax(maxv, s[i]);
  return min(accumulate(s.begin(), s.end(), (int)0) - maxv , LLINF);
}
  

signed main()
{
  
  cin >> N >> M;
  fill_n(val, 100005, LLINF);
  
  Rep(i, M) {
    cin >> A >> B; B--;
    val[B] = A;
    bs.pb(A);
  }

  Rep(i, N - M) {
    cin >> A;
    bs.pb(A); D.pb(A);
  }
  
  sort(bs.begin(), bs.end());

  int l = 0, r = N;
  while(l + 1 < r) {
    int m = (l + r) / 2;
    int cnt = 0; X = bs[m];
    Rep(i, D.size()) if(D[i] >= X) cnt++;
    if(dfs(N + N / 2 - 1) <= cnt) l = m;
    else r = m;
  }

  cout << bs[l] << endl;
  return 0;
}

Measured memory_bytes: 5596
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define pf push_front
#define popf pop_front
#define popb pop_back
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"

#define mem(a,n) memset(a, n, sizeof(a)); // n = 0 OR -1 only

#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define MOD 1000000007
#define MOD2 998244353

using namespace std;


int main()
{
  ll n,x;
  cin >> n >> x;
  
  ll *a = new ll[n];
  for01(0,n)
    cin >> a[i];
  
  ll ct = 0;
  for(ll i = 1; i < n; i++)
  {
    //cout << "\n*****" << i << "****\n" ;
    if(a[i] + a[i-1] <= x)
      continue;
    else
    {
      ll sub = -x + (a[i] + a[i-1]);
      if(a[i] >= sub)
        a[i] -= sub;
      else
      {
        a[i] = 0;
        a[i - 1] -= sub - a[i - 1];
      }
      ct += sub;
    }
  }
    p1(ct);
    
  
       
  return 0;
}

Measured memory_bytes: 1024
type bs_tree = Nil | Node of node and
     node = {
         key:int;
         mutable left:bs_tree;
         mutable right:bs_tree
       };;

let new_node key = {key=key;left=Nil;right=Nil};;

let insert t z =
  let rec loop y = function
      Nil -> y
    | Node x ->
       if z.key < x.key then
         loop (Node x) (x.left)
       else
         loop (Node x) (x.right)
  in
  let y = loop t t in
  match y with
    Nil -> (Node z)
  | Node y ->
     if z.key < y.key then
       y.left <- (Node z)
     else
       y.right <- (Node z)
    ;t
;;

let rec print_in = function
    Nil -> ()
  | Node x ->
     print_in (x.left);
     print_string " ";print_int  x.key;
     print_in (x.right)
;;

let rec print_pre = function
    Nil -> ()
  | Node x ->
     print_string " ";print_int x.key;
     print_pre (x.left);print_pre (x.right)
;;

let () =
  let n = read_int () in
  let rec read t = function
      0 -> ()
    | i ->
       let com = Scanf.scanf "%s" (fun x -> x) in
       if com = "insert" then begin
           let arg = Scanf.scanf " %d\n" (fun x -> x) in
           let z = new_node arg in
           read (insert t z) (i-1)
         end
       else if com = "print" then begin
           let _ = Scanf.scanf "%s\n" (fun x -> x) in
           print_in t;print_newline ();
           print_pre t;print_newline ();
           read t (i-1)
         end
       else ()
  in read Nil n
;;

Measured memory_bytes: 28136
def resolve():
    from collections import deque
    S = "abcdefghijklmnopqrstuvwxyz"
    N = int(input())
    A = deque()
    while True:
        N -= 1
        N, a = divmod(N, 26)
        A.appendleft(a)
        if N == 0:
            break
    for a in A:
        print(S[a], end="")
    print()


resolve()


Measured memory_bytes: 9468
s = int(input())

a = [0,s]
for n in range(2,10**6+1):
  if a[n-1] % 2 == 0:
    an = a[n-1] // 2
  else:
    an = a[n-1] * 3 + 1
  
  if an in a:
    m = n
    break
  
  a.append(an)
  
print(m)

Measured memory_bytes: 9184
def make_divisors(n):
    from collections import deque
    divisors = deque([])
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    lst_divisors = list(divisors)
    lst_divisors.sort()
    return lst_divisors

a, b = map(int,input().split())

ya = set(make_divisors(a))
yb = set(make_divisors(b))

cand = list(ya&yb)
cand.sort()

#print(cand)

ans = []
if len(cand) > 1:
    for n in cand[1:]:
        if ans:
            for n in cand[1:]:
                for waru in ans:
                    if n%waru == 0:
                        break
                else:
                    ans.append(n)
        else:
            ans.append(n)
#print(ans)
print(len(ans)+1)

Measured memory_bytes: 74848
import sys
def input():
    return sys.stdin.readline()[:-1]
import math
from itertools import permutations, combinations
from collections import defaultdict

sys.setrecursionlimit(10**7)
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
mod = 10**9+7

edges = [[] for _ in range(N)]
for abi in ab:
    a, b = abi[0], abi[1]
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

max_edges = max(list(map(len, edges)))
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


res = K
def dfs(last, cur):
    global res

    if last == -1:
        for i, np in enumerate(edges[0]):
            res *= (K-i-1)
            res %= mod
            dfs(0, np)

    else:
        num_edges_cur = len(edges[cur]) - 1
        if num_edges_cur == 0:
            return
        i = 0
        for i in range(K-2, K-num_edges_cur-2, -1):
            res *= i
            res %= mod
        for np in edges[cur]:
            if np == last:
                continue
            else:
                dfs(cur, np)
        
dfs(-1, 0)

print(res)

Measured memory_bytes: 159580
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
    }
    
    Scanner sc;
    int N;
    int X;
    int[] m;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        N = sc.nextInt();
        X = sc.nextInt();
        m = new int[N];
        //for (int i=0; i<N; ++i){
        //    m[i] = sc.nextInt();
        //}
    }
    
    //解答処理
    int solve() {
        int count =0;
        
        for (int i=0; i<N; ++i){
            m[i] = sc.nextInt();
            X -= m[i];
            count++;
        }
        
        Arrays.sort(m); //昇順にソート
        while (m[0] <= X){
            X -= m[0];
            count++;
        }
        
        
        return count;
    }
    
    //出力
    void show(int answer) {
        System.out.println(answer);
    }
}


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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    map<int, int> mp;
    int sq = sqrt(n)+5;
    REP(i, 2, sq) {
        int c = 0;
        while(n%i == 0) {
            ++c;
            n /= i;
        }
        if(c) mp[i] = c;
    } 
    if(n > 1) mp[n] = 1;
    int res = 0;
    for(auto it: mp) {
        int p = 1;
        int j = it.second;
        ++res;
        while(j-p > p) {
            j -= p;
            ++p;
            ++res;
        }
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <cstdio>
#define MN 300
#define mod 998244353
using namespace std;
int n;
char s[MN + 5];
/*
  f:
  (from the end) length = i, has inserted j '0' and k '1', i.e. keep the last i - j - k bits of the original sequence
  how many (different) possible sequences
  note that j,k are the minimum number of bits to insert
*/
int f[MN + 5][MN + 5][MN + 5]; 
/*
  g:
  has performed i deletion, whether possible to insert j '0' and k '1' into the latter part
*/
bool g[MN + 5][MN + 5][MN + 5];
int num0[MN + 5], Max[MN + 5];

inline void R(int &x, int y) {
  (x += y) >= mod ? x -= mod : 0;
}

int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = n; i; --i) {
    num0[i] = num0[i + 1] + (s[i] == '0');
  }
  // first part: f
  f[0][0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0 ; j < i; ++j) {
      for (int k = 0; k < i - j; ++k) {
        int t = s[n - i + 1 + j + k] - '0'; // current position in s
        // if we want a t, then we should not insert (to minimize the number of insertion).
        R(f[i][j][k], f[i - 1][j][k]);
        // if we want a different bit(!t), then we should insert.
        R(f[i][j + t][k + (!t)], f[i - 1][j][k]);
      }
    }
  }
  // second part: g
  g[0][0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < i; ++j) {
      for (int k = 0; k < i - j; ++k) {
        if (!g[i - 1][j][k]) continue;
        //printf("possible g: %d %d %d\n", i - 1, j, k);
        int pos = i + j + k; // current position if we want to delete
        if (pos < n) { // possible to delete 2 bits
          int num0 = (s[pos] == '0') + (s[pos + 1] == '0');
          int num1 = 2 - num0;
          /* 
            possible action:
            *  keep one bit for insertion
            *  use 1 bit that kept before and keep another bit
            *  use 2 bit that kept before and keep one of them
          */
          if (num0) g[i][j + 1][k] = 1;
          if (num1) g[i][j][k + 1] = 1;
        }
        if (pos <= n) { // possible to delete 1 bit
          if (j && s[pos] == '1') {
            g[i][j - 1][k + 1] = 1;
          } else if (k && s[pos] == '0') {
            g[i][j + 1][k - 1] = 1;
          }
          if (j|k) g[i][j][k] = 1;
        }
        if (j >= 2) g[i][j - 1][k] = 1;
        if (k >= 2) g[i][j][k - 1] = 1;
      }
    }
  }
  // calculate the answer
  int ans = 0;
  for (int length = 1; length <= n; ++length) {
    memset(Max, -1, sizeof(Max));
    // if we can get one by insert j '0' and k '1'
    // then we can also get it by insert more '0' and '1'
    // as long as the number of '0' and '1' is correct
    for (int j = length; ~j; --j) {
      for (int k = length - j; ~k; --k) {
        int now_num0 = num0[n - length + 1 + j + k] + j;
        if (g[n - length][j][k]) {
          Max[now_num0] = max(Max[now_num0], k);
        }
        if (Max[now_num0] >= k) {
          R(ans, f[length][j][k]);
        }
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 66552
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,s,t;
	cin>>n>>m>>s>>t;
	s--;
	t--;
	vector<vector<P>> adj(n);
	REP(i,m) {
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		a--;
		b--;
		c--;
		adj[a].pb(P(c,d));
		adj[b].pb(P(c,d));
		adj[b].pb(P(a,d));
		adj[c].pb(P(a,d));
		adj[c].pb(P(b,d));
		adj[a].pb(P(b,d));
	}
	vector<ll> d(n,INF*INF);
	d[s]=0;
	priority_queue<P,vector<P>,greater<P>> q;
	q.push(P(0,s));
	while(!q.empty()) {
		ll p=q.top().second;
		ll c=q.top().first;
		q.pop();
		if(d[p]!=c) continue;
		REP(i,adj[p].size()) {
			ll next=adj[p][i].first;
			ll cost=adj[p][i].second;
			if(d[next]>d[p]+cost) {
				d[next]=d[p]+cost;
				q.push(P(d[next],next));
			}
		}
	}
	cout<<d[t]<<endl;
}



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


def lcm(x, y):
    return (x * y) // gcd(x, y)


if __name__ == "__main__":
    a, b, c, d = map(int, input().split())
    a -= 1
    cnt = b - a
    cnt -= b//c - a//c
    cnt -= b//d - a//d
    l = lcm(c, d)
    cnt += b//l - a//l
    print(cnt)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int a, b, c; cin >> a >> b >> c;
  if (a == b) {
    outl(c);
  } else if (a == c) {
    outl(b);
  } else {
    outl(a);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord

--import qualified Data.IntSet as S
import qualified Data.Sequence as S

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)

main :: IO ()
main = do
    n <- readLn :: IO Int
    as' <- r' :: IO [Int]
    let as = S.fromList (sort as')
    (res,r) <- solve as []
    print r
    mapM_ printtup (reverse res)

printtup (x,y) = putStrLn $ unwords [show x, show y]

solve :: S.Seq Int -> [(Int,Int)] -> IO ([(Int,Int)],Int)
solve set ac
    | S.length set <= 1  = error "should not happen"
    | S.length set == 2  = let x = S.index set 1 ; y = S.index set 0
                            in return ((x,y):ac, x-y)
    | otherwise = do
        -- print set
        let (x,rest)    = lastSplit set
        let (y,rest')   = headSplit rest
        let (z,rest'')  = headSplit rest'
        -- y < z < x
        let newset = if z < 0
            then y S.<| (rest'' S.|> (x-z)) -- XZ
            else (y-z) S.<| (x S.<| rest'') -- YZ
        let newpair = if z < 0 then ((x,z):ac) else ((y,z):ac)

        solve newset newpair


headSplit :: S.Seq Int -> (Int, S.Seq Int)
headSplit set = let (hs,ts) = S.splitAt 1 set
                    h  = S.index hs 0
                in  (h,ts)
lastSplit :: S.Seq Int -> (Int, S.Seq Int)
lastSplit set = let (is,ls) = S.splitAt (S.length set - 1) set
                    l  = S.index ls 0
                in  (l,is) 



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

int main(){
    int n;
    scanf("%d",&n);
    vector<int> w(n);
    int min;
    for(int i=0;i<n;i++) scanf("%d",&w[i]);
    for(int i=1;i<n;i++){
        int sum1=0;
        int sum2=0;
        for(int j=0;j<n;j++){
            if(j<=i) sum1+=w[j];
            else sum2+=w[j];
        }
        if(i==1) min=abs(sum1-sum2);
        if(abs(sum1-sum2)<min) min=abs(sum1-sum2);
    }
    printf("%d\n",min);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define ort ((bas+son+1ll)/2ll)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
 
typedef long long ll;
typedef pair < int , int > ii;

int r,k,x;

int main() {
	
	cin >> r >> k >> x;
	for(int i = 0; i < 10; i++)
	{
		x = x*r-k;
		cout << x << endl;
	}
	  
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;



int main() {
    int n, k, count[200005], type = 0, ans = 0;
    for (int i = 0; i < 200001; i++) count[i] = INF;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (count[a] == INF) {
            count[a] = 1;
            type++;
        }
        else count[a]++;
    }
    sort(count, count + n+1);
    for (int i = 0; i < type - k; i++) ans += count[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanInit()

	n := nextInt()
	hl := make([]int, n)

	for i := 0; i < n; i++ {
		hl[i] = nextInt()
	}

	cnt := 0
	push(hl)
	for stack.Len() > 0 {
		ei := pop()
		if len(ei) == 0 {
			continue
		}
		if len(ei) == 1 {
			cnt += ei[0]
			continue
		}

		nowmin := 999
		for i := 0; i < len(ei); i++ {
			nowmin = min(nowmin, ei[i])
		}
		cnt += nowmin
		for i := 0; i < len(ei); i++ {
			ei[i] -= nowmin
		}
		online := 0
		neweiidxs := -1
		for i := 0; i < len(ei); i++ {
			if ei[i] != 0 {
				if online == 0 {
					online = 1
					neweiidxs = i
				}
			} else {
				if online == 1 {
					online = 0
					push(ei[neweiidxs:i])
				}
			}
		}
		if online == 1 {
			push(ei[neweiidxs:len(ei)])
		}

	}

	fmt.Println(cnt)

}
func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var stack = list.New()

func push(a []int) {
	stack.PushFront(a)
}
func pop() []int {
	e := stack.Front()
	stack.Remove(e)
	return e.Value.([]int) // 明示的キャストが必要
}

// DBGprintstack print the stack
//! DBG
func DBGprintstack() {
	fmt.Printf("DBGstack: [")
	now := stack.Front()
	for now != nil {
		fmt.Printf("%d ", now.Value.([]int))
		now = now.Next()
	}
	fmt.Printf(" ]")
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1792
N = int(input())
A_list = list(map(int, input().split()))
apr_flag = True
for i in range(N):
    if A_list[i]%2 == 0:
        if A_list[i]%3 == 0 or A_list[i]%5 == 0:
            pass
        else:
            apr_flag = False
            break
print("APPROVED") if apr_flag == True else print("DENIED")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int mp[25][25];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    int a, b;
    cin >> h >> w >> a >> b;

    for( int i = 0; i < a; ++i ) {
        for( int j = 0; j < w; ++j ) {
            mp[i][j] = 1;
        }
    }
    
    for( int i = 0; i < b; ++i ) {
        for( int j = 0; j < h; ++j ) {
            mp[j][i] = 1;
        }
    }
    int cnt = 0;
    for( int i = 0; i < h; ++i ) {
        for( int j = 0; j < w; ++j ) {
            if( !mp[i][j] ) ++cnt;

        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
ac = 0
wa = 0
 
ac_tf = [0] * n
wa_num = [0] * n
 
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        if ac_tf[p] == 0:
            ac += 1
            wa += wa_num[p]
            ac_tf[p] = 1
    else:
        wa_num[p] += 1
            
print(ac, wa)

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <iomanip>
using namespace std;

using c_p_dd = pair<double, double>;

double f_slope(c_p_dd temp) { return temp.second / temp.first; }

int main() {
	vector<c_p_dd> v; int n; double t; cin >> n >> t; v.resize(n);
	for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end(),
		[](const c_p_dd& l, const c_p_dd& r) { return f_slope(l) > f_slope(r); }
	);
	cout << fixed << setprecision(4) << f_slope(v[0]) * t << endl;
	return 0;
}


Measured memory_bytes: 3296
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

#define P 998244353

int a[3000];
int b[3001][3001];
int main(void){
	int n=nextint();
	int s=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
	}
	b[0][0]=1;
	for(int i=0; i<=n; i++){
		for(int j=s-a[i]+1; j<=s; j++){
			b[i+1][j]+=b[i][j]*2%P;
			b[i+1][j]%=P;
		}
		for(int j=s-a[i]; j>=0; --j){
			b[i+1][j]+=b[i][j]*2%P;
			b[i+1][j]%=P;
			if(j+a[i]<=s){
				b[i+1][j+a[i]]+=b[i][j];
				b[i+1][j+a[i]]%=P;
			}
		}
	}
	printf("%d\n", b[n][s]);
}


Measured memory_bytes: 36788