akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	
	
	public static void main(String[] args) {
	int n =sc.nextInt();
	Map<String, Integer> map = new HashMap<String, Integer>(n);
	ArrayList<String> cc = new ArrayList<>(n);
	int max =0;
	String tmp;
	for(int i=0;i<n;i++) {
		tmp=sc.next();
		if(map.containsKey(tmp)) {
			map.put(tmp,map.get(tmp)+1);
		}else {
			map.put(tmp,1);		
			cc.add(tmp);
		}
		if(max<map.get(tmp)) {
			max=map.get(tmp);
		}
	
	}
	Collections.sort(cc);
	for(String a:cc) {
		if(map.get(a)==max) {
			p(a);
		}
	}
	
 }
}

Measured memory_bytes: 83476
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;  
  if (S =="Sunny" )
    {cout <<"Cloudy" << endl;}
  else if (S =="Cloudy" )
    {cout <<"Rainy" << endl;}
  else if (S =="Rainy" )
    {cout <<"Sunny" << endl;}
  }

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

long long int recursive(int arr[100005][3], int sz, int row, int initial, long long int dp[100005][3]) {
	if (row >= sz)
		return 0;

	if (dp[row][initial] != -1)
		return dp[row][initial];

	if (initial == 0) {
		int mchoice = arr[row][1] + recursive(arr, sz, row + 1, 1, dp);
		int rchoice = arr[row][2] + recursive(arr, sz, row + 1, 2, dp);
		//ans = max(ans, max(mchoice, rchoice));
		ans = max(mchoice, rchoice);
	} else if (initial == 1) {
		int lchoice = arr[row][0] + recursive(arr, sz, row + 1, 0, dp);
		int rchoice = arr[row][2] + recursive(arr, sz, row + 1, 2, dp);
		//ans = max(ans, max(lchoice, rchoice));
		ans = max(lchoice, rchoice);
	} else if (initial == 2) {
		int lchoice = arr[row][0] + recursive(arr, sz, row + 1, 0, dp);
		int mchoice = arr[row][1] + recursive(arr, sz, row + 1, 1, dp);
		//ans = max(ans, max(lchoice, mchoice));
		ans = max(lchoice, mchoice);

	}
	else {
		int lans = arr[row][0] + recursive(arr, sz, row + 1, 0, dp);
		int mans = arr[row][1] + recursive(arr, sz, row + 1, 1, dp);
		int rans = arr[row][2] + recursive(arr, sz, row + 1, 2, dp);
		//int ans1 = max(lans, max(mans, rans));
		//ans = max(ans, ans1);
		ans = max({lans, mans, rans});

	}

	return dp[row][initial] = ans;

}

int main() {
	int n;
	cin >> n;
	int arr[100005][3];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 3; j++)
			cin >> arr[i][j];


	long long int dp[100005][3];

	memset(dp, -1, sizeof dp);
	cout << recursive(arr, n, 0, 3, dp) << "\n";
	return 0;
}

