akhauriyash/Code-Regression huggingface dataset:
/*
Writer: SPD_9X2
https://atcoder.jp/contests/abc128/tasks/abc128_es

それぞれの工事がどのDの範囲の人を制限するのか計算すればよい
Xiが最も小さいものが影響を及ぼす。
heap & いもす法で解ける？

具体的には、

X-S <= D < X-T　のDが封鎖を食らう
*/

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

#define rep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
using ll = long long;

int main(){

    ll N,Q;
    cin >> N >> Q;

    vector<vector<ll>> sti(0,vector<ll> (2,0));
    vector<vector<ll>> goi(0,vector<ll> (2,0));
    vector<vector<ll>> STX(0,vector<ll> (3,0));

    rep(i,0,N){

        ll S,T,X;
        cin >> S >> T >> X;
        sti.push_back({S-X,i});
        goi.push_back({T-X,i});
        STX.push_back({S,T,X});
    }

    sort(sti.begin(),sti.end());
    sort(goi.begin(),goi.end());

    sti.push_back({100000000000,0});
    goi.push_back({100000000000,0});

    vector<ll> D(0,0);
    vector<ll> ans(Q,-1);

    rep(i,0,Q){
        ll d;
        cin >> d;
        D.push_back(d);
    }

    D.push_back(100000000000);

    ll si=0 , gi=0 , di=0;
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>> > hq;
    vector<ll> inlis(N,0);

    while ((di!=Q) && (gi!=N)){

        ll st,stind,startX;
        st = sti[si][0];
        stind = sti[si][1];
        startX = STX[stind][2];
        ll go,goind;
        go = goi[gi][0];
        goind = goi[gi][1];
        ll nd = D[di];

        ll nmin = min(st,min(go,nd));
        if (nmin==go){
            inlis[goind] = 0;
            gi++;
        }else if (nmin==st){
            inlis[stind] = 1;
            hq.push(make_pair(startX,stind));
            si++;
        }else{

            while ((hq.size()>0) && (inlis[hq.top().second] == 0)){
                hq.pop();
            }

            if (hq.size()==0){
                ans[di] = -1;
            }else{
                ans[di] = hq.top().first;
            }
            di++;
        }
    }

    rep(i,0,Q){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 50308
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
//#define iinf (3000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int f[105][11],p[105][12],n;
ll calc(int n1){
	int v[123]={0};
	int i,j,ans=0;
	rep(i,10){
		ans=0;
		if(n1&(1<<i))
			ans=1;
		if(!ans)
			continue;
		rep(j,n){
			if(f[j][i])
				v[j]++;
		}
	}
	ans=0;
	rep(j,n){
		ans+=p[j][v[j]];
	}
	return ans;
}
int main(){
	int i,j;
	ll maxx=-inf;
	cin>>n;
	rep(i,n){
		rep(j,10){
			cin>>f[i][j];
		}
	}
	rep(i,n){
		rep(j,11){
			cin>>p[i][j];
		}
	}
	f(i,1,(1<<10)){
		maxx=max(maxx,calc(i));
	}
	cout<<maxx<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	for _, i := range nums {
		if i % 2 == 0 && i % 3 != 0 && i % 5 != 0 {
			fmt.Println("DENIED")
			return
		}
	}
	fmt.Println("APPROVED")
	return
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 3010
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
#define INF 10000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int a,b;
    cin>>a>>b;
    int ans=-1;
    if(a<10&&b<10) ans=a*b;
    OUT(ans);
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

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

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


class CMultiplication3 {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        long double a,b;cin >> a >> b;
        int64_t ans = a * b;
        cout << ans << '\n';
	}
	void main2(istream& cin,ostream& cout){

	}
};


int main() {
	CMultiplication3 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;
using P = pair<int, int>;

class DisjointSets
{
public:
    DisjointSets(const int v)
    {
        m_parent.resize(v);
        m_rank.resize(v);
        m_size.resize(v);
        for (int i = 0; i < v; i++) {
            m_parent[i] = i;
            m_rank[i] = 0;
            m_size[i] = 1;
        }
    }

    bool same(const int a, const int b)
    {
        return find(a) == find(b);
    }


    int find(const int a)
    {
        if (m_parent[a] == a) {
            return a;
        } else {
            return m_parent[a] = find(m_parent[a]);
        }
    }

    void unite(const int a_, const int b_)
    {
        const int a = find(a_);
        const int b = find(b_);
        if (a == b) {
            return;
        }
        if (m_rank[a] > m_rank[b]) {
            m_parent[b] = a;
            m_size[a] += m_size[b];
        } else {
            m_parent[a] = b;
            m_size[b] += m_size[a];
        }
        if (m_rank[a] == m_rank[b]) {
            m_rank[b]++;
        }
    }

    int getSize(const int a)
    {
        return m_size[m_parent[a]];
    }

private:
    vector<int> m_parent;
    vector<int> m_rank;
    vector<int> m_size;
};

int main()
{
    int V;
    cin >> V;
    DisjointSets uf(V);
    vector<vector<bool>> a(V, vector<bool>(V));
    int e = 0;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            char c;
            cin >> c;
            if (c == 'N') {
                a[i][j] = false;
            } else {
                a[i][j] = true;
                if (i < j) {
                    e++;
                    uf.unite(i, j);
                }
            }
        }
    }
    vector<int> num(V);
    for (int i = 0; i < V; i++) {
        num[uf.find(i)]++;
    }
    int odd = 0;
    int even = 0;
    for (int i = 0; i < V; i++) {
        if (num[i] > 0) {
            if (num[i] % 2 == 0) {
                even++;
            } else {
                odd++;
            }
        }
    }

    const int E = (V - 1) * V / 2 - e;
    if (E % 2 == 0) {
        if (odd < 2) {
            cout << "Hanako" << endl;
        } else {
            if ((even == 1 and odd == 2) or (even == 0 and odd == 2)) {
                cout << "Taro" << endl;
            } else {
                cout << "Hanako" << endl;
            }
        }
    } else {
        if (even == 0 and odd == 2) {
            cout << "Hanako" << endl;
        } else {
            cout << "Taro" << endl;
        }
    }

    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(int i = (int)(s); i < (int)(e); ++i)
#define per(i,s,e) for(int i = (int)(s)-1; i >= (int)(e); --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,0,n)a[i] = 20000 * (i+1);
  
  
  vector<int> b(n);
  rep(i,0,n){
    b[i] = (n-i)*20000;
  }
  rep(i,0,n){
    int x; cin >> x;x--;
    b[x] += i;
  }
  rep(i,0,n){
    if(i)cout << ' ';cout << a[i];
  }cout << endl;
  rep(i,0,n){
    if(i)cout << ' ';cout << b[i];
  }cout << endl;
  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int W[10], K[10];
  for (int i = 0; i < 10; i++)
    cin >> W[i];
  for (int i = 0; i < 10; i++)
    cin >> K[i];
  sort(W, W+10);
  sort(K, K+10);
  cout << W[9]+W[8]+W[7] << ' ' << K[9]+K[8]+K[7] << endl;
  return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;
	return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
s=[[] for i in range(h+2)]
for i in range(h):
    x=input()
    x="."+x
    x=x+"."
    s[i+1]=list(x)
s[0]=["." for i in range(w+2)]
s[-1]=["." for i in range(w+2)]
f=0
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]=="#" and s[i][j+1]==s[i][j-1]==s[i+1][j]==s[i-1][j]==".":
            f=1
print("Yes" if f==0 else "No")


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

int main(){
    int a,b,c;
    char op;

    while(op != '?'){

        cin >> a >> op >> b;

        if(op == '+'){
            c = a + b;
            cout << c << endl;
        }else if(op == '-'){
            c = a - b;
            cout << c << endl;
        }else if(op == '*'){
            c = a * b;
            cout << c << endl;
        }else if(op == '/'){
            c = a / b;
            cout << c << endl;
        }


    }



    return 0;
}


Measured memory_bytes: 3092
H,W,A,B = map(int,input().split())
temp = ""
for l in range(0,W):
    temp = temp + "0"


Alist = list()
for k in range(0,H):
    Alist.append(list(temp))


for i in range(0,H):
    for j in range(0,W):
        if i < B and j < A :
            Alist[i][j] = "1"
        elif j >= A and i<B:
            Alist[i][j] = "0"
        elif i >= B and j < A :
            Alist[i][j] = "0"
        else:
            Alist[i][j] = "1"

for a in Alist:
    print(''.join(a))


Measured memory_bytes: 12916
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long 
#define ar array
#define f first
#define s  second
#define REP(i,n) for (int i=0;i<(n);i++)
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using o_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);

  freopen("output1.txt","w",stdout);
