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

#define fi first
#define se second
const int N=100010;
typedef long long ll;
set<pair<ll, int>> sab, sba, sac, sca, sbc, scb;
set<pair<ll, int>>::iterator itab, itba, ita, itb, itc;
ll ans, a[N], b[N], c[N], anss;
int i, n, na, nb, nc, X, Y, Z, xi, yi, zi;

void pusha(int i)
{
	ans += a[i];
	sab.insert({a[i] - b[i], i});
	sac.insert({a[i] - c[i], i});
}
void pushb(int i)
{
	ans += b[i];
	sba.insert({b[i] - a[i], i});
	sbc.insert({b[i] - c[i], i});
}
void pushc(int i)
{
	ans += c[i];
	sca.insert({c[i] - a[i], i});
	scb.insert({c[i] - b[i], i});
}
void popa(int i)
{
	ans -= a[i];
	sab.erase({a[i] - b[i], i});
	sac.erase({a[i] - c[i], i});
}
void popb(int i)
{
	ans -= b[i];
	sba.erase({b[i] - a[i], i});
	sbc.erase({b[i] - c[i], i});
}
void popc(int i)
{
	ans -= c[i];
	sca.erase({c[i] - a[i], i});
	scb.erase({c[i] - b[i], i});
}

int main()
{
	scanf("%d%d%d", &X, &Y, &Z);
	n = X + Y + Z;
	na = nb = nc = 0;
	for (i = 1; i <= n; ++i)
	{
		scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
		if (na < X) pusha(i), ++na;
		else if (nb < Y) pushb(i), ++nb;
		else if (nc < Z) pushc(i), ++nc;
	}
	anss = ans;
	bool flag = 1;
	while (flag)
	{
		flag = 0;
		
		itab = sab.begin();
		itba = sba.begin();
		if (itab->fi + itba->fi < 0)
		{
			flag = 1;
			xi = itab->se;
			yi = itba->se;
			popa(xi);  popb(yi);
			pusha(yi); pushb(xi);
			anss = max(ans, anss);
		}
		
		itab = sac.begin();
		itba = sca.begin();
		if (itab->fi + itba->fi < 0)
		{
			flag = 1;
			xi = itab->se;
			yi = itba->se;
			popa(xi);  popc(yi);
			pusha(yi); pushc(xi);
			anss = max(ans, anss);
		}
		
		itab = sbc.begin();
		itba = scb.begin();
		if (itab->fi + itba->fi < 0)
		{
			flag = 1;
			xi = itab->se;
			yi = itba->se;
			popb(xi);  popc(yi);
			pushb(yi); pushc(xi);
			anss = max(ans, anss);
		}
		
		ita = sab.begin();
		itb = sbc.begin();
		itc = sca.begin();
		if (ita->fi + itb->fi + itc->fi < 0)
		{
			flag = 1;
			xi = ita->se;
			yi = itb->se;
			zi = itc->se;
			popa(xi); popb(yi); popc(zi);
			pusha(zi); pushb(xi); pushc(yi);
			anss = max(ans, anss);
		}
		ita = sac.begin();
		itb = sba.begin();
		itc = scb.begin();
		if (ita->fi + itb->fi + itc->fi < 0)
		{
			flag = 1;
			xi = ita->se;
			yi = itb->se;
			zi = itc->se;
			popa(xi); popb(yi); popc(zi);
			pusha(yi); pushb(zi); pushc(xi);
			anss = max(ans, anss);
		}
	}
	printf("%lld\n", anss);
	return 0;
}

