akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
  int P,Q,R;
  cin>>P>>Q>>R;

  int min = 300;
  if(P+Q<min){
    min = P+Q;
  }

  if(P+R < min){
    min = P+R;
  }

  if(Q+R < min){
    min = Q+R;
  }
  cout<<min<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%d",&x)
using namespace std;
struct ed {
	int x,y;
	int c;
} e[1100000];

int f[5][2]= {{1,0},{-1,0},{0,1},{0,-1}};

int dis[1100][1100];
string a[1100];
int vis[1100][1100];
int tt[1100][1100];
queue<int>q;

int main() {
	int n,m;
	cin>>n>>m;
	int t=0;
	for(int i=1; i<=n; i++)
		cin>>a[i];

	for(int i=1; i<=n; i++)
		for(int j=0; j<m; j++) {
			t++;
			e[t].x=j;
			e[t].y=i;
			tt[i][j]=t;

			if(a[i][j]=='#') {
				q.push(t);
				vis[i][j]=1;
			}
		}

	int ans=0;
	while(!q.empty()) {
		int t=q.front();
		q.pop();
		int x=e[t].x;
		int y=e[t].y;
		for(int i=0; i<=3; i++){
			int nx=x+f[i][0];
			int ny=y+f[i][1];
			if(nx>=0&&ny>0) {
				if(a[ny][nx]=='.'&&!vis[ny][nx]){
					a[ny][nx]='#';
					int temp=tt[ny][nx];
					vis[ny][nx]=1;
					q.push(temp);
					dis[ny][nx]=dis[y][x]+1;
					ans=max(ans,dis[ny][nx]);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 30464
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N, Y; cin >> N >> Y;

	repe(x, 0, 2000) {
		repe(y, 0, 2000) {
			if ((N - x - y) >= 0 && x * 9 + 4 * y + N == Y / 1000) {
				cout << x << " " << y << " " << N - x - y << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;

	return 0;
}

Measured memory_bytes: 256
//package abc043a;

import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int n, sum = 0;
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		
		for(int i = 1; i <= n; i++)
		{
			sum += i;
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll max(ll a,ll b)
{
	if(a>b)
		return a;
	else
		return b;
}
int main()
{
	
    ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	long long int val=INT_MIN;
	
	val=max(a*c,max(a*d,max(b*c,b*d)));
	cout<<val;

	


}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
	int box[100];
	int t,i=0;
	while(scanf("%d",&t)!=EOF){
		if(t==0){
			i--;
			printf("%d\n",box[i]);
		}else{
			box[i]=t;
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>

using namespace std;
int main(){
    
    set<int> nGood;
    int N,M;
    cin >> N >> M;
    int H[N];
    int height;
    int A,B;
    for(int i =0;i < N;i++)
    {
        cin >> H[i];
    }
    while(M--){
        cin >> A >> B;
        if (H[A-1] > H[B-1])
            nGood.insert(B);
        else if(H[B-1] > H[A-1])
            nGood.insert(A);
        else{
            nGood.insert(A);
            nGood.insert(B);
        }
    }
    cout << N - nGood.size() << "\n";
    
    return 0;
}

Measured memory_bytes: 6684
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
const ll MOD = (ll)(1e9) + 7;

int main() {
	int n, m; scanf("%d %d", &n, &m);
	ll a = 0, b = 0;
	rep(i,n) {
		ll x; scanf("%lld", &x);
		(a += x * (i + i - n + 1)) %= MOD;
	}
	rep(i,m) {
		ll y; scanf("%lld", &y);
		(b += y * (i + i - m + 1)) %= MOD;
	}
	printf("%lld\n", a * b % MOD);
}

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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using mii = map<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

signed main() {
  int n,x;cin>>n>>x;
  int ans = 0;
  int pre = 0;
  rep(i,n) {
    int a;cin>>a;
    int diff = a + pre - x;
    if (diff > 0) {
      ans += diff;
      a -= diff;
    }
    pre = a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int h, w;
    cin >> h >> w;
    vector<int> cnt(26, 0);
    rep(i, h) rep(j, w) {
        char c;
        cin >> c;
        ++cnt[c-'a'];
    }
    //rep(i, 26) cout << cnt[i] << " " ;
    //cout << endl;
    bool odd_odd = (h % 2 != 0 && w % 2 != 0) ? true : false;
    bool odd = false;
    if (h % 2 == 0 && w % 2 == 0) {
        rep(i, 26) {
            if (cnt[i] % 4 != 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    else {
        int lim_num;
        if (h % 2 != 0 && w % 2 != 0) {
            lim_num = h * w - (h + w - 1);
        }
        else if (h % 2 != 0 && w % 2 == 0) {
            lim_num = h * w - w;
        }
        else {
            lim_num = h * w - h;
        }
        int tmp_cnt = 0;
        bool ok = false;
        rep(i, 26) {
            if (cnt[i] >= 4) {
                tmp_cnt += cnt[i] / 4 * 4;
                cnt[i] -= cnt[i] / 4 * 4;
            }
            if (tmp_cnt >= lim_num) {
                cnt[i] += tmp_cnt - lim_num;
                ok = true;
                break;
            }
        }
        if (!ok) {
            cout << "No" << endl;
            return 0;
        }
        rep(i, 26) {
            if (cnt[i]&1) {
                if (!odd_odd) {
                    cout << "No" << endl;
                    return 0;
                }
                else if (!odd) {
                    odd = true;
                }
                else {
                    cout << "No" << endl;
                    return 0;
                }
            } 
        }
    }
    if (odd_odd) cout << ((odd) ? "Yes" : "No") << endl;
    else         cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3636
#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++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> A(n,0);
    rep(i,n-1){
        int a; cin >> a;
        A[a-1]++;
    }
    rep(i,n){
        cout << A[i] << endl;
    }
}

Measured memory_bytes: 4052
program b159

      character*100 S
      integer A,B


      read(*,*)S

      A = len_trim(S)
      B = (A-1)/2
      if(S(1:B) == S(A-B+1:A)) then
        
      write(*,*)"Yes"
      else
      write(*,*)"No"
      endif


      end program b159


      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

int main(void){
	string a;
	cin >> a;
	lld num = 0;
	for(int e=0;e<sz(a);e++){
		int nn = (a[e]-'0');
		num += nn;
	}
	if(num%9==0) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop") 
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
#define ps push_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
ll dp[1001][1001];
ll validp(char ar[1001][1001],ll i,ll j,ll h,ll w){
	if(i==h-1&&j==w-1){
		return 1;
	}
	if(dp[i][j]!=-1){
		return dp[i][j]%mod;
	}

	ll a=0,b=0;
	if(i+1<h&&ar[i+1][j]!='#'){
		a=validp(ar,i+1,j,h,w)%mod;
	}
	if(j+1<w&&ar[i][j+1]!='#'){
		b=validp(ar,i,j+1,h,w)%mod;
	}
	return dp[i][j]=(a+b)%mod;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,h,w;
	cin>>h>>w;

	memset(dp,-1,sizeof(dp));
	char ar[1001][1001];
	for(i=0;i<h;i++){
		cin>>ar[i];
	}
	
	k=validp(ar,0,0,h,w);
	cout<<k;
	return 0;
}
//ctrl H replace

Measured memory_bytes: 9216
N, K, Q = map(int, input().split(' '))
scores = [ 0 for _ in range(N)]

for _ in range(Q):
    A = int(input()) - 1
    scores[A] += 1

for score in scores:
    result = 'Yes' if K - Q + score > 0 else 'No'
    print(result)

Measured memory_bytes: 4672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 10;

struct edge {int to, cost;}; // 辺
vector<edge> graph[MAX]; // 隣接リスト
bool visited[MAX]; // 訪問状況

void dfs(int s, int i, int n, int &cnt) {
    if (i == n-1) cnt++;
    visited[s] = true;
    for (edge e : graph[s]) {
        if (visited[e.to]) continue;
        dfs(e.to, i+1, n, cnt);
    }
    visited[s] = false;
}

int main() {
    // input
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        graph[u].push_back({v, 0});
        graph[v].push_back({u, 0});
    }
    // solve
    int cnt = 0;
    dfs(0, 0, n, cnt);
    // output
    cout << cnt << endl;
}

Measured memory_bytes: 3504
def resolve():
    s = input()
    t = input()
    ls = list()
    lt = list()
    for c in s:
        ls.append(ord(c))
    for c in t:
        lt.append(ord(c))
    ls.sort()
    lt.sort()
    
    can = False
    if len(ls) == ls.count(ls[0]) and len(lt) == lt.count(lt[0]) and len(ls) < len(lt):
        can = True
    else:
        for i in range(len(lt)-1, -1, -1):
            if ls[0] < lt[i]:
                can = True
                break

    if can:
        print("Yes")
    else:
        print("No")
resolve()

Measured memory_bytes: 9088
import fractions
import copy

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

def calc_divisore(n):
    divisors=[]
    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)
    return divisors

la=calc_divisore(a)
lb=calc_divisore(b)
ll=sorted(list(set(la)&set(lb)))
ansl=[1]
ll_c=copy.copy(ll)
for i in ll_c:
    len_s=len(ll)
    ll=list(filter(lambda x: fractions.gcd(i,x)==1, ll))
    if len(ll)!=len_s:
        ansl.append(i)
print(len(ansl))

Measured memory_bytes: 7240
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  for (;;) {
    int N, K;
    cin >> N >> K;
    if (!N && !K) return 0;
    int S[100], s[100];
    for (int i = 0; i < K; i++)
      cin >> S[i];
    fill(s, s+K, 0);
    for (int i = 0; i < N; i++)
      for (int j = 0; j < K; j++) {
        int x;
        cin >> x;
        s[j] += x;
      }
    bool f = true;
    for (int i = 0; i < K; i++)
      if (s[i] > S[i]) {
        f = false;
        break;
      }
    cout << (f ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 852
import math
a,b,x = map(int,input().split())
if x >= (a*b/2)*a:
    r = math.degrees(math.atan((2*((a*a*b)-x)) / (a**3)))
    print(r)
else:
    r = math.degrees(math.atan((2*x) / (a*b*b)))
    print(90-r)


Measured memory_bytes: 38384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

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

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	int N = in.nextInt();
        	int A = in.nextInt();
        	int B = in.nextInt();
        	int[] P = new int[N];
        	int count1 = 0;
        	int count2 = 0;
        	int count3 = 0;
        	int ans = 0;
        	for(int i = 0; i < N; i++) {
        		P[i] = in.nextInt();
        		if(P[i] <= A) {
        			count1++;
        		}else if(A + 1 <= P[i] && P[i] <= B) {
        			count2++;
        		}else{
        			count3++;
        		}
        	}
        	ans = Math.min(count1, count2);
        	ans = Math.min(ans, count3);
        	out.println(ans);

        	

        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23636
from collections import deque

n, u, v = map(int, input().split())
u -= 1
v -= 1

g = [[] for _ in range(n)]

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)


memov = [-1] * n
q = deque()
memov[v] = 0
q.append((v, 0))

while q:
    v_, d = q.popleft()
    for nv in g[v_]:
        if memov[nv] != -1:
            continue
        memov[nv] = d + 1
        q.append((nv, d+1))

memou = [-1] * n
q = deque()
memou[u] = 0
q.append((u, 0))

while q:
    v_, d = q.popleft()
    for nv in g[v_]:
        if memou[nv] != -1:
            continue
        if d + 1 >= memov[nv]:
            continue
        memou[nv] = d + 1
        q.append((nv, d+1))

max_v = -1
max_d = 0
for i in range(n):
    if memou[i] == -1:
        continue
    if memov[i] >= max_d:
        max_v = i
        max_d = memov[i]

print(max_d - 1)










Measured memory_bytes: 64288
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a , b ;
    cin >> a >> b;
    
    if(( a + b ) % 2 >> 0){
        cout << ( a + b ) / 2 + 1 << endl;
    }
    if (( a + b ) % 2 <= 0){
        cout << ( a + b ) / 2  << endl;
    }
   
}


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

int main(){
  int n;
  cin >> n;
  vector<ll> a(3*n);
  rep(i,3*n) cin >> a[i];
  sort(a);
  reverse(a);
  ll ans = 0;
  for(int i=0;i<n;i++){
    ans += a[2*i+1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int N, K; cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];

    vector<int> dp(N + K + 1, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int k = 1; k <= K; k++) {
            chmin(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
        }
    }
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
solve :: Int -> Int -> Int
solve x n
    | n == 0    = x
    | otherwise = if r == 0 then y else y + 1000 - r
        where y = solve x (n - 1) * 105 `div` 100
              r = y `mod` 1000

main :: IO ()
main = do
    n <- readLn
    print $ solve 100000 n

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    int n;
    scanf("%d",&n);
    ll ans=0;
    for(int i=1;i<=n;i++) {
        if(i%3==0||i%5==0) continue;
        ans+=i;
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(4);
    string ans = "No";

    for (int i = 0; i < 4; ++i) {
        v[i] = n % 10;
        n /= 10;
    }

    for (int i = 0; i < 2; ++i) {
        int cnt = 1;
        for (int j = i+1; j < 4; j++) {
            if (v[i] == v[j]) ++cnt;
            else break;
            if (cnt >= 3) {
                ans = "Yes";
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, M, D = MI()
    if D == 0:
        print((M-1) / N)
    else:
        print((M-1) * 2 * (N - D) / pow(N, 2))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9120
import java.util.Scanner;

public class Main {
	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		int days = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int c = (int) Math.ceil(a / in.nextDouble());
		int d = (int) Math.ceil(b / in.nextDouble());
		System.out.println(days - Math.max(c, d));
	}
}

Measured memory_bytes: 18364
#include <bits/stdc++.h>
#define N 200010
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;
}
struct edge
{
	int v,next;
}vs[N];
int n,mask[N][30],st[N],ee,Ans;
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
inline void dfs(int rt,int pr)
{
	int cur=-1;
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		dfs(vs[i].v,rt);
		for(int j=0;j<30;j++)
		{
			if(mask[rt][j]&&mask[vs[i].v][j]) cur=max(cur,j);
			mask[rt][j]|=mask[vs[i].v][j];
		}
	}
	for(++cur;cur<30;++cur) if(!mask[rt][cur]) break;
	Ans=max(Ans,cur); mask[rt][cur]=1;
	for(--cur;cur>=0;cur--) mask[rt][cur]=0;
}
int main()
{
	n=read(); for(int i=1;i<n;i++)
	{
		int u=read(), v=read();
		addedge(u,v);
		addedge(v,u);
	}
	dfs(1,0); cout << Ans << endl;
}

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

using namespace std;

#define M 200005
#define mp make_pair

int n, fa[M];

set<int> se[M];
map< pair<int, int>, int > ext;
queue< pair<int, int> > q;

int findf(int x)
{ return fa[x] == x ? x : fa[x] = findf(fa[x]); }

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '0') f = -1; ch = getchar(); }
	while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); }
	return x * f;
}

int main()
{
	n = read();
	for (int i = 1, u = 0, v = 0; i <= n * 2 - 2; i++)
	{
		u = read(), v = read();
		se[u].insert(v); se[v].insert(u);
		ext[mp(u, v)]++; ext[mp(v, u)]++;
		if (ext[mp(u, v)] == 2) q.push(mp(u, v));
	}

	for (int i = 1; i <= n; i++) fa[i] = i;

	while (!q.empty())
	{
		int u = q.front().first, v = q.front().second; q.pop();
		int uf = findf(u), vf = findf(v);
		se[uf].erase(vf), se[vf].erase(uf);
		if (se[uf].size() < se[vf].size()) swap(uf, vf);
		for (auto to : se[vf])
		{
			ext[mp(to, vf)] = ext[mp(vf, to)] = 0;
			se[to].erase(vf); se[to].insert(uf); se[uf].insert(to);
			ext[mp(to, uf)]++; ext[mp(uf, to)]++;
			if (ext[mp(to, uf)] == 2) q.push(mp(to, uf));
		}
		fa[vf] = uf; se[vf].clear();
	}

	int cnt = 0;
	for (int i = 1; i <= n; i++)
		if (fa[i] == i) cnt++;
	puts(cnt > 1 ? "NO" : "YES");

	return 0;
}

Measured memory_bytes: 63528
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string s; cin >> s;

    long long n = s.size();

    string x = "", y = "";

    for(long long i = 0; i < n; i++) {
        if(i & 1) {
            x += "1";
            y += "0";
        }
        else {
            x += "0";
            y += "1";
        }
    }

    long long a = 0, b = 0;
    for(long long i = 0; i < n; i++) {
        a += s[i] != x[i];
        b += s[i] != y[i];
    }

    cout << min(a, b);

    return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
typedef long long ll;
#define FOR(i,n) for(int i=0;i<n;i++)

int main(){
  int a,b;
  cin >> a>>b;
    cout <<  max(0,a- 2*b);
    return 0;
}


Measured memory_bytes: 256
// Problem : F - Strivore
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

//Macros

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

//Solution

int binpow(int x,int y){
    x %= mod;
    int res = 1;
    while(y){
        if(y&1) res = (res*x)%mod;
        x = (x*x)%mod;
        y = y/2;
    }
    return res;
}
 
int inv(int a){
    return binpow(a,mod-2);
}
 
int fact[N], invfact[N];
 
void precompute(){
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = (fact[i-1]*i)%mod;
    invfact[N-1] = inv(fact[N-1])%mod;
    for(int i=N-2;i>=0;i--) invfact[i] = (invfact[i+1]*(i+1))%mod;
}
 
int ncr(int n, int r){
    if(n<r) return 0;
    return (((fact[n]*invfact[r])%mod)*invfact[n-r])%mod;
}

int k;
string s;

void solve(){
    precompute();
    cin>>k>>s;
    int n = sz(s)+k;
    int ans = binpow(26,n);
    for(int i=0;i<sz(s);i++) (ans += mod-(ncr(n,i)*binpow(25,n-i))%mod) %= mod;
    cout<<ans<<endl;
}

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

Measured memory_bytes: 35504
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int main()
{
    int a;
    scanf("%d", &a);
    printf("%d\n",a+a*a+a*a*a);
    return 0;
}


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

int main(){
    int n,a,tmp;
    bool ok=true;
    cin >> n;
    while(true){
        a=2;
        tmp=sqrt(n);
        for(int i=a;i<=tmp;i++){
            if(n%i==0)ok=false;
        }
        if(ok){cout << n << endl;break;}
        n++;
        ok=true;
    }
    return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
lines=[]
for i in range(H):
    lines.append(input().strip())

chars=dict()
for line in lines:
    for c in line:
        if c not in chars:
            chars[c]=0
        chars[c]+=1

def judge(H,W,chars):
    #両方奇数
    if H%2+W%2==2:
        ones=1
        twos=H//2 + W//2
    #両方偶数
    elif H%2+W%2==0:
        ones=0
        twos=0
    elif H%2==1:
        ones=0
        twos=W//2
    else:
        ones=0
        twos=H//2
    for c in chars:
        if ones<0 or twos<0:
            return False
        chars[c]%=4
        if chars[c]==0:
            continue
        if chars[c]==2:
            twos-=1
        elif chars[c]==3:
            twos-=1
            ones-=1
        else:
            ones-=1
    return True

if judge(H,W,chars):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38640
{-# LANGUAGE CPP #-}
module Main where

import qualified Data.Vector.Unboxed as V 
import qualified Data.Map.Strict as M
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Char
import qualified Data.List as L

dump :: (Show a) => a -> IO()
#if __GLASGOW_HASKELL__ >= 800
dump x = print x
#else
dump _ = pure ()
#endif

-- "101010" -> [1,0,1,0,1,0]
readToList :: String -> [Int]
readToList [] = []
readToList (x:xs) = read [x] : readToList xs

 
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getlist :: IO [Int]
getlist = (fmap (read . BS.unpack) . BS.words) <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readmat :: Int -> IO [[Int]]
readmat rows = replicateM rows getlist

newtype UF a = UF (M.Map a a) deriving (Show) -- Map node parent

makeuf :: Int -> UF Int
makeuf n = let m = M.fromList $ zip [0..n] [0..n]
                in UF m

union :: (Eq a, Ord a) => a -> a -> UF a -> UF a
union l r uf@(UF m) = let lp = find l uf
                          rp = find r uf
                      in if lp == rp
                         then uf
                         else if size l uf < size r uf
                              then UF $ M.update (const $ Just rp) lp m
                              else UF $ M.update (const $ Just lp) rp m

find :: (Eq a, Ord a) => a -> UF a -> a
find x uf@(UF m) = let px = m M.! x
                in if px == x
                   then px
                   else find px uf -- TODO 貼り直し

size :: (Eq a, Ord a) => a -> UF a -> Int
size x (UF m) = M.size $ M.filter (\par -> par==x) m

genbit :: Int -> [[Int]]
genbit 0 = []
genbit 1 = [[0],[1]]
genbit len = do
  x <- [0,1]
  map (x:) $ genbit (len-1)

base :: Int
base = 10 ^ 9 + 7

forn :: (Num a, Enum a, Monad m) => a -> (a -> m b) -> m [b]
forn x = forM [0..(x-1)]

count :: (Eq a) => a -> [a] -> Int
count y = length . filter (== y)

main :: IO()
main = do
  n <- getInt
  [xs, ys] <- words <$> getLine
  putStrLn $ concat $  zipWith (\x y -> [x]++[y]) xs ys




Measured memory_bytes: 508
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 300123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define oo 1000000123
#define sz(x) ((int)((x).size()))
#define OUT -oo
#define left(x) (x << 1)
#define right(x) ((x << 1) | 1)
#define mid(a, b) ((a + b) >> 1)

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    ll ans = 0;
    ll n;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            for(int k = 1; k <= n; ++k){
                ans += __gcd(__gcd(i, j), k);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


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

long long rec(int N, long long X) {
  if (N == 0) {
    if (X == 0) return 0;
    if (X == 1) return 1;
  }
  // レベル N-1 のバンとパティ
  long long bp = (1LL << (N+1)) - 3;
  // レベル N-1 のパティ
  long long p = (1LL << N) - 1;
  if (X == 1) return 0;
  else if (X <= 1 + bp) return rec(N-1, X-1);
  else if (X == 1 + bp + 1) return p + 1;
  else if (X <= 2 + 2*bp) return p + 1 + rec(N-1, X-2-bp);
  else return 2*p + 1;
}

int main() {
  int N; cin >> N;
  long long X; cin >> X;
  cout << rec(N, X) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

using LP = pair<ll, int>;
ll chmin(ll &a, ll b){ return a = min(a, b);}
int main(){
  int H, W;
  cin >> H >> W;
  const int NUMS = 10;
  vector<vector<ll>> c(NUMS, vector<ll>(NUMS));
  for(int i=0; i<NUMS; i++){
    for(int j=0; j<NUMS; j++) cin >> c[i][j];
  }
  vector<vector<int>> A(H, vector<int>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++) cin >> A[i][j];
  }
  
  // 解1 ダイクストラで 数字iを1に変える最小コストを求める
  // const ll INF = (ll)1 << 60;
  // vector<ll> to1(NUMS, INF); to1[1] = 0;
  // for(int i=0; i<NUMS; i++){
  // // for(int i=8; i<9; i++){
  //   if(i==1) continue;
  //   vector<vector<ll>> costs(NUMS, vector<ll>(NUMS, INF));
  //   for(int i=0; i<NUMS; i++) costs[i][i] = 0;
  //   priority_queue<LP, vector<LP>, greater<LP>> pri_qu;
  //   pri_qu.push(LP(0, i));
  //   while(!pri_qu.empty()){
  //     ll cost = pri_qu.top().first;
  //     int num = pri_qu.top().second;
  //     pri_qu.pop();
      
  //     for(int j=0; j<NUMS; j++){
  //       if(j==num) continue;
  //       if(costs[num][j] <= cost + c[num][j]) continue;
  //       costs[num][j] = cost + c[num][j];
  //       pri_qu.push(LP(costs[num][j], j));
  //       if(j==1) to1[i] = min(to1[i], costs[num][1]);
  //     }
  //   }
  // }
  // ll ans = 0;
  // for(int i=0; i<H; i++){
  //   for(int j=0; j<W; j++){
  //     if(A[i][j] == 1 || A[i][j] == -1) continue;
  //     int num = A[i][j];
  //     ans += to1[num];
  //   }
  // }
  // cout << ans << endl;
  
  // 解2　ワーシャルフロイド法  O(V^3)解法
  for(int k=0; k<NUMS; k++){
    for(int i=0; i<NUMS; i++){
      for(int j=0; j<NUMS; j++){
        chmin(c[i][j], c[i][k]+c[k][j]);
      }
    }
  }
  ll ans = 0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(A[i][j] == 1 || A[i][j] == -1) continue;
      int num = A[i][j];
      ans += c[num][1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3808
N=int(input())
ls=list(map(int,input().split()))
lst=sorted(ls,reverse=True)

A=[]
B=[]

for i in range(N):
    if i==0 or i%2==0:
        A.append(lst[i])
    else:
        B.append(lst[i])

print(sum(A)-sum(B))

Measured memory_bytes: 3060
#include <stdio.h>
#define MAX 1000000
int binarySearch(int, int);
int S[MAX],T[MAX];
int main(){
  int n,q,i,j,count=0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
    
  }

  for(i = 0; i < q; i++){
    count = count + binarySearch(T[i],n);
  }
  
  

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

  return 0;
}

int binarySearch(int key, int n){
  int left,right,mid;
  left = 0;
  right = n;
  while(left < right){
    mid = (left + right) / 2;
    if(S[mid] == key){
      return 1;
    }
    else if(key < S[mid]){
      right = mid;
    }
    else{
      left = mid + 1;
    }
  }
  return 0;
}

Measured memory_bytes: 4892
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {

    int N, i;
    cin >> N >> i;
    int x = N - i + 1;
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl "/n";

long long max(long long a,long long b){
    return (a>b)?a:b;
}

int main(){
    fast;
    long long a,b,c,d;

    cin >> a >> b >> c >> d;
    long long w=a*c,x=a*d,y=b*c,z=b*d;
    cout << max(w,max(x,max(y,z)));
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

void add_zero (string & A, string & B )
{
	int lenA = A.length();
	int lenB = B.length();

	while (lenA != lenB ){
		B = '0' + B;
		lenB = B.length();
	} // end while
}

int stoi (string s )
{
	stringstream ss (s );
	int res = 0;
	ss >> res;

	return res;
}

int main()
{
	string A, B;
	int K;
	cin >> A >> B >> K;
	add_zero (A, B );
	int res = 0;
	int len = A.length();

	for (int k = 0; k <= K; k++ ){
		for (int n = 0; n < (1<<len); n++ ){
			int cnt = 0;
			for (int j = 0; j < len; j++ ){
				if (n & (1<<j ) ) cnt++;
			} // end for
			if (cnt != k ) continue;
			string C = string (len, '0');	
			int borrow = 0;
			int curr = 0;
			for (int i = 0; i < len; i++ ){
				if (A[len-1-i] - '0' - borrow  >= B[len-1-i] - '0'){
						C[len-1-i] = (A[len-1-i] - '0') - (B[len-1-i] - '0') - borrow + '0';
					borrow = 0;
				}else{
						C[len-1-i] = (A[len-1-i] - '0' ) - (B[len-1-i] - '0' ) + 10 - borrow + '0';
					if (n&(1<<i) ) 
						borrow = 0;
					else
						borrow = 1;
				} // end if
			} // end for
			curr = stoi (C );
			res = max (res, curr );
		} // end for
	} // end loop

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

Measured memory_bytes: 0
x1, y1, x2, y2 = map(int, raw_input().split())

x3 = x2-(y2-y1)
y3 = y2+(x2-x1)
x4 = x3-(y3-y2)
y4 = y3+(x3-x2)
print x3, y3, x4, y4


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 n, ans;
        while(cin >> n) {
            ans = 0;
            _rep(a, 10) {
                if(a > n) { break; }
                _rep(b, 10) {
                    if(a + b > n) { break; }
                    _rep(c, 10) {
                        if(a + b + c > n) { break; }
                        if(a + b + c <= n && n <= a + b + c + 9) { ++ans; }
                    }
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
n = int(input())
hn = list(map(int, input().split()))

ans = 0

while sum(hn) > 0:
    ans+= 1
    flag = False
    for i in range(n):
        if hn[i] > 0:
            hn[i] -= 1
            flag = True
        elif flag is True:
            break

print(ans)

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

int main(void){
 
    char str[2500];
    char *tok;
    int h,w;
    int i1,i2,i3;
    int mapa[2002][2002];
    int mapw[2002][2002];
    int maph[2002][2002];
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    h=strtol(tok,NULL,10);
    tok=strtok(NULL," ");
    w=strtol(tok,NULL,10);
    
    for(i1=0;i1<h;i1++){
        fgets(str, sizeof(str), stdin);
        for(i2=0;i2<w;i2++){
            if(str[i2]=='.'){
                mapa[i2][i1]=0;
            }else{
                mapa[i2][i1]=1;
            }
        }
    }
    
    for(i1=0;i1<h;i1++){
        //printf("\n");
        for(i2=0;i2<w;i2++){
            //printf("%d",mapa[i2][i1]);
        }
    }
  
  //printf("\n");
  
  
  for(i1=0;i1<h;i1++){
    for(i2=0;i2<w;i2++){
      if(mapa[i2][i1]==1){
        mapw[i2][i1]==0;
      }else{
        if(i2==0){
          mapw[0][i1]=1;
        }else{
          mapw[i2][i1]=mapw[i2-1][i1]+1;
        }
      }
    }
  }
  
  for(i1=0;i1<h;i1++){
    for(i2=w-2;i2>=0;i2--){
      if(mapw[i2][i1]*mapw[i2+1][i1]!=0){
        mapw[i2][i1]=mapw[i2+1][i1];
      }
    }
  }
  

  

  
  
  //aaaaa
  
  
  for(i2=0;i2<w;i2++){
    for(i1=0;i1<h;i1++){
      if(mapa[i2][i1]==1){
        maph[i2][i1]==0;
      }else{
        if(i1==0){
          maph[i2][0]=1;
        }else{
          maph[i2][i1]=maph[i2][i1-1]+1;
        }
      }
    }
  }
  
  for(i2=0;i2<w;i2++){
    for(i1=h-2;i1>=0;i1--){
      if(maph[i2][i1]*maph[i2][i1+1]!=0){
        maph[i2][i1]=maph[i2][i1+1];
      }
    }
  }
  /*
  for(i1=0;i1<h;i1++){
    printf("\n");
    for(i2=0;i2<w;i2++){
      printf("%d",mapw[i2][i1]);
    }
  }
  printf("\n");
  
  for(i1=0;i1<h;i1++){
    printf("\n");
    for(i2=0;i2<w;i2++){
      printf("%d",maph[i2][i1]);
    }
  }
  printf("\n");
  */
  int maxim=0;
  
  
  for(i1=0;i1<h;i1++){
    for(i2=0;i2<w;i2++){
      i3=maph[i2][i1]+mapw[i2][i1];
      if(i3>maxim){
        maxim=i3;
      }
    }
  }
  
  printf("%d",maxim-1);
    
}


Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
int main (){
    int S,h,m,s;
    cin>>S;
    h=S/(60*60);
    m=(S-h*60*60)/60;
    s=S-h*60*60-m*60;
    cout<<h<<":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3092
import bisect


def main() -> None:
    S = input()
    T = input()
    SS = S + S
    alphas = [[] for _ in range(26)]
    for i, s in enumerate(SS):
        alphas[ord(s) - ord('a')].append(i)
    rep, now = 0, -1
    for t in T:
        alpha = alphas[ord(t) - ord('a')]
        i = bisect.bisect_left(alpha, now + 1)
        if i == len(alpha):
            print(-1)
            return
        now = alpha[i]
        if now >= len(S):
            now -= len(S)
            rep += 1
    print(rep * len(S) + now + 1)



if __name__ == '__main__':
    main()


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

// これはAC。いちおう解説動画見る
int main() {
    int n;
    cin >> n;
    int a[26] = {0};
    for (int i = 0; i < 26; i++) {
        a[i] = 1e6;
    }

    for (int i = 0; i < n; i++) {
        int cnt[26] = {0};
        string s;
        cin >> s;
        for (char c : s) {
            cnt[c-'a']++;
        }
        for (int j = 0; j < 26; j++) {
            a[j] = min(a[j], cnt[j]);
        }
    }

    string ans;
    for (int i = 0; i < 26; i++) {
        ans += string(a[i], i+'a');
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
	int h1, h2, k1, k2, a, b, c, d;

	cin >> h1;
	cin >> h2;
	cin >> k1;
	cin >> k2;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;

	
	if (a*h1 + b*h2 + h1 / 10 * c + h2 / 20 * d > a*k1 + b* k2 + k1 / 10 * c + k2 / 20 * d)
	{
		cout << "hiroshi"<< endl;
	}
	else if (a*h1 + b*h2 + h1 / 10 * c + h2 / 20 * d < a*k1 + b* k2 + k1 / 10 * c + k2 / 20 * d)
	{
		cout << "kenjiro" << endl;
	}
	else
	{
		cout << "even"<< endl;
	}
	return 0;



}


Measured memory_bytes: 3104
#include <stdio.h>

using namespace std;

int main(){
	int r,c,sum,total_sum = 0;
	scanf("%d %d",&r,&c);
	int table[r+1][c+1];

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c+1; j++){
			table[i][j] = 0;
		}
	}

	for(int i = 0; i < r; i++){
		sum = 0;
		for(int j = 0; j < c; j++){
			scanf("%d",&table[i][j]);
			sum += table[i][j];
			table[r][j] += table[i][j];
		}
		table[i][c] = sum;
		total_sum += sum;
	}
	table[r][c] = total_sum;

	for(int i = 0; i < r+1; i++){
		for(int j = 0; j < c; j++){
			printf("%d ",table[i][j]);
		}
		printf("%d\n",table[i][c]);
	}
}



Measured memory_bytes: 2600
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
const int MOD = 1000 * 1000 * 1000 + 7;
const int N = 10000;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
ll fac[N] ;
ll mul ( ll a , ll b )
{
    return ((a % MOD )* (b % MOD )) % MOD ;

}
ll fastExp( ll base , ll pow )
{
    ll res = 1 ;
    while ( pow > 0 )
    {

        if ( pow & 1 ) res = mul ( res , base );
        base = mul ( base , base ) ;
        pow >>= 1 ;

    }
    return res ;
}
ll Inv ( ll base  )
{
    return fastExp( base , MOD - 2  );
}
void fact()
{
    fac[0] = 1 ;
    for ( int i = 1 ; i < N ; ++i )
        fac[i]= mul( fac[i-1] , i );

}
ll nCr ( ll n , ll r ){
ll C = fac[n];
C = mul(C , Inv(fac[r]));
C = mul (C , Inv ( fac[n - r] ));
return C ;


}
int main()
{
    fast_io();
    fact();
    int n , blue  ;
    cin >> n >> blue ;
    int red = n - blue ;
    ll res = 0 ;
    for ( int i = 1 ; i <= blue ; ++ i )
     {  if ( n - blue - i +1 < 0 ){cout << "0";br  continue ;}
        res = mul ( nCr ( red + 1 , i ) , nCr( blue - 1  , i - 1  ));
        cout << res ;
        br
     }

    return 0 ;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;


int main(){
  ll W,H,x,y,a,b;
  cin >>W>>H>>x>>y;
  if(x*2ll==W&&y*2ll==H){
  	cout<<(W*H)/2ll<<' '<<1;
  }
  else{
  	double g;
  	g=W*H/(double)2;
    cout<<g<<' '<<0;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll; 
int main()
{
	ll a,b;
	scanf("%lld%lld",&a,&b);
	ll p=a*b;
	if(p<=0)
	{
		cout<<"Zero"<<endl;
	}
	else
	{
		if(a<0&&b<0)
		{
			if((b-a)%2==0)
			{
				if(b==a)
				{
					cout<<"Positive"<<endl;
				}
				else
				{
					cout<<"Negative"<<endl;
				}
			}
			else
			{
				cout<<"Positive"<<endl;
			}
		}
		else
		{
			cout<<"Positive"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256