akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    string s;cin>>s;
    ll l=0,r=s.size()-1;
    
     while(l<r){
        if(s[l]!=s[r]){
            cout<<"No"<<endl;
            return 0;
        }else{
            l++;
            r--;
        }
    }
    l=0;
    r=(s.size()-1)/2-1;
    while(l<r){
        if(s[l]!=s[r]){
            cout<<"No"<<endl;
            return 0;
        }else{
            l++;
            r--;
        }
    }
    l=(s.size()+3)/2-1;
    r=s.size()-1;
    while(l<r){
        if(s[l]!=s[r]){
            cout<<"No"<<endl;
            return 0;
        }else{
            l++;
            r--;
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}






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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

int main(){
  ll N;
  cin>>N;
  vector<ll>x(N),y(N);
  for(int i=0;i<N;i++)cin>>x[i]>>y[i];
  vector<pair<ll,ll>>X(N);
  for(int i=0;i<N;i++)X[i]={x[i],y[i]};
  sort(rng(X));
  map<pair<ll,ll>,ll>m;
  m[{0,0}]=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ll p=X[j].first-X[i].first;
      ll q=X[j].second-X[i].second;
      m[{p,q}]++;
    }
  }
  vector<pair<ll,pair<ll,ll>>>ans;
  for(auto it:m)ans.push_back({it.second,it.first});
  sort(rng(ans));
  reverse(rng(ans));
  //for(auto it:ans)cout<<it.second.first<<" "<<it.second.second<<" "<<it.first<<endl;
  ll res=max(N-ans[0].first,0ll);
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int ans=0;
    map<string, int> s;
    string t;
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        cin >> t;
        s[t] += 1;
        
        if(s[t]<=1){
            
            ans += 1;
            
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}


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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

std::vector<long long> getDivisors(long long n) {
    std::vector<long long> ret;
    long long i;
    for (i = 1; i * i < n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            ret.push_back(n / i);
        }
    }
    if (i * i == n) { ret.push_back(i); }
    std::sort(ret.begin(), ret.end());
    return ret;
}

int N;
signed main() {
    cin >> N;
    vint v = getDivisors(N);
    int ans = LLONG_MAX;
    for (int x:v) {
        chmin(ans, (x - 1) + (N / x - 1));
    }
    cout << ans << endl;
}

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

int g[205][205];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  // 入力処理
  int n,m,r;cin>>n>>m>>r;
  vector<int> rs(r);
  for(int i=0;i<r;i++){
    cin>>rs[i];rs[i]--;
  }
  // グラフ初期化
  for(int i=0;i<205;i++){
    for(int j=0;j<205;j++){
      g[i][j]=1000*1000*1000;
    }
  }
  sort(rs.begin(), rs.end());
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;a--;b--;
    g[a][b]=c;g[b][a]=c;
  }
  // グラフチェック
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
          g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }

  ll res=1000*1000*1000;
  do{
    ll mn=0;
    for(int i=0;i<r-1;i++){
      int v=rs[i];
      int u=rs[i+1];
      mn += g[u][v];
    }
    res=min(res, mn);
  } while(next_permutation(rs.begin(), rs.end()));
  cout<<res<<endl;

  return 0;
}


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

int main() {
    int h, w;
    string s;
    cin >> h >> w;
    for(int i = 0; i < w+2; ++i) {
        cout << '#';
    }
    cout << '\n';
    for(int i = 0; i < h; ++i) {
        cin >> s;
        s = '#' + s + '#';
        cout << s << '\n';
    }
    for(int i = 0; i < w+2; ++i) {
        cout << '#';
    }
    cout << '\n';
}


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

int main() {
 int n;
  cin>>n;
  int a,b,c,d;
  a=n/1000;
    b=(n-a*1000)/100;
  c=(n-a*1000-b*100)/10;
    d=n-a*1000-b*100-c*10; 
  if (a==b && b==c){cout<<"Yes"<<endl;}
  else if (b==c && c==d){cout<<"Yes"<<endl;}
  else cout <<"No"<<endl;
}


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