#endif
}
const int mod=1000000007;
int power(int a,int b,int mod){
  a=a%mod;
  if(a==0){
    return 1;
  }
  int res=1;
  while(b){
    if(b&1){
      res=(res*a)%mod;
    }
    b>>=1;
    a=(a*a)%mod;
  }
  return res;
}

int  MMI(int p){
  return power(p,mod-2,mod);
}
int32_t main()
{
 c_p_c();
 int n;
 cin>>n;
 int m=0,ans=0;
 for(int i=0;i<n;i++){
  int a;
  cin>>a;
  if(a<m)ans+=(m-a);
  else m=a;
 }
 cout<<ans;



 return 0;  
 
 
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s,t;
int n,m;
vvi dp;

int main(){
	cin>>s>>t;
	n=s.size();m=t.size();
	dp=vvi(n+1,vi(m+1));
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){
		if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
		else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	}
	int I=n,J=m;
	string res;
	while(res.size()<dp[n][m]){
		if(s[I-1]==t[J-1]){
			res+=s[I-1];
			I--;J--;
		}
		else{
			if(dp[I][J]==dp[I-1][J]) I--;
			if(dp[I][J]==dp[I][J-1]) J--;
		}
	}
	reverse(res.begin(),res.end());
	cout<<res<<endl;
}

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

