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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
  
	for(int i=1;i<n;i++){
		int cnt=0;
      for(char c='a';c<='z';c++){
			bool left=false,right=false;
			
			for(int j=0;j<i;j++)
				if(s[j]==c)
					left=true;
			
			for(int j=i;j<n;j++)
				if(s[j]==c)
					right=true;
			
			if((left==true)&&(right==true))
				cnt++;
		}
      ans=max(ans,cnt);
    }
  cout<<ans<<endl;
  return 0;
}

      
      
  
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

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

    cout << fixed << setprecision(20);
    cout << (double)((n+1)/2) / n << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int front,last,n;
	cin>>n;
	last=n%100;
	front=n/100;
	if(last>0&&last<=12&&front>0&&front<=12)
	    cout<<"AMBIGUOUS"<<endl;
	else if(front>0&&front<=12)
	    cout<<"MMYY"<<endl;
	else if(last>0&&last<=12)
	    cout<<"YYMM"<<endl;
	else
	    cout<<"NA"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, m;
  string blue[10000];
  string red[10000];
  
  cin>> n;
  for(int i = 0; i < n; i++) cin>> blue[i];
  cin>> m;
  for(int i = 0; i < m; i++) cin>> red[i];
  
  int mx = 0;
  for(int i = 0; i < n; i++) {
    
    string tar = blue[i];
    int cnt = 0;
    for(int j = 0; j < n; j++) if(tar == blue[j]) cnt++;
    for(int j = 0; j < m; j++) if(tar == red[j]) cnt--;
    
    mx = max(mx, cnt);
  }
  
  cout<< mx <<endl;
  
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		boolean[][] card = new boolean[4][13];
		for (int i = 0; i < n; ++i) {
			String s = scanner.next();
			int num = scanner.nextInt();
			card[s.equals("S") ? 0 : s.equals("H") ? 1 : s.equals("C") ? 2 : 3][num - 1] = true;
		}
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 13; ++j) {
				if (!card[i][j])
					System.out.printf("%s %d\n", i == 0 ? "S" : i == 1 ? "H" : i == 2 ? "C" : "D", j + 1);
			}
		}
	}
}



Measured memory_bytes: 26264
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll n,k;cin>>n>>k;
    vll a(n, 0);
    REP(i,n) cin>>a[i];
    vll rui(n+1,0);
    ll sum=0;
    map<ll,ll> mp;
    REP(i,n){
        sum+=a[i];
        rui[i+1] = sum-i-1;
        rui[i+1] %= k;
    }
    sum=0;
    for(auto p:mp){
        sum += p.second * (p.second-1) /2;
    }
    REP(i,min(k-1, n)){
        mp[rui[i+1]]++;
    }
    sum =0;
    for(ll i=0; i<n; i++){
        sum+=mp[rui[i]];
        mp[rui[i+1]]--;
        if (i+k-1<n) mp[rui[i+k]]++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	set<int>s;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		s.insert(a);
	}
	cout<<s.size()<<"\n";
}

Measured memory_bytes: 256
using System;

class C {
    public static void Main() {
        var s = Console.ReadLine();
        var a = new long[s.Length + 1];
        var b = new long[s.Length + 1];
        a[s.Length] = 0L;
        b[s.Length] = 1L;
        for (int i = s.Length - 1; i >= 0; --i) {
            var v = 0L;
            for (int j = i + 1; j <= s.Length; ++j) {
                v = v * 10L + (s[j - 1] - '0');
                a[i] += a[j] + v * b[j];
                b[i] += b[j];
            }
        }
        Console.WriteLine(a[0]);
    }
}