Measured memory_bytes: 16476
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int H, W;

    cin >> H >> W;
    char pixel[H + 2][W + 2];

    for (int i = 0; i < H + 2; i++) {
        for (int j = 0; j < W + 2; j++) {
            pixel[i][j] = '#';
        }
    }
    
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            cin >> pixel[i][j];
        }
    }

    for (int i = 0; i < H + 2; i++) {
        for (int j = 0; j < W + 2; j++) {
            cout << pixel[i][j];
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> X(3);
    REP(i, 3) {
        cin >> X[i];
    }
    SORT(X);
    int res = X[2] - X[1];
    X[0] += res;
    int d = X[2] - X[0];
    if (d % 2 == 0) {
        res += d / 2;
    } else {
        res += d / 2 + 2;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

K, N = map(int, input().split())
A = [int(x) for x in input().split()]
A.append(K+A[0])

diff_A = []
for i in range(N):
    diff_A.append(A[i+1] - A[i])
diff_max = max(diff_A)
print(K - diff_max)

Measured memory_bytes: 35136
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <map>
#include <cassert>
#include <sstream>
#include <numeric>
#include <regex>
#include <cctype>
#include <utility>
#include <stdio.h>

typedef long long ll;

#define nums vector<int>
#define words vector<string>
#define letrs vector<char>
#define MOD 1000000007
#define pb push_back
#define llnums vector<ll>
#define FOR(i,n) for(int i{0}; i < n; ++i)

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x, y;
  cin >> x >> y;
  bool ans = false;
  for (int i{0}; i < x+1; ++i) {
      int b = x - i;
      if (2*i + 4*b == y) {
          ans = true;
      }
  }
  if (ans) {cout << "Yes\n";}
  else {cout << "No\n";}
  return 0;
}









Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int H, W;
    int h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - (H * w + W * h - h * w);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

public static void main(String args[]) {
	Scanner s = new Scanner(System.in);
	int a =s.nextInt();
	int b= s.nextInt();
	int c = s.nextInt();
	if(a<b&&b<c) System.out.println("Yes");
	else System.out.println("No");
	s.close();
}


}



Measured memory_bytes: 26300
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;
#define int ll
signed main(){
    
    int N;
    cin >> N;
    bool valid = false;
    int H = 0,W = 0;
    for(int i = 1; i * (i + 1)<= 2 *  N; ++i){
        if(i * (i + 1) == 2* N){
            valid = true;
            H = i + 1;W = i;
        }
    }
    if(not valid) return puts("No") * 0;
    puts("Yes");
    cout << H << endl;
    vector<vector<int>>ans(H,vector<int>(W,-1));
    for(int i = 0; i < W; ++i)
        ans[0][i] = i + 1;
    for(int i = 0; i <= W; ++i)
        ans[i][0] = (i + 1);
    ans[H - 1].front() = 1;
    int crt = W + 1;
    for(int i = 0; i < H; ++i){
        int cnt = 1;
        for(int j = 0; j < W; ++j){
            if(ans[i][j] != -1) continue;
            ans[i][j] = crt;
            ans[i + cnt++][i] = crt;
            ++crt;
        }
    }
    for(auto v : ans ){
        int blank = 0;
        cout << v.size() << " ";
        for(auto e : v){
            if(blank++) cout << " ";
            cout << e;
        }
        cout << endl;
    }
}


Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define pb push_back
using namespace std;
typedef pair<int,int> P;
int main(){
	int n;
	while(cin>>n){
		vector<P> v;
		char p='x';
		for(int i=0;i<n;i++){
			char c;
			int x;
			cin>>c>>x;
			if(p!=c){
				v.pb(P(c,x));
			}else{
				P t=v[v.size()-1];
				v[v.size()-1]=P(c,t.second+x);
			}
			p=c;
		}
		if(v.size()%2==1){
			cout<<"NO"<<endl;
			continue;
		}
		
		//cout<<v.size()<<endl;
		bool flag=true;
		int now=0;
		for(int i=0;i<v.size();i++){
			if(v[i].first=='('){
				now+=v[i].second;
			}else{
				if(now<=0){
					//cout<<"^^^^^^^^^^^^"<<endl;
					flag=false;
					break;
				}
				if(now<v[i].second){
					//cout<<"--------"<<endl;
					flag=false;
					break;
				}else{
					now-=v[i].second;
				}
			}
		}
		
		
		if(!flag||now>0){
			cout<<"NO"<<endl;
		}else{
			cout<<"YES"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1208
//Bottom up solution
//same space complexity but reduced recc overhead
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
	ll N, W;
	int f;
	cin>>N>>W;
	std::vector<ll> wt(N);
	std::vector<ll> v(N);
	std::vector<std::vector<ll> > memo(2, std::vector<ll> (W+1));
	for(int i=0; i<N; i++){
		cin>>wt[i]>>v[i];
	}
	f = 0;
	for(int i=0; i<=N; i++){
		for(int w=0; w<=W; w++){
			if(i==0 || w == 0){
				memo[f][w] = 0;
			}
			else if(w >= wt[i-1]){
				memo[f][w] = std::max(v[i-1] + memo[(f+1)%2][w-wt[i-1]], memo[(f+1)%2][w]);
			}
			else{
				memo[f][w] = memo[(f+1)%2][w];
			}
		}
		f = (f+1)%2;
	}
	(N%2==0) ? cout<<memo[0][W]:cout<<memo[1][W];
	return 0;
}

Measured memory_bytes: 2560
n, m, q = gets.split.map(&:to_i)
mtx = n.times.map{ [0] * n }
m.times do
  l, r = gets.split.map(&:to_i)
  mtx[l-1][r-1] += 1
end

n.times do |y|
  (1...n).each do |x|
    mtx[y][x] += mtx[y][x-1]
  end
end

n.times do |x|
  (1..x).each do |y|
    mtx[y][x] += mtx[y-1][x]
  end
end

q.times do
  l, r = gets.split.map(&:to_i)
  if l == 1
	puts mtx[r-1][r-1]
  else
    puts mtx[r-1][r-1] - mtx[l-2][r-1]
  end
end


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

int main(void){
    int N;
    cin >> N;
    
    vector<int> A(N);
    vector<bool> unvisit(N,false);
    
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    int ans = 0;
    int now = 0;
    while (true) {
        if (unvisit[now]||now==1) {
            break;
        }
        else {
            ans++;
            unvisit[now]=true;
            now=A[now]-1;
        }
    }
    
    if (now == 1) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
    
    return 0;
    
}


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

using namespace std;

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

typedef long long ll;

const int N = 2e5 + 10;
const ll INF = 1e18;

struct SegmentTree {
	ll t[4 * N];

	ll get(int v, int tl, int tr, int l, int r) {
		if (l > r) {
			return -INF;
		}
		if (tl == l && tr == r) {
			return t[v];
		}
		int tm = (tl + tr) >> 1;
		return max(get(v * 2, tl, tm, l, min(r, tm)),
							 get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
	}

	void update(int v, int tl, int tr, int pos, ll val) {
		if (tl == tr) {
			t[v] = max(val, t[v]);
			return;
		}
		int tm = (tl + tr) >> 1;
		if (pos <= tm)
			update(v * 2, tl, tm, pos, val);
		else
			update(v * 2 + 1, tm + 1, tr, pos, val);
		t[v] = max(t[v * 2], t[v * 2 + 1]);
	}
} st1, st2;

void solve() {
  fill(st1.t, st1.t + 4 * N, -INF); fill(st2.t, st2.t + 4 * N, -INF);
  int n; cin >> n;
  vector<pair<ll, ll> > vt(n);
  vector<ll> cp;
  for (int i = 0; i < n; i++) {
    cin >> vt[i].first >> vt[i].second;
    cp.push_back(vt[i].second);
  }
  sort(all(cp)); cp.erase(unique(all(cp)), cp.end());
  sort(all(vt));
  int sz = cp.size();
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    // xi - x + yi - y = (xi + yi) + (-x - y)
    // xi - x + y - yi = (xi - yi) + (y - x)
    ll x = vt[i].first, y = vt[i].second;
    int id = lower_bound(all(cp), y) - cp.begin();
    ll mx1 = st1.get(1, 0, sz - 1, 0, id);
    ll mx2 = st2.get(1, 0, sz - 1, id, sz - 1);
    ans = max(ans, x + y + mx1);
    ans = max(ans, x - y + mx2);
    st1.update(1, 0, sz - 1, id, -x - y);
    st2.update(1, 0, sz - 1, id, y - x);
  }
  cout << ans;
}

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

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


Measured memory_bytes: 20964
#include <iostream>
using namespace std;
 int main(){
 string s;
 cin >> s;
 int ans;
 if(s == "SUN")ans = 7;
 else if(s == "MON")ans = 6;
 else if(s == "TUE")ans = 5;
 else if(s == "WED")ans = 4;
 else if(s == "THU")ans = 3;
 else if(s == "FRI")ans = 2;
 else if(s == "SAT")ans = 1;
 cout << ans << endl;
 }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int X, N;
    cin >> X >> N;
    int p[N];
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &p[i]);
    }
    int j = 0;
    bool found;
    while (true)
    {
        found = false;
        int Y = X - j;
        for (int i = 0; i < N; i++)
        {
            if (p[i] == Y)
            {
                found = true;
            }
        }
        if (!found)
        {
            cout << Y;
            return 0;
        }
        found = false;
        Y = X + j;
        for (int i = 0; i < N; i++)
        {
            if (p[i] == Y)
            {
                found = true;
            }
        }
        if (!found)
        {
            cout << Y;
            return 0;
        }
        j++;
    }
    return 0;
}

