akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int maxheight = 0;
		int n = sc.nextInt();
		int currenth = 0, canwatch = 0;
		for(int i = 0;i < n;i ++) {
			currenth = sc.nextInt();
			if(maxheight <= currenth) {
				canwatch++;
				maxheight = currenth;
			}
		}
		System.out.println(canwatch);
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll n;
  cin >> n;
 string s;
  cin >> s;
  rep(i,0,s.size()) s[i]=(s[i]-'A'+n)%26+'A';

 cout << s << endl;  
}


Measured memory_bytes: 256
/*
Author - Glitched
Yeet!!
*/
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define loop(i,x,n) for(ll i = x;i<n;i++)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll sum = 0;
    loop(i,0,m){
        ll x;
        cin>>x;
        sum+=x;
    }
    cout<<(n>=sum?n-sum:-1);
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

struct UnionFind {
    vector<int> parent;

    UnionFind(int n) : parent(n, -1) {}
    void Init(int n) { parent.assign(n, -1); }

    int Root(int x) {
        if (parent[x] < 0) return x;
        else return parent[x] = Root(parent[x]);
    }

    bool IsSame(int x, int y) {
        return Root(x) == Root(y);
    }

    bool Merge(int x, int y) {
        x = Root(x); y = Root(y);
        if (x == y) return false;
        if (parent[x] > parent[y]) swap(x, y);
        parent[x] += parent[y];
        parent[y] = x;
        return true;
    }

    int Size(int x) {
        return -parent[Root(x)];
    }
};

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

    int N, M; cin >> N >> M;
    vector<int> X(M), Y(M), Z(M);
    rep(i, 0, M) cin >> X[i] >> Y[i] >> Z[i], --X[i], --Y[i];

    UnionFind uf(N);
    rep(i, 0, M) uf.Merge(X[i], Y[i]);

    set<int> res;
    rep(i, 0, N) res.insert(uf.Root(i));

    cout << res.size() << endl;
}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A,B;
		A=scan.nextInt();
		B=scan.nextInt();
		for(int C = 1; C<=3;C++) {
			if((A*B*C)%2!=0) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");

	}

}


Measured memory_bytes: 23764
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut map = std::collections::HashMap::<i64, u64>::with_capacity(n + 1);
    map.insert(0, 1);
    let mut ans = 0u64;
    let mut sum = 0;
    for s in it {
        let a: i64 = s.parse().unwrap();
        sum += a;
        let po = map.entry(sum).or_insert(0);
        ans += *po;
        *po += 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}

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

int main()
{
   int n;
   scanf("%d",&n);
   int a=n%10;
   if(a==3)  printf("bon\n");
   else if(a==0||a==1||a==6||a==8)  printf("pon\n");
   else  printf("hon\n");
}


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

