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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      int N, Q;
      string S;
      cin >> N >> Q >> S;
      vector<long long int> head (N,0);
      vector<long long int> leg (N,0);
      int dummy = 0;
      for(int i = 0;i < N;i++){
      	if(i != 0 && S[i-1] == 'A' && S[i] == 'C'){
      		dummy++;
      	}
      	head[i] = dummy;
      }
      int ans = dummy;
      dummy = 0;
      for(int i = N-1;i > -1;i--){
      	if(i != N-1 && S[i+1] == 'C' && S[i] == 'A'){
      		dummy++;
      	}
      	leg[i] = dummy;
      }
      
      for(int i = 0;i < Q;i++){
      	int a, b;
      	cin >> a >> b;
      	cout << ans-head[a-1]-leg[b-1] << endl;
      }
}

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

int main() {
	int n,i;;
	cin>>n;
	int ht[n];
	for(i=0;i<n;i++)
	{
	    cin>>ht[i];
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(ht[1]-ht[0]);
	for(i=2;i<n;i++)
	{
	    dp[i]=min(dp[i-1]+abs(ht[i]-ht[i-1]),dp[i-2]+abs(ht[i]-ht[i-2]));
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4328
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; cin >> n;
    vector<string> s(n);
    vvi to(n);

    rep(i, n) {
        cin >> s[i];
        rep(j, n){
            if(s[i][j] == '1') {
                to[i].pb(j);
            }
        }
    }
    
    int ans = -2;
    rep(i, n) {
        vi dist(n, -1);
        bool ok = true;
        int res = -2;
        queue<P> q;
        q.push({i, -1});
        dist[i] = 0;
        while(!q.empty()){
            P now = q.front(); q.pop();
            int v = now.fi, p = now.se; 
            for(auto u : to[v]){
                if(u == p) continue;
                if(dist[u] != -1 && dist[u] != dist[v]-1 && dist[u] != dist[v]+1){
                    ok = false;
                    // cout << i << " !OK" << endl;
                    break;
                }
                if(dist[u] == -1){
                    dist[u] = dist[v] + 1;
                    q.push({u, v});
                }
            }
            if(!ok) break;
        }
        if(ok){
            rep(i, n) res = max(res, dist[i]);
        }
        // cout << i << " " << res << endl;
        ans = max(ans, res);
    }

    cout << ans + 1 << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3824
import os
import sys

import numpy as np


def solve(n, m, q, sss, xy):
    dp1 = np.zeros((n + 1, m + 1), dtype=np.int64)
    dpv = np.zeros((n + 1, m + 1), dtype=np.int64)
    dph = np.zeros((n + 1, m + 1), dtype=np.int64)
    for i in range(n):
        for j in range(m):
            if sss[i, j] == 1:
                dp1[i + 1, j + 1] = 1

                if i > 0 and sss[i - 1, j] == 1:
                    dpv[i + 1, j + 1] = 1
                if j > 0 and sss[i, j - 1] == 1:
                    dph[i + 1, j + 1] = 1

    for i in range(1, n + 1):
        dp1[i] = dp1[i].cumsum()
        dpv[i] = dpv[i].cumsum()
        dph[i] = dph[i].cumsum()

    for j in range(1, m + 1):
        dp1[:, j] = dp1[:, j].cumsum()
        dpv[:, j] = dpv[:, j].cumsum()
        dph[:, j] = dph[:, j].cumsum()

    buf = np.zeros(q, dtype=np.int64)
    for i in range(q):
        x1 = xy[i * 4 + 0]
        y1 = xy[i * 4 + 1]
        x2 = xy[i * 4 + 2]
        y2 = xy[i * 4 + 3]
        cnt1 = dp1[x2, y2] - dp1[x1 - 1, y2] - dp1[x2, y1 - 1] + dp1[x1 - 1, y1 - 1]
        ver1 = dpv[x2, y2] - dpv[x1, y2] - dpv[x2, y1 - 1] + dpv[x1, y1 - 1]
        hor1 = dph[x2, y2] - dph[x1 - 1, y2] - dph[x2, y1] + dph[x1 - 1, y1]
        buf[i] = cnt1 - ver1 - hor1

    return buf


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8,i8,i8,i1[:,:],i8[:])')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8,i8,i8,i1[:,:],i8[:])', cache=True)(solve)

n, m, q = map(int, input().split())
sss = np.array([list(map(int, input())) for _ in range(n)], dtype=np.int8)
xy = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(n, m, q, sss, xy)
print('\n'.join(map(str, ans)))


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

int main() {
  
  int N;
  double T;
  double A;
  
  cin >> N;
  cin >> T >> A;
  
  vector<double> H(N);
  
  double num;
  double num2;
  double num3 = 1000000000.0;
  double num4 = 0.0;
  double num5;
  double num6;
  
  for(int i = 0;i < N;++i){
    cin >> H[i];
  }
  
  for(int i = 0;i < N;++i){
    num = T - (H[i] * 0.006);
    num2 = abs(num - A);
    num3 = min(num3,num2);
  }
  
  for(int i = 0;i < N;++i){
    num4++;
    num5 = T - (H[i] * 0.006);
    num6 = abs(num5 - A);
    
    if(num6 == num3){
      break;
    }
  }
    
  cout << num4 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;


int h, w;
string s[2001];
signed main() {
    cin >> h >> w;
    for (int i=0;i<h;i++) cin >> s[i];

    vector<int> yoko[h];
    vector<int> tate[w];


    int cnt;
    // 横
    for (int i=0;i<h;i++) {
        cnt = 0;
        for (int j=0;j<w;j++) {
            if (s[i][j] == '#') {
                yoko[i].push_back(cnt);
                if (cnt != 0) yoko[i].push_back(0);
                cnt = 0;
            }
            else {
                cnt++;
                if (j == w-1) yoko[i].push_back(cnt);
            }
        }
    }

    // y[h][w];
    vector<int> y[h];
    for (int i=0;i<h;i++) {
        vector<int> v = yoko[i];
        for (auto&it :v) {
            if (it == 0) y[i].push_back(0);
            else {
                for (int j=0;j<it;j++) {
                    y[i].push_back(it);
                }
            }
        }
    }
    // たて
    for (int i=0;i<w;i++) {
        cnt = 0;
        for (int j=0;j<h;j++) {
            if (s[j][i] == '#') {
                tate[i].push_back(cnt);
                if (cnt != 0) tate[i].push_back(0);
                cnt = 0;
            }
            else {
                cnt++;
                if (j == h-1) tate[i].push_back(cnt);
            }
        }
    }

        // t[w][h];
    vector<int> t[w];
    for (int i=0;i<w;i++) {
        vector<int> v = tate[i];
        for (auto&it :v) {
            if (it == 0) t[i].push_back(0);
            else {
                for (int j=0;j<it;j++) {
                    t[i].push_back(it);
                }
            }
        }
    }

    int ans = 0;
    for (int i=0;i<w;i++) {
        for (int j=0;j<h;j++) {
            ans = max(ans, t[i][j] + y[j][i] - 1);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 132736
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int N = sc.nextInt();

        int ans = 0;

        for (int i = 1; i <= N; i++) {
            int sum = 0;
            for (int j = 1; j <= N; j++) {
                if (i % j == 0) {
                    sum++;
                }
            }

            if (sum == 8 && i % 2 != 0) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;


signed main(){
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    vector<vector<char>> queries(Q);
    int reverseCnt = 0;
    rep(i,0,Q) {
        char t;
        cin >> t;
        queries[i].push_back(t);
        if (t == '1') {
            reverseCnt++;
            continue;
        } else {
            char f, c;
            cin >> f >> c;
            queries[i].push_back(f);
            queries[i].push_back(c);
        }
    }
    string reversedHead, tail;
    if (reverseCnt % 2 == 1) {
        reverse(all(S));
    }
    rep(i,0,Q) {
        if (queries[i][0] == '1') {
            reverseCnt--;
            continue;
        }
        debug(queries[i][2]);
        debug((queries[i][1] - '0'));
        debug(reverseCnt);
        if ((((queries[i][1] - '0') + reverseCnt % 2)) % 2 == 1) {
            reversedHead.push_back(queries[i][2]);
        }
        else tail.push_back(queries[i][2]);
    }
    reverse(all(reversedHead));
    debug(reversedHead);
    debug(S);
    debug(tail);
    cout << reversedHead << S << tail << endl;
    return 0;
}


Measured memory_bytes: 11968
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;


ll gcd(ll a,ll b,ll c){
	return __gcd(a,__gcd(b,c));
}


int main(){
	// FILE;
	SPEED;
	int n;
	cin>>n;
     ll ans=0;
     for(int i=1;i<=n;i++)
     for(int j=1;j<=n;j++)
     for(int k=1;k<=n;k++)
     	ans+=gcd(i,j,k);

     cout<<ans<<endl;
}


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

int main() {
  int n, W;
  cin>>n>>W;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++) cin>>w[i]>>v[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(100001));
  for (int i = 0; i < 100001; i++) dp[0][i] = LONG_MAX;
  for (int i = 0; i < n + 1; i++) dp[i][0] = 0;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < 100001; j++) {
      dp[i][j] = dp[i - 1][j];
      if (v[i - 1] <= j && dp[i - 1][j - v[i - 1]] != LONG_MAX) {
        dp[i][j] = min(dp[i][j], w[i - 1] + dp[i - 1][j - v[i - 1]]);
      }
    }
  }
  int an;
  for (int i = 100000; i >= 0; i--) {
    if (dp[n][i] != LONG_MAX && dp[n][i] <= W) {
      an = i;
      break;
    }
  }
  cout<<an<<endl;
}

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


void solve(long long N, std::vector<long long> X){
    long long ans = 100 * 100 * 100 * 100;
    for(int i= 1;i <= 100;i++){
        long long sum =0;
        for(int j=0;j<N;j++){
            sum += (X[j]-i)*(X[j]-i);
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


Measured memory_bytes: 256
a = input()
b = a.split(' ')
W = int(b[0])
H = int(b[1])
x = int(b[2])
y = int(b[3])
r = int(b[4])

if  -100 <= x < 0:
    print('No')
elif -100 <= y < 0:
    print('No')
elif W >= x + r and H >= y + r:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7676
#include<bits/stdc++.h>
using namespace std;
long long a,b,i=1;

int main()
{
	scanf("%lld %lld",&a,&b);
	if(a%b)
	{
		printf("%d\n",a);
	}
	else
	{
		printf("-1\n");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b;
  cin>>a>>b;
  int l=0,r=1;
  FOR(i,1,999){
    l += i;
    r += (i+1);
    int sal = l-a;
    int sar = r-b;
    if(sal!=sar)continue;
    printf("%d\n",sal);return 0;
  }
  return 0;
}


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

class Stack{
    private:
        int sp;
        int S[100];
    public:
        Stack(){sp=0;}
        void push(int d);
        int pop();
};

void Stack::push(int d){
    S[sp++]=d;
}

int Stack::pop(){
    sp--;
    return S[sp];
}

int main(){
    Stack s;
    string expr;
    getline(cin,expr);

    istringstream is(expr);

    while(!is.eof()){
        string op;
        is>>op;
        int tmp1,tmp2;
        switch(op[0]){
            case '+':
                tmp1=s.pop();
                tmp2=s.pop();
                s.push(tmp2+tmp1);
                break;
            case '-':
                tmp1=s.pop();
                tmp2=s.pop();
                s.push(tmp2-tmp1);
                break;
            case '*':
                tmp1=s.pop();
                tmp2=s.pop();
                s.push(tmp2*tmp1);
                break;
            default:
                istringstream is2(op);
                is2>>tmp1;
                s.push(tmp1);
                break;
        }
    }
    cout<<s.pop()<<endl;

    return 0;
}


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

using namespace std;
const int INF = 1e9+7;
int dp[10055];
int cost(int j){
	int cost[]={0,2,5,5,4,5,6,3,7,6};
	return cost[j];
}
int main(void){
	int N,M;
	cin >> N >> M;
	vector<int> A(M);
	for(int i=0;i<M;i++){
		cin >> A[i];
	}
	sort(A.rbegin(),A.rend());
	//dp[i]はi本使って出来る桁数の最大値
	dp[0]=0;
	for(int i=1;i<=N;i++){
		dp[i] = -1;
		for(int j=0;j<M;j++){
			if(i-cost(A[j])<0)continue;
			dp[i] = max(dp[i-cost(A[j])]+1,dp[i]);
		}
	}
	for(int i=1;i<=N;i++){
		fprintf(stderr,"%d 本使ったときの最大の桁数は%d\n",i,dp[i]);
	}
	vector<int>ans;
	while(N>0){
		for(int i=0;i<M;i++){
			if(cost(A[i])>N)continue;
			if(dp[N-cost(A[i])] == dp[N]-1){
				ans.push_back(A[i]);
				N -= cost(A[i]);
				break;
			}
		}
	}
	for(auto x:ans)cout << x;
	cout << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b[]=new int[a];
		int fig=0;
		for(int i=0;i!=a;i++) {
			b[i]=scan.nextInt();
		}
		int za=0;
		int count=0;
		for(int i=0;i!=a+1;i++) {
			if(b[za]==2) {
				fig=1;
				count=i+1;
				break;
			}
			za=b[za]-1;
		}
		System.out.println(fig==1?count:-1);
	}
}

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

int main(){
    int n, x, count;
    while(1){
        count = 0;
        cin >> n >> x;
        if(n==0 && x==0) break;

        for(int i=1; i<=n-2; i++){
            for(int j=i+1; j<=n-1; j++){
                for(int k=j+1; k<=n && i+j+k <= x; k++){
                    if(i+j+k == x) count ++;
                }
            }
        }

        cout << count << endl;
    }    
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int d;
	scanf("%d",&d);
	if (d==25)
	{
		cout<<"Christmas";
	}
	if (d==24)
	{
		cout<<"Christmas Eve";
	}
	if (d==23)
	{
		cout<<"Christmas Eve Eve";
	}
	if (d==22)
	{
		cout<<"Christmas Eve Eve Eve";
	}
	return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve() {
  int n; double p; cin >> n >> p;
  p = p / 100.0;
  n = (n + 1) / 2;
  cout << double(n) / p;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();
    string key = "keyence";
    bool ans = false;
    rep(i, n) {
        for (int j = i; j < n; j++) {
            string t = s.substr(0, i) + s.substr(j, n-j);
            if (t == key) ans = true;
        }
    }
    cout << (ans?"YES":"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++)
typedef long long ll;

int GetHeight(int x, int y, int h, int top_x, int top_y) {
  return h + abs(top_x - x) + abs(top_y - y);  
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  rep(i, n) { cin >> x[i] >> y[i] >> h[i]; }
 
  constexpr int kMax= 100; 
  for (int top_y = 0; top_y <= kMax; ++top_y) {
    for (int top_x = 0; top_x <= kMax; ++top_x) {

      int height = -1;
      rep(i, n) {
        if (h[i] == 0) continue; 

        int temp = GetHeight(x[i], y[i], h[i], top_x, top_y);
        if (height < 0) {
          height = temp;
          continue;
        }
        if (height != temp) {
            height = -1;
            break;
        }
      }

      if (height < 0) continue;

      rep(i, n) {
        if (h[i] != 0) continue;
        
        int dist = abs(top_x - x[i]) + abs(top_y - y[i]);
        if (dist < height) {
          height = -1;
          break;
        }
      }
      
      if (height < 0) continue;

      cout << top_x << " " << top_y << " " << height << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x7f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
const int maxn = 100010;
const double EPS = 1e-6;
using namespace std;
int main()
{
	ll a,b;
	cin>>a>>b;
	if(a-b>=0) printf("%lld\n",a-b);
	else printf("0\n");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> ans(h, vector<int>(w, 0));
    rep(i, h){
        int blk = -1;
        rep(j, w){
            if(s[i][j] == '#'){
                blk = j;
                continue;
            }
            ans[i][j] += j - blk;
        }
        blk = w;
        for(int j=w-1; j>=0; j--){
            if(s[i][j] == '#'){
                blk = j;
                continue;
            }
            ans[i][j] += blk - j;
        }
    }
    rep(i, w){
        int blk = -1;
        rep(j, h){
            if(s[j][i] == '#'){
                blk = j;
                continue;
            }
            ans[j][i] += j - blk;
        }
        blk = h;
        for(int j=h-1; j>=0; j--){
            if(s[j][i] == '#'){
                blk = j;
                continue;
            }
            ans[j][i] += blk - j;
        }
    }
    int an = 0;
    rep(i, h)rep(j, w) chmax(an, ans[i][j]-3);
    cout << an << endl;
}

Measured memory_bytes: 20096
#include <iostream>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>
#include <type_traits>
#include <map>
#include <cstdio>
#include <string>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

// 最大公約数算出
int calc_gcd(const vector<int> vec){
	int gcd = *min_element(vec.begin(), vec.end());
	for (const int ele: vec){
		gcd = gcd_euclid(gcd,ele);
	}
	return gcd;
}

// 最小公倍数
int calc_lcm(const vector<int> vec) {
	int tmp = 1;
	for (const int ele: vec){
		tmp *= ele;
	}
	int gcd = calc_gcd(vec);
	return tmp/gcd;
}

// nが奇数、偶数の場合の場合分け
// n & 1 ? odd : even

// distinctはsortしてunique + erase
// https://qiita.com/ysk24ok/items/30ae72f4f1060b088588
//std::sort(vec.begin(), vec.end());
//vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

int a[100005], b[100005], mx = -1e9, sec, pos, ans;
void run() {

	int a,b,k; get a >> b >> k;

	vector<int> vec{a,b};

	rep(i,0,k){
		if(vec.front() & 1){
			vec.front() = vec.front() - 1;
		}
		vec[1] = vec[1] + vec.front()/2;
		vec.front() = vec.front() / 2;
		swap(vec.front(), vec[1]);
	}

	if (k & 1){
		put vec[1] << " " << vec.front();
	} else {
		put vec.front() << " " << vec[1];
	}
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

s = b[a[0] - 1]

for i in range(1, n):
    s += b[a[i] - 1]
    if a[i] == a[i-1] + 1:
        s += c[a[i-1] - 1]

print(s)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main() {
    int n, i, x[200001], cx[200001];
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &x[i]);
        cx[i] = x[i];
    }
    qsort(cx, n, sizeof(int), compare_int);
    for (i = 0; i < n; i++) {
        if (x[i] < cx[n / 2])
            printf("%d\n", cx[n / 2]);
        else
            printf("%d\n", cx[n / 2 - 1]);
    }
    return 0;
}

Measured memory_bytes: 3704
//Satyam Chaudhary https://github.com/satyam3976
#include <bits/stdc++.h>
using namespace std;
typedef vector<long long> vll;
typedef long l;
#define mp make_pair
#define pb push_back
#define long long int
#define f(i,s,n) for(l i=s;i<n;i++)
#define fe(i,s,n) for(l i=s;i<=n;i++)
#define fr(i,s,n) for(l i=s;i>n;i--)
#define fre(i,s,n) for(l i=s;i>=n;i--)
const int maxn = 2e6 + 10;

int countDigit(int n2) 
{ 
    int n=n2;
    if (n == 0) 
        return 0; 
    return 1 + countDigit(n / 10); 
} 


int32_t main()
{
    int x;
    cin>>x;
    int y=countDigit(x);
    if(y%2==0)
    {
        int k=y-1;
        int z2=9;
        int z=9;
        k--;
        while(k>0)
        {
            
            z=z+(z2*pow(10,k));
            k=k-2;
            // cout<<"s"<<z<<endl;
        }
        cout<<z<<endl;
    }
    else{
        if(y==1)
            cout<<x<<endl;
        else
        {
        int k=y-2;
        int z2=9;
        k--;
        int z=9;
        while(k>0)
        {
            z=z+(z2*pow(10,k));
            k=k-2;
        }
       
        cout<<(x-pow(10,y-1)+1)+z<<endl;
        }
    }
}

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

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

#define mod 1000000007



using namespace std;

class CompareFirst

{

public:

  bool operator()(pair<int,int> n1,pair<int,int> n2) {

    return n1.first>n2.first; //>:desc <:asc

  }

};





int main(){
  string s,t,ss;
  int i,j,k,l,n,m;
  vector<string> vs;
  vector<int> v[26];
  pair<int,int> pr;
  //unordered_map<string,int> mp;
  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst> pq

  int r;
  cin >> r;
  
  cout << 3*r*r << endl;

  return 0;

}

Measured memory_bytes: 256
use proconio::{input, fastout};
use itertools::Itertools;
use std::collections::{HashMap, HashSet};

#[fastout]
fn main() {
    input! {
        _h: usize,
        _w: usize,
        m: usize,
        targets: [(usize, usize); m],
    }
    let mut h_counter = HashMap::<usize, usize>::new();
    let mut w_counter = HashMap::<usize, usize>::new();
    let mut hw_dict = HashMap::<usize, HashSet<usize>>::new();
    for (hi, wi) in targets {
        *h_counter.entry(hi).or_insert(0) += 1;
        *w_counter.entry(wi).or_insert(0) += 1;
        (*hw_dict.entry(hi).or_insert(HashSet::<usize>::new())).insert(wi);
    }
    let h_sorted: Vec<_> = h_counter.iter().sorted_by(|a, b| b.1.cmp(&a.1)).collect();
    let w_sorted: Vec<_> = w_counter.iter().sorted_by(|a, b| b.1.cmp(&a.1)).collect();

    let h_max = &h_sorted[0].1;
    let w_max = &w_sorted[0].1;
    let mut filled = true;
    for (hi, hc) in &h_sorted {
        if hc != h_max { break; }
        for (wi, wc) in &w_sorted {
            if wc != w_max { break; }
            if hw_dict.contains_key(hi) && hw_dict[hi].contains(wi) { continue; }
            filled = false;
            break;
        }
    }

    let mut ans = *h_max + *w_max;
    if filled { ans -= 1; }
    println!("{}", ans);
}


Measured memory_bytes: 92996
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	for(int i=0;i<k;i++)
	{
		if(a>b&&a>c)
	    {
		   a=a*2;
	    } 
	    else if(b>a&&b>c)
	    {
		   b=b*2;
	    }
	    else
     	{
	    	c=c*2;
	    }
	}
	cout<<a+b+c;
	return 0;
} 

Measured memory_bytes: 256
K = gets.chomp.to_i

k = 0
n = 0
q = (1..9).to_a

until k == K
  k += 1
  n = q.shift
  q << "#{n.to_s}#{(n % 10 - 1).to_s}".to_i if n % 10 > 0
  q << "#{n.to_s}#{(n % 10).to_s}".to_i
  q << "#{n.to_s}#{(n % 10 + 1).to_s}".to_i if n % 10 < 9
end

puts n


Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
const int MOD = 1000000007;

int main(){
    ll a,b,x;cin>>a>>b>>x;
    cout << a*b/2 << endl;
    return 0;
}


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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
#include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	vector<int> num;
	for (int i = 0; i < 3; i++) {
		int tmp;
		cin >> tmp;
		num.push_back(tmp);
	}
	sort(num.begin(), num.end());
	cout << num[0] << " " << num[1] << " " << num[2] << endl;
	return 0;
}



Measured memory_bytes: 3148
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;



void main() {
    auto N = readln.chomp.to!int;

    string d1 = "..##";
    string d2 = ".#.#";
    string r1 = "";
    string r2 = "";
    bool right_end = false;
    
    while (true) {
        bool t = false;
        foreach (k; 0..4) {
            if (right_end) {
                r1 = d1[k] ~ r1;
                r2 = d2[k] ~ r2;
            }
            else {
                r1 = r1 ~ d1[k];
                r2 = r2 ~ d2[k];
            }
            writeln(r1);
            writeln(r2);
            stdout.flush;
            string tf = readln.chomp;
            if (tf == "T") {
                t = true;
                break;
            }
            else if (tf == "end")
                return;
            
            if (right_end) {
                r1 = r1[1..$];
                r2 = r2[1..$];
            }
            else {
                r1 = r1[0..$-1];
                r2 = r2[0..$-1];
            }
        }

        if (!t) {
            right_end = true;
            N += 1;
        }
        
    }
}



Measured memory_bytes: 724
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N, K := sc.nextInt(), sc.nextInt()
	H := sc.nextIntSlice(N)
	sort.Ints(H)
	ans := int(1e+9)
	for i := 0; i <= N-K; i++ {
		mi, ma := H[i], H[i+K-1]
		ans = min(ans, ma-mi)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3072
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main 
{
	static long[] divin; //identity
	static int[] divs; //quantity
	static int divkinds; //kinds
	static long orin;
	static long an = 0;
	
	static void go(int prog, int[] divam)
	{
		if(prog < divkinds)
		{
			for(int i = 0; i <= divs[prog]; i++)
			{
				int[] ndivam = divam.clone();
				ndivam[prog] = i;
				go(prog+1, ndivam);
			}
		}
		else
		{
			long k = 1;
			for(int i = 0; i < divkinds; i++)
				for(int j = 0; j < divam[i]; j++)
				{
					k *= divin[i];
				}
			
			if(k!=1)
			{
				long curn = orin;
				while(curn%k == 0)curn/=k;
				long mod = curn%k;
				if(mod == 1)
				{
					an++;
				}
			}
		}
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong()-1;
		long sn = n+1;
		orin = sn;
		OccurrenceCounter<Long> oc = new OccurrenceCounter<>();
		
		if(n==2)
		{
			System.out.println(1);
			return;
		}
		an = 1;
		for(long i = 2; i*i<=n; i++)
		{
			while(n%i == 0)
			{
				n /= i;
				oc.add(i);
			}
		}
		if(n>1)oc.add(n);
		
		for(long l : oc.map.keySet())
		{
			an *= oc.get(l)+1;
		}
		an--; //1 doesn't count
		
		
		
		//bonus
		n=sn;
		oc = new OccurrenceCounter<>();
		for(long i = 2; i*i<=n; i++)
		{
			while(n%i == 0)
			{
				n /= i;
				oc.add(i);
			}
		}
		if(n>1)oc.add(n);
		
		divkinds = oc.map.keySet().size();
		divin = new long[divkinds];
		divs = new int[divkinds];
		int curdi = 0;
		long mindi = 999999999999l;
		for(long l : oc.map.keySet())
		{
			divin[curdi] = l;
			divs[curdi] = oc.get(l);
			mindi = Math.min(mindi, oc.get(l));
			curdi++;
		}
		
		go(0,new int[divkinds]);

		
		
		
		System.out.println(an);
		
		
	}

	static class OccurrenceCounter<T>
	{ //Stores and modifies occurrences.
		HashMap<T, Integer> map = new HashMap<>();
		
		int add(T t, int amount)
		{
			if(map.containsKey(t))
				map.put(t, map.get(t)+amount);
			else
				map.put(t, amount);
			return map.get(t);
		}
		
		int add(T t)
		{
			return add(t,1);
		}
		
		int get(T t)
		{
			if(map.containsKey(t))return map.get(t);
			else return 0;
		}
	}
}


Measured memory_bytes: 22356
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

    int sol1 = 0;
    for(int i = 0; i < m; i++)
    {
        if(a[i]> x) sol1++;
    }
    int sol2 = 0;
    for(int i = 0; i < m; i++)
    {
        if(a[i]< x) sol2++;
    }
    cout << min(sol1,sol2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000000
#define MAX2 10000

int main(){
  int *A, *B;

  int C[MAX2+1];
  int num, i, j;
  scanf("%d", &num);

  A = malloc(sizeof(int)*num);
  B = malloc(sizeof(int)*num);

  for ( i = 0; i <= MAX2; i++ ) C[i] = 0;

  for ( i = 0; i < num; i++ ){
    scanf("%d", &A[i + 1]);

    C[A[i + 1]]++;
  }

  for ( i = 1; i <= MAX2; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= num; j++ ){

    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= num; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 16272
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextInt()-1)
  val visited = Array.fill(n)(false)

  var now = 0
  var count = 0
  while (now != 1 && !visited(now)) {
    visited(now) = true
    now = a(now)
    count += 1
  }

  println(if (now == 1) count else -1)
}


Measured memory_bytes: 59548
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n)         for(int i=0; i<(n); i++)
#define P pair<int, int>
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"

//----------------------------------------------------

int main(){
    int k;
    string s, ans = "";
    cin >> k >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        for(int i = 0; i < k; i++){
            ans += s[i];
        }
        ans += "...";
        cout << ans << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    vector<ll> v;
    v.push_back(0);
    rep(i, n){
        ll a; cin >> a;
        v.push_back(a);
    }
    v.push_back(0);

    ll res = 0;
    ll ans = 0;
    for(int i=0; i<=min(n, k); i++){
        for(int j=0; j<=min(n, k)-i; j++){
            int ni=i, nj=j;
            priority_queue<ll, vector<ll>, greater<ll> > q;
            res = 0;
            while(ni!=-1){
                res+=v.at(ni);
                if(v.at(ni)<0) {
                    q.push(v.at(ni));
                }
                ni--;
            } 
            while(nj!=-1){
                res += v.at(n+1-nj);
                if(v.at(n+1-nj)<0) {
                    q.push(v.at(n+1-nj));
                }
                nj--;
            }

            for(int l=0; l<(k-i-j); l++){
                if(q.empty()) break;
                res -= q.top();
                q.pop();
            }
            
            ans = max(ans, res);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// You Are the Judge

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

struct DATA{
  int id,correct,penalty;
  vector<int>wrong;
  DATA(int i, int P){
    id=i;
    correct=penalty=0;
    wrong.resize(P);
    for(int i=0;i<P;i++)wrong[i]=0;
  }
};
bool operator<(DATA a, DATA b){
  return a.correct!=b.correct?a.correct>b.correct:(a.penalty!=b.penalty?a.penalty<b.penalty:a.id<b.id);
}

int main()
{
  int T,P,R;
  int t,p,time;
  string message;
  while(cin>>T>>P>>R,T|P|R){
    vector<DATA>team;
    for(int i=0;i<T;i++)team.push_back(DATA(i+1,P));
    for(int i=0;i<R;i++){
      cin>>t>>p>>time>>message;
      t--;
      p--;
      if(message=="WRONG"){
	team[t].wrong[p]++;
      }else{
	team[t].correct++;
	team[t].penalty+=team[t].wrong[p]*1200+time;
      }
    }
    sort(team.begin(),team.end());
    for(int i=0;i<T;i++){
      cout<<team[i].id<<" "<<team[i].correct<<" "<<team[i].penalty<<endl;
    }
  }
}

Measured memory_bytes: 940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <numeric>
#define rep(i,s,n) for (int i = s; i < n; ++i)
#define drep(i,s,n) for (int i = n; i >= s; --i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a, int b)
{
   if (a%b == 0) return(b);
   else          return(gcd(b, a%b));
}
int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
void printvv(vector<vector<auto>> vv, int n)
{
  cout << '[' << endl;
  rep(q, 0, n)
  {
    cout << '[';
    rep(p, 0, n)
    {
      cout << vv.at(q).at(p) << ',';
    }
    cout << ']' << endl;
  }
  cout << ']' << endl;
}

void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

//------------------------------------------------------------
void solve() {
  int n,i=0,j=1,sum=0,ans=300001,e=0,w=0;
  string s;
  cin>>n>>s;

  while (i<n)
  {
    if(i==0)
    {
      while(j<n) {if(s[j]=='E'){++e;} ++j;}
    }
    else
    {
      if(s[i-1]=='W') ++w;
      if(s[i]  =='E') --e;
    }

    sum=w+e;
    if(sum==0) {print(0); return;}
    ans=min(ans, sum);
    ++i;
  }

  print(ans);

  return;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
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;
}
///////////////////////////////////////////////
int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int ans = 0;
    vector<int> B(M);
    REP(i,M){
        cin >> B[i];
    }

    REP(i,N){
        int nans = 0;
        REP(j,M){
            int A;
            cin >> A;
            nans += A * B[j];
        }

        nans += C;
        if (nans > 0) ans++;
    }

    cout << ans << endl;


}






Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char c;
	
	scanf("%c",&c);
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
		printf("vowel\n");
	}
	else{
		printf("consonant\n");
	}

	return 0;
}


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

int main(void){
  
  int N,M;
  int sum=0;
  
  // NとMの標準入力
  std::cin >> N >> M;
  
  std::vector<int> A(N);
  // Anの標準入力
  for (int i=0;i<N;i++){
  	std::cin >> A.at(i);
    
    // Anの合計値
    sum += A.at(i);  
  }  
    
  std::sort(A.begin(),A.end(),std::greater<int>());//降順ソート
  
  // Yes or No の判断
  for (int i=0;i<M;i++){
    if (A.at(i)*4*M < sum){
      std::cout << "No\n" << std::endl;
      return 0;
    } else {
      // 特に何もなし
    }  
  }
  
  std::cout << "Yes\n" << std::endl;
  
  return 0;

}

Measured memory_bytes: 256
import math  # noqa: F401
from collections import deque  # noqa: F401
from typing import Deque, Dict, List, Optional, Tuple, Union  # noqa: F401


def main(A: int, B: int, C: int, K: int):
    for _ in range(K):
        if A >= B:
            B *= 2
            continue
        if B >= C:
            C *= 2

    if C > B > A:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    A, B, C = map(int, input().split())
    K = int(input())
    main(A, B, C, K)

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

using namespace std;

// Function to solve the problem come here.

int main(int argc, char **argv)
{
    int A, B;
    cin >> A >> B;

    int sum = A + B;
    int sub = A - B;
    int mul = A * B;

    if (sum > sub && sum > mul)
    {
        cout << sum << endl;
    }
    else if (sub > mul)
    {
        cout << sub << endl;
    }
    else
    {
        cout << mul;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;


const int MAX_N = 100005;
int par[MAX_N], ran[MAX_N];

void init(int n) {
	if (n > MAX_N) cout << "BAD INPUT" << endl;
	for (int i = 0; i < n; ++i) {
		par[i] = i;
		ran[i] = 0;
	}
}

int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;

	if (ran[x] < ran[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (ran[x] == ran[y]) ++ran[x];
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

int main() {
	ll n, m; cin >> n >> m;
	init(n);
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		unite(a - 1, b - 1);
	}
	ll cnt0 = 0, cnt1 = 0;
	for (int i = 0; i < n; ++i) {
		if (same(0, i)) ++cnt0;
		if (same(1, i)) ++cnt1;
	}
	ll ans = 0;
	if (cnt0 >= cnt1) {
		ll zero = cnt0 + (n - cnt0 - cnt1);
		ans += zero*(zero - 1) / 2;
		ans += cnt1*(cnt1 - 1) / 2;
	}
	else {
		ll one = cnt1 + (n - cnt0 - cnt1);
		ans += one*(one - 1) / 2;
		ans += cnt0*(cnt0 - 1) / 2;
	}
	cout << ans - m << endl;
	return 0;
}

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

int main(){
  	int count = 0;
	string S;
  	cin >> S >> S;
  	for (; S.find("ABC") != string::npos; count++) {
    	S = S.substr(S.find("ABC") + 3);
    }
  	cout << count << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
 int n,flag=0;   
 cin>>n;   
 for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
        if(i*j==n){
            flag++;
        }
    }
 }
 if(flag!=0){
    cout<<"Yes";
 }
 else{
    cout<<"No";
 }   
   return 0;
}

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

int main() {
  string str;
  cin >> str;
  int status_num = 3;
  int block_status[status_num];
  
  // intに変換
  transform(begin(str), end(str), block_status, [](char c){return c - '0';});
    
  int counter = 0;  
  for (int i = 0, size = status_num; i < size; i++) {
    if (block_status[i] == 1) counter++;
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


int main() {
	int n;
	cin >> n;
	int B[n+1];
	B[0] = 1000000;
	B[n] = 1000000;
	for (int i=1; i<n; i++) {
		cin >> B[i];
	}
	int res = 0;
	rep(i, n) {
		res += min(B[i], B[i+1]);
	}
	cout << res << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
using namespace std;
int main(){
    int K;
    string S;
    cin >> K;
    cin >> S;
    size_t k = S.length();
    if (k<=K){
        cout << S;
    }else{
        cout << S.substr(0,K) << "...";
    }
}

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

typedef long long int   ll;
#define cases           int t;cin>>t;while(t--)
#define FIO             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl            "\n"
#define scan(n)         scanf("%d",&n)
#define PI              3.1415926535897932384626433832795
#define int             ll
#define loop0           for(int i=0;i<n;i++)
#define loop1           for(int i=1;i<=n;i++)
#define inpar0(ar)      for(int i=0;i<n;i++)cin>>ar[i]
#define inpar1(ar)      for(int i=1;i<=n;i++)cin>>ar[i]
#define showar0(ar)     for(int i=0;i<n;i++)cout<<ar[i]<<" "
#define showar1(ar)     for(int i=1;i<=n;i++)cout<<ar[i]<<" "
int mod=1000000007;
int maxn=200001;
int binpow(int a,int b,int mod){int res=1;while(b>0){if(b%2){res=(res*a)%mod;b--;}a=(a*a)%mod;b/=2;}return res%mod;}
bool isPrime(int n){if(n==1)return false;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

signed main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0) cout<<1;
    if(b==0) cout<<2;
    if(c==0) cout<<3;
    if(d==0) cout<<4;
    if(e==0) cout<<5;
}


Measured memory_bytes: 3572