Measured memory_bytes: 3740
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=100010;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int n,m,a[N],tot,ans;
signed main()
{
	n=read(), m=read();
	for(ri int i=1;i<=n;i++) a[i]=read(), tot+=a[i], a[i]=a[i]*m*4ll;
	for(ri int i=1;i<=n;i++)
	{
		if(a[i]>=tot) ans++;
	}
	if(ans>=m) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t=1;
	while(t--)
	{
		int n,m;
		cin>> n >> m;
		vector<long long int>v(n+1);
		for(int i=1;i<=n;i++ )
		{
			cin>> v[i];
		}
		long long int count=0;
		int arr[100005]={0};
        while(m--)
		{
			long long int a,b;
			cin>> a >> b;
			if( v[a]>=v[b])
			{
				arr[b]++;
			}
			if(v[b]>=v[a])
			{
				arr[a]++;
			}

		}

		for(int i=1;i<=n;i++)
		{
			if(arr[i]==0)
			{
				count++;
			}
		}
		cout<< count<< endl;

	}
}


Measured memory_bytes: 4588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

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

	int N;
	cin >> N;
	int X;
	pair<int, int> PI[200000];
	rep(i, N) {
		cin >> X;
		PI[i] = make_pair(i, X);
	}

	sort(PI,PI+N, [](pair<int, int> x, pair<int, int> y) { return x.second < y.second; });

	int gyaku[200000];
	rep(i, N) {
		gyaku[PI[i].first] = i;
	}

	rep(i, N) {
		if (gyaku[i] < N / 2) co(PI[N / 2].second);
		else co(PI[N / 2 - 1].second);
	}
	Would you please return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i = 0; i < n; ++i)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
    int n; string s;
    cin >> n >> s;
    int lcnt = 0,rcnt = 0;
    int lnum = 0, rnum = 0;
    rep(i,n){
        if(s[i] == ')'){
            rcnt++;
            if(rcnt > lcnt){
                lnum++;
                lcnt++;
            }
        }else{
            lcnt++;
        }
    }
    lcnt = 0; rcnt = 0;
    for(int i = n-1; i >= 0; --i){
        if(s[i] == '('){
            lcnt++;
            if(lcnt > rcnt){
                rnum++;
                rcnt++;
            }
        }else{
            rcnt++;
        }
    }
    rep(i,lnum) cout << '(';
    cout << s;
    rep(i,rnum) cout << ')';
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  static int min(int p, int q){return p<q?p:q;}
  public static void main(String[] args){


    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    int c =  n * a;

    System.out.println(min(b,c));
  }
}

Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long li;
const li MAX = 3001;
li n, dp[MAX][MAX], a[MAX], mus = 0;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mus += a[i];
	}
	li ch = n % 2;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < n; j++) {
			if (i + j > n) continue;
			if (ch == i % 2) {
				dp[i][j] = max(dp[i - 1][j] + a[i + j - 1], dp[i - 1][j + 1] + a[j]);
			}
			else {
				if (i == 1) dp[i][j] = 0;
				else dp[i][j] = min(dp[i - 1][j], dp[i - 1][j + 1]);
			}
		}
	}
	cout <<dp[n][0] - (mus - dp[n][0]);
	//system("pause");
	return 0;
}