int main(){
  string s1, s2, s3;
  cin>>s1;
  cin>>s2;
  cin>>s3;
  int c1 = 0, c2 = 0, c3 = 0;
  int j = 1;
  while(true){
    if(j == 1){
      if(c1 <= s1.length() - 1){
        j = (s1[c1] == 'a'? 1:(s1[c1] == 'b'? 2 : 3) );
        c1++;
      }else
        break;
    }
    if(j == 2){
      if(c2 <= s2.length() - 1){
        j = (s2[c2] == 'a'? 1:(s2[c2] == 'b'? 2 : 3) );
        c2++;
      }else
        break;
    }
    if(j == 3){
      if(c3 <= s3.length() - 1){
        j = (s3[c3] == 'a'? 1:(s3[c3] == 'b'? 2 : 3) );
        c3++;
      }else
        break;
    }
  }
  cout<<(j == 1? "A":(j == 2? "B" : "C") )<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 5000
#define Inc(x,y) ((x+=(y))>=X&&(x-=X))
using namespace std;
int n,X,f[N+5][N+5][2];
int main()
{
	RI i,j;scanf("%d%d",&n,&X),f[1][0][0]=1;
	RI hn=(n+1)/2;for(i=2;i<=hn;++i) for(j=0;j^n;++j)
		f[i][j][1]=f[i-1][j][0],j-i+1>=0&&Inc(f[i][j][1],f[i][j-i+1][1]),
		f[i][j][0]=f[i][j][1],j-i+1>=0&&Inc(f[i][j][0],f[i][j-i+1][0]);
	RI ans=0;for(i=1;i<=n;++i) for(j=(n-i)/hn;~j;--j)
		ans=(1LL*((n-1)&1?j+1:1)*f[hn][n-i-j*hn][0]+ans)%X;
	return printf("%d",ans),0;
}

Measured memory_bytes: 98432
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

long long right[101][101];

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

	auto result = 0;
	for (auto l = 0; l <= N && l <= K; ++l)
	{
		auto sum = 0;
		vector<long long> minus;
		for (auto i = 0; i < l; ++i)
		{
			sum += V[i];
			if (V[i] < 0)
			{
				minus.push_back(V[i]);
			}
		}

		for (auto r = 0; r <= N - l && r <= K - l; ++r)
		{
			if (r >= 1)
			{
				auto v = V[N - r];
				sum += v;
				if (v < 0)
				{
					minus.push_back(v);
				}
			}

			auto tempResult = sum;
			sort(minus.begin(), minus.end());
			for (auto i = 0; i < minus.size() && i < K - l - r; ++i)
			{
				tempResult -= minus[i];
			}
			result = max(result, tempResult);
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<ll> x(n + 1, 0);
    rep (i, n) cin >> x[i];

    ll ans = 100000000000000000LL;
    for (int i = 0; i < n - k + 1; i++) {
        int lef = x[i];
        int rig = x[i + k - 1];
        ll tmp = min(abs(lef), abs(rig)) + abs(rig - lef) ;
        chmin(ans, tmp);
    }

    

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll 	 long long
#define pb push_back
#define mp make_pair
using namespace std;

int main()  
{  

double a, b; int c; cin>>a>>b>>c;

int d= ceil(a/b);

cout<<d*c<<endl;
    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS; ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MX  100002
#define FF freopen("input.in","r",stdin); freopen("output.txt","w",stdout);
int n,m;
vector<int >ve[MX];
int mx=0;
int dp[MX];
bool vis[MX];
int dfs(int nod)
{
    dp[nod]=0;
    int ans=-1;
    for(int i=0;i<ve[nod].size();i++)
    {
        int to=ve[nod][i];
        if(dp[to]!=-1)dp[nod]=max(dp[to]+1,dp[nod]);
        else
            dp[nod]=max(dfs(to)+1,dp[nod]);
    }
    return dp[nod];
}
int main()
{
    //FF;
    IOS;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin >>x>>y;
        ve[x].push_back(y);
        //ve[y].push_back(x);
    }
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=n;i++)
    {
        dfs(i);
    }
    int ans=-1;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,dp[i]);
    }
    cout<<ans;
    //bfs();

}