Measured memory_bytes: 15104
#include <iostream>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    int N = S.size();
    
    for(int i = 0; i < N; i++){
        if(S.at(i) != S.at(N - 1 - i)){
            cout << "No" << endl;
            return 0;
        }
    }
    
    for(int i = 0; i < (N - 1) / 2; i++){
        if(S.at(i) != S.at((N - 1) / 2 - 1 - i)){
            cout << "No" << endl;
            return 0;
        }
    }
    
    for (int i = (N + 3) / 2; i < N; i++){
        if(S.at(i) != S.at(N - 1 - i)){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B,M = II()
a = LI()
b = LI()
ticket = [LI() for _ in range(M)]

cost = min(a) + min(b)
costl = [a[t[0]-1] + b[t[1]-1] - t[2] for t in ticket]

print(min(cost,min(costl)))

Measured memory_bytes: 51472
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define ces(d) cout<<" "<<endl;

 
int main() {
int N;
cin>>N;
int x=0;
for(int n=1;n<1000000000;n++){
  x+=n;
 if(x>=N){
  ce(n)
break;
  }
}

}

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

int main(){
	string s;
	cin >> s;
	s = ">" + s + "<";
	int n = s.size() - 1;
	vector <int> a(n+2, 0);
	int j = 1;
	while (j <= n) {
		if (s[j-1] == '>' && s[j] == '<') {
			while (j <= n && s[j] == '<') {
				a[j+1] = max(a[j+1], a[j]+1);
				j++;
			}
		}else {
			j++;
		}
	}
	j = n;
	while (j >= 1) {
		if (s[j-1] == '>' && s[j] == '<') {
			while (j >= 1 && s[j-1] == '>') {
				a[j-1] = max(a[j-1], a[j]+1);
				j--;
			}
		}else {
			j--;
		}
	}
	long long sum = 0;
	for (int i = 1; i <= n; ++i) sum += a[i];
	cout << sum << "\n";
	return 0;
}


Measured memory_bytes: 2840
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		if(n+m<10) {
			System.out.println(n+m);
		}
		else {
			System.out.println("error");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fast_io                                                                \
    ios::sync_with_stdio(false);                                               \
    cin.tie(0)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf = 0x3f3f3f3f;
const int N = (int)2e5 + 5;
const int M = (int)1e5 + 5;
const int mod = (int)998244353;
const double esp = 1e-8;
int T;
//------------------------------
int dp[N];
int sum[N];
int seg[10][2];
int main() {
    fast_io;
    int n;
    int k;
    cin >> n >> k;
    for (int i = 0; i < k; ++i) {
        cin >> seg[i][0] >> seg[i][1];
    }
    dp[2] = 1;
    for (int i = 2; i <= n + 1; ++i) {
        for (int j = 0; j < k; ++j) {
            int l = seg[j][0], r = seg[j][1];
            l = i - l, r = i - r;
            if (l <= 1)
                l = 1;
            if (r <= 1)
                r = 1;
            dp[i] = ((dp[i] + sum[l] - sum[r - 1]) % mod + mod) % mod;
        }
        sum[i] = (sum[i - 1] + dp[i]) % mod;
    }
    cout << dp[n + 1] << endl;
    return 0;
}

Measured memory_bytes: 5144
#include <iostream>
#include <string>

using namespace std;
int main() {
	string d;
	cin >> d;
	int max,curr;
	max = 0;
	curr = 0;
	for(int i = 0; i <3; i++){
		if (d[i] == 'R'){
			curr ++;
		} 
		else {
			curr = 0;
		}
		if (curr > max){
			max = curr;
		}

	}
	cout << max;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
using namespace std; void solve();
using ll = long long; using vi = vector<int>;
using vl = vector<ll>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cout << #v << " = "; array_out(v , N);cout << endl;} while(0)
  int main(){ auto start = clock(); m_dbg(); cerr << "time : " << clock() - start  << " ms" << endl; }
#else
  #define trc(...)
  #define trca(...)
  int main(){ solve(); }
#endif

using P = pair<int,int>;
constexpr int MOD = 1000000007;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
//////////////////////////////////////////

void solve(){
  ini(N,M);
  vector<P> v(N); in(v);
  sort(all(v));
  v.eb(inf , 0);
  multiset<int> m;
  ll ans = 0;
  for(int d = 1; d <= M; d++){
    const P p(d,0);
    auto it = lower_bound(all(v) , p);
    while(it->fi == d) {
      m.insert(it->se);
      it++;
    }
    if(m.empty()) continue;
    auto itm = m.end(); itm--;
    ans += *itm; m.erase(itm);
  }
  out(ans);
}

Measured memory_bytes: 5744
// ABC138A2.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include<string> // stringを使うとき
using namespace std;
int main()
{
	int a;
	string s;
	string red = "red";

	cin >> a;
	cin >> s;

	if (a>=3200)
	{
		cout << s;
	}
	else
	{
		cout << red;
	}
}


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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

template<typename T> inline constexpr auto sqr(T x) { return (x) * (x); }
void printd(double x) { printf("%.10lf\n", x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	int N, K;
	cin >> N >> K;

	string S;
	cin >> S;

	const char first = S[0];
	char before = first;
	int k = 0;

	rbf(s, S) {
		if ((s == first) && (s != before)) {
			k++;
		}
		if (k == K) break;
		before = s;
		if (s != first) {
			s = first;
		}
	}

	S = 'x' + S + 'x';
	int happy = 0;
	rng(i, 1, N + 1) {
		if (S[i] == 'L') {
			if (S[i] == S[i - 1]) happy++;
		}
		else {
			if (S[i] == S[i + 1]) happy++;
		}
	}

	COL(happy);

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
#define int long long
using namespace std;
int dp[214514][5];
signed main(){
	int l;
	cin>>l;
	int n=l;
	vector<int> a;
	for(int i=0;i<l;i++){
		int ta;cin>>ta;a.pb(ta);
	}
	dp[0][0] = a[0];
	dp[0][1] = a[0]%2 +  max((ll)0,2-2*a[0]);
	dp[0][2] = 1-(a[0]%2);
	dp[0][3] = a[0]%2 +  max((ll)0,2-2*a[0]);
	dp[0][4] = a[0];
	for(int i=1;i<n;i++){
		dp[i][0] = dp[i-1][0] + a[i];
		dp[i][1] = min(dp[i-1][0],dp[i-1][1]) + a[i]%2 + max((ll)0,2-2*a[i]);
		dp[i][2] = min(dp[i-1][0],min(dp[i-1][1],dp[i-1][2])) + 1 -(a[i]%2);
		dp[i][3] = min(dp[i-1][0],min(dp[i-1][1],min(dp[i-1][2],dp[i-1][3]))) + a[i]%2 +  max((ll)0,2-2*a[i]);
		dp[i][4] = min(dp[i-1][0],min(dp[i-1][1],min(dp[i-1][2],min(dp[i-1][3],dp[i-1][4])))) + a[i];
	}
	cout<<min(dp[n-1][0],min(dp[n-1][1],min(dp[n-1][2],min(dp[n-1][3],dp[n-1][4]))))<<endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define int long long

const int maxn = 1e6+50, inf = 1e9;

int n, a[maxn], b[maxn], ans;
vector <int> v;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for ( int i = 0; i < n; i++)
    {
        cin >> a[i];
        v.pb(a[i]);
    }
    sort( v.begin(), v.end());
    for ( int i = 0; i < n; i++)
    {
        b[i] = lower_bound( v.begin(), v.end(), a[i])-v.begin();
    }
    for ( int i = 0; i < n; i++)
    {
        if ( (b[i] - i) % 2 )
            ans++;
    }
    cout << ans/2;
}


Measured memory_bytes: 6004
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
using namespace std;
const int mxn = 2010;
const int mxm = 80100;
#define ms(x,y) memset(x,y,sizeof(x))
const int inf = 0x3f3f3f3f;
int x,y,n,m,vis[mxn],b[mxn],viss[mxn],dfn[mxn],ans = inf;

vector<int>path;
int head[mxn],cnt = 0 ;
struct edge
{
	int v,nx;
}e[mxm];
void add(int u,int v)
{
	e[++cnt].v = v;
	e[cnt].nx = head[u];
	head[u] = cnt;
}
void dfs(int x,int num)
{
	vis[x] = 1;
	dfn[x] = num ;
	for(int i =head[x];~i;i = e[i].nx)
	{
		int v = e[i].v;
		if(viss[v])
		{
			if(dfn[x] - dfn[v] +1 <ans)
			{
				ans = dfn[x] - dfn[v] + 1;
				int sz = path.size();
				for(int i=  1;i<=ans;i++)
				{
					b[i] = path[sz-i];
				}
			}
		}
		if(!vis[v])
		{
			viss[v] = 1;
			path.push_back(v);
			dfs(v,num+1);
		}
	}
	path.pop_back();
	viss[x] =  0 ;
	
}
int main()
{
	memset(vis,0,sizeof(vis));
	memset(viss,0,sizeof(viss));
	memset(head,-1,sizeof(head));
	cin>>n>>m;
	for(int i = 1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);
	}
	for(int i = 1;i<=n;i++)
	{
		if(!vis[i])
		{
			path.clear();
			path.push_back(i);
			viss[i] = 1;
			dfs(i,1);
		}
	}
	if(ans == inf)printf("-1\n");
	else
	{
		printf("%d\n",ans);
		for(int i  = ans ;i>= 1;i--)printf("%d\n",b[i]);
	}
	return 0;
}

Measured memory_bytes: 384
import scala.io.StdIn._
object Main{
  def main(args: Array[String]): Unit = {
    val s = readLine
    var c = 0
    if(s.length!=4) return
    for(i <- 0 to 3){
      if(s.charAt(i)=='+') c += 1
      else if(s.charAt(i)=='-') c-=1
    }
    println(c.toString)
  }
}


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

using namespace std;

int main(){
    string s;
    cin>>s;
    if(s.at(0)=='7' || s.at(1)=='7' || s.at(2)=='7') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

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

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  int ans1, ans2, n, m, taro[128], hana[128], i, j, min;
  int taro_sum, hana_sum;
  
  while(scanf("%d%d", &n, &m), n){

    taro_sum=hana_sum=0;
    
    for(i=0; i<n; i++){
      scanf("%d", &taro[i]);
      taro_sum+=taro[i];
    }
    for(i=0; i<m; i++){
      scanf("%d", &hana[i]);
      hana_sum+=hana[i];
    }

    ans1=ans2=0;
    min=200;
    for(i=0; i<n; i++){
      for(j=0; j<m; j++){
	if(taro_sum-taro[i]+hana[j]==hana_sum-hana[j]+taro[i]){
	  if(min>taro[i]+hana[j]){
	    ans1=taro[i];
	    ans2=hana[j];
	    min=taro[i]+hana[j];
	  }
	}
      }
    }

    if(ans1==0 || ans2==0){
      printf("-1\n");
    }else{
      printf("%d %d\n", ans1, ans2);
    }
    
  }

  return 0;
}

Measured memory_bytes: 612
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int A = sc.nextInt();
		int[] X = new int[N];
		for (int i = 0; i < N; ++i) {
			X[i] = sc.nextInt();
		}
		long[][][] dp = new long[N + 1][N + 1][50 * N + 1];
		dp[0][0][0] = 1;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j <= i; ++j) {
				for (int k = 0; k + X[i] < dp[0][0].length; ++k) {
					dp[i + 1][j][k] += dp[i][j][k];
					dp[i + 1][j + 1][k + X[i]] += dp[i][j][k];
				}
			}
		}
		long ans = 0;
		for (int i = 1; i <= N; ++i) {
			ans += dp[N][i][A * i];
		}
		System.out.println(ans);
	}

}


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

int main(){
  int64_t H, W;
  cin >> H >> W;
  if(H==1 || W==1){
    cout << 1 << endl;
  }
  else if(H%2==1 && W%2==1){
    cout << H*W/2+1 << endl;
  }
  else{
    cout << H*W/2 << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readIntegerList()
    val aList = readLongList()
    for (i in k until n) {
        val ans = if (aList[i] > aList[i - k]) "Yes" else "No"
        out.println(ans)
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)




Measured memory_bytes: 75688
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]


n,m = imap()
g = [[] for i in range(n+1)]
for i in range(m):
    a,b = imap()
    g[a].append(b)
    g[b].append(a)

q = col.deque([1])
know = barr(n+1); know[1] = True
anss = iarr(n+1)
while q:
    now = q.popleft()
    for next in g[now]:
        if know[next]: continue
        else: know[next] = True; q.append(next); anss[next] = now

print("Yes")
for ans in anss[2:]: print(ans)


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

using ll = long long int;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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

    while(1) {
        ll n, m;
        cin >> n >> m;
        if(!n) break;
        vector<ll> a(n);
        REP(i, n) cin >> a[i];

        ll ret = -1;
        REP(i, n) FOR(j, i+1, n) {
            if(a[i]+a[j] <= m) chmax(ret, a[i]+a[j]);
        }

        if(ret == -1) cout << "NONE" << endl;
        else cout << ret << endl;
     }

    return 0;
}



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


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


  vector<int> b;
  for(int i=n-1; i>n/2; i--){
    if(a.at(i) == 1){
      b.push_back(i);
      ans.at(i) = 1;
    }
  } 

  for(int i = n/2;i >= 0; i--){
    int k = 0;
    for(int j = 1; j < n/(i+1); j++){
      
      k += ans.at((i+1)*(j+1)-1);
    }
    if((k % 2) != a.at(i)){
      b.push_back(i);
      ans.at(i) = 1;
    }
  }

  cout << b.size() << endl;

  if(b.size() != 0){
    for(int i=0; i < b.size(); i++){
      cout << b.at(i) + 1 << " ";
    }
    cout << endl;
  }

  
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = 1e18+1;
ll MOD=1e9+7;

int main(){
  int N,M;
  cin>>N>>M;
  int d[100][100] = {0};
  for(int i(0);i<100;i++){
    for(int j(0);j<100;j++){
      if(i == j) continue;
      d[i][j] = INFint;
    }
  }
  int a[10000],b[10000],c[10000];
  for(int i(0);i<M;i++){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < N; k++){       // 経由する頂点
    for (int i = 0; i < N; i++) {    // 始点
      for (int j = 0; j < N; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans(0);
  for(int i(0);i<M;i++){
    if(d[a[i]][b[i]] != c[i]){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list()
xy = list()
for i in range(n):
  A = int(input())
  XY = [tuple(map(int, input().split())) for i in range(A)]
  a.append(A)
  xy.append(XY)
honest = [None] * n
ans = 0
for i in range(2 ** n-1,-1,-1):
  mini_ans = 0
  honest = []
  for j in range(n):
    honest.append(i % 2)
    i = i // 2
  for k,v in enumerate(honest):
    if v:
      mini_ans += 1
      for x,y in xy[k]:
        x -= 1
        if honest[x] != y:
          break
      else:
        continue
      break
  else:
    ans = max(ans,mini_ans)
    continue
print(ans)


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

int main(void){
  int N, K, count = 1;
  bool flag = true;
  cin >> N >> K;
  int tmp = N;
  
  for(int i = 1; i<=K; i++){
    tmp -= 2;
    if(tmp <= 0 && i < K){flag = false;}
  }
  if(flag == true){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = (ll)1e9 + 7;

int n, k;
int a[N];

void solve() {
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + n + 1);
    int ans = 0;
    for (int i = 1; i <= k; ++i)
        ans += a[i];
    cout << ans << "\n";
}

int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;

const int MAXN = 2e5;

int parent[MAXN], sz[MAXN];

// Initialise - set parent[i] = i, rank[i] = 0 for each i.

int Find(int v)
{
	return parent[v] = parent[v] == v?v:Find(parent[v]);
}

void Union(int u, int v)
{
	u = Find(u);
	v = Find(v);
	if (u == v) return;
	if (sz[u] < sz[v]) swap(u, v);
	sz[u] += sz[v];
	parent[v] = u;
}

void solve()
{
	int n; cin >> n;
	int m; cin >> m;
	for (int i = 1; i <= n; ++i)
	{
		parent[i] = i;
		sz[i] = 1;
	}
	for (int i = 0; i < m; ++i)
	{
		int x, y, z; cin >> x >> y >> z;
		Union(x, y);
	}
	set<int> s;
	for (int i = 1; i <= n; ++i)
	{
		s.insert(Find(i));
	}
	cout << s.size();
}

//  ---------------------Template---------------------------
void InputSetup()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
}

int main(void)
{
	auto start = chrono::high_resolution_clock::now();

	InputSetup();
	solve();

	auto finish = chrono::high_resolution_clock::now();
	cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
}
//  ---------------------Template---------------------------

Measured memory_bytes: 5760
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = (char *)malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = (char *)malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = (int64 *)malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;

typedef int64 simple_t;

int compare_simple(const void *a, const void *b)
{
  simple_t *x;
  simple_t *y;

  x = (simple_t *)a;
  y = (simple_t *)b;

  if (x > y) return 1;
  if (y < x) return -1;

  return 0;
}
void qsort_simple (simple_t *array, int size)
{
  qsort(array, size, sizeof(simple_t), compare_simple);
}

int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}


int resolve1()
{
  int64 R;
  double pi=3.14159;
  double L;

  get_N(&R);

  L = pi*R*2;

  printf("%lf", L);
  return 0;
}

int resolve2()
{
  int64 N,M;
  int64 *A;
  int64 i;
  int64 total = 0;
  int64 play=0;
  
  get_NK(&N, &M);
  A = get_NSeq(M);

  for (i=0; i < M; i++) {
    total += A[i];
  }

  if (N >= total) {
    play = N - total;
  } else {
    printf("-1");
    return 0;
  }

  printf("%lld",play);
  return 0;
}


int main()
{
  char *str;
  int64 size;
  int64 i;
  
  str = get_SN(21, &size);

  for (i=0; i < 3; i++) {
    printf("%c", str[i]);
  }

  return 0;
}



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

using namespace std;
const long long LINF = LLONG_MAX;
const int INF = INT_MAX;
const int MOD = 1000000007;

int gcd(int a , int b)
{
    if(b==0) return a;
    a%=b;
    return gcd(b,a);
}

int main() {
    ios::sync_with_stdio(false);
    long long n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (auto& v : a)
        cin >> v;
    long long l = a[0];
    for (int i = 1; i < n; i++){
        l = l  / __gcd(l, (long long)a[i]) * a[i];
    }
    for (auto& v : a)
        if ((l / v) % 2 == 0){
            cout << "0";
            return 0;
        }
    l /= 2;
    m /= l;
    cout << (m + 1) / 2;

    return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

int main(){
  int n,m,c;
  cin>>n>>m>>c;
  vi l(c);
  rep(i,c)cin>>l[i];
  vector<pii> cw(n);
  rep(i,n){
    int cc,ww;
    cin>>cc>>ww;
    cc--;
    cw[i]=pii(ww,cc);
  }
  sort(cw.rbegin(),cw.rend());
  lint ans=0;
  int rem=m;
  rep(i,n){
    if(rem<=0)break;
    int cc=cw[i].second;
    if(l[cc]>0){
      l[cc]--;
      ans+=cw[i].first;
      rem--;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3884
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String ns = sc.nextLine();
        int n = Integer.parseInt(ns);
        
        String inputs = sc.nextLine();
        String[] input = inputs.split(" ");
        
        double[] nums = new double[input.length];
        for (int i = 0; i < input.length; i++) {
            nums[i] = Integer.parseInt(input[i]);
        }
        
        Arrays.sort(nums);
        
        double result = makeResult(nums);
        System.out.println(result);
        
    }

    private static double makeResult(double[] nums) {
        if (nums.length == 1) {
            return nums[0];
        }
        
        double[] newNums = new double[nums.length - 1];
        newNums[0] = (nums[0] + nums[1]) / 2;
        for (int i = 1; i < newNums.length; i++) {
            newNums[i] = nums[i + 1];
        }
        return makeResult(newNums);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct Pos { int y, x; };

int main(void)
{
    int w, h;
    int map[52][52] = {{0}};
    int nx[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    int ny[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    queue<Pos> poss;
    Pos now;
    int ans;
    while (true)
    {
        cin >> w >> h;
        if (!w && !h) break;
        ans = 0;
        for (int i = 1; i <= h; i++) for (int j = 1; j <= w; j++) cin >> map[i][j];
        for (int i = 1; i <= h; i++)
        {
            for (int j = 1; j <= w; j++)
            {
                if (map[i][j])
                {
                    poss.push({i, j});
                    while (!poss.empty())
                    {
                        now = poss.front();
                        poss.pop();
                        if (!map[now.y][now.x]) continue;
                        else map[now.y][now.x] = 0;
                        for (int k = 0; k < 8; k++) if (map[now.y + ny[k]][now.x + nx[k]]) poss.push({now.y + ny[k], now.x + nx[k]});
                    }
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define RI register int
#define lc(x) child[x][0]
#define rc(x) child[x][1]
typedef long long LL;

using namespace std;

template <class T> inline void read(T &n) {
	n = 0; RI ch;
	while (!isdigit(ch = getchar()));
	for (n = ch ^ 48; isdigit(ch = getchar()); n = n * 10 + (ch ^ 48));
}

int const MAXN = 2e5 + 5;
struct Edges {
	int x, y;
	LL val;
} e[MAXN];
LL a[MAXN], Rsize[MAXN], Esize[MAXN];
int vis[MAXN], fa[MAXN], child[MAXN][2], r[MAXN], stk[MAXN], top;

inline bool cmp(Edges x, Edges y) { return x.val < y.val; }

inline void Update(int x) { Rsize[x] = Rsize[lc(x)] + Rsize[rc(x)] + Esize[x] + a[x]; }
inline bool Isroot(int x) { return lc(fa[x]) != x && rc(fa[x]) != x; }
inline void Reverse(int x) { swap(lc(x), rc(x)), r[x] ^= 1; }
inline void Pushdown(int x) {
	if (r[x]) {
		if (lc(x)) Reverse(lc(x));
		if (rc(x)) Reverse(rc(x));
		r[x] = 0;
	}
}
inline void Rotate(int x) {
	int f = fa[x], g = fa[f], c = rc(f) == x;
	if (!Isroot(f)) child[g][rc(g) == f] = x;
	child[f][c] = child[x][!c];
	child[x][!c] = f;
	if (child[f][c]) fa[child[f][c]] = f;
	fa[x] = g;
	fa[f] = x;
	Update(f);
}
inline void Splay(int x) {
	int y = x; top = 0;
	stk[++top] = y;
	while (!Isroot(y)) stk[++top] = y = fa[y];
	while (top) Pushdown(stk[top--]);
	while (!Isroot(x)) {
		y = fa[x];
		if (!Isroot(y))
			Rotate((lc(y) == x) == (lc(fa[y]) == y) ? y : x);
		Rotate(x);
	}
	Update(x);
}
inline void Access(int x) {
	for (RI y = 0; x; y = x, x = fa[x])
		Splay(x), Esize[x] += Rsize[rc(x)], Esize[x] -= Rsize[y], rc(x) = y, Update(x);
}
inline void Makeroot(int x) {
	Access(x), Splay(x), Reverse(x);
}
inline bool Unicom(int x, int y) {
	Makeroot(x), Access(y), Splay(y);
	int k = y;
	while (lc(k)) k = lc(k);
	return k == x;
}
inline void Link(int x, int y) {
	Makeroot(x), Splay(x);
	fa[x] = y, Esize[y] += Rsize[x];
}
inline void Cut(int x, int y) {
	Makeroot(x), Access(y), Splay(y);
	lc(y) = fa[x] = 0;
	Update(y);
}

int main() {
	//freopen("bridge.in", "r", stdin);
	//freopen("bridge.out", "w", stdout);
	int n, m, ans = 0; read(n), read(m);
	for (RI i = 1; i <= n; ++i) read(a[i]);
	for (RI i = 1; i <= m; ++i)
		read(e[i].x), read(e[i].y), read(e[i].val);
	sort(e + 1, e + 1 + m, cmp);
	for (RI i = 1; i <= m; ++i) {
		if (Unicom(e[i].x, e[i].y)) continue;
		Link(e[i].x, e[i].y), vis[i] = 1;
	}
	for (RI i = m; i; --i)
		if (vis[i]) {
			Makeroot(e[i].x), Splay(e[i].x);
			if (Rsize[e[i].x] < e[i].val) Cut(e[i].x, e[i].y);
		}
	for (RI i = 1; i <= m; ++i)
		if (!Unicom(e[i].x, e[i].y)) ++ans;
		else {
			Makeroot(e[i].x), Splay(e[i].x);
			if (Rsize[e[i].x] < e[i].val) ++ans;
		}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11392
#include<cstdio>

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

int solve(int x, int y)
{
  if(y==0)
    return x;
  solve(y,x%y);
}

Measured memory_bytes: 1024
#メモ，葉の一つ手前でぶつかるはず？
#uの位置を無視していたけど，例えばuが葉，vがその一つ手前にいる場合に他の葉の深さが関係なくなる，やはり根付きとかにする？
import heapq
class Dijkstra():
    """
    ・有向 / 無向は問わない(無向の場合は，逆向きの辺もたす)
    ・負のコストがない場合のみ
    ・計算量はO(E log|V|)　
    ・heapを使うことで頂点を走査する必要がなくなる（代わりに，距離更新したものは確定でなくともqueに入れておく）
    """
    
    #最短のpathをたす
    
    
    class Edge():
        #重み付き有向辺
        
        def __init__(self, _to, _cost):
            self.to =_to
            self.cost = _cost
    
    def __init__(self, V):
        #引数Vは頂点数
        self.G = [[] for _ in range(V)] #隣接リストG[u][i]が頂点uのi番目の辺
        self. _E = 0 #辺の数
        self._V = V #頂点数
    
    #proparty - 辺の数
    def E(self):
        return self._E
    
    #proparty - 頂点数
    def V(self):
        return self._V
    
    def add(self, _from, _to, _cost):
        #2頂点と辺のコストを追加
        self.G[_from].append(self.Edge(_to,_cost))
        self._E +=1
        
    def add2(self, _from, _to, _cost):
        #2頂点と辺のコスト（無向）を追加
        self.G[_from].append(self.Edge(_to, _cost))
        self.G[_to].append(self.Edge(_from, _cost))
        self._E +=1
        
    def shortest_path(self,s):
        #始点sから頂点iまでの最短経路長のリストを返す
        
        que = [] #priority queue
        d = [float("inf")] * self.V()
        prev = [None]*self.V() #prev[j]は，sからjへ最短経路で行くときのjの一つ前の場所
        d[s] = 0
        heapq.heappush(que,(0,s)) #始点の距離と頂点番号をヒープに追加
        
        while len(que)!=0:
            #キューに格納されてある中で一番コストが小さい頂点を取り出す
            cost,v = heapq.heappop(que)
            
            #キューに格納された最短経路長候補がdの距離よりも大きい場合に処理をスキップ
            if d[v] < cost:
                continue
                
            #頂点vに隣接する各頂点iに対して，vを経由した場合の距離を計算して，これがd[i]よりも小さい場合に更新
            for i in range(len(self.G[v])):
                e = self.G[v][i] #vのi個目の隣接辺
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost #更新
                    prev[e.to] = v
                    heapq.heappush(que,(d[e.to],e.to)) #queに新たな最短経路長候補を追加
                    
        return d
#ここまでダイクストラ


N, u, v = map(int, input().split())
list=[[] for _ in range(N)]
djk = Dijkstra(N)

#a,bなどは1からスタートするので1引いておく
for i in range(N-1):
    a,b  = map(int, input().split())
    list[a-1].append(b-1)
    list[b-1].append(a-1)
    djk.add2(a-1,b-1,1)


#青木くんの位置(v-1)から各葉までの距離を出す
d_v=djk.shortest_path(v-1)
d_u=djk.shortest_path(u-1)

#青木くんより高橋くんが先に到達できる葉でなければならない？
path_to_leaf_v=[]

for i in range(N):
    if len(list[i])==1:
        if d_v[i] >= d_u[i]:
            path_to_leaf_v.append(d_v[i])


#上記の中で，一番深い葉に高橋くんが逃げ込む
ans = max(path_to_leaf_v)-1
print(ans)

Measured memory_bytes: 123680
#include <stdio.h>

int main(void){
    float h,l,n;
    int y = 0;
    while(scanf("%f",&n) != EOF){
        if (y == 0){
            h = n;
            l = n;
            y = 1;
        }
        else{
            if (h < n) h = n;
            if (l > n) l = n;
        }
    }
    printf("%f\n",h-l);
    return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main()
{
    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a < 3200){
        cout << "red" << endl;
    }
    else {
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;

class watch
{
    public static void Main()
    {
        int S = int.Parse(Console.ReadLine());
        int h = S / 3600;

        S = S - h * 3600;

        int m = S / 60;

        S = S - m * 60;
        int s = S;
        Console.WriteLine("{0}:{1}:{2}",h,m,s);
    }
}


Measured memory_bytes: 9184
N = int(input())
l=[int(input()) for i in range(N)]
l.sort()
res = sum(l)

if res%10 != 0:
    print(res)
else:
    for i in range(N):
        if l[i]%10 != 0:
            res -= l[i]
            break
    if res%10 == 0:
        res = 0
    print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

sl s;
int n;
vl v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  s.insert(-1);
  s.insert(n);
  v.resize(n);
  FOR(i, 0, n){
    int a;
    cin >> a;
    a--;
    v[a] = i;
  }
  sl::iterator itr;
  ll ans = 0;
  FOR(i, 0, n){
    itr = s.lower_bound(v[i]);
    ll l, r = *itr;
    itr--;
    l = *itr;
    ans += (r-v[i])*(v[i]-l)*(i+1);
    s.insert(v[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}




int main(void) {
  ll N;
  cin >> N;
  ll a[MAX];
  ll b[MAX];
  ll i;
  ll s=0;
  ll t=0;
  
  for(i=0; i<N; i++) {
    cin >> a[i];
    s+=a[i];
    if(i&1) t+=a[i];
  }
  
  b[0]=s-t*2;
  pt(b[0]);
  for(i=1; i<N; i++) {
    b[i]=a[i-1]*2-b[i-1];
    pt(b[i]);
  }
  
}














Measured memory_bytes: 2816
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
  int key;
  struct node *p, *l, *r;
}T_node;
void mahpy(T_node ** ,int);
int main(){
  int n;
  scanf("%d", &n);
  T_node **heap;
  heap = (T_node **)malloc(sizeof(T_node *) * (n + 1));
  int i;
  for(i = 1; i <= n; i++){
    heap[i] = (T_node *)malloc(sizeof(T_node));
    heap[i]->p = heap[i]->l = heap[i]->r = NULL;
    scanf("%d", &(heap[i]->key));
    if(i /2){
      heap[i]->p = heap[i / 2];
      if(i % 2)
	heap[i / 2]->r = heap[i];
      else
	heap[i / 2]->l = heap[i];
    }
  }
  for(i = n / 2; i > 0; i--)
    mahpy(heap, i);
  for(i = 1; i <= n; i++){/*
    printf("node %d: key = %d, ", i, heap[i]->key);
    if(heap[i]->p != NULL)
      printf("parent key = %d, ", heap[i]->p->key);
    if(heap[i]->l != NULL)
      printf("left key = %d, ", heap[i]->l->key);
    if(heap[i]->r != NULL)
      printf("right key = %d, ", heap[i]->r->key);
      printf("\n");*/
    printf(" %d", heap[i]->key);
  }
  printf("\n");
  for(i = n; i > 0; i--)
    free(heap[i]);
  free(heap);
  return 0;
}

void mahpy(T_node **heap, int i){
  T_node *max;
  int tmp, ni = 0;
  if(heap[i]->r != NULL){
    if(heap[i]->l->key >= heap[i]->r->key){
      max = heap[i]->l;
      ni = i * 2;
    }
    else{
      max = heap[i]->r;
      ni = i * 2 + 1;
    }
  }
  else if(heap[i]->l != NULL){
    max = heap[i]->l;
    ni = i * 2;
  }
  else
    max = heap[i];
  if(max->key > heap[i]->key){
    tmp = heap[i]->key;
    heap[i]->key = max->key;
    max->key = tmp;
  }
  if(ni)
    mahpy(heap, ni);
}

Measured memory_bytes: 27888
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=5010,MOD=1e9+7;
struct xxx{
	int y,nxt;
}a[N*2];
int h[N],f[N][N][2],sz[N],g[N],tmpf[N][2];
int n,m,tot,ans;
int plu(int x,int y){return (1LL*x+y)-(1LL*x+y>=MOD?MOD:0);}
int mul(int x,int y){return 1LL*x*y%MOD;}
void add(int x,int y){a[++tot].y=y; a[tot].nxt=h[x]; h[x]=tot;}
void dfs(int fa,int x){
	int u,tmp0,tmp1;
	sz[x]=1;
	f[x][1][0]=1;
	for (int i=h[x];i!=-1;i=a[i].nxt){
		u=a[i].y;
		if (u==fa) continue;
		dfs(x,u);
		for (int k=1;k<=sz[x]+sz[u];++k) tmpf[k][0]=tmpf[k][1]=0;
		for (int j=1;j<=sz[u];++j)
			for (int k=1;k<=sz[x];++k){
				tmp1=plu(mul(f[x][k][0],f[u][j][1]),mul(f[x][k][1],f[u][j][0]));
				tmp0=plu(mul(f[x][k][0],f[u][j][0]),mul(f[x][k][1],f[u][j][1]));

				//link
				tmpf[j+k][0]=plu(tmpf[j+k][0],tmp0);
				tmpf[j+k][1]=plu(tmpf[j+k][1],tmp1);
				//cut
				tmpf[k][0]=plu(tmpf[k][0],mul(tmp1,g[j]));
				tmpf[k][1]=plu(tmpf[k][1],mul(tmp0,g[j]));
			}
		for (int k=1;k<=sz[x]+sz[u];++k) 
			f[x][k][0]=tmpf[k][0],f[x][k][1]=tmpf[k][1];
		sz[x]+=sz[u];
	}
}
void get_g(int n){
	g[0]=1;
	for (int i=2;i<=n;i+=2) g[i]=mul(g[i-2],i-1);
}
void get_ans(){
	ans=0;
	for (int i=2;i<=n;i+=2)
		ans=plu(ans,mul(g[i],plu(f[1][i][0],MOD-f[1][i][1])));
	printf("%d\n",ans);
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	int x,y;
	scanf("%d",&n);
	memset(h,-1,sizeof(h));
	tot=0;
	for (int i=1;i<n;++i){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	get_g(n);
	dfs(0,1);
	get_ans();
}


Measured memory_bytes: 195200
import sys

sys.setrecursionlimit(100000)

# input data
n=int(input())
u=[]
v=[]
w=[]
for i in range(0,n-1):
	ui,vi,wi = map(int, input().split())
	u.append(ui)
	v.append(vi)
	w.append(wi%2)


# solve
ans=[]
for i in range(0,n+1):
	ans.append(-1)

_neighbors=[]
for i in range(0,n+1):
	_neighbors.append([])

for i in range(0,n-1):
	_neighbors[u[i]].append([v[i], w[i]])
	_neighbors[v[i]].append([u[i], w[i]])

# paint v with c=0,1 and its neighbors
def bfs(u,c):
	if ans[u] != -1:
		return

	ans[u] = c

	for vw in _neighbors[u]:
		if vw[1] == 0:
			bfs(vw[0],c)
		else:
			bfs(vw[0],1-c)

bfs(1,0)

for i in range(1,n+1):
	print(ans[i])


Measured memory_bytes: 84436
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N//R+1):
    for g in range(N//G + 1):
        if (N-r*R-g*G) % B == 0:
            b = (N-r*R-g*G)//B
            if 0 <= b and r*R+g*G+b*B == N:
                ans += 1
print(ans)
            

Measured memory_bytes: 40684
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        for k in range(w):
            if (i+k) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7004
// AOJ 1590: One-Time Path
// 2017.11.29 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX 200000
typedef struct { int t, node; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
//	*n = que[0].node, *t = que[0].t, *c = que[0].c;
	que[0] = que[--qsize];
	min_heapify(0);
//	return 1;
}

void enq(int n, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].node = n, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 1000000010
typedef struct { int to[20]; int c[20]; } TBL;
TBL tbl[100002];
int len[100002];
int dist[100002];
char mk[1000002];

typedef struct { int a, c; } T;
T last[100002]; int sz;

int cmp(T *a, T *b) { return b->c - a->c; }

void dijkstra(int start)
{
	int i, s, e, c, d;

	qsize = 0;
	dist[start] = 0;
	enq(start, 0);
	while (qsize) {
		s = que[0].node; c = que[0].t, deq();
		if (mk[s]) continue;
		mk[s] = 1;
		for (i = 0; i < len[s]; i++) {
			e = tbl[s].to[i];
			if (mk[e]) continue;
			if (c <= (d = tbl[s].c[i]) && d < dist[e]) dist[e] = d, enq(e, d);
		}
	}
}

char buf[40], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, n1, m, a, b, c, i;

	fgets(bp=buf, 40, stdin);
	n = getint(), bp++, m = getint();
	n1 = n - 1;

	for (i = 0; i < m; i++) {
		fgets(bp=buf, 40, stdin);
		a = getint()-1, bp++, b = getint()-1, bp++, c = getint();
		tbl[a].to[len[a]] = b, tbl[a].c[len[a]++] = c;
		if (b == n1) last[sz].a = a, last[sz++].c = c;
	}

	memset(dist, 0x77, sizeof(dist));
	dijkstra(0);

	if (dist[n-1] > INF) puts("-1");
	else {
		qsort(last, sz, sizeof(T), cmp);
		for (i = 0; i < sz; i++) {
			a = last[i].a;
			if (dist[a] <= last[i].c) { printf("%d\n", last[i].c); break; }
		}
	}
	return 0;
}

Measured memory_bytes: 18216