int main() {
  long count=3000;
  long L,R;
  cin>>L>>R;
  if(R-L>2030){
    cout<<0;
    return 0;
  }
  for(long i=L;i<=R-1;i++){
    for(long j=i+1;j<=R;j++){
      count=min(count,(i*j)%2019);
      if(count==0){
        cout<<0;
        return 0;
      }
    }
  }
  cout<<count;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	slice := strings.Split(s, "")
	pre := ""
	num := 0
	for _, v := range slice {
		if pre != v {
			num++
			pre = v
		}
	}
	fmt.Println(num)
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
int i,a,b,count=0;
char S[25],T[25];
gets(S);
gets(T);
a=strlen(S);
b=strlen(T);
if(a<b)
{
for(i=0;i<a;i++)
  {
  if(S[i]!=T[i])
    {
    printf("No\n");
    count=count+1;
    break;
    }
  }
  if(count==0)
  printf("Yes\n");
}
return 0;
}


Measured memory_bytes: 1512
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(set)
for _ in range(M):
    src, dst = map(int, input().split())
    d[src].add(dst)

ans = False
for x in d[1]:
    if N in d[x]:
        ans = True
        break
print("POSSIBLE" if ans else "IMPOSSIBLE")


Measured memory_bytes: 74284
import java.io.*;
  
  
public class Main {  
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Main m = new Main();
        String line = br.readLine();
        int[] num = m.splitIntChange(line);
          
        if(num[0] < num[1]){
            System.out.println("a < b");
        }
        else if(num[0] > num[1]){
            System.out.println("a > b");
        }
        else if(num[0] == num[1]){
            System.out.println("a == b");
        } 
    }
 
    public int[] splitIntChange(String str){
        String[] str_ = str.split(" ");
        int strlen = str_.length;
        int[] numarray = new int[strlen];
         
        for(int i = 0;i < strlen;i++){
            numarray[i] = Integer.parseInt(str_[i]); 
        }
         
        return numarray;
    }
}

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

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {

    int w,h,n;
    cin>>w>>h>>n;
    int x1,x2,y1,y2;
    x1=0,x2=w,y1=0,y2=h;

    rep(i,n){
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1){
            if(x>x1){x1=x;}

        }else if(a==2){
            if(x<x2){x2=x;}

        }else if(a==3){
            if(y>y1){y1=y;}

        }else if(a==4){
            if(y2>y){y2=y;}
        }

    }
    int ans;
    if(y2>y1&&x2>x1){
        ans=(y2-y1)*(x2-x1);
        cout<<ans<<endl;
    }else{
        cout<<0<<endl;
    }


    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s; cin >> s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])cout << "Bad" << endl;
	else cout << "Good" << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc073.contest.atcoder.jp/tasks/arc073_b>
問題文============================================================
 あなたは N 個の物と、強度 W のバッグを持っています。 i 個目の物は、重さが wi で価値が vi です。
 
 あなたは、物のうちいくつかを選び、バッグに入れます。 ただし、選んだ物の重さの和は W 以下でなくてはいけません。
 
 あなたは、バッグに入れた物の価値の総和を最大化したいです。
 
 制約
 1≦N≦100
 1≦W≦10^9
 1≦wi≦10^9
 すべての i=2,3,…,N について、w1≦wi≦w1+3
 1≦vi≦10^7
 W,wi,vi はすべて整数である

=================================================================

解説=============================================================

 100*(w1+3) = 100*w1 + 300
 
================================================================
*/

ll dp[110][110][330];