Measured memory_bytes: 8192
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    String S;

    AtCoder(FastScanner sc) {
        S = sc.next();
    }

    void solve(PrintWriter out) {
        int cnt = 0;
        for (int i = 0; i < S.length(); i++) {
            char c = S.charAt(i);
            if (c == 'o') cnt++;
        }
        out.println(700 + 100 * cnt);
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int main() {
	// your code goes here
	long long N, D, count = 0;
	cin >> N;
	cin >> D;
	
	while (N--) {
		long long x, y;
		cin >> x >> y;
		if (x * x + y * y <= D * D)
			count += 1;
	}
	cout << count << "\n";
	return 0;
}

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

int main() {
  int n,ans;
  ans=0;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++) {
    cin >> d.at(i);
    for(int j=0;j<i;j++) ans+= d.at(i)*d.at(j);
  };
  cout << ans << endl;
}

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

int main() {
    int m,n;
    cin>>m>>n;
    char arr[m][n];
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>arr[i][j];
        }
    }
    
    
    //   for(int i=0;i<H;i++){
    //     for(int j=0;j<W;j++){
    //         cout<<arr[i][j]<<" ";
    //     }cout<<endl;
    // }
    
    int dp[m][n];
    
    
    for(int i=m-1;i>=0;i--){
        for(int j=n-1;j>=0;j--){
            if(i==m-1&&j==n-1)dp[i][j]=1;
            
            else if(arr[i][j]=='#')dp[i][j]=0;
            
            else{
                if(i+1==m)dp[i][j]=dp[i][j+1];
                else if(j+1==n)dp[i][j]=dp[i+1][j];
                else dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mod;
            }
            
        }
    }
    
    //for(int i=0;i<m;i++){for(int j=0;j<n;j++){cout<<dp[i][j]<<" ";}cout<<endl;}
    
    cout<<dp[0][0]<<endl;
    
    
}

Measured memory_bytes: 5120
#include <cstdio>
#include <vector>
#include <algorithm>
#include "memory.h"
#include <string>
#include <set>

using namespace std;

int main() {
	int H, W, h, w;
	scanf("%d%d%d%d", &H, &W, &h, &w);
	if (H % h == 0 && W % w == 0) { printf("No\n"); return 0; }
	printf("Yes\n");
	if (W % w != 0) {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if ((j+1) % w == 0) printf("%d", -1 - (w-1)*1000); else printf("1000");
				if (j != W-1) printf(" ");
			}
			printf("\n");
		}
	} else {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if ((i+1) % h == 0) printf("%d", -1 - (h-1)*1000); else printf("1000");
				if (j != W-1) printf(" ");
			}
			printf("\n");
		}
	}
    return 0;
}

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