Measured memory_bytes: 11092
import java.util.*;
class Main
{
    public static void topological(Stack<Integer> stack ,LinkedList<Integer> adj[],boolean visited[] , int v)
    {
        visited[v]=true;
        Iterator<Integer> iter =adj[v].iterator();
        while(iter.hasNext())
        {
            int value = iter.next();
            if(visited[value]==false)
            {
                topological(stack,adj,visited,value);
            }
        }
        stack.push(v);
    }
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        int m = sc.nextInt();
        LinkedList<Integer> adj[] = new LinkedList[n];
        for(int i=0;i<n;i++)
        {
            adj[i]=new LinkedList<Integer>();
        }
        for(int i=0;i<m;i++)
        {
            int src = sc.nextInt()-1;
            int dest = sc.nextInt()-1;    
            adj[src].add(dest);
        }
        boolean visited[]= new boolean[n];
        Arrays.fill(visited,false);
        Stack<Integer> stack = new Stack<>();
        for(int i=0;i<n;i++)
        {
            if(visited[i]==false)
            {
                topological(stack,adj,visited,i);
            }
        }
        int dist[]=new int[n];
        Arrays.fill(dist,0);
        int max = 0;
       while(!stack.isEmpty())
       {
           int val = stack.pop();
           Iterator<Integer> iter = adj[val].iterator();
           while(iter.hasNext())
           {
               int value = iter.next();
               if(dist[value]<dist[val]+1)
               {
                   dist[value]=dist[val]+1;
                   max = Math.max(dist[value],max);
               }
           }
       }
       System.out.println(max);
    }
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 x;
    cin >> x;
    int32 s = 0;
    for(int32 i = 1;;++i){
        s += i;
        if(s >= x){
            ANS(i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <cmath>
#define INF 1000000007
using namespace std ;

int main(int argc, char const *argv[])
{

	int n,h ;
	cin>>h>>n ;

	for(int i = 0 ; i < n ; i++) 
	{
		int temp ;
		cin>>temp ;

		h-= temp ;

		if(h <= 0) {cout<<"Yes"<<endl ; return 0 ; }
	}

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

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {

	int h, w;
	vector<string> s(50);
	int a[50][50] = {};

	cin >> h >> w;

	//cout << "1\n";

	for (int i = 0; i < h; i++)
	{
		cin >> s[i];
	}

	for (int ih = 0; ih < h; ih++)
	{
		for (int iw = 0; iw < w; iw++)
		{
			//cout << ih << " " << iw << "\n";
			if (s[ih][iw] == '#') {
				for (int kh = max(0,ih-1); kh < min(h,ih+2); kh++)
				{
					for (int kw = max(0, iw - 1); kw < min(w, iw + 2); kw++)
					{
						//printf("kh%d kw%d\n", kh, kw);
						a[kh][kw]++;
					}
				}
			}
		}
	}

	//cout << "2\n";
	
	for (int ih = 0; ih < h; ih++)
	{
		for (int iw = 0; iw < w; iw++)
		{
			if (s[ih][iw] == '#')cout << "#";
			else cout << a[ih][iw];
		}
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String args[]){
    int[] nums = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    Scanner s = new Scanner(System.in);
    k = s.nextInt();
    System.out.println(""+nums[k-1]);
  }
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int dp[100009],wt[100009],val[100009];
int main() {
    int n,W;
    cin>>n>>W;
    for(int i=1;i<=n;i++)
        cin>>wt[i]>>val[i];
    // for(int i=1;i<=n;i++)
    //     cout<<wt[i]<<" "<<val[i]<<" ";
    // cout<<endl;
    for(int i=0;i<=100005;i++)
        dp[i]=1000000009;
    dp[0]=0;
    for(int i=1;i<=n;i++){
        for(int j=100005;j>0;j--){
            if(j-val[i]>=0 ){
                    dp[j]=min(dp[j], wt[i]+dp[j-val[i]]);
            }
        }
        // cout<<endl;
    }
    for(int i=100005;i>=0;i--){
        // cout<<i<<" "<<dp[n][i]<<endl;
        if(dp[i]<=W){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


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

#define sz size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

using namespace std;

const int N = 1e6 + 9;
const int inf = 1e9 + 7;

int n;
int a[N], dp[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin>> n;
    for(int i = 1; i <= n; i++)cin>> a[i];
    dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);
    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout<< dp[n];
}


Measured memory_bytes: 4736
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    map<string, int> m;
    int n;
    cin >> n;
    rep(i, 0, n){
        string s;
        cin >> s;
        m[s]++;
    }
    
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

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

signed main(void)
{
	ll N;
	cin >> N;
	for (ll h = 1; h <= 3500; h++) 
	{
		for (ll w = 1; w <= 3500; w++)
		{
			ll n = N * w * h;
			ll m = 4 * w * h - N * h - N * w;
			if (m <= 0 || n % m != 0) continue;
			n /= m;
			cout << h << " " << w << " " << n << endl; 
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3552
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	long long n;
	scanf("%lld",&n);
	long long num[40000];
	num[0]=100;
	int i;
	for(i=1;i<=40000;i++)
	{
		num[i]=num[i-1]*1.01;
		if(num[i]>=n)
			break;
	}
	printf("%lld",i);
	return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define eb emplace_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,b) FOR(i,0,b)
#define REP rep
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define reps FOR
#define rreps(i,a,b) for (int i=int(b)-1;i>=(a);--i)
#define rrep(i,b) rreps(i,0,b)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
const ll MOD=1e9+7;

#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}


/*
idom[w]: immediate dominator of w
(nearest dominator)
*/

struct DominatorTree{
	int n;
	vector<vector<int>>G,rG;
	vector<int>semi,id,et,par,mn,uf;

	DominatorTree(int n):
		n(n),G(n),rG(n),semi(n),
		id(n,-1),et(n),par(n,-1),mn(n),uf(n)
	{
        for(int i=0;i<n;i++){
            semi[i]=mn[i]=uf[i]=i;
        }
	}

	void addEdge(int a,int b){
		G[a].push_back(b);
        rG[b].push_back(a);
	}
	int find(int v){
		if(uf[v]==v)return v;
		int a=find(uf[v]);
		if(id[semi[mn[uf[v]]]]<id[semi[mn[v]]])mn[v]=mn[uf[v]];
		return uf[v]=a;
	}

	void link(int c,int p){
		uf[c]=p;
	}

	void dfs(int v,int p,int &k){
		id[v]=k;
		et[k++]=v;
		par[v]=p;
		for(int c:G[v])if(id[c]==-1)dfs(c,v,k);
	}

	vector<int>calc(int root){
		int sz=0;
		dfs(root,-1,sz);

        vector<int>us(n);
        vector<vector<int>>bucket(n);

		for(int i=sz-1;i>0;i--){
			int w=et[i];
			for(int v:rG[w])if(id[v]!=-1){
				find(v);
				if(id[semi[mn[v]]]<id[semi[w]])semi[w]=semi[mn[v]];
			}
			bucket[semi[w]].pb(w);
			for(int v:bucket[par[w]]){
				find(v);
				us[v]=mn[v];
			}
			bucket[par[w]].clear();
			link(w,par[w]);
		}

        vector<int>idom(n,-1);
		for(int i=1;i<sz;i++){
			int w=et[i];
			if(semi[w]==semi[us[w]])idom[w]=semi[w];
			else idom[w]=idom[us[w]];
		}
		return idom;
	}
};

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    DominatorTree dt(n);
    rep(i,m){
        int a,b;
        scanf("%d%d",&a,&b);
        a--;b--;
        dt.addEdge(a,b);
    }

    auto idom=dt.calc(0);
    int Q;scanf("%d",&Q);
    while(Q--){
        int r;scanf("%d",&r);
        r--;
        int ans=idom[r];
        if(ans==0)ans=r;
        printf("%d\n",ans+1);
    }
}


Measured memory_bytes: 22632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,w=0,cnt=0;
  cin >> n >>m;
  int a[n];
  vector<int> s((1<<19),0);
  for(int i=0;i<n;i++){
    int k;
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> a[i];
      s[a[i]]++;
      w=max(w,a[i]);
    }
  }
  for(int i=0;i<=w;i++)if(s[i]==n)cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 5368
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
using namespace std;
string tostr(int, int);
string toresult(string);

int main() {
  vector<string> v;
  for(int j = 0; j < 2; ++j) {
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) {
      int h, m;
      cin >> h >> m;
      v.push_back(tostr(h, m));
    }
  }
  sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
  for(auto j = 0; j < v.size() - 1; ++j) {
    string str = v[j];
    cout << toresult(str) << " ";
  }
  cout << toresult(v[v.size() - 1]) << endl;
  return 0;
}

string tostr(int h, int m) {
  //sprintf(str, "%2d%2d", h, m);
  ostringstream str;
  str << setw(2) << setfill('0') << h;
  str << setw(2) << setfill('0') << m;
  return (str.str());
}

string toresult(string s) {
  if(s.at(0) == '0') {
    s.erase(s.begin());
    return s.insert(1, ":");
  }
  return s.insert(2, ":");
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
int main(){
  int u=0,o=0;
  string a,b,c,d,e;
  cin>>a;
  for(int i=1;i<=a.size();i++){
    // cout<<i<<" "<<a[i]<<"\n";
    if(i%2==1){
      if(a[i-1]=='R'||a[i-1]=='U'||a[i-1]=='D') u++;
    }
    else {
      if(a[i-1]=='L'||a[i-1]=='U'||a[i-1]=='D') o++;
    }
  }
  if(u+o==a.size()) cout<<"Yes";
  else cout<<"No";
  cout<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll a[100005] = {}, b = 1;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) if (!a[i]) {
        cout << 0;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        if (b > 1000000ll * 1000000ll * 1000000ll / a[i]) {
            cout << -1;
            return 0;
        }
        b *= a[i];
    }
    cout << b;
}


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

const int maxN=2*1e5+1;
vector<int> adj[maxN];

int n;

long long ans=0;

void calc_val(int a,int b)
{
	//cout<<a<<' '<<b<<endl;
	if(a<b)
	{
		ans+=(long long)(b-a)*(n-b+1);	
	}
	else
	{
		ans+=(long long)(a-b)*b;
	}	
}

void dfs(int i,int p)
{
	for(auto ch:adj[i])
	{
		if(ch!=p)
		{
			calc_val(i,ch);
			dfs(ch,i);
		}
	}
}
int main()
{
	cin>>n;
	
	int u,v;
	for(int i=0;i<n-1;i++)
	{
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	ans+=n;
	
	dfs(1,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 23796
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        if(v[i]>c) ans += v[i]-c;
    }
    cout << ans << endl;
}


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


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

  for (int i = 0; i < n; i++)
  {
    int t;
    cin >> t;
    if (t % 2 == 0 && (t % 3 != 0 && t % 5 != 0))
    {
      cout << "DENIED" << endl;
      return 0;
    }
  }

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Threfore_0527_1問目
{
    class Program
    {
        static void Main(string[] args)
        {

            string a = Console.ReadLine();
            int N = Convert.ToInt32(a);
            int b = N % 10;

            if(b==3)
            {
                Console.WriteLine("bon");
            }
            else if(b==0||b==1||b==6||b==8)
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("hon");
            }

            Console.Read();


        }
    }
}


Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >>  a >> b >> c;
    long long A[30];
    A[0] = c;
    for(int i = 1; i <= 10; i++){
        A[i] = a*A[i-1] - b;
        cout << A[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

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

       List<Integer> list = new ArrayList<>();
       for(int i = 0;i < n;i++){
           list.add(sc.nextInt());
       }
       Collections.sort(list);
       int sum = list.get(n-1)/2;
       for(int i = 0;i < n-1;i++){
           sum+=list.get(i);
       }
        System.out.println(sum);
    }
}

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

/************* Using *************/
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using graph_t = vector<vector<ll>>;

/*********** Constants ***********/
const auto INF  = static_cast<int>(1e10);
const auto INFL = static_cast<ll>(1e18);
const auto MOD  = static_cast<ll>(1e9 + 7);
const auto NIL  = nullptr;

/*********** Variables ***********/
ll A;
string S, ANS;

/************* Utils *************/

/*********** Functions ***********/
bool init() {
    cin >> A >> S;
    return true;
}

void solve() {
    if (A < 3200) {
        ANS = "red";
    }
    else {
        ANS = S;
    }
}

void output() {
    cout << ANS << endl;
}

int main() {
    init();
    solve();
    output();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check(int a,vector<int>& b,int k){
	if(a==0)
	return false;
	int sum=0;
	for(int i=0;i<b.size();i++){
		if(b[i]>a)
		sum+=b[i]/a;
	}
	return sum<=k;
}
int main(){
	int n,k,l,r,mid,ans;
	cin>>n>>k;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	l=0,r=*max_element(a.begin(),a.end());
	while(l<=r){
		mid=ceil((l+r)/2.0);
		if(check(mid,a,k)){
			r=mid-1;
			ans=mid;
		}
		else l=mid+1;
	}
	cout<<ans<<endl;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")


signed main() {
    int n;
    cin >> n;
    vector<int> cs(n), vs(n);
    rep(i, n) cin >> cs[i];
    rep(i, n) cin >> vs[i];
    int ans = 0;
    rep(i, n) {
        int m = cs[i] - vs[i];
        if (m > 0) ans += m;
    }
    cout << ans << nl;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
using namespace std;
int main()
{
    list<int> lis;
    list<int>::iterator i;
    int q, quer, x, d;
    i = end(lis);
    cin >> q;
    while (q--) {
        cin >> quer;
        if (quer == 0) {
            cin >> x;
            lis.insert(i, x);
            i--;
        }
        if (quer == 1) {
            cin >> d;
            if (d > 0) {
                while (d--)
                    i++;
            }
            else if (d < 0) {
                while (d++) {
                    i--;
                }
            }
        }
        if (quer == 2) {
            i=lis.erase(i);
        }
    }
    for (i = lis.begin(); i != lis.end(); ++i) {  //用迭代器遍历容器
        cout << *i << endl;
    }
}


Measured memory_bytes: 18628
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,w;
void solve(){
  cin>>n>>w;vvi v(2,vi(n+2,inf));vvi dp((int)1e5+10,vi(n+2,inf));
  rep(i,1,n)
    rep(j,0,1){
      cin>>v[j][i];
    }
  rep(i,0,n+1)dp[0][i]=0;
  // rep(j,1,n)if(v[0][j]<=w)dp[v[1][j]][j]=v[0][j];
  //dp[i][j] is max weight taken by consider all elements from 1 to j
  //with total weight i
  int ma=0;
  per(j,n,1){
    rep(i,1,1e5)dp[i][j]=dp[i][j+1];
    rep(i,v[1][j],1e5){
    dp[i][j]=min(dp[i-v[1][j]][j+1]+v[0][j],dp[i][j+1]);
  }
}
  rep(i,0,1e5)rep(j,0,n)if(dp[i][j]<=w)ma=max(ma,i);
  cout<<ma;
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 83840
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import  java.io.*;
import  java.math.*;
import java.nio.Buffer;
import java.sql.SQLSyntaxErrorException;
import  java.util.*;
import  java.text.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;


public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        /*int n=cin.nextInt();
        int x=cin.nextInt();
        int y=cin.nextInt();
        int num[][]=new int[n+1][n+1];
        num[x][y]=1;
        int sum[]=new int[n+1];
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                if(num[i][j]!=0){
                    num[i][j]=Math.min(num[i][j],Math.abs(i-j));
                    sum[num[i][j]]++;
                    sum[Math.abs(i-j)]++;
                }
                else{
                    if(i<=x&&j>=y){
                        num[i][j]=x-i+1+y-j;
                        sum[x-i+1+y-j]++;
                    }

                        num[i][j]=Math.abs(i-j);
                        sum[Math.abs(i-j)]++;

                }
            }
        }
        for(int i=1;i<n;i++){
            System.out.println(sum[i]);
        }*/
        int X=cin.nextInt();
        int Y=cin.nextInt();
        int A=cin.nextInt();
        int B=cin.nextInt();
        int C=cin.nextInt();

        Integer[] num=new Integer[A];

        Integer[] num1=new Integer[B];
        Integer[] num2=new Integer[C+X+Y];
        for(int i=0;i<A;i++){
            num[i]=cin.nextInt();
        }
        Arrays.sort(num, 0, A, Collections.reverseOrder());
        for(int i =0; i<B; i++){
            num1[i] = cin.nextInt();
        }
        Arrays.sort(num1,0,B,Collections.reverseOrder());
        for(int i=0;i<C; i++){
            num2[i]=cin.nextInt();
        }
        for(int i=C; i<C+X;i++){
            num2[i]=num[i-C];
        }
        for(int i=C+X;i<C+X+Y; i++){
            num2[i]=num1[i-C-X];
        }
        Arrays.sort(num2,0,C+X+Y,Collections.reverseOrder());
        long sum =0;
        for(int i=0;i<X+Y; i++){
            sum+=num2[i];
        }
        System.out.println(sum);

    }
}


Measured memory_bytes: 101336
#include <iostream>
using namespace std;
int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
               if ( (i + j) % 2 == 0 ){
                   cout << "#";
               } else {
                   cout << ".";
               }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3044
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;

ll res;
ll a[N], dis[11];

bool ok(ll x){
    while(x){
        if(dis[x % 10]) return 0;
        x /= 10;
    }
    return 1;
}

void solve(){
    ll n, k, x;
    cin >> n >> k;
    for(int i = 0; i < k; ++i){
        cin >> x;
        dis[x] = 1;
    }
    while(n){
        if(ok(n)){   
            cout << n << "\n";
            return ;
        }
        n++;
    }
}
 
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int graph[10][10];

void solve() {
    int N, M;
    cin >> N >> M;
    for (int i = 1; i <= N; ++i)
        for (int j = 1; j <= N; ++j)
            graph[i][j] = -1;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        graph[a][b] = 1;
        graph[b][a] = 1;
    }
    vector<int> perm(N);
    for (int i = 0; i < N; ++i) {
        perm[i] = i;
    }
    int ans = 0;
    do {
        int a = perm.at(0);
        if (a != 0) continue;
        bool ok = true;
        for (int b = 1; b < N; ++b) {
            int r = graph[perm.at(a) + 1][perm.at(b) + 1];
            if (r != 1) ok = false;
            if (!ok) break;
            a = b;
        }
        if (ok) ++ans;
    } while (next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
package main

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

type Action struct {
	y  int
	x  int
	yd int
	xd int
}

func main() {
	sc := NewScanner()
	H, W := sc.NextInt(), sc.NextInt()
	A := make([][]int, H)
	for i := 0; i < H; i++ {
		A[i] = sc.NextIntArray()
	}

	actions := make([]Action, 0)
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if A[i][j]%2 == 1 {
				i2 := i
				j2 := j + 1
				if j == W-1 {
					if i == H-1 {
						continue
					}
					i2 = i + 1
					j2 = j
				}
				A[i][j]--
				A[i2][j2]++
				actions = append(actions, Action{i, j, i2, j2})
			}
		}
	}
	fmt.Println(len(actions))
	for _, v := range actions {
		fmt.Println(v.y+1, v.x+1, v.yd+1, v.xd+1)
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 29312
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int a[3030];
vector<int> g[3030];

bool dfs(int s){
	for(int t:g[s]){
		if(a[s]>a[t]){
			if(!dfs(t))return true;
		}
	}
	return false;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=1;i<n;i++){
		int x,y; cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	vector<int> v;
	for(int i=0;i<n;i++){
		if(dfs(i))v.push_back(i+1);
	}
	for(int r:v){
		printf("%d ",r);
	}
	printf("\n");
}

Measured memory_bytes: 3908
s = input()
sa = s[:len(s)//2]
if len(s)%2 == 0:
    sb = s[len(s)//2:]
if len(s)%2 == 1:
    sb = s[len(s)//2+1:]

sbr = sb[::-1]
cnt = 0
for i in range(len(sa)):
    if sa[i] != sbr[i]:
        cnt+=1

print(cnt)

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

int main() {
  int N,M,sum=0,cnt=0;
  cin >> N >> M;
  vector<int>A(N+1);
  for(int i=1;i<=N;i++){
    cin >> A.at(i);
    sum+=A.at(i);
  }
  for(int i=1;i<=N;i++){
    if(A.at(i)>=(sum+4*M-1)/(4*M)){
      cnt++;
    }
  }
  if(cnt>=M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
long int gcd(long C,long D){
	if(D==0)
		return C;
	if(C==0)
		return D;
	if(C%D==0)
		return D;
	return gcd(D,C%D);
}
int main(){
	ll A,B;
	long C,D;
	cin>>A>>B>>C>>D;
	// cout<<"before gcd";
	long int g=gcd(C,D);
	// long g=1;
	// cout<<"gcd:"<<g<<"\n";
	ll res=0;
	res+=(B/C-(A-1)/C);
	// cout<<res<<"\n";
	res+=(B/D-(A-1)/D);
	// cout<<res<<"\n";
	long int lcm=(C/g)*(D/g)*g;
	res-=(B/lcm-(A-1)/lcm);
	// cout<<res<<"\n";
	ll ans=B-A+1-res;
	cout<<ans;
	return 0;
}

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

int main() {
  int N,D;
  cin >> N >> D;
  
  if (N%(2*D+1) == 0) {
    cout << N/(2*D+1) <<endl;
  }
  else {
    cout << N/(2*D+1)+1 <<endl;
  }
}


Measured memory_bytes: 256
use std::io::*;

mod disjoint_set {
    pub struct DisjointSet {
        parent: Vec<usize>,
        size: Vec<usize>,
    }
    impl DisjointSet {
        pub fn new(n: usize) -> DisjointSet {
            DisjointSet {
                parent: (0..n).collect(),
                size: vec![1; n],
            }
        }
        pub fn root(&mut self, x: usize) -> usize {
            if x == self.parent[x] {
                x
            } else {
                let tmp = self.parent[x];
                self.parent[x] = self.root(tmp);
                self.parent[x]
            }
        }
        pub fn merge(&mut self, x: usize, y: usize) {
            let x = self.root(x);
            let y = self.root(y);
            if x == y {
                return;
            }
            if self.size[x] > self.size[y] {
                self.size[x] += self.size[y];
                self.parent[y] = x;
            } else {
                self.size[y] += self.size[x];
                self.parent[x] = y;
            }
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse::<usize>().unwrap() - 1,
                itr.next().unwrap().parse::<usize>().unwrap() - 1,
            )
        })
        .collect();

    let mut ds = disjoint_set::DisjointSet::new(200020);
    let mut count = vec![0; 200020];
    let mut ans = 0;
    for i in 0..n {
        ds.merge(a[i].0, a[i].1 + 100000);
    }
    for i in 0..100000 {
        count[ds.root(i)] += 1;
    }
    for i in 100000..200000 {
        ans += count[ds.root(i)];
    }
    println!("{}", ans - n);
}

// この解法ではすでに長方形ができてる場合を余分に数えてる。
// すでにできてるかの判定が面倒なので、ありうる辺の数を数えて最後にnを引きたい。
// これは二部グラフの各連結成分を完全グラフにした時の辺の数。連結成分内なら絶対に長方形が作れる。
// 逆に連結成分でない頂点と長方形を作ろうとすると新たに辺が２本必要になるので無理。


Measured memory_bytes: 14588
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int a[100000];

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }
const int maxn = 1000000;
int f[maxn + 1], fi[maxn + 1];
int ncr(int n, int r) { if (r > n) return 0; return mul(f[n], mul(fi[r], fi[n - r])); }

void precompute()
{
    f[0] = 1;
    for (int i = 1; i <= maxn; ++i)
        f[i] = mul(f[i - 1], i);

    fi[maxn] = inv(f[maxn]);
    for (int i = maxn - 1; i >= 0; --i)
        fi[i] = mul(fi[i + 1], i + 1);
}

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

    precompute();
    sort(a, a + n);
    for (int i = 0; i < n; ++i)
    {
        a[i] += mod;
        a[i] %= mod;
    }
    int sol = 0;
    for (int i = n - 1; i >= 0; --i)
        adds(sol, mul(a[i], ncr(i, k - 1)));
    for (int i = 0; i < n; ++i)
        subs(sol, mul(a[i], ncr(n - i - 1, k - 1)));
    cout << sol;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T, typename F>
T KnuthYao(int n,F cost){
  vector< vector<T> > dp(n,vector<T>(n));
  vector< vector<int> > ar(n,vector<int>(n));
  for(int i=0;i<n;i++) dp[i][i]=T(0),ar[i][i]=i;
  for(int w=1;w<n;w++){
    for(int i=0;i+w<n;i++){
      int j=i+w;
      int p=ar[i][j-1],q=ar[i+1][j];
      dp[i][j]=dp[i][p]+dp[p+1][j]+cost(i,p,j);
      ar[i][j]=p;
      for(int k=p;k<=q&&k+1<=j;k++){
        T res=dp[i][k]+dp[k+1][j]+cost(i,k,j);
        if(res<dp[i][j]) dp[i][j]=res,ar[i][j]=k;
      }
    }
  }
  return dp[0][n-1];
}
//END CUT HERE
//INSERT ABOVE HERE

signed AOJ_2488(){
  using ll = long long;
  int n;
  cin>>n;
  vector<ll> xs(n),ys(n);
  for(int i=0;i<n;i++) cin>>xs[i]>>ys[i];
  auto calc=
    [&](int i,int k,int j){
      return xs[k+1]-xs[i]+ys[k]-ys[j];
    };
  cout<<KnuthYao<ll>(n,calc)<<endl;
  return 0;
}
/*
  verified on 2018/09/30
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2488
*/

signed KUPC2012_J(){
  using ll = long long;
  int n;
  cin>>n;
  vector<ll> ws(n);
  for(int i=0;i<n;i++) cin>>ws[i];
  vector<ll> sm(n+1);
  for(int i=0;i<n;i++) sm[i+1]=sm[i]+ws[i];
  auto cost=[&](int i,int k,int j){(void) k;return sm[j+1]-sm[i];};
  cout<<KnuthYao<ll>(n,cost)<<endl;
  return 0;
}
/*
  verified on 2018/09/30
  https://atcoder.jp/contests/kupc2012/tasks/kupc2012_10
*/

signed main(){
  AOJ_2488();
  //KUPC2012_J();
  return 0;
}



Measured memory_bytes: 14632
n,k = map(int, input().split())
dpa = {}

for i in range(k):
	d = int(input())
	s = list(map(int, input().split()))
	for j in range(d):
#		print("  ",j,s[j])
		dpa[s[j]] = 1

#print(len(dpa))
print(n-len(dpa))


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int max=0;int l;
	int n;cin>>n;
	int a[n+5]={0};
	int i,j,k;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>max)
		{
			max=a[i];
			l=i;
		}
	}
	int s=a[0];long long count=0;
	for(i=1;i<l;i++)
	{
		if(a[i]>=s)
		s=a[i];
		else
		count+=s-a[i];
	}
	for(i=l+1;i<n;i++)
	if(a[i]<max)
	count+=max-a[i];
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 4376
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>

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

using namespace std;
using ll = long long;

int X[] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Y[] = {1, 1, 1, 0, -1, -1, -1, 0};

void solve() {
    string s;
    cin >> s;
    for(int i = s.size()-1; i > 0; i--){
        if(s.size()%2 == 0){
            bool f = true;
            for(int j = 0; j < i/2; j++){
                if(s[j] != s[j+(i/2)]){
                    f = false;
                }
            }
            if(f){
                cout << i-1 << endl;
                return;
            }
        }
    }
}

int main(){
    solve();
    return 0;
}

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

using namespace std;

int main(){
	
	long long n, k, ans;
	vector <long long> a;
	
	cin >> n >> k;
	
	for (int i = 0; i < n; i++){
		
		long long h;
		
		cin >> h;
		a.push_back(h);
		
	}
	
	sort(a.begin(), a.end(), greater<int>());
	
	for (int i = k; i < n; i++){
		ans += a[i];
	}
	
	cout << ans;
	
	
}




Measured memory_bytes: 2420
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define REP(i,a,n) for(int i = a; i < n; i++)
#define rep(i,n) REP(i,0,n)
int n;
int joint[70000];
long long  sum;

void solve(){
  long long ans = sum*n;
  int num = n;
  long long joint_sum = 0;
  rep(i, n-1){
    joint_sum += joint[i];
    ans = max(ans, (sum+joint_sum)*(n-i-1));
  }
  cout << ans << endl;
}


int main(){
  while(cin >> n, n){
    sum = 0;
    rep(i,n){
      int p;
      cin >> p;
      sum += p;
    }
    rep(i, n-1){
      cin >> joint[i];
    }
    sort(joint, joint+(n-1),greater<int>());
    solve();
  }
  return 0;
}

Measured memory_bytes: 1432
from math import *
a, b, x = list(map(int,input().split()))

theta = 0.0
if (x <= 0.5*a*a*b):
    theta = atan(0.5*a*b*b/x)
else:
    theta = atan( 2.0*(b-x/(a*a))/a )
theta = theta * 180 / pi
print('{:.10f}'.format(theta))


Measured memory_bytes: 3060
#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>;
int main() {
  int a; cin >> a;
  int ans = 0;
  ans = a + a * a + a * a * a;
  cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int h,w;
    cin >>h>>w;
    vector<vector<char>> c(h,vector<char> (w,'-'));
    vector<vector<int>> dis(h,vector<int> (w,-1));
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    int dp[101][101]={};
    int sy = 0,sx=0;
    int gy = h-1, gx = w-1;
    if(c[0][0]=='#'){
        dp[0][0]=1;
    }
    for(int j=1;j<w;j++){
        if(c[0][j-1]=='.'&&c[0][j]=='#'){
            dp[0][j] = dp[0][j-1]+1;
        }
        else{
            dp[0][j] = dp[0][j-1];
        }
    }
    for(int i=1;i<h;i++){
        if(c[i-1][0]=='.' && c[i][0]=='#'){
            dp[i][0] = dp[i-1][0]+1;
        }
        else{
            dp[i][0] = dp[i-1][0];
        }
    }
    for(int i =1;i<h;i++){
        for(int j=1;j<w;j++){
            if(c[i][j]=='#'){
                int l=0,u=0;
                if(c[i-1][j]=='.'){
                    u=1;
                }
                if(c[i][j-1]=='.'){
                    l=1;
                }
                dp[i][j]=min(dp[i-1][j]+u,dp[i][j-1]+l);
            }
            else{
                dp[i][j] = min(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define NL '\n'
using namespace std;

int fk[200005];

int main() {
	int n, k, num, cnt = 0, nm = 0;
    cin >> n >> k;
    
    for( int i = 0; i < n; i++ ){
        cin >> num;

        if( fk[num] == 0 ) nm++;
        fk[num]++;
    }
    
    if( nm <= k ){
        cout << 0 << NL;
        return 0;
    }
    
    sort(fk, fk+200005, greater<int>());

	for( int i = nm-1; nm > k; i-- ){
        cnt += fk[i];
        nm --;
    }
 
    cout << cnt << NL;

	return 0;
}

Measured memory_bytes: 1024
package main

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

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N+2) // A[0]=A[N+1]=0
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 1; i <= N; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}
	cost := 0
	for i := 0; i+1 < len(A); i++ {
		cost += abs(A[i] - A[i+1])
	}
	// 総コストから(1)A[i-1]->A[i]のコストとA[i]->A[i+1]のコストを引き、(2) A[i-1]->A[i+1]のコストを足す。
	for i := 1; i <= N; i++ {
		newcost := cost - (abs(A[i-1]-A[i]) + abs(A[i]-A[i+1])) + abs(A[i-1]-A[i+1])
		fmt.Println(newcost)
	}
}

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


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target ("avx2,avx,fma")
#define ll long long int
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define make_pair
#define rep(i,l,r) for(i=l;i<r;i++)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
int main()
{
    io;
    int i,j,n,m,k,a,l;
    cin>>n>>m;
    vector<vector<int> >v(n);
    vector<int>cnt;
    vector<int>p(m);
    rep(i,0,m)
    {
        cin>>k;
        rep(j,0,k)
        {
        cin>>a;
        v[a-1].pb(i);
        }
    }
    rep(i,0,m)
    cin>>p[i];
    a=1<<n;
    int cn=0;
    rep(i,0,a)
    {
        cnt.resize(m,0);
        rep(j,0,n)
            if(i&(1<<j))
            rep(l,0,v[j].size())
            cnt[v[j][l]]++;
        k=0;
        rep(j,0,m)
            if(cnt[j]%2==p[j])
                k++;
                if(k==m)
                    cn++;
        cnt.clear();
    }
    cout<<cn;
    return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
tx, ty = tx-sx, ty-sy
ans = ''

ans += 'U' * ty + 'R' * tx + 'D' * ty + 'L' * tx
ans += 'L' + 'U' * (ty + 1) + 'R' * (tx + 1) + 'DR' + 'D' * (ty + 1) + 'L' * (tx + 1) + 'U'
print(ans)

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

using namespace std;

using ll = long long;

const long long MOD_NUMBER = 1000000007;
const double PI = 3.14159265358979323846;


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


Measured memory_bytes: 3636
fun main (args: Array<String>) {
    val userInput : String = readLine()!!
    val userMoney : Int    = userInput.toInt()
    val fiveHundredCoins:Int = Math.floor(userMoney.toDouble()/500.0).toInt()
    val fiveYenCoins : Int  = Math.floor((userMoney.toDouble() - (fiveHundredCoins*500).toDouble()) / 5.0).toInt()
    println(fiveHundredCoins*1000 + fiveYenCoins * 5)
}

Measured memory_bytes: 31584
#ABC-118-B
N, M = map(int, input().split())
memo = [0]*(M+1)

for _ in range(N):
    Ki, *A = map(int, input().split())
    for item in A:
        memo[int(item)] += 1

ans = 0
for i in range(1, M+1):
    if memo[i] == N:
        ans += 1

print(ans)

Measured memory_bytes: 3060