Measured memory_bytes: 70144
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

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

const ll MOD = 1e9+7;

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

	int a, b; cin >> a >> b;
	FOR(i, 1262){
		if( (int) ((i+1)*0.08) == a && (int) ((i+1)*0.1) == b){
			cout << i+1 << '\n';
			return 0;
		}
	}

	cout << "-1\n";

	return 0;
}

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

int solve(int n, int s, int pre) {
    if(n == 0) {
        return s == 0;
    }
    if(9*n < s) {
        return 0;
    }
    int res = 0;
    for(int i=pre+1; i<=min(s, 9); ++i) {
        res += solve(n-1, s-i, i);
    }
    return res;
}

int main() {
    int n, s;
    while(cin >> n >> s, n) {
        cout << solve(n, s, -1) << endl;
    }
}


Measured memory_bytes: 2980
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    let m = (n + 1) / 2;
    println!("{}", m as f64 / n as f64);
}


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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<vector<ll>> G;

ll bfs(ll num) {
    queue<pair<ll,ll>> Q;
    vector<ll> color(N,-1);
    Q.push(make_pair(num,0));
    color[num] = 0;
    while(!Q.empty()) {
        pair<ll,ll> p = Q.front();
        Q.pop();
        for(int i=0;i<G[p.first].size();i++) {
            if(color[G[p.first][i]]!=-1) {
                if(color[G[p.first][i]]%2==p.second%2) {
                    return -1;
                }
            }
            if(color[G[p.first][i]]==-1) {
                Q.push(make_pair(G[p.first][i],p.second+1));
                color[G[p.first][i]] = p.second+1;
            }
        }
    }
    tmp=-1;
    for(int i=0;i<N;i++) {
        tmp = max(tmp, color[i]);
    }
    return tmp+1;
}