int main()
{
	int n;
	cin >> n;
	long long int A[100001];
	long long int B[100001];
	for (int i = 0; i < n + 1; ++i)
	{
		cin >> A[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> B[i];
	}
	long long int ans = 0;
	int tmp;
	for (int i = 0; i < n; ++i)
	{
		ans += min(A[i], B[i]);
		if (B[i] > A[i])
		{
			B[i] -= A[i];
			ans += min(A[i+1], B[i]);
			A[i+1] -= min(A[i+1], B[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;

struct sushi{
    int t, d;
    bool operator<(const sushi other) const{
        return d < other.d;
    }
};

int main(){
    int n, k, t, d;
    cin >> n >> k;

    vector<sushi> v(n);
    for(int i = 0; i < n; i++){
        cin >> t >> d;
        v[i] = sushi({t, d});
    }

    sort(v.rbegin(), v.rend());

    ll ans = 0;
    vector<int> ate(n+1, 0);
    ll kind = 0, sum = 0;
    priority_queue<pair<int,int>> pq;

    for(int i = 0; i < k; i++){
        sum += v[i].d;
        ate[v[i].t]++;
        if(ate[v[i].t] == 1)    kind++;
        pq.push({-v[i].d, v[i].t});
    }

    ans = kind*kind + sum;

    for(int i = k; i < n; i++){
        sushi now = v[i];
        if(ate[now.t] != 0)    continue;
        while(!pq.empty()){
            auto p = pq.top();  pq.pop();
            if(ate[p.second] == 1)  continue;
            ate[p.second]--;
            ate[now.t]++;
            sum += p.first;
            sum += now.d;
            kind++;
            //pq.push({-now.d, now.t});
            break;
        }
        ans = max(ans, kind*kind+sum);
    }

    cout << ans << endl;

    return 0;
}

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

struct Card{ char suit, value; };

void bubble(struct Card A[], int N ){
    for(int i=0; i<N; i++){
        for(int j=N-1; j>=i; j--){
            if(A[j].value < A[j-1].value){
                Card t = A[j];
                A[j] = A[j-1];
                A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for(int i=0; i<N; i++){
        int minj = i;
        for(int j=i; j<N; j++){
            if(A[j].value < A[minj].value)minj = j;
        }
        Card t = A[i];
        A[i] = A[minj];
        A[minj] = t;
    }
}

void print(struct Card A[], int N){
    for(int i=0; i<N; i++){
        if(i > 0)cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for(int i=0; i<N; i++){
        if(C1[i].suit != C2[i].suit)return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> C1[i].suit >> C1[i].value;
    }

    for(int i=0; i<N; i++)C2[i] = C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if(isStable(C1, C2, N)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

    return 0;
}


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

int main(void) {
    int N;
    std::cin >> N;
    std::vector<int> A(N, 0);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    int status = 0;//0 start 1init 2cont 
    int trans = -1; // 0 inc 1 dec
    int value = -1; // 現在の値
    int sep = 1;
    for (int i = 0; i < N; i++) {
        if (status == 0) {
            value = A[i]; 
            status = 1;
            continue;
        } else if(status == 1) {
            if (A[i] > value) {
                trans = 0; 
                value = A[i];
                status = 2;
            } else if(A[i] < value) {
                trans = 1; 
                value = A[i];
                status = 2;
            }  
            continue;
        } else if (status == 2){
            if (trans == 0 && A[i] < value) {
                status = 1;
                trans = -1;
                value = A[i];
                sep++;
            } else if (trans == 1 && A[i] > value) {
                status = 1;
                trans = -1;
                value = A[i];
                sep++;
            } else {
                value = A[i];
            }
            continue;

        } else {
            std::cout << "ERROE" << std::endl;
        }
    }
    std::cout << sep << std::endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define maxN 2002
using namespace std;

//FILE *fin = freopen("d.in", "r", stdin);

int n;
char a[maxN], b[maxN];

int x[maxN], y[maxN];
struct Dist
{
    int x, y;
    bool operator < (const Dist &ot) const
    {
        if (x == ot.x)
            return y < ot.y;
        return x < ot.x;
    }
} v[maxN];
int maxY[maxN];

int ans;

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

void getAns(int d)
{
    int sol = 0;

    for (int i = 0; i < n; ++ i)
        if (a[i] != b[(i + d + n) % n])
        {
            ++ sol;
            if ((d >= 0 && x[(i + d + n) % n] <= d) || (d <= 0 && y[(i + d + n) % n] <= -d))
                {
                    v[i].x = v[i].y = 0;
                    continue;
                }

                if (d < 0)
                    v[i].x = x[(i + d + n) % n];
                else
                    v[i].x = x[i];

           if (d < 0)
                    v[i].y = y[i];
                else
                    v[i].y = y[(i + d + n) % n];

        }
        else
            v[i] = {0, 0};
    sort(v, v + n);
    maxY[n - 1] = v[n - 1].y;
    for (int i = n - 2; i >= 0; -- i)
        maxY[i] = max(maxY[i + 1], v[i].y);
    int crtx = 0, crty = maxY[1];
    for (int i = 0; i <= n; ++ i)
    {
        if (ans > (sol + 2 * (crtx + crty) + abs(d)))
            ans = sol + 2 * (crtx + crty) + abs(d);
        crtx = v[i].x;
        crty = maxY[i + 1];
    }
}

int main()
{
    scanf("%s\n%s", a, b);
    n = strlen(a);
    bool ok = 1, one = 0;
    for (int i = 0; i < n; ++ i)
        if (a[i] == '1')
            ok = 0;
    for (int i = 0; i < n; ++ i)
        if (b[i] == '1')
        {
            ok = 1;
            one = 1;
        }
    if (!ok || !one)
    {
        printf("%d", !ok * (-1));
        exit(0);
    }
    if (one)

        for (int i = 0; i < n; ++ i)
        {
            for (int j = i; ; j --)
            {
                if (j < 0)
                    j = n - 1;
                if (b[j] == '1')
                    break;
                ++ x[i];
            }
            for (int j = i; ; ++ j)
            {
                if (j >= n)
                    j = 0;
                if (b[j] == '1')
                    break;
                ++ y[i];
            }
        }
    ans = 2 * n;
    for (int d = -n + 1; d < n; ++ d)
        getAns(d);
    printf("%d\n", ans);
    return 0;
}


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

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    
    int sum = 0;
    sum += (n > k ? k * x : n * x);
    
    for (int i = 0; i < n - k; i++) {
        sum += y;
    }
    
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
int n;
int i;
int pow=64;

scanf("%d",&n);
for(i=1;i<8; i++)
{
 if(n>=pow)
 {
  printf("%d\n",pow);
  break;
 }else{
  pow=pow/2;
 }
}
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	char arr[55][55], a;
	int H, W, i, j;
	scanf("%d %d", &H, &W);
	a = getchar();
	for(i = 1; i <= H; i++)
	{
		for(j = 1; j <= W; j++) 
		{
			scanf("%c", &arr[i][j]);	
		}
		if(i != H) a = getchar(); 
	}
	for(i = 1; i <= H; i++)
		{
			for(j = 1; j <= W; j++)
			{
				int flag = 0;
				if(arr[i][j] == '#') cout<<'#';
				else 
				{
					if(arr[i-1][j-1] == '#') flag++;
					if(arr[i-1][j] == '#') flag++;
					if(arr[i-1][j+1] == '#') flag++;
					if(arr[i][j-1] == '#') flag++;
					if(arr[i][j+1] == '#') flag++;
					if(arr[i+1][j-1] == '#') flag++;
					if(arr[i+1][j] == '#') flag++;
					if(arr[i+1][j+1] == '#') flag++;
					cout<<flag;	
				} 
				if(j == W) cout<<endl;
			}
		}
	return 0;
} 

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

int comp(const void *a,const void *b){
	return *(long *)a-*(long*)b;
}

int main(){
	long n,k,i,step,c,max,step2;
	long a[100000];
	scanf("%ld %ld",&n,&k);
	while(n!=0){
		for(i=0;i<k;i++){
			scanf("%ld",&a[i]);
		}
		qsort(a,k,sizeof(long),comp);
		step=1;
		step2=1;
		max=1;
		if(a[0]==0){
			c=1;
			while(c<k-1){
					if(a[c]+1==a[c+1]){
						step++;
						step2++;
						max=step>max?step:max;
						max=step2>max?step2:max;
					}else if(a[c]+2==a[c+1]){
						step2=step+2;
						step=1;
					}else{
						step=1;
						step2=1;
					}
				c++;
			}
		}else{
			c=0;
			while(c<k-1){
					if(a[c]+1==a[c+1]){
						step++;
						max=step>max?step:max;
					}else{
						step=1;
					}
				c++;
			}
		}
		printf("%ld\n",max);
		scanf("%ld %ld",&n,&k);
	}
	return 0;
}

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


int main() {
  int N1,N2,S;
  cin >> N1;
  N2 = N1;
  while(N2 / 10 >= 1) {
    S += N2 % 10;
    N2 /= 10;
  }
  S += N2;
  if(N1 % S == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        //進度
        double tan = 0;
        tan = (H * 30) + (M * 0.5);
        double tyo = 0;
        tyo = (M * 6);

        // 角度
        double kaku = 0;
        kaku = (tan - tyo);

        // ラジアン
        double radi = Math.toRadians(kaku);
        
        // C
        double C = 0;
        C = Math.cos(radi);

        // 余弦定理
        C = Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C));
        System.out.println(C);

    }
}


Measured memory_bytes: 27196
#include <iostream>
#define MAX 100
using namespace std;


int main()
{
	//??????????????°?????£?¨?
	int intable[MAX][MAX];
	int yoko[MAX];
	int tate[MAX];
	for (int i = 0; i < MAX; i++)
	{
		yoko[i] = 0;
		tate[i] = 0;
	}

	//??¨????????°??¨?????°??\???
	int r, c;
	cin >> r >> c;
	
	//??¨??????????????\????¨?????????°????¨????
	for (int i1 = 0; i1 < r; i1++)
	{
		for (int i2 = 0; i2 < c; i2++)
		{
			cin >> intable[i1][i2];
			yoko[i1] = yoko[i1] + intable[i1][i2];
		}
		i1;
	}

	//??\????????¨?¨????????¨??????????
	for (int i1 = 0; i1 < r; i1++)
	{
		for (int i2 = 0; i2 < c; i2++)
		{
			cout << intable[i1][i2] << ' ';
		}
		cout << yoko[i1] << endl;
	}

	//??????????¨?????¨?????????????
	for (int i1 = 0; i1 < c; i1++)
	{
		for (int i2 = 0; i2 < r; i2++)
		{
			tate[i1] = tate[i1] + intable[i2][i1];
		}
		cout << tate[i1] << ' ';
	}

	//????¨?????¨?????????????
	int sum = 0;
	for (int i = 0; i < r; i++)
	{
		sum = sum + yoko[i];
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(void){
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<int> p(a),q(b),r(c);
  for(int i=0;i<a;i++){
    cin>>p[i];
  }
  for(int i=0;i<b;i++){
    cin>>q[i];
  }
  for(int i=0;i<c;i++){
    cin>>r[i];
  }
  sort(p.rbegin(),p.rend());
  sort(q.rbegin(),q.rend());
  vector<int> d;
  for(int i=0;i<x;i++){
    d.push_back(p[i]);
  }
  for(int i=0;i<y;i++){
    d.push_back(q[i]);
  }
  for(int i=0;i<c;i++){
    d.push_back(r[i]);
  }
  sort(d.rbegin(), d.rend());
  ll ans=0;
  for(int i=0;i<x+y;i++){
    ans+=d[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
typedef pair<int, int>P;
typedef pair<P, int> PP;
#define int long long
int a[114514],par[114514],rnk[114514];
vector<int>cst[100004];
void init(int n) {
	for (int i = 0; i<n; i++) {
		par[i] = i;
		rnk[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rnk[x]<rnk[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
signed main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> a[i];
	init(n);
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		unite(x, y);
	}

	for (int i = 0; i < n; i++) {
		cst[find(i)].push_back(a[i]);
	}

	int ans = 0;
	int need = 0, ki = 0;;

	for (int i = 0; i < n; i++) {
		if (cst[i].size())ki++;
		sort(cst[i].begin(), cst[i].end());
	}
	need = ki*2-2;
	if (!need) {
		cout << 0 << endl;
		return 0;
	}
	else if (need > n) {
		puts("Impossible");
		return 0;
	}
	else {
		for (int i = 0; i < n; i++) {
			if (cst[i].size())ans += cst[i][0];
		}
		vector<int>V;
		for (int i = 0; i < n; i++) {
			for (int j = 1; j < cst[i].size(); j++)V.push_back(cst[i][j]);
		}
		sort(V.begin(), V.end());
		for (int i = 0; i < need - ki; i++) {
			ans += V[i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 8192
# import numpy as np
# import queue
# import heapq



def main():
    N, M = map(int, input().split())
    heights = list(map(int, input().split()))
    towers = [True for _ in range(N)]

    pathes = (list(map(int, input().split())) for _ in range(M))

    for path in pathes:

        a = path[0] - 1
        b = path[1] - 1

        ha = heights[a]
        hb = heights[b]

        if ha > hb:
            towers[b] = False
        elif ha < hb:
            towers[a] = False
        else:
            towers[a] = False
            towers[b] = False

    print(sum(towers))


if __name__ == "__main__":
    main()


Measured memory_bytes: 20132
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    boolean flg = false;
    for(int i=0; i<=n/4; i++) {
      for(int j=0; j<=n/7; j++) {
        if((4*i+7*j)==n) {
          flg = true;
          break;
        }
      }
    }
    System.out.println(flg==true?"Yes":"No");
  }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define MAX 1000000001

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    int n;
	    cin >> n;
	    ll arr[n];
	    for(int i=0 ; i<n ; i++){
	        cin >> arr[i];
	    }
	    ll maxm=arr[0];
	    ll ans=0;
	    for(int i=1 ; i<n ; i++){
	        if(arr[i]>=maxm){
	            maxm=arr[i];
	        }else{
	            ans+=(maxm-arr[i]);
	        }
	    }
	    cout << ans << endl;
	}
	return 0;
}

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

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

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    ll N;
    cin >> N;
    vector<pair<ll, ll>> AB(N);
    rep(i, N)
    {
        ll a, b;
        cin >> a >> b;
        AB[i] = make_pair(a, b);
        // cout << a << " " << b << endl;
    }
    sort(ALL(AB), [](pair<ll, ll> x, pair<ll, ll> y) { return x.second < y.second; });
    ll t = 0;
    rep(i, N)
    {
        // DEBUG(t);
        // cout << AB[i].first << " " << AB[i].second << endl;
        t = t + AB[i].first;
        if (AB[i].second < t)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

int main()
{
	double r, S, L;
	cin >> r;
	S = r * r * 3.141592653589;
	L = r * 2 * 3.141592653589;
	
	printf("%f %f\n", S, L);
	
	return 0;
}

Measured memory_bytes: 1232
//package com.company;

import java.io.*;
import java.util.*;


public class Main {
    static int[][] con;
    static int[] a;
    static int[] b;
    static int n;
    public static void main(String[] args) throws IOException {
        MyScanner sc = new MyScanner(System.in);
        n = sc.nextInt();
        int m = sc.nextInt();
        a = new int[m];
        b = new int[m];
        con = new int[n][n];
        for (int i = 0; i < m; i++) {
            int a1 = sc.nextInt() - 1; int b1 = sc.nextInt() - 1;
            a[i] = a1; b[i] = b1;
            con[a1][b1] = 1;
            con[b1][a1] = 1;
        }
        int ss = 0;
        for (int i = 0; i < m; i++) {
            if (is_con(i)){
                ss++;
            }
        }
        System.out.println(m - ss);
    }
    public static boolean is_con(int dis){
        boolean[] vis = new boolean[n];
        Stack<Integer> st = new Stack<>();
        st.push(0);
        vis[0] = true;
        while (!st.empty()){
            int idx = st.pop();
            for (int i = 0; i < n; i++) {
                if ((a[dis] == idx && b[dis] == i) || (a[dis] == i) && b[dis] == idx) continue;
                if (!vis[i] && con[idx][i] != 0){
                    st.push(i);
                    vis[i] = true;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            if (!vis[i]){
                return false;
            }
        }
        return true;
    }

    static class MyScanner {
        StringTokenizer st;
        BufferedReader br;

        public MyScanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public MyScanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}

        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

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

        public boolean ready() throws IOException {return br.ready();}
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	sort(all(A));
	int l = 0, r = N - 1;
	if (K % 2) {
		if (A[N - 1] < 0) {
			ll ans = 1;
			for (int i = 0;i < K;i++) {
				ans *= A[N - 1 - i];
				ans %= MOD;
			}
			if (ans < 0)ans += MOD;
			cout << ans << endl;
			return 0;
		}
		else {
			r--, K--;
		}
	}
	ll lv = 0, rv = 0;
	while (K) {
		lv = A[l] * A[l + 1];
		rv = A[r] * A[r - 1];
		if (lv > rv) {
			l += 2;
		}
		else {
			r -= 2;
		}
		K -= 2;
	}
	ll f = 1;
	for (int i = 0;i < l;i++) {
		f *= A[i];
		f %= MOD;
	}
	for (int i = r + 1;i < N;i++) {
		f *= A[i];
		f %= MOD;
	}
	if (f < 0)f += MOD;
	cout << f << endl;
}

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

int main() {

    int N;

    cin >> N;

    if (N%10 == 2 || N%10 == 4 || N%10 == 5 || N%10 == 7 || N%10 == 9) {
        cout << "hon" << endl;
    }
    else if (N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8) {
        cout << "pon" << endl;
    }
    else {
        cout << "bon" << endl;
    }
}

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

int main(int argc, char *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;

    int count = 0;
    for (int i = a; i <= b; i++)
    {
        if (i > c)
            break;
        if (c % i == 0)
            count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
   int n;
   cin >> n;
   string s;
   cin >> s;
   for(int i=0;i<s.size();i++){
     
     if(s.at(i)+n>'Z'){
       s.at(i)+=n-26;
     }
     else s.at(i)+=n;
   }
   cout << s <<endl;
 }


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

int main()
{
  i64 l;
  cin >> l;
  vector<i64> c(l);
  for (i64 i = 0; i < l; i++)
    cin >> c[i];
  vector<i64> h;
  vector<bool> in(l);
  for (i64 i = 0; i < l; i++)
  {
    if (0 < c[i])
    {
      h.push_back(c[i]);
      if (in[c[i] - 1])
      {
        cout << i + 1 << endl;
        return 0;
      }
      in[c[i] - 1] = true;
    }
    else
    {
      if (0 < h.size() && h[h.size() - 1] == -c[i])
      {
        h.pop_back();
        in[-c[i] - 1] = false;
      }
      else
      {
        cout << i + 1 << endl;
        return 0;
      }
    }
  }
  cout << "OK" << endl;
  return 0;
}



Measured memory_bytes: 3148
hexToBi={"0":"0000","1":"0001","2":"0010","3":"0011","4":"0100","5":"0101","6":"0110",
         "7":"0111","8":"1000","9":"1001","a":"1010","b":"1011","c":"1100","d":"1101",
         "e":"1110","f":"1111"}
convDec=[5000000,2500000,1250000,625000,312500,156250,78125]
Q=input()
for i in range(Q):
    s="".join(hexToBi[ch] for ch in raw_input())
    sign=s[0]
    integer=s[1:-7]
    dec=map(int,s[-7:])
    large=int(integer,2)
    small=sum(i*j for i,j in zip(dec,convDec))
    small=str(small).zfill(7).rstrip("0")
    small="0" if small=="" else small
    print "%d.%s"%(large,small) if sign=="0" else "-%d.%s"%(large,small)

Measured memory_bytes: 4512
#include <bits/stdc++.h>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
using namespace std;
int main(){
    int n,m; cin >>n >>m;
    vector<int> a(n),b(n),c(m),d(m);
    cinf(n,a,b);
    cinf(m,c,d);
    for(int i=0;i<n;i++){
    	ll min=10000000000000;
    	int ans=-1;
    	for(int j=0;j<m;j++){
    		if(abs(a[i]-c[j])+abs(b[i]-d[j])<min){
    			ans=j+1;
    			min=abs(a[i]-c[j])+abs(b[i]-d[j]);
    		}
    	}
    	cout <<ans << endl;
    }
}

      
    

Measured memory_bytes: 256
//BISMILLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,length,sum=0,digit,rem,temp,flag=0;
    char str[101];
    cin>>k;
    scanf("%s",str);
    length=strlen(str);
    if(length<=k) cout<< str;
    else
    {
        for(int i=0;i<k;i++) cout<<str[i];
        sum=1;
    }
    if(sum==1) cout<< "..."<<endl;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;
using namespace std::chrono;

/*
#define trav(a, v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
*/

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
ll n,m,k,r;
ll nt;
ll T;

ll sig(ll a){
if(a < 0)return -1;
if(a == 0)return 0;
return 1;
}

ll solve(ll a, ll b){
if(a == b)return 0;
if(a < b){
    ll a1 = b-a;
    ll a2 = big*big;
    if(-a <= b && sig(b) == 1 && sig(a) == -1){
        a2 = 1 + solve(-a,b);
    }
    if(-a > b && sig(a) == -1 && sig(b) == 1){
        a2 = -a-b+1;
    }
    if(a2 != big*big)return min(a1,a2);
    return a1;
}
if(a > b){

    if(b >= 0){
        return 1 + solve(-a , b);
    }
    if(b < 0 && a >= 0){

        if(a >= -b){return 1 + solve(-a,b);}
        return -b-a+1;

    }
    return 1+solve(-a,b);
}


}

int main()
{

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int c1,c2,c3,c4,c5,c6;
    ll a,b,c,e;

    cin >> a >> b;
    cout << solve(a,b);



    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
   int  h,a,c=0;
   cin >> h>>a;
   REP(i,INF){
       c++;
       h-=a;
       if(h<=0){
           cout << c ;
           return 0;
       }
   }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	char input[21];
	int check = 0;

	scanf("%s", input);
	if(input[0] == input[1] && input[1] == input[2] && input[2] == input[0]){printf("No");}
	else{printf("Yes");}
	
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#include <functional>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //aからb - 1まで
#define p(x) cout<<x<<endl  //xを改行付きで出力
const int INF = 1000000007;  //最大値兼MOD
//  cin.tie(0);
//  ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
  int a;
  cin>>a;
  int temp = 0;
  vector<pair<int,int>>b(a);
  rep0(i,a){
    cin>>temp;
    b[i].first = (temp);
    b[i].second = i + 1;
  }
  sort(b.begin(),b.end());
  rep0(j,a){
    cout<<b[j].second<<" ";
  }
  cout<<"\n";
  return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define rg register
#define ll long long 
#define inf 0x3f3f3f3f
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
int b[100];
int main(){
    int n,m,k;
    n=read(),m=read();
    for(int i=1;i<=n;i++)
    {
        k=read();
        for(int j=1;j<=k;j++)
        {
            int x=read();
            b[x]++;
        }
    }
    int sum=0;
    for(int i=1;i<=m;i++)
        if(b[i]==n) sum++;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0004
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

double zc(double n) {
	if (-0.000000001<n&&n <= 0) return 0;
	else return n;
}

int main() {
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double x = 1 / (a*e - b*d)*(c*e - b*f);
		double y = 1 / (a*e - b*d)*(a*f - c*d);
		printf("%.3f %.3f\n", zc(x), zc(y));
	}

}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9+7;
const long double PI=acos(-1);



void solve(int T){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n==1){
        cout<<"0\n";
        return;
    }
    sort(a.begin(),a.end());
    ll ans=MAX;
    for(int i=a[0];i<=a[n-1];i++){
        ll md=i;
        ll tmp=0;
        for(int i=0;i<n;i++){
            tmp+=abs(a[i]-md)*abs(a[i]-md);
            //cout<<ans<<" ";
        }
        ans=min(tmp,ans);
    }
    //cout<<md<<"\n";

    cout<<ans<<"\n";
}

int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
    }
	return 0;
}


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

int o(string a) {
	vector<char> o(a.size());
	vector<char> q(a.size());
	for (int i=0; i < a.size(); i++) {
		o.at(i) = a.at(i);
	}
	q = o;
	reverse(o.begin(), o.end());
	if (q==o) {
		return 0;
	}
	return 1;
}

int main() {
	string a;
	cin >> a;
	if (o(a)) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

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

char b[8][8];

void dfs(int x, int y) {
	b[y][x] = '0';
	for (int d = -3; d <= 3; d++) {
		if (0 <= x + d && x + d < 8 && b[y][x + d] == '1') dfs(x + d, y);
		if (0 <= y + d && y + d < 8 && b[y + d][x] == '1') dfs(x, y + d);
	}
}

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

	int T;
	cin >> T;
	for (int i = 1; i <= T; i++) {

		for (int y = 0; y < 8; y++) {
			for (int x = 0; x < 8; x++) {
				cin >> b[y][x];
			}
		}

		int sx, sy;
		cin >> sx >> sy;
		sx-- , sy--;
		dfs(sx, sy);

		cout << "Data " << i << ":" << endl;

		for (int y = 0; y < 8; y++) {
			for (int x = 0; x < 8; x++) {
				cout << b[y][x];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1196
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
if k % 2:
    ans = (n // k) ** 3
else:
    ans = ((n // (k // 2)) - (n // k)) ** 3 + (n // k) ** 3
print(ans)

Measured memory_bytes: 38756
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a,b,ans;
main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d%d",&a,&b),ans+=b-a+1;
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
 int i;
 char a[19];
 cin>>a;
 for (i=0;i<19;i++){
  if (a[i]==','){
   cout<<" ";
  }
  else {
   cout<<a[i];
  }
 }
 return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main {

	/*
	 * 着席位置：２列目の真ん中あたり
	 */

	private static BufferedReader br;

	public static void main(String args[]) throws Exception{
		br = new BufferedReader(new InputStreamReader(System.in));

		for(;;){
			//入力
			String input = br.readLine();
			if(input.equals("0 0 0")) break;

			Scanner scanner = new Scanner(input);
			int oldRate = scanner.nextInt();
			int newRate = scanner.nextInt();
			int sum_before_change = scanner.nextInt();
			scanner.close();

			/*
			 * 新税率での合計価格の最大値を総当たりで調べる
			 * けど実際に計算するのは半分まででいい、
			 * と最初は思ったけれどそうでもない気がしたので
			 * ２つ目の商品の税抜価格を計算して０以下になったら
			 * ループを抜けることにしました。
			 *
			 * price1, price2は２つの商品の税抜価格
			 *
			 * 問題文には１つの商品の税抜価格として
			 * 1円から((変更前の合計価格)-1)円まで考慮に入れろと書いてあったけれど
			 * 税抜で((変更前の合計価格)-1)円の商品があったら絶対に
			 * 変更前の合計価格が与えられたより大きくなるように思うのですが
			 * 変更前の合計価格が小さい時はそういうこともあるのでしょうか…
			 *
			 * そしてprice2を計算する時に
			 * 最後に小数点以下を切り上げる処理が要ることに気づいたので
			 * 丸めるメソッドを作りました。
			 *
			 * 書けたと思って入力サンプルで試したところ答えが全然違ったので
			 * 処理のロジック的な間違いを探したけれど見当たらず、
			 * 切り上げ処理がうまくできていないのではないかと思って
			 * roundUpメソッドのコメントアウトしているような処理を入れてみたところ、
			 * (eclipseのデバッグ機能に慣れてないせいでデバッグ時に値を覗きたい時は
			 * いつも標準出力に出力させています)
			 * 引数の時点ですでに切り捨てられていた(valの値が45.0とかになっていた)
			 * ので、そういえばint型同士では除法でもint型で返ってくる
			 * (=intにキャストされている=切り捨てられている)ことを思い出したので
			 * intとdoubleの計算にしてdouble型で返させるために
			 * 100+oldRateをdoubleにキャストしました。
			 *
			 * それでもいくつかのケースで答えが違ってました。
			 * よく見ると違っているのはどれも１〜２円高い値が出ているので
			 * 違うとすればやはりprice2だろうと思い、
			 * もともとの和とprice1とprice2の税込の和を比べたところ
			 * 後者の方が１だけ大きい場合がありました。
			 *
			 * 厳密にそうだと示すのは難しいように思いますが、
			 * 1円から((変更前の合計価格)-1)円までのそれぞれのprice1に対して
			 * 必ずしも整数値のprice2が存在するとは限らないのではないかと思ったので
			 * 検算の処理を入れたら
			 */
			int max_sum = 0;
			for(int price1=1; ; price1++){
				int price2 = roundUp((sum_before_change -tax(oldRate, price1)) *100 / (double)(100+oldRate));
				if(price2<=0) break;
				if(sum_before_change != tax(oldRate, price1) +tax(oldRate, price2)) continue;
				//System.out.printf("%d %d", sum_before_change, tax(oldRate, price1) +tax(oldRate, price2));
				//System.out.println();
				int sum = tax(newRate, price1) +tax(newRate, price2);
				if(max_sum < sum) max_sum = sum;
			}
			System.out.println(max_sum);
		}

		br.close();
	}

	//税込価格を計算
	private static int tax(int rate, int price_without_tax){
		return price_without_tax*(100+rate)/100;//切り捨てなのでOK
	}

	//切り上げ処理 多分合ってる…
	private static int roundUp(double val){
		int ret = (int) val;
		//System.out.print(val);
		//System.out.print(" ");
		if(val-ret > 0) ret++;
		//System.out.println(ret);
		return ret;
	}
}



Measured memory_bytes: 49192
from collections import deque
n,m=map(int,input().split())
g=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
def bfs(u):
    queue = deque([u])
    d = [None]*n
    
    d[u] = 0
    while queue:
        v=queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v]+1
                queue.append(i)
    return d


d = bfs(0)
print('Yes')
for i in range(1,n):
    for j in g[i]:
        if d[j]<d[i]:
            print(j+1)
            break
        
    


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

int main() {
	int k;
	cin >> k;
	int a[k + 1] = {1};
	for (int i = 1; i <= k; i++) {
		cin >> a[i];
	}
	if (a[k] != 2) {
		cout << "-1\n";
		return 0; 
	}
	ll mi = 2, ma = 2;
	for (int i = k; i > 0; i--) {
		if (mi % a[i])
			mi = mi - mi % a[i] + a[i];
		else
			mi = mi - mi % a[i];
		ma = ma - ma % a[i] + a[i] - 1;
	//	cout << mi << " " << ma << endl;
		if (ma < mi) {
			cout << "-1\n";
			return 0;
		}
	}
	cout << mi << " " << ma << endl;
	return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    long h = sc.nextLong();
    long w = sc.nextLong();
    if (h == 1L || w == 1L) {
      System.out.println(1);
    } else {
      System.out.println((h * w - 1L) / 2L + 1L);
    }
  }
}

Measured memory_bytes: 22100
#include <stdio.h>
#include <math.h>

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

    int n, a, b, c;
    
    scanf("%d %d %d %d", &n, &a, &b, &c);
    
    int d[n];
    
    int i, j, temp, calorie, max = 0;
    
    for (i = 0; i < n; i++) {
        scanf("%d", &d[i]);
    }
    
    for (i = 0; i < n - 1; i++) {
       for (j = i + 1; j < n; j++) {
            if (d[i] < d[j]) {
                temp = d[i];
                d[i] = d[j];
                d[j] = temp;
            }
        }
    }
    
    for (i = 0; i < n; i++) {
        int sum = 0;
        for (j = 0; j < i; j++) {
            sum += d[j];
            calorie = (int) ((c + sum) / (a + i * b));
            if (max < calorie) {
                max = calorie;
            }
        }
    }
    
    printf("%d\n", max);
    
    return 0;
}

Measured memory_bytes: 596
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
mod = 10 ** 9 + 7
res = 0
if N == 1:
  print(a[0] * 2 % mod)
  exit(0)
for i in range(N):
  res += a[i] * (pow(2, N - 1, mod) % mod + pow(2, N - 2, mod) * i % mod) % mod
  res %= mod
print(res * pow(2, N, mod) % mod)

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

int main() {
  int A, B;
  string s;
  cin >> A >> B >> s;
  for (int i = 0; i < A+B+1; i++) {
    if((!isdigit(s[i]) && i != A) || (s[A]!='-')) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
int main(void){
	int N,X;
	cin >> N >> X;
	int D=0;
	int L[N+1];
	for(int i=1;i<=N;i++)cin >> L[i];
	int ans = 1;
	for(int i=2;i<=N+1;i++){
		D = D + L[i-1];
		if(D<=X)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf = 1e18;

int N;
int x[200010];
int y[200010];
int main(){
    cin>>N;
    REP(i,0,N){
        cin>>x[i];
        y[i] = x[i];
    }
    sort(y,y+N);
    int a=y[N/2-1], b = y[N/2];
    REP(i,0,N){
        if(x[i]>=b){
            p(a);
        }else{
            p(b);
        }
    }
    return 0;
}


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

int main()
{
    int i;
    string st;
    cin>>st;
    for(i=1; i<=st.size(); i++)
    {
        if(st[i-1]=='R' && !(i&1))
        {
            printf("No\n");
            return 0;
        }
        else if(st[i-1]=='L' && i&1)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#coding:utf-8
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]

count = 0

for i in range(0, n):
    #n行ごとに答えを計算する。最初はcで初期化
    ans = c
    for j in range(0, m):
        ans += a[i][j] * b[j]
        #m列目になったら判定実施
        if j == m-1 and ans > 0:
            count += 1

print(count)


Measured memory_bytes: 3064
#include <stdio.h> 
#define MAX 1000000 

int isPrime[MAX]; 
 
int main(){ 
     int num; 
     int i, j; 
     int count; 
      
     isPrime[0] = isPrime[1] = 0; 
     for(i = 2; i < MAX; i++){ 
         isPrime[i] = 1; 
     } 
      
     for(i = 2; i * i < MAX; i++){ 
         if(isPrime[i]){ 
             for(j = 2 * i; j < MAX; j+=i){ 
                 isPrime[j] = 0; 
             } 
         } 
     } 
 

     while(scanf("%d", &num) != EOF){ 
         count = 0; 
         while(num){ 
             count += isPrime[num--]; 
         } 
         printf("%d\n", count); 
     } 
     return 0; 
 } 



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

int dp[100001][3];
    
int main()
{
  	int n;
    cin >> n;
    
    int **arr = new int*[n];
    for(int i = 0; i < n; i++)
    {
       	arr[i] = new int[3];
    }
    
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    
    memset(dp, 0, sizeof(dp));
    
    dp[n-1][0] = arr[n-1][0];
    dp[n-1][1] = arr[n-1][1];
    dp[n-1][2] = arr[n-1][2];

    for(int i = n-2; i >= 0; i--)
    {
        dp[i][0] = arr[i][0] + max(dp[i+1][1], dp[i+1][2]);
        dp[i][1] = arr[i][1] + max(dp[i+1][0], dp[i+1][2]);
        dp[i][2] = arr[i][2] + max(dp[i+1][0], dp[i+1][1]);
    }
     
    cout<<max(dp[0][0], max(dp[0][1], dp[0][2]))<<"\n";
    return 0;
}

Measured memory_bytes: 8680
n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
ans = 0
min = [a, b, c, d, e].min
if min >= n
  ans = 5
else
  ans = n / min
  ans += 1 if n % min != 0
  ans += 4
end
puts ans

Measured memory_bytes: 1916
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <iostream>


template<class... Ts> using tuple_t = std::tuple<Ts...>;
template<class T, class U> using map_t = std::map<T, U>;
template<class T, class U> using pair_t = std::pair<T, U>;
template<class T> using vector_t = std::vector<T>;
template<class T> using set_t = std::set<T>;

uint64_t digit(uint64_t num, uint64_t base = 10)
{
	uint64_t i = 0;
	while(num)
	{
		++i;
		num /= base;
	}
	return i;
}

uint64_t digit_sum(uint64_t num, uint64_t base = 10)
{
	uint64_t i = 0;
	while(num)
	{
		i += num % base;
		num /= base;
	}
	return i;
}

int main()
{
	int a;
	std::cin>>a;
	if(a%digit_sum(a)==0)
		std::cout<<"Yes"<<std::endl;
	else
		std::cout<<"No"<<std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

int main(){
    int n; cin >> n;
    map<int,int> mp;
    rep(i,n){
        int x; cin >> x;
        mp[x]++;
        mp[x-1]++;
        mp[x+1]++;
    }
    int maa=0;
    int ans=0;
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        if(maa<itr->se){
            ans=itr->fi;
            maa=itr->se;
        }
    }
    cout << maa << endl;
}


Measured memory_bytes: 4736
def solve():
    MOD = 10**9 + 7

    N, M = map(int, input().split())
    Ss = list(map(int, input().split()))
    Ts = list(map(int, input().split()))

    dp = [1]*(M+1)
    for i, S in enumerate(Ss, 1):
        dp2 = [1]*(M+1)
        for j, T in enumerate(Ts, 1):
            dp2[j] = dp[j] + dp2[j-1]
            if S != T:
                dp2[j] -= dp[j-1]
            dp2[j] %= MOD
        dp = dp2

    print(dp[-1])


solve()


Measured memory_bytes: 3416