void init(){
    for(int i = 0; i < 110; i++) for(int j = 0; j < 110; j++) for(int k = 0; k < 330; k++)
        dp[i][j][k] = -1;
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    init();
    ll N,W; cin >> N >> W;
    vector<ll> w(N),v(N);
    for(int i = 0; i < N;i++) cin >> w[i] >> v[i];
    ll base_w = w[0];
    for(int i = 0; i < N;i++) w[i] -= base_w;
    
    dp[0][0][0] = 0;
    for(int i = 0; i < N;i++){
        for(int j = 0; j < 110; j++){
            for(int k = 0; k < 330; k++){
                if(dp[i][j][k] == -1) continue;
                dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
                dp[i+1][j+1][k+w[i]] = max(dp[i+1][j+1][k+w[i]],dp[i][j][k] + v[i]);
            }
        }
    }
    ll ans = 0;
    for(int j = 0; j < 110; j++){
        for(int k = 0; k < 330; k++){
            if(dp[N][j][k] == -1) continue;
            if(base_w*j + k <= W){
                ans = max(ans,dp[N][j][k]);
            }
        }
    }
    cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
    int a;
    cin >> a;
    float n[a];
    for (int i = 0; i < a; i++)
        cin >> n[i];
    float sum = 0;
    for (int i = 0; i < a; i++)
        sum += (1 / n[i]);
    float re = (1 / sum);
    cout << re << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int x, a, b;
	cin >> x >> a >> b;
	cout << ((x - a) % b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, a, N) for(int i = a; i < N; i++)

int main() {
    int N, K;
    cin >> N >> K;
    ll a = 0, b = 0;
    ll ans = 0;

    if (K % 2 == 0) {
        rep(i, 1, N + 1) {
            if (i % K == 0) a++;
            else if (i % K == K / 2) b++;
        }
        ans = pow(a, 3) + pow(b, 3);
        cout << ans << endl;
    }

    else {
        rep(i, 1, N + 1) {
            if (i % K == 0) a++;
        }
        ans = pow(a, 3);
        cout << ans << endl;
    }
}

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

#define M 1046526/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M/* your task */; }
int h2(int key){ return 1+(key%(M-1))/* your task */; }

int h(int key,int i){ return (h1(key)+i*h2(key))%M;}

int find(char str[]){
    /* your task */
    long long key,i=0,j;
    key=getKey(str);
    while(1){
        j=h(key,i);
        if(strcmp(H[j],str)==0){
            return 1;
        }else if(strlen(H[j])==0){
            return 0;
        }
        i++;
    }
}

int insert(char str[]){
    /* your task */
    long long key,i=0,j;
    key=getKey(str);
    while(1){
        j=h(key,i);
        if(strcmp(H[j],str)==0)
            return 1;
        else if(strlen(H[j])==0){
            strcpy(H[j],str);
            return 0;
        }
        i++;
    }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef pair<int, bool> ib;

#define FOR(a, b, c) for(int a = b; a < c; ++a)
#define RFOR(a, b, c) for(int a = b; a >= c; --a)
#define mp(a, b) make_pair(a, b)
#define all(v) v.begin(), v.end()

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define fst first
#define snd second
#define MAXN 500010
#define MAXM 44100
#define LOGMAXN 20
#define INF 1e9+7
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007LL

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, m;
	while(cin >> n)
	{
		vector<int> v(n);
		FOR(i, 0, n)
		{
			cin >> v[i];
		}
		sort(v.begin(), v.end());
		ll sum = 0LL;
		FOR(i, 0, n-2)
		{
			int rp = i+2;
			FOR(j, i+1, n-1)
			{
				while(rp < n && v[rp] < v[i] + v[j]) rp++;
				rp--;
				if(v[rp] >= v[i] + v[j]) break;
				sum += (rp-j);
			}
		}
		printf("%lld\n", sum);
	}
	return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
       
        for(;true;){
            int x = sc.nextInt();
            int y = sc.nextInt();
            
            if(x==0 && y==0)break;
            
            if(x < y){
                System.out.println(x+" "+y);
            }else{
                System.out.println(y+" "+x);
            }
        }
    }
}



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

int main(){
	int A,B,C,D; cin >> A >> B >> C >> D;
  
	if(A*B >= C*D){
      cout << A*B << endl;
    }
     
    else{
      cout << C*D << endl;
    }
  
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    ll n, k;
    cin >> n >> k;

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

    vector<int> s;
    vector<int> ord(n + 1, -1);

    int c = 1, l = 0;

    int v = 1;
    while (ord[v] == -1) {
        ord[v] = s.size();
        s.push_back(v);
        v = a[v - 1];
    }
    c = s.size() - ord[v];
    l = ord[v];

    if (k < l) cout << s[k] << endl;
    else {
        k -= l;
        k %= c;
        cout << s[l + k] << endl;
    }

    return 0;
}

Measured memory_bytes: 5892
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

void no() {
    cout << "No" << endl;
}