signed main(){
    cin >> N;
    G.resize(N);
    for(int i=0;i<N;i++) {
        for(int j=0;j<N;j++) {
            char c;
            cin >> c;
            if(c=='1') {
                G[i].push_back(j);
            }
        }
    }
    ans=-1;
    for(int i=0;i<N;i++) {
        ans = max(ans, bfs(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"

using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;
  int size = s.size();
  int ans = 1000;
  for (int i = 0; i < size - 2; i++)
  {
    int a = stoi(s.substr(i, 3));
    ans = min({ans, abs(a - 753)});
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    LL N; cin >> N;
    for (LL i = 1; i <= 3500; ++i) {
        for (LL j = 1; j <= 3500; ++j) {
            LL n1 = 4*i*j - N*j - N*i;
            LL n2 = N*i*j;
            if (n1 > 0 && n2 > 0 && n2 % n1 == 0) {
                cout << i << ' ' << j << ' ' << n2/n1 << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

//階乗計算 a^n mod
int mod_pow(int x, int n, int mod) {
  int res = 1;
  while (n > 0) {  //最下位ビットが立っている時にx^(2^i)を掛ける
    if (n & 1) res = res * x % mod;
    x = x * x % mod;  // xを順次二乗していく
    n >>= 1;          // nを1ビット右へ
  }
  return res;
}

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  int ans;
  ans = mod_pow(10, n, mod1);
  ans -= mod_pow(9, n, mod1);
  ans -= mod_pow(9, n, mod1);
  ans += mod_pow(8, n, mod1);
  ans %= mod1;
  cout<<(ans<0?ans+mod1:ans)<<'\n';
  return 0;
}

Measured memory_bytes: 3624
program main
  implicit none
  integer :: n, x, rem, add
  integer, allocatable :: m(:)
  read(*, *) n, x
  allocate(m(n))
  read(*, *) m
  rem = x - sum(m)
  add = rem / minval(m)
  write(*, "(i0)") n + add
end program main


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}

int main(void){
  long long int n;
  cin >> n;
  long long int v;
  priority_queue<long long int> values;
  for(long long int i=0;i<n;i++){
    cin >> v;
    values.push(v);
  }

  long long int firstUppper;
  for(long long int i=0;i<n/2;i++){
    firstUppper = values.top();
    values.pop();
  }
  long long int lastLower = values.top();

  cout << firstUppper-lastLower << endl;
  return 0;
}




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

int main(){
    int n, k, num=1;
    cin >> n >> k;
    for (int i=0; i<n; i++) {
        if ((num+k)<(num*2)) {
            num += k;
        }
        else {
            num *= 2;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int sosuu(int x) {
  int i = 0;
  for (int j = 2; j < x; j++) {
    if (x % j == 0) {
		i = 1;
		break;
	}
  }
  if (i == 0)
    return 0;  //素数
  else
    return 1;  //合成数
}
int main() {
  int n;
cin>>n;
  int a[55] = {0};
  int k = 0;
  for (int i = 11; k < 55; i = i + 5) {
    if (sosuu(i) == 0) {
      a[k] = i;
      k++;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    cout << a[i] << ' ';
  }
  cout << a[n-1] << endl;
  return 0;
}


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

int main(){
    int n,ans=0;
    cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++){
        cin>>d.at(i);
        }
    sort(d.begin(),d.end());
    reverse(d.begin(),d.end());
    ans=d.at(0);
    for(int i=1;i<n;i++){
        ans=-ans+d.at(i);
        }
    if(ans<0)ans=-ans;
    cout<<ans<<endl;
    }


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N, K;

int main()
{
    cin >> N >> K;
    if (N % K == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
As.insert(0, 0)
As.append(0)

total = 0
costs = []
for i in range(1, N+1):
    total += abs(As[i] - As[i-1])
    x1 = As[i] - As[i-1]
    x2 = As[i+1] - As[i-1]
    if x1 * x2 >= 0 and abs(x1) <= abs(x2):
        costs.append(0)
    elif x1 * x2 >= 0 and abs(x1) > abs(x2):
        costs.append(2 * abs(x2 - x1))
    elif x1 * x2 < 0:
        costs.append(2 * abs(x1))
total += abs(As[N+1] - As[N])

for i in range(N):
    print(total - costs[i])

Measured memory_bytes: 14048
/**
 *    author:  tourist
 *    created: 12.12.2019 18:56:59       
**/
#include <bits/stdc++.h>

using namespace std;

string rep(string s, int k) {
  string t = "";
  for (int i = 0; i < k; i++) {
    t += s;
  }
  return t;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int len;
  cin >> len;
  string s;
  string t;
  cin >> s;
  cin >> t;
  int ns = (int) s.size();
  int nt = (int) t.size();
  string ans = "}";
  for (int i = 0; i * ns <= len; i++) {
    if ((len - i * ns) % nt == 0) {
      int j = (len - i * ns) / nt;
      ans = min(ans, rep(s, i) + rep(t, j));
      ans = min(ans, rep(t, j) + rep(s, i));
      break;
    }
  }
  for (int i = len / ns; i >= 0; i--) {
    if ((len - i * ns) % nt == 0) {
      int j = (len - i * ns) / nt;
      ans = min(ans, rep(s, i) + rep(t, j));
      ans = min(ans, rep(t, j) + rep(s, i));
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1232
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>
#include<iomanip>


using namespace std;

void Solution()
{
    string str;
    
    int count = 0;
    
    while (cin>>str)
    {
        string temp = str; //need a declaration temp for comparing
        
        reverse(temp.begin(), temp.end());
        
        if(str == temp)
        {
            count++;
        }
    }
    
    cout<<count<<endl;
}

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

Measured memory_bytes: 1196
#include <stdio.h>

int asumisu(int mizuhasu) {
	int kitaeri = 1;
	int i;
	for (i = 2; i * i <= mizuhasu; i++) {
		if (mizuhasu % i == 0) {
			int hayaminn = 0;
			while (mizuhasu % i == 0) {
				mizuhasu /= i;
				hayaminn++;
			}
			kitaeri *= hayaminn + 1;
		}
	}
	if (mizuhasu > 1) kitaeri *= 2;
	return kitaeri;
}

int main(void) {
	int N;
	int i;
	int emirinn = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i += 2) {
		if (asumisu(i) == 8) emirinn++;
	}
	printf("%d\n", emirinn);
	return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

int n,a[26];
ll ans=1;
string s;
int main(){
  cin >> n >> s;
  rep(i,n){
    a[s[i]-'a']++;
  }
  rep(i,26){
    ans = ans*(a[i]+1)%1000000007;
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    int ans = 64;
    while (ans > N)ans /= 2;
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int N, A, B, C;
vi v;

int dfs(int num, int a, int b, int c, int i){
    if (i == N ) {
        return a*b*c==0? 10000 : max(num-3, 0)*10 + abs(A-a) + abs(B-b) + abs(C-c);
    }

    int t0 = dfs(num, a, b, c, i+1);
    int t1 = dfs(num+1, a+v[i], b, c, i+1);
    int t2 = dfs(num+1, a, b+v[i], c, i+1);
    int t3 = dfs(num+1, a, b, c+v[i], i+1);

    return min(t0,min(t1,min(t2,t3)));
}

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


    int t;
    cin >> N >> A >> B >> C;

    REP(i,N) {
        cin >> t;
        v.emplace_back(t);
    }

    cout << dfs(0,0,0,0,0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair < llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗を1000000007で割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= 1000000007;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= 1000000007;
	}
	return tmp;
}

int main() {
	int n;
	cin >> n;
	vint a(n);
	rep(i, n)cin >> a[i];
	sort(a.begin(), a.end(), check);
	double ans = 0;
	rep(i, n) {
		ans += (double)a[i] / (double)pow(2, min(i + 1, n - 1));
	}
	printf("%.15f\n", ans);
	return 0;
}

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

using namespace std;

int main()
{
    int n;

    while (scanf("%d", &n), n) {
        int s[5001] = {};

        for (int i = 1; i <= n; ++i) {
            int a; scanf("%d", &a);
            s[i] = a + s[i - 1];
        }

        int ma = INT_MIN;

        for (int i = 1; i <= n; ++i) for (int j = 1; j <= i; ++j) {
            ma = max(ma, s[i] - s[j - 1]);
        }

        printf("%d\n", ma);
    }
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <cmath>
typedef long long ll;
using namespace std;
int main()
{
    ll x, y, i, num = 0;
    cin >> x;
    for (i = sqrt(x); i > 0; --i)
    {
        y = x / i;
        if (y * i == x)
            break;
    }
    cout << y + i - 2 << endl;
}

Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <list>
using namespace std;

int main() {
  int H,W;
  cin >> H >> W;
  char c[H][W];
  for(int i=0; i<H; ++i){
    for(int j=0; j<W; ++j){
      cin >> c[i][j];
    }
  }

  char resC[2*H][W];
  for(int i=0; i<H; ++i){
    for(int j=0; j<W; ++j){
      resC[2*i][j]=c[i][j];
      resC[2*i+1][j]=c[i][j];
    }
  }
  
  for(int i=0; i<2*H; ++i){
    for(int j=0; j<W; ++j){
      cout << resC[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

// const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }



void setimos(int h, int w, vector<vector<int>> &imos, int K){
    if(h < 0 || w < 0) return;

    ++imos[max(0, h-K+1)][max(0, w-K+1)];
    --imos[max(0, h-K+1)][w+1];
    --imos[h+1][max(0, w-K+1)];
    ++imos[h+1][w+1];
}

int main(){
    int N, K; cin >> N >> K;
    vector<int> x(N), y(N);
    for(int i=0; i<N; ++i){
        cin >> x[i] >> y[i];
        char c; cin >> c;
        if(c == 'W') x[i] += K;

        x[i] %= 2*K;
        y[i] %= 2*K;
    }

    vector<vector<int>> imos(4*K+5, vector<int>(4*K+5, 0));

    for(int i=0; i<N; ++i){
        int h = y[i], w = x[i];
        setimos(h, w, imos, K);
        setimos(h+K, w-K, imos, K);
        setimos(h+K, w+K, imos, K);
        setimos(h, w-2*K, imos, K);
        setimos(h, w+2*K, imos, K);
        setimos(h-K, w-K, imos, K);
        setimos(h-K, w+K, imos, K);
    }

    for(int h=0; h<2*K; ++h){
        for(int w=1; w<2*K; ++w) imos[h][w] += imos[h][w-1];
    }

    for(int w=0; w<2*K; ++w){
        for(int h=1; h<2*K; ++h) imos[h][w] += imos[h-1][w];
    }

    int ans = 0;
    for(int i=0; i<2*K; ++i) for(int j=0; j<2*K; ++j) chmax(ans, imos[i][j]);

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

Measured memory_bytes: 63872
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e6 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =225;
const long double EPS = 1e-7;

int h, w, a, b;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> h >> w >> a >> b;

  string row = string(a, '1') + string(w - a, '0');
  f(i,0,b)
  cout << row << '\n';
  row = string(a, '0') + string(w - a, '1');
  f(i,0,h-b)
  cout << row << '\n';


  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M,S,S1,S2;cin >> N;
    std::vector<int> X(N);
    for(int i=0;i<N;i++) cin >> X[i];
    M = (std::accumulate(X.begin(),X.end(),0))/X.size();
    
    S = 0;S1 = 0;S2 = 0;
    for(int i=0;i<N;i++){
        S+=(X[i]-M)*(X[i]-M);
    }
    for(int i=0;i<N;i++){
        S1+=(X[i]-(M+1))*(X[i]-(M+1));
    }
    for(int i=0;i<N;i++){
        S2+=(X[i]-(M-1))*(X[i]-(M-1));
    }
    
    if(S>S1){
        S = S1;
    }
    if(S>S2){
        S = S2;
    }
    cout << S << endl;

    
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		int co = 9999;
		for(int i = 0; i < a.length()-2; i++){
			String b = a.substring(i,i+3);
			int c = Integer.parseInt(b);
			if(Math.abs(753-c)<co){
				co = Math.abs(753-c);
			}
		}
		System.out.println(co);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5;
const int inf=1e9;
int main(){
	int N,M; long K; cin>>N>>M>>K;
	long A[N+1],B[M+1]; A[0] = B[0] = 0;
	rep(i,1,N+1) cin>>A[i];
	rep(i,1,M+1) cin>>B[i];
	rep(i,0,N) A[i+1] += A[i];
	rep(i,0,M) B[i+1] += B[i];
	long ans = 0;
	rep(i,0,N+1){
		auto it = upper_bound(B, B+M+1, K - A[i]);
		if(it == B) continue;
		else ans = max(ans, i + (it - B) - 1);
	}cout<<ans<<endl;
}

Measured memory_bytes: 6720
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

// ****************************** For N! of mod r
template<typename T>
void InvMod(T *inv_mod, T n, T r)
{
    inv_mod[0] = 1;
    if(1 <= n)
        inv_mod[1] = 1;
    for(T i = 2; i <= n; ++i)
    {
        inv_mod[i] = r - ((r / i) * inv_mod[r % i] % r);
        ast(((inv_mod[i] * i) % r) == 1);
    }
}

template<typename T>
void InvFactMod(T * inv_fact_mod, const T *inv_mod, T n, T r)
{
    inv_fact_mod[0] = 1;
    if(1 <= n)
        inv_fact_mod[1] = 1;
    for(T i = 2; i <= n; ++i)
    {
        inv_fact_mod[i] = inv_fact_mod[i - 1] * inv_mod[i] % r;
    }
}

template<typename T>
void FactMod(T * fact_mod, T n, T r)
{
    fact_mod[0] = 1;
    if(1 <= n)
        fact_mod[1] = 1;
    for(T i = 2; i <= n; ++i)
    {
        fact_mod[i] = fact_mod[i-1] * i % r;
    }
}

int N, M;

const int MAX_N = 100000 + 3;
const uint64_t R = 1000000000 + 7;
vector<uint64_t> inv_mod, fact_mod, inv_fact_mod;


int main(int, char *[])
{
    cin >> N >> M;

    if(abs(N - M) >= 2)
    {
        cout << 0 << endl;
        return 0;
    }
    inv_mod.resize(MAX_N);
    inv_fact_mod.resize(MAX_N);
    fact_mod.resize(MAX_N);
    InvMod<uint64_t>(inv_mod.data(), MAX_N - 2, R);
    InvFactMod<uint64_t>(inv_fact_mod.data(), inv_mod.data(), MAX_N - 2, R);
    FactMod<uint64_t>(fact_mod.data(), MAX_N - 2, R);
    uint64_t mul = fact_mod[N];
    mul *= fact_mod[M];
    mul %= R;
    if( N == M)
    {
        mul *= 2;
        mul %= R;
    }

    cout << mul << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
    ll n,k; cin >> n >> k;
    ll ans = n % k;
    if(llabs(ans-k) < ans) ans = llabs(ans-k);

    cout << ans;
    
return 0;
}

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

const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  vector<int> n(N);
  for (int i = 0; i < N; i++) {
    int A; cin >> A;
    n[A]++;
  }

  int ans = 1;
  for (int i = (N + 1) % 2; i <= N - 1; i += 2) {
    if (i == 0 && (n[i] == 0 || n[i] >= 2)) ans = 0; else if (i == 0) continue;
    if (n[i] == 2) ans = (ans % MOD * 2) % MOD; else ans = 0;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String ards[])
	{
		Scanner cin = new Scanner(System.in);
		long a=cin.nextInt();
        long b=cin.nextInt();
        long c=cin.nextInt();
        if(c-a-b<0){
            System.out.println("No");
            return;
        }
        if(4*a*b<(c-a-b)*(c-a-b)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
	}
}

Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	char str[100];
	cin>>str;
	if (str[2]=='\0')
	{
		cout<<str<<endl;
	} else {
		printf("%c%c%c\n",str[2],str[1],str[0]);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main()
{
	int a1,a2,a3,b1,b2,b3,c1,c2,c3;
	cin>>a1>>a2>>a3>>b1>>b2>>b3>>c1>>c2>>c3;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int s;
		cin>>s;
		if(a1==s)
		a1=-1;
		if(a2==s)
		a2=-1;
		if(a3==s)
		a3=-1;
		if(b1==s)
		b1=-1;
		if(b2==s)
		b2=-1;
		if(b3==s)
		b3=-1;
		if(c1==s)
		c1=-1;
		if(c2==s)
		c2=-1;
		if(c3==s)
		c3=-1;
	}
	if(a1==-1 && a2==-1 &&a3==-1)
	{
		cout<<"Yes";
		return 0;
	}
	if(b1==-1 && b2==-1 &&b3==-1)
	{
		cout<<"Yes";
		return 0;
	}
	if(c1==-1 && c2==-1 &&c3==-1)
	{
		cout<<"Yes";
		return 0;
	}
	if(a1==-1 && b1==-1 && c1==-1)
	{
		cout<<"Yes";
		return 0;
	}
	if(a2==-1 && b2==-1 && c2==-1)
	{
		cout<<"Yes";
		return 0;
	}
	if(a3==-1 && b3==-1 && c3==-1)
	{
		cout<<"Yes";
		return 0;
	}
	if(a1==-1 && b2==-1 && c3==-1)
	{
		cout<<"Yes";
		return 0;
	}
	if(a3==-1 && b2==-1 && c1==-1)
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
 } 

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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



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

	REP(h, H)
	{
		REP(w, W)
		{
			if (h < B && w < A || B <= h && A <= w)
				std::cout << 0;
			else
				std::cout << 1;
		}
		std::cout << std::endl;
	}
}

Measured memory_bytes: 1280