int main() {
    double N;
    cin >> N;
    
    double T, A;
    cin >> T >> A;

    double H;
    int ans = 0;
    double value = 0;
    
    for (int i = 0; i < N; i++){
        cin >> H;
        if (i == 0){
            ans = i + 1;
            value = abs(A - (T - 0.006 * H));
        }else{
            if (abs(A - (T - 0.006 * H)) < value){
                ans = i + 1;
                value = abs(A - (T - 0.006 * H));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int m1 = sc.nextInt();
        int d1 = sc.nextInt();
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();
        if (m1 == m2) {
            System.out.println(0);
        } else {
            System.out.println(1);
        }
    }

}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

bool red[500][500];
bool blue[500][500];

int main() {
	int H, W; cin >> H >> W;
	for (int i = 0; i < H; i++) {
		red[i][0] = true;
		blue[i][0] = false;

		for (int j = 1; j < W - 1; j++) {
			if (i % 2 == 0) {
				red[i][j] = true;
				blue[i][j] = false;
			}
			else {
				red[i][j] = false;
				blue[i][j] = true;
			}
		}
		red[i][W - 1] = false;
		blue[i][W - 1] = true;
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char c; cin >> c;
			if (c == '#') { red[i][j] = true; blue[i][j] = true; }
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (red[i][j] == true) {
				cout << '#';
			}
			else {
				cout << '.';
			}
		}
		cout << endl;
	}
	cout << endl;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (blue[i][j] == true) {
				cout << '#';
			}
			else {
				cout << '.';
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const int MAX_N = 1 << 17;

//?????°?????????????????????????????????
int n, dat[2 * MAX_N - 1];

void init(int n_){
    n = 1;
    while(n < n_) n *= 2;
    rep(i,2 * n - 1) dat[i] = INT_MAX;
}

void update(int k, int a){
    //????????????
    k += n - 1;
    dat[k] = a;
    //?????????????????´??°
    while(k > 0){
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

//[a, b)???????°????????±???????
//query(a, b, 0, 0, n)
int query(int a, int b, int k, int l, int r){
    //[a, b) ??¨[l, r)???????????????????????°???INT_MAX
    if(r <= a || b <= l) return INT_MAX;

    //[a,b)???[l,r)????????¨???????????§????????°?????????????????????
    if(a <= l && r <= b) return dat[k];
    else{
        //????????§???????????°??????????????????????°????
        int vl = query(a, b, k * 2 + 1, l, ( l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}
//main??¢??°??§?????°??????????????¢??°n????????¨??????

int main(){
    int q;
    cin >> n >> q;
    init(n);
    rep(i,q){
        int c, a, b;
        cin >> c >> a >> b;
        if(not c) update(a,b);
        else cout << query(a,b + 1,0,0,n) << endl;
    }

}

Measured memory_bytes: 4096
n,m=map(int,input().split())
l=[list(map(str,input().split())) for i in range(m)]
a=0
b=0
r=[0]*n
q=[0]*n
for i in range(m):
    l[i][0]=int(l[i][0])
for i in range(m):
    if q[l[i][0]-1]==0 and l[i][1]=='WA':
        r[l[i][0]-1]+=1
    elif q[l[i][0]-1]==0 and l[i][1]=='AC':
        a+=1
        b+=r[l[i][0]-1]
        q[l[i][0]-1]=1
print(a,b)

Measured memory_bytes: 80600
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, a[100010], ans=0, pv, cnt=1;
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    pv=a[0];
    for (int i=1; i<n; i++)
    {
        if (a[i]!=pv)
        {
            if (cnt<pv) ans+=cnt;
            if (cnt>pv) ans+=cnt-pv;
            pv=a[i];
            cnt=1;
        }
        else cnt++;
    }
    if (cnt<pv) ans+=cnt;
    if (cnt>pv) ans+=cnt-pv;
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int h, n;
  cin >> h >> n;
  ll sum = 0;
  rep(i,n){
    ll a;
    cin >> a;
    sum += a;
  }
  if (sum >= h) puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n - 1];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		for (int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
		}

		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += b[a[i] - 1];
			if (i > 0 && a[i] == a[i - 1] + 1) {
				ans += c[a[i - 1] - 1];
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#include <stdio.h>
int main(void){
  int a,b,c;
  int tmp1,tmp2;
  scanf("%d %d %d",&a,&b,&c);
  tmp1=a;
  a=b;
  b=tmp1;
  tmp2=a;
  a=c;
  c=tmp2;
  printf("%d %d %d",a,b,c);
  
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m;
char a[444][444];
int b[444][444], hor[444][444], ver[444][444];
string s;

LL solve() {
    LL res = 0;
    forn(i, 400) {
        hor[i][0] = 0;
        forn(j, 400) {
            hor[i][j + 1] = hor[i][j] + b[i][j];
        }
    }
    forn(j, 400) {
        ver[0][j] = 0;
        forn(i, 400) {
            ver[i + 1][j] = ver[i][j] + b[i][j];
        }
    }
    forn(i, 400) {
        forn(jj, 400) forn(j, jj) {
            if (!b[i][j] || !b[i][jj]) {
                continue;
            }
            int ii = i - (jj - j);
            if (ii >= 0 && ii < 400) {
                res += hor[ii][jj + 1] - hor[ii][j];
            }
            ii = i + (jj - j);
            if (ii >= 0 && ii < 400) {
                res += hor[ii][jj + 1] - hor[ii][j];
            }
        }
    }
    forn(j, 400) {
        forn(ii, 400) forn(i, ii) {
            if (!b[i][j] || !b[ii][j]) {
                continue;
            }
            int jj = j - (ii - i);
            if (jj >= 0 && jj < 400) {
                res += ver[ii][jj] - ver[i + 1][jj];
            }
            jj = j + (ii - i);
            if (jj >= 0 && jj < 400) {
                res += ver[ii][jj] - ver[i + 1][jj];
            }
        }
    }
    return res;
}

int main() {
//    freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    forn(i, n) {
        cin >> s;
        forn(j, m) {
            a[i][j] = s[j];
        }
    }
    LL ans = 0;
    forn(t, 2) {
        memset(b, 0, sizeof b);
        forn(i, n) forn(j, m) {
            if ((i + j) % 2 == t && a[i][j] == '#') {
                b[(i + j + t) / 2][(i - j + t) / 2 + 180] = 1;
            }
        }
        ans += solve();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#define ll long long
#define llu unsigned long long
#define pb push_back
#define f(n) for(ll i=0;i<n;i++)
#define ina for(ll i=0;i<n;i++)cin>>a[i];
#define all(v) v.begin(),v.end()
#define YES printf("YES\n")
#define NO printf("NO\n")
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//long long bigmod/* (a^p)%m */ ( long long a, long long p, long long m ){long long res = 1;long long x = a;while ( p ){if ( p & 1 ){res = ( res * x ) % m;}x = ( x * x ) % m;p = p >> 1;}return res;}
//ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; if (m == 1) return 0; while (a > 1) { ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } if (x < 0) x += m0; return x; }
//call manipulated_seive(N) and get prime in prime vector
//const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for (long long int j=0; j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
//ll phi[5000001];bool mark[5000001];void sievephi(ll n){ll i,j;for(ll i=1;i<=n;i++) phi[i]=i;mark[1]=true;for(ll i=2;i<=n;i++)if(!mark[i]){for(ll j=i;j<=n;j+=i){mark[j]=true;phi[j]=phi[j]/i*(i-1);}}}

/*speedup
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
// vule geli coilbi na dada cout << fixed << setprecision(6) << pi <<" "<<npi<<endl;
//Pattern? OEIS
// prime factorize?? think about 2





int main()
{
    fastio;

       int n,x; cin>>n;
       vector<ll>v;
            ll __=0;
            for(int i=0;i<n;i++)
            {
               cin>>x;
               v.pb(x);
               __+=x;
            }
            ll sum=0,m=1e9+7,_=0;
            for(int i=0;i<n;i++)
            {
                _ += v[i];
              sum +=  (v[i] * (( __ - _)%m) )%m ;
              sum %= m;
              
            }
            cout<<sum%m<<endl;

    return 0;
}





Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> Pii;
#define rep(i,n) for (int i=0;i<(n);++i)
const int INF=1e9;

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

const int MAX_AB=51;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N),B(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    vector<vector<int>> dp(1<<N,vector<int>(MAX_AB,INF));
    dp[0][0]=0;
    rep(bit,1<<N){
        int cnt=0;
        vector<Pii> can;
        rep(i,N) if (bit&1<<i) ++cnt;
        int order=cnt;
        rep(i,N) if (!(bit&1<<i)) can.emplace_back(i,order++);
        rep(j,MAX_AB){
            if (dp[bit][j]>=INF) continue;
            for (Pii p:can){
                int i=p.first,nj=(i%2==cnt%2?A[i]:B[i]);
                if (nj>=j) chmin(dp[bit|1<<i][nj],dp[bit][j]+p.second-cnt);
            }
        }
    }
    int ans=INF;
    rep(j,MAX_AB) chmin(ans,dp[(1<<N)-1][j]);
    if (ans==INF) ans=-1;
    cout << ans << endl;
}

Measured memory_bytes: 63744
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m = MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------// 
void solve(){
    string s;
    cin >> s;
    
    for (int i = 0; i < (int)s.length(); i++){
	   if (s[i] == ',') s[i] = ' ';	
	}
	cout << s << endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		if (X%Y==0) {
			System.out.println(-1);
			return ;
		}
		System.out.println(X*(Y-1));
	}
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  string s1, s2;
  cin >> s1 >> s2;

  string s = "";
  for (int i = 0; i < N; i++) {
    if (s1[i] == s2[i]) {
      s += 'h';
    } else {
      s += 'l';
      i++;
    }
  }

  int ans;
  if (s[0] == 'h') {
    ans = 3;
  } else {
    ans = 6;
  }

  for (int i = 1; i < s.size(); i++) {
    if (s[i - 1] == 'h') {
      ans *= 2;
      ans %= MOD;
    } else {
      if (s[i] == 'l') {
        ans *= 3;
        ans %= MOD;
      }
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll A, B;
  char op;
  cin >> A >> op >> B;

  cout << ((op=='+') ? A+B : A-B) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  ll k;
  cin >> s >> k;
  int head_one = 0, next = -1;
  rep(i, 0, (int)s.size()) {
    if (s[i] == '1')
      head_one++;
    else {
      next = (int)(s[i] - '0');
      break;
    }
  }

  if (head_one >= k)
    cout << 1 << endl;
  else
    cout << next << endl;
}


Measured memory_bytes: 3632
s = gets.strip

words = ['dream', 'dreamer', 'erase', 'eraser']

until s.empty? do
    reduced = false
    words.map do |w|
        if s[-w.size, w.size] == w
            s = s[0..-w.size - 1]
            reduced = true
            break
        end
    end

    unless reduced
        puts 'NO'
        exit 0
    end
end

puts 'YES'

Measured memory_bytes: 56256
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int isqrt(int x) {
  double d = sqrt(x);
  int i = (int)(d+0.5);
  if(i*i>x) return i-1;
  else return i;
}

int main() {
  for(int tci = 0; ; tci++) {
    int e; scanf("%d", &e);
    if(e==0) break;
    int mv = e;
    for(int z = 0; z*z*z <= e; z++) {
      int y = isqrt(e-z*z*z);
      int x = e-z*z*z-y*y;
      mv = min(mv,x+y+z);
    }
    printf("%d\n", mv);
  }
  return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

class Main {
	public static  void DT(int count){
		for(int i=0;i<N;i++){
			for(int j=0;j<W+1;j++){
				if(j<w[i]){
					niji[i+1][j] = niji[i][j];
				}else{
					niji[i+1][j] = Math.max(niji[i][j],niji[i][j-w[i]]+v[i]);
				}
			}
		}

		for(int i=W;i>0;i--){
			if(niji[N][i]>niji[N][i-1]){
				System.out.println("Case "+count+":");
				System.out.println(niji[N][i]);
				System.out.println(i);
				break;
			}
		}
	}
	

	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		count = 0;
		String temp;
		while(sc.hasNextInt()){
			temp=sc.nextLine();
			W = Integer.valueOf(temp);
			if(W==0)break;
			
			
			temp=sc.nextLine();
			N = Integer.valueOf(temp);
			w = new int[N];
			v = new int [N];
			
			
			
			String[] s;
			for(int i=0;i<N;i++){
				s = sc.nextLine().split(",");
				v[i] = Integer.valueOf(s[0]);
				w[i] = Integer.valueOf(s[1]);
			}
			niji = new int[N+1][W+1];
			count++;
			DT(count);
		}
	}
	static  int W,N,count;
	static int[] w;
	static int[] v;
	static int[][] niji;
}

Measured memory_bytes: 30452
#include<iostream>

int sum[2];

int main(){
	for(int i=0;i<2;i++){
		for(int j=0,a;j<4;j++){
			std::cin>>a;
			sum[i]+=a;
		}
	}
	std::cout<<std::max(sum[0],sum[1])<<std::endl;
	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var N, K, ans int
	fmt.Scan(&N, &K)

	var V = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&V[i])
	}
	var V_left = make(SortBy, 0)

	for left := 0; left <= min(N, K); left++ {
		// left=0は左からの操作回数0を示す．left=0の場合，appendしない
		if 0 < left {
			V_left = append(V_left, V[left-1])
		}

		// V_leftをV_rightにコピー
		var V_right = make(SortBy, len(V_left))
		copy(V_right, V_left)

		for right := 0; left+right <= min(N, K); right++ {
			// right=0は左からの操作回数0を示す．right=0の場合，appendしない
			if 0 < right {
				V_right = append(V_right, V[len(V)-1-right+1])
			}

			// V_rightをV_ansにコピーし，V_ansを昇順にソート
			var V_ans = make(SortBy, len(V_right))
			copy(V_ans, V_right)
			sort.Sort(V_ans)

			// 価値が負の宝石は，負の大きい宝石から筒へリターン
			for trash := 0; trash < min(K-(left+right), len(V_right)); trash++ {
				if V_ans[0] < 0 {
					V_ans = V_ans[1:]
				}
			}
			var result int
			for i := 0; i < len(V_ans); i++ {
				result += V_ans[i]
			}
			ans = max(ans, result)

		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }


Measured memory_bytes: 1024
n=gets.chomp.to_i
a=gets.chomp.split.map(&:to_i)

c = []
a.each_with_index do |v, i|
  c << (v-(i+1))
end

c.sort!
b = c[c.size/2]

ans = 0
a.each_with_index do |v, i|
  ans += (v-(i+1+b)).abs
end

puts ans


Measured memory_bytes: 21816
#include <iostream>
#include <ios>
#include <algorithm>
using namespace std;
int n, A[20] = {};

bool check(int i, int v){
	if (v == 0)		return true;
	if (v < 0)		return false;
	if (i == n)		return false;
	if (v < A[i])	return false;
	if (check(i + 1, v))		return true;
	if (check(i + 1, v - A[i]))	return true;
	return false;
}

int main()
{
	int m, i, k;
	cin >> n;
	for (i = 0; i < n; ++i)
		cin >> A[i];
	sort(A, A + n);
	cin >> m;
	for (i = 0; i < m; ++i){
		cin >> k;
		cout << (check(0, k) ? "yes\n" : "no\n");
	}

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int>x(N);
    int mx=-1;
    for(int i=0; i<N; i++){
        cin >> x[i];
       mx = max(x[i],mx);
    }
    int mn=9999999;
    for(int i=0; i<=mx; i++){
        int sum = 0 ;
        for(int j=0; j<N; j++){
            int tmp =  pow(x[j]-i,2);   
            sum += tmp;       
        }
       mn =  min(sum,mn);
    }

    cout << mn;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
d = {}
graph = {i:[] for i in range(n)}
for _ in range(n-1):
  u,v,w = map(int,input().split())
  d[(u-1,v-1)] = w
  graph[u-1].append(v-1)
  graph[v-1].append(u-1)
  
  
color = [-1 for i in range(n)] 
color[0] = 0
from collections import deque
queue =deque([0])

while queue:
  p = queue.popleft()
  color_p = color[p]
  for i in graph[p]:
    if color[i] != -1:
      continue
    else:
      if d[(min(i,p),max(i,p))] %2:
        color[i] = 1 - color_p
      else:
        color[i] = color_p
      queue.append(i)

for i in range(n):
  print(color[i])




Measured memory_bytes: 54800
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 2E9;
const uint64_t MOD = 1E9 + 7;

int cnt = 0;

void merge(vector<int> &a, int left, int mid, int right)
{
	int n0 = mid - left;
	int n1 = right - mid;

	vector<int> l(n0 + 1);
	vector<int> r(n1 + 1);

	for (int i = 0; i < l.size() - 1; i++)
	{
		l.at(i) = a.at(left + i);
	}

	for (int i = 0; i < r.size() - 1; i++)
	{
		r.at(i) = a.at(mid + i);
	}

	l.at(n0) = INF;
	r.at(n1) = INF;

	int x = 0;
	int y = 0;

	for (int i = left; i < right; i++)
	{
		if (l.at(x) <= r.at(y))
		{
			a.at(i) = l.at(x);
			x++;
		}
		else
		{
			a.at(i) = r.at(y);
			y++;
		}
		cnt++;
	}
}

void merge_sort(vector<int> &a, int left, int right)
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		merge_sort(a, left, mid);
		merge_sort(a, mid, right);
		merge(a, left, mid, right);
	}
}

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	merge_sort(a, 0, a.size());

	for (int i = 0; i < n; i++)
	{
		cout << (i == 0 ? "" : " ") << a.at(i);
	}

	cout << endl;
	cout << cnt << endl;
}


Measured memory_bytes: 6744
#include <bits/stdc++.h> 
   
using namespace std; 
   
int main() { 
  double ans; 
  double N; 
  cin >> N; 
   
  if ((int)N % 2 == 0) { 
    ans = 0.5;
  } else {
    ans = (N + 1) / (2 * N); 
  } 
   
  cout << ans << endl; 
  return 0; 
}  

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

const int INITIAL = 1000;
const int TARGET = 753;

int main()
{
	string s;
	cin >> s;

	string sub;
	int num;
	int res = INITIAL;
	int dist;
	for ( int i = 0; i < s.size() - 2; ++i ) {
		sub = s.substr( i, 3 );
		num = ::atoi( sub.c_str() );
		dist = ::abs( num - TARGET );
		if ( dist < res ) {
			res = dist;
		}
	}

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

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

struct UnionFindTree {
	vector<int> par;

	UnionFindTree(int N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;
	}

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

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		else par[rx] = root(ry); // rxの親はryにする
	}

	bool same(int x, int y) {
		if (root(x) == root(y)) return true;
		else return false;
	}
};

int main(void) {
	int N, M; cin >> N >> M;
	vector<int> P(N);
	for (int i = 0; i < N; i++) cin >> P[i], P[i]--;

	UnionFindTree uf_tree(N);

	for (int i = 0; i < M; i++) {
		int x, y; cin >> x >> y;
		x--, y--;
		uf_tree.unite(x, y);
	}

	int res = 0;
	for (int i = 0; i < N; i++) {
		if (uf_tree.same(i, P[i])) res++;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024