int main() {
    int h, w;
    cin >> h >> w;
    unordered_map<char, int> count;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            count[c]++;
        }
    }
    if (h % 2 == 0 && w % 2 == 0) {  //両方偶数
        for (auto itr = count.begin(); itr != count.end(); itr++) {
            auto now = *itr;
            if (now.second % 4 != 0) {
                no();
                return 0;
            }
        }
    } else if ((h + w) % 2 == 1) {  //片っぽ奇数
        // h:奇数と思いたい
        if (h % 2 == 0) swap(h, w);
        // a:4n
        int a = 0;
        for (auto itr = count.begin(); itr != count.end(); itr++) {
            auto now = (*itr).second;
            if (now % 2 != 0) {
                no();
                return 0;
            } else if (now % 4 != 0) {
                a++;
            }
        }
        if (a > w / 2) {
            no();
            return 0;
        }
    } else {  //両方奇数
        // a:4n+2,b:奇数
        int a = 0, b = 0;
        for (auto itr = count.begin(); itr != count.end(); itr++) {
            auto now = (*itr).second;
            if (now % 2 != 0) {
                b++;
            } else if (now % 4 != 0) {
                a++;
            }
        }
        if (a > h / 2 + w / 2 || b != 1) {
            no();
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

struct Pos
{
    int x;
    int y;
    Pos(int w, int h): x(w), y(h) {};
};


int main()
{
    int cum = 0;
    int w = 0;
    int h = 0;
    string slopes;
    cin >> slopes;
    stack<Pos> heights;
    heights.push(Pos{-1, 100000});
    heights.push(Pos{0, 0});
    vector<Pos> ponds;
    for (auto ch : slopes){
        ++w;
        if (ch == '\\'){
            --h;
            heights.push(Pos{w, h});
        }else if (ch == '/'){
            ++h;
            while (heights.top().y < h){
                heights.pop();
            }
            if (heights.top().y == h){
                auto dif = w - heights.top().x - 1;
                cum += dif;
                while (!ponds.empty() && ponds.back().x > heights.top().x){
                    dif += ponds.back().y;
                    ponds.pop_back();
                }
                ponds.push_back(Pos{heights.top().x, dif});
                heights.top().x = w;
            }else{
                heights.push(Pos{w, h});
            }
            
        }else if (ch == '_'){
            heights.top().x = w;
        }
    }
    cout << cum << endl;
    cout << ponds.size();
    for (auto pond : ponds) cout << ' ' << pond.y;
    cout << endl;
    return 0;
}

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

long long N;
string S;

int main(){
	cin >> N >> S;
	
	long long ans = 1;
	for(long long i = 0; i < N - 1; i++){
		if(S[i] != S[i+1]){
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct UnionFind{
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int size){init(size);}
  void init(int size){
    r.resize(size,0);
    p.resize(size,0);
    for(int i=0;i<size;i++) r[i]=1,p[i]=i;
  }
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};

signed main(){
  int n,m;
  int MOD=1000000007LL;
  while(cin>>n>>m,n||m){
    UnionFind uf(n);
    for(int i=0;i<m;i++){
      int x,y;
      cin>>x>>y;
      x--;y--;
      uf.unite(x,y);
    }
    int ans=1;
    for(int i=0;i<n;i++) if(uf.find(i)==i) (ans*=2)%=MOD;
    if(m) (ans+=1)%=MOD;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int n;
	while(cin>>n&&n!=0){
		int num=n*n,m,l;
		int hyou[16][16]={0};
		m=(n/2)+1;
		l=m+1;
		hyou[l][m]=1;
		for(int i=2;i<=num;i++){
			m++,l++;
			if(m>n || l>n)if(m>n)m=1;if(l>n)l=1;

			if(hyou[l][m]==0){
				hyou[l][m]=i;
			}else{
				m-=1;
				if(m==0)m=n;
				l+=1;
				if(l>n)if(l==n+1)l=1;else l=2;
				
				hyou[l][m]=i;
			}
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				printf("%4d",hyou[i][j]);
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3192
import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int n;
    	int x;
    	int total = 0;
    	int count = 0;
    	int c = 3 * 2 * 1; //3?????????????????????????????????????????????
    	int end = 0;
    	
    	for(;;){
    		n = scan.nextInt();
    		x = scan.nextInt();
    		
    		if(n == end && x == end){
    			break;
    		}
    		
    		for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    		}
        		}
    		}
    		System.out.println(count / c);
    		count = 0;
    	}
    }
}

Measured memory_bytes: 26392
from enum import Enum
class  Suit(Enum):
    S = 0
    H = 1
    C = 2
    D = 3

n = int(input())
Cards = [[1 for x in range(4)] for y in range(13)] 

for i in range(0,n):
    (s, r) = input().split()
    s = str(s)
    r = int(r)
    if s == "S":
        Cards[r-1][0] = 0
    elif s == "H":
        Cards[r-1][1] = 0
    elif s == "C":
        Cards[r-1][2] = 0
    elif s == "D":
        Cards[r-1][3] = 0

for m in range(0,4):
    for n in range(0,13):
        if Cards[n][m]==1:
            print(Suit(m).name, n+1)


Measured memory_bytes: 6336
n=int(input())
s=list(input())
minn=5
ban=n
count=0
for i in range(n):
    if s[i]=='W':
        count=count+1
    else:
        count=count-1
    
    if count<minn:
        minn=count
        ban=i
ans=0

for j in range(n):
    if j<ban and s[j]=='W':
        ans=ans+1
    if j>ban and s[j]=='E':
        ans=ans+1


print(ans)


Measured memory_bytes: 5796
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int a, b;
  cin >> a >> b;
  if(b%a==0) cout << a + b << endl;
  else cout << b - a << endl;
  return 0;
}

Measured memory_bytes: 3632
//Bokann ga bokka--nn!!
//JOI 2008yo-5
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define mod 100000
int dp[105][105][2][2]={};
//dp[][][a][b] aは前の方向 0は上　1は右 bは曲がってokか 0はng 1はok
int main(){
	int h,w;
	while(1)
	{
		cin >> w >> h;
		if(!h) return 0;
		for(int i=2;i<=w;i++) dp[i][1][1][1]=1;
		for(int i=2;i<=h;i++) dp[1][i][0][1]=1;
		for(int i=2;i<=w;i++)
		{
			for(int j=2;j<=h;j++)
			{
				dp[i][j][0][0]=dp[i][j-1][1][1];
				dp[i][j][0][1]=(dp[i][j-1][0][0]+dp[i][j-1][0][1])%mod;
				dp[i][j][1][0]=dp[i-1][j][0][1];
				dp[i][j][1][1]=(dp[i-1][j][1][0]+dp[i-1][j][1][1])%mod;

			}
		}
		cout << (dp[w][h][0][0]+dp[w][h][0][1]+dp[w][h][1][0]+dp[w][h][1][1])%mod << endl;
	}
}

Measured memory_bytes: 1324
using System;

namespace CSharp_Study
{
    class Program
    {
        static void Main(string[] args)
        {


            int n = int.Parse(Console.ReadLine());
            string[] line = Console.ReadLine().Split(' ');
            int[] nums = Array.ConvertAll(line, int.Parse);

            int m = int.Parse(Console.ReadLine());
            int sum;
            for (int i = 0; i < m; i++)
            {
                sum = 0;
                line = Console.ReadLine().Split(' ');
                int a = int.Parse(line[0]);
                int b = int.Parse(line[1]);

                for (int j = 0; j < n; j++)
                {
                    if (j == a - 1) sum += b;
                    else sum += nums[j];
                }
                Console.WriteLine(sum + "\n");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int N, K, i, min=1000000000;
    scanf("%d %d",&N,&K);
    int h[N];
    for (i=0; i<N; i++) {
        scanf("%d",&h[i]);
    }
    sort(h,h+N);
    for (i=0; i<=N-K; i++) {
        if (h[i+K-1]-h[i] < min) {
            min = h[i+K-1]-h[i];
        }
    } 
    printf("%d\n",min);
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<cmath>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int h[maxn],go[maxn*2],nxt[maxn*2],fa[maxn],co[maxn],kk[maxn],bb[maxn],sta[maxn];
bool bz[maxn];
int i,j,k,l,t,n,m,u,v,a,b,x,tot,top,num;
ll ans;
bool czy,gjx;
void add(int x,int y){
    go[++tot]=y;
    nxt[tot]=h[x];
    h[x]=tot;
}
int getfa(int x){
    if (!fa[x]) return x;
    int t=getfa(fa[x]);
    co[x]=co[x]^co[fa[x]];
    return fa[x]=t;
}
void travel(int x,int y){
    bz[x]=1;
    int t=h[x];
    while (t){
        if (go[t]!=y){
            if (bz[go[t]]){
                u=x;v=go[t];
                if (co[u]==co[v]) gjx=1;
            }
            else{
                co[go[t]]=co[x]^1;
                travel(go[t],x);
            }
        }
        t=nxt[t];
    }
}
void dfs(int x,int y){
    int t=h[x];
    while (t){
        if (go[t]!=y&&!(x==u&&go[t]==v||x==v&&go[t]==u)){
            dfs(go[t],x);
            kk[x]+=kk[go[t]];
            bb[x]+=bb[go[t]];
        }
        t=nxt[t];
    }
}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,m){
        scanf("%d%d",&j,&k);
        add(j,k);add(k,j);
        /*a=getfa(j);b=getfa(k);
        if (a!=b){
            add(j,k);add(k,j);
            fa[a]=b;
            co[a]=co[j]^co[k]^1;
        }
        else{
            u=j;v=k;
            if (co[j]==co[k]) gjx=1;
        }*/
    }
    //fo(i,1,n) getfa(i);
    /*if (!co[1])
        fo(i,1,n) co[i]^=1;*/
    co[1]=1;
    travel(1,0);
    fo(i,1,n) 
        if (co[i]) bb[i]=1;else bb[i]=-1;
    fo(i,1,n) num+=bb[i];
    if (m==n-1){
        if (num){
            printf("-1\n");
            return 0;
        }
    }
    else{
        if (gjx){
            if (num%2==1){
                printf("-1\n");
                return 0;
            }
            bb[u]-=num/2;bb[v]-=num/2;
            ans+=(ll)abs(num/2);
        }
        else{
            if (num){
                printf("-1\n");
                return 0;
            }
            kk[u]=1;kk[v]=-1;
        }
    }
    dfs(1,0);
    fo(i,1,n)
        if (!kk[i]) ans+=(ll)abs(bb[i]);
        else{
            if (kk[i]) bb[i]=-bb[i];
            sta[++top]=bb[i];
        }
    sta[++top]=0;
    sort(sta+1,sta+top+1);
    x=sta[(top+1)/2];
    fo(i,1,top) ans+=(ll)abs(sta[i]-x);
    printf("%lld\n",ans);
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mx = 1e18;
int n,a;
int ans = 1;
int calcws(int x){
	int cnt = -1;
	while(x)
		x/=10,cnt++;
	return cnt;
}
int g(int x){
	while(x>=10) x /= 10;
	return x;
}
signed main(){
	cin >> n;
	a = 1ll;
	for(int i = 1;i<=n;i++){
		int x;
		cin >> x;
		int rr = (g(a)*g(x))>=10;
		if(calcws(a)+calcws(x)+rr>=18) ans = -1;
		a = a*x;
        if(a==mx) ans = 1;
		if((a&&a<x)||a>mx)
			ans = -1;
		if(x==0) ans = 0;
	}
	if(ans==-1||ans==0) cout << ans << endl;
	else cout << a << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int D,T,S;
    cin >> D >> T >> S;
    if(D<=T*S) {
        cout << "Yes" << endl;

    } else {
        cout << "No" << endl;
    }
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();
    ll ans = n;
    REP(i, n) {
        if(i + m > n)
            break;
        ll tmp = 0;
        REP(j, m) {
            if(s[i + j] != t[j])
                tmp++;
        }
        chmin(ans, tmp);
    }
    cout << ans << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	int W, H; string s;
	cin >> H >> W >> s;
	for (int i = 0; i < W; ++i) {
		for (int j = 0; j < H; ++j) {
			bool fi = (i == 0 || i == W - 1);
			bool fj = (j == 0 || j == H - 1);
			if (fi && fj) {
				cout << '+';
			}
			else if (fi) {
				cout << '-';
			}
			else if (fj) {
				cout << '|';
			}
			else if(i == W / 2 && j == H / 2){
				cout << s;
			}
			else {
				cout << '.';
			}
		}
		cout << endl;
	}
	
	return 0;
}



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

int ans[100001];

int main()
{
    int n;
    cin >> n;
    int p[51];
    for(int i=0; i<n; i++) cin >> p[i];

    int count =0;
    for(int i=0; i<n; i++){
        if(p[i] != i+1) count++;
    }
    if(count<=2) cout << "YES" << endl;
    else         cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.util.*
import kotlin.math.min
import kotlin.system.exitProcess

fun main() = msolutions2019d()

@OptIn(ExperimentalStdlibApi::class)
fun msolutions2019d() = SimpleFastIOWithToken_msolutions2019d().exec {
    data class Edge(val from: Int, val to: Int)
    data class Vertex(val index: Int, val neighbor: MutableSet<Int> = mutableSetOf())

    val n = readInt()
    val edges = List(n - 1) { Edge(readInt() - 1, readInt() - 1) }
    val points = IntArray(n) { readInt() }.sortedArrayDescending()

    var count = 0
    val allocation = IntArray(n) { -1 }
    val graph = Array(n) { mutableSetOf<Int>() }
    edges.forEach { (from, to) -> graph[from].add(to); graph[to].add(from) }

    fun allocateDfs(currentIndex: Int) {
        if (allocation[currentIndex] != -1) return
        allocation[currentIndex] = points[count++]
        graph[currentIndex].forEach { allocateDfs(it) }
    }

    allocateDfs(0)

    val answer = buildString {
        appendln(edges.map { (u, v) -> min(allocation[u], allocation[v]).toLong() }.sum())
        append(allocation.joinToString(" "))
    }

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_msolutions2019d(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_msolutions2019d.() -> Unit) = run {
        Thread(null, { action() }, "(^o^)", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); exitProcess(1) } }
            .apply { start() }.join()
    }.run { kotlin.io.print(sb) }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 52756
#include <bits/stdc++.h>
using namespace std;
#define ll              long long int
#define int             ll
#define ff              first
#define ss              second
#define pb              emplace_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define forr(i, a, b)   for(int i =int(a);i<=int(b);i++)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
    template <typename Arg1>
     void __f(const char* name,Arg1&& arg1){
        cout<<name<<" : "<<arg1<<std::endl;
     }
     template <typename Arg1, typename... Args>
     void __f(const char* names,Arg1&& arg1,Args&&... args){
        const char* comma = strchr(names+1 ,',');
        cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
     }
#else
#define trace(...)
#endif
/*     
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
*/
double pi = 2.0*acos(0);
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}

///////////////////////////////////////////////////////////////////////////////////////////////
 int mod = 998244353;
 int power(int a,int b)
 {
    int res = 1;   
    while(b>0)
    {
		if(b&1)
		 res = (res*a)%mod;
		a = (a*a)%mod;
		b=b>>1; 
	}	  
	 return res; 
 }
int fact[200001];
int Comb(int n,int k)
{
	if(n<k)
	return 0;
	int res = fact[n];
	res=( res* power(fact[n-k],mod-2))%mod;
	res=(res*power(fact[k],mod-2))%mod;
	return res;
}
void solve(){
   int n,m,h;
   cin>>n>>m>>h;
   // m*(m-1)^(n-k-1)*  (n-1)ck
   int sum = 0;
   for(int k= 0;k<=h;k++){
   int res =( m* power(m-1,n-k-1))%mod;
   res = (res*Comb(n-1,k))%mod;
  sum =( sum + res)%mod;
  
   }
   
   cout<<sum<<endl;
   
 }


signed main(void)
{
	 fact[0] = 1;
	for(int  i =1;i<=200000;i++)
	 fact[i] =(fact[i-1]*(i%mod))%mod;
	 
      //  w(t)
      solve();

}


Measured memory_bytes: 5192
#include <algorithm>
#include <iostream>
#include <string>

int main() {
  std::string str;
  std::string input;

  std::cin >> str;
  std::cin >> input;

  std::reverse(str.begin(), str.end());
  if(str == input){
    std::cout << "YES" << std::endl;
  }
  else{
    std::cout << "NO" << std::endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int m, f, b;
  scanf("%d %d %d", &m, &f, &b);
  if ( m  + f < b ) printf("NA\n");
  else if ( m >= b ) printf("0\n");
  else printf("%d\n",  b - m);
  return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int index=0, ww=0;

    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }

    int b[n],w[n];
    if(s[0] == '#'){
        b[0] = 1;
        w[0] = 0;
    }else{
        b[0] = 0;
        w[0] = 1;
    }
    for(int i=1;i<n;i++){
        if(s[i] == '#'){
            b[i] = b[i-1] + 1;
            w[i] = w[i-1];
        }
        else{
            b[i] = b[i-1];
            w[i] = w[i-1] + 1;
        }
    }

   int minans = w[n-1];
    for(int i=0;i<n;i++){
        int bb = b[i];
        int ww = w[n-1] - w[i];
        if (minans > bb + ww) minans = bb+ ww;
    }
    cout << minans << endl;
}


Measured memory_bytes: 2180
#include <stdio.h>
int main() {int N,i,RB[51][2],TT=1;while (1) {scanf("%d",&N);if (!N) return 0;for (i=0;i<N;scanf("%d %d",&RB[i][0],&RB[i][1]),i++);int ans=0;for (i=0;i<N;i++) ans+=RB[i][0]*RB[(i+1)%N][1]-RB[i][1]*RB[(i+1)%N][0];if (ans<0) ans=-ans;printf("%d %.1lf\n",TT++,ans/2.00);}}

Measured memory_bytes: 0
using System;
using System.Linq;

class abc125_A
{
    static void Main(string[] args)
    {
        var read = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var QA = read[0];
        var QB = read[1];
        var QC = read[2];

        Console.WriteLine(QC / QA * QB);
    }

    static int readInt() {
        return int.Parse(Console.ReadLine());
    }
}

Measured memory_bytes: 13268
N = int(input())
Hs = list(map(int, input().split()))
ok = True
c = 0
for i in range(N):
  H = Hs[i]
  if H < c-1:
    ok = False
    break
  elif H == c-1:
    c = H+1
  else:
    c = H
if ok:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 14396
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
struct S{
  int x,y,r,m;
  S(int x,int y,int r,int m) :
    x(x),y(y),r(r),m(m) {}
  bool operator < (const S& s) const {
    return (x!=s.x)?(x<s.x):(y!=s.y)?(y<s.y):(r!=s.r)?(r<s.r):(m<s.m);
  }
};
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
  int h,w;
  while(cin>>h>>w){
    vector<string> grid(h);
    REP(i,h)cin>>grid[i];
    queue<S> que;
    set<S> used;
    que.push(S(0,0,0,0));
    while(!que.empty()){
      S s = que.front(); que.pop();
      if(used.find(s)!=used.end()) continue;
      used.insert(s);
      bool all = false;
      bool end = false;
      switch(grid[s.y][s.x]){
        case '<':
          s.r = 2;
          break;
        case '>':
          s.r = 0;
          break;
        case '^':
          s.r = 3;
          break;
        case 'v':
          s.r = 1;
          break;
        case '_':
          s.r = ((s.m)?2:0);
          break;
        case '|':
          s.r = ((s.m)?3:1);
          break;
        case '?':
          all = true;
          break;
        case '.':
          break;
        case '@':
          end = true;
          break;
        case '+':
          s.m = (s.m+1)%16;
          break;
        case '-':
          s.m = (s.m+16-1)%16;
          break;
      }
      if(end){
        cout<<"YES"<<endl;
        goto END;
      }
      if(grid[s.y][s.x]<='9'&&grid[s.y][s.x]>='0'){
        s.m = (grid[s.y][s.x]-'0');
      }
      for(int r = 0; r < 4; r++){
        if(all || s.r == r){
          int nx = (s.x+dx[r]+w)%w;
          int ny = (s.y+dy[r]+h)%h;
          que.push(S(nx,ny,r,s.m));
        }
      }
    }
    cout<<"NO"<<endl;  
END:;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=1e5+10;
const long long maxx=1e9+7;
int a[maxn];
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        memset(a,0,sizeof(a));
        for(int i=2;i<=N;i++)
        {
            int x=i;
            for(int j=2;j<=x;j++)
            {
                while(x%j==0)
                {
                    a[j]++;
                    x/=j;
                }
            }
               if(x!=1)
            a[x]++;
        }
       // for(int i=1;i<=N;i++)
           // cout<<"  "<<a[i];
        long long ans=1;
        for(int i=1;i<=N;i++)
        {
            if(a[i]!=0)
                ans=(ans*(a[i]+1))%maxx;
        }
        printf("%lld\n",ans);
    }
    return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

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

  ll a, b, x; cin >> a >> b >> x;
  cout << b / x - max(0ll, a-1) / x + (a == 0) << endl;

}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private List<Long> divisor(long n) {
		ArrayList<Long> l = new ArrayList<>();
		for (long i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				l.add(i);
				if (i * i != n) {
					l.add(n / i);
				}
			}
		}
		l.sort(Comparator.naturalOrder());
		return l;
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long N = sc.nextLong();
		long ans = 0;


		for (long q : divisor(N)) {
			long m = N / q - 1;
			if (m != 0 && // q が N自身の場合m==0となる 
					N / m == N % m) {
				ans += m;
			}
		}

		out.println(ans);

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = int(1e9)+10;
const ll INFll = ll(1e18)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

int main() {
  ll N, K; cin >> N >> K;
  Vll A(N), F(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> F[i];
  sort(ALL(A));
  sort(ALL(F));
  reverse(ALL(F));

  auto f = [&] (ll x) {
    ll y = 0;
    rep(i, N) y += max(A[i] - x/F[i], 0ll);
    return (y <= K);
  };

  ll ok = ll(2e12) + 5;
  ll ng = -1;
  while (llabs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (f(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 3328
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

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

Measured memory_bytes: 256