akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define INF (1<<28)
#define MAX_N 100
#define MAX_M (20+1)

int m, n;
int book[MAX_N];
int length[MAX_N];

int len(int from, int to) { // [from, to)
    return length[to] - length[from];
}

int dp[MAX_N][MAX_M];
int solve(int index, int rem) {
    if (rem == 1) return len(index, n);
    if (index == n) return 0;
    if (dp[index][rem] >= 0) return dp[index][rem];
    int min_len = INF;
    for (int i = index+1; i <= n; i++) {
        min_len = min(min_len, max(solve(i, rem-1), len(index, i)));
    }
    return dp[index][rem] = min_len;
}

void init() {
    for (int i = 0; i < n; i++) scanf("%d", &book[i]);
    length[0] = 0;
    for (int i = 1; i <= n; i++) 
        length[i] = length[i-1] + book[i-1];
    memset(dp, -1, sizeof(dp));
}

int main() {
    while (scanf("%d %d", &m, &n), m || n) {
        init();
        printf("%d\n", solve(0, m));
    }
    return 0;
}

Measured memory_bytes: 1044
n = int(input())
a = list(map(int, input().split()))
b = sorted([a[i] - i - 1 for i in range(n)])
c = [i + (0 - b[0]) for i in b]

d = []
if n == 1:
    print(0)
else:
    if n % 2 == 1:
        d.append(0 - c[n//2])
    else:
        d.append(0 - c[n//2])
        d.append(0 - c[n//2 - 1])
        d.append(1 - c[n//2])
        d.append(-1 - c[n//2 - 1])

    ans = []
    for j in d:
        e = [i + j for i in c]
        ans.append(sum([abs(i) for i in e]))

    print(min(ans))

Measured memory_bytes: 119184
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);

 //debug func
template<typename T>
void vprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vvprint(vector<vector<T>> vv) {
    REP(i, SIZE(vv)) {
        REP(j, SIZE(vv[i])) {
            cerr << vv[i][j] << " ";
        }
        cerr << endl;
    }
}

template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
T lcm(T a, T b) {
    return (a / gcd(a, b)) * b;
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    LL n, m;
    cin >> n >> m;
    if(n * 2 > m) {
        cout << m / 2 << endl;
    } else {
        LL ans = n;
        m -= n * 2;
        ans += m / 4;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, x;
  cin >> a >> b >> x;
  int mid = (a * b * a) / 2.0;
  double tant = 0.0;
  if (x == mid) {
    tant = b/double(a);
  } else if ( x > mid) {
    tant = abs(double(a) / ((2 * b) - (double(2*x) / (a*a))));
  } else {
    // tan(theta) = (2*x) / (a * b * b)
    tant = double(2*x) / (a * b * b);
  }
  // cerr << tant << endl;
  double upper = 89.9999999;
  double lower = 0.0;
  double val = 45.0;

  rep(i, 100) {
    double rad = (val * 3.141592653589793 / 180);
    if (tan(rad) > tant) {
      upper = val;
      val = ((upper - lower) / 2.0) + lower;
    } else if (tan(rad) < tant) {
      lower = val;
      val = ((upper - lower) / 2.0) + lower;
    } else {
      break;
    }
  }

  printf("%.7f\n", 90.0 - val);
  return 0;
}


Measured memory_bytes: 512
s = input()

ans = []
for i in s:
    if i == '0':
        ans.append(i)
    elif i == '1':
        ans.append(i)
    elif i == 'B':
        if len(ans) != 0:
            # ans.remove(ans[-1])
            ans = ans[0:len(ans)-1]
print("".join(ans))


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

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        int k = sc.NextInt();
        var list = new List<int>();
        int c = 0;
        for (int i = 100; i > 0; i--)
            if (a % i == 0 && b % i == 0)
            {
            	c++;
            	if (c == k)
            	{
            		Console.WriteLine(i);
            		return;
            	}
            }
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }
        
    public long NextLong()
    {
    	CheckNext();
    	return long.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}

Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var a = int.Parse(Console.ReadLine());
        var b = int.Parse(Console.ReadLine());
      
        var list = new List<int>();

        for (int i = 0; i < a; i++)
        {
            int num = 1;

            for (int j = i; j < a; j++)
            {
                num *= 2;
            }

            for (int j = a-i; j < a; j++)
            {
                num += b;
            }

            list.Add(num);
            
        }

        Console.WriteLine(list.Min());
    }
}

Measured memory_bytes: 13268
#include <iostream>
#define llint long long

using namespace std;

llint n, m, Q;
llint s[1005];
string b[1005];
llint mask[1005];

llint enc(string s)
{
	llint ret = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1') ret += 1LL<<i;
	}
	return ret;
}

char get(llint x)
{
	if(x < 10) return x + '0';
	else return (x-10) + 'A';
}

int main(void)
{
	while(1){
		cin >> n >> m >> Q;
		if(n == 0 && m == 0 && Q == 0) break;
		
		string S;
		for(int i = 1; i <= Q; i++){
			cin >> S >> b[i];
			s[i] = enc(S);
		}
		for(int i = 0; i < m; i++) b[0] += '0';
		
		for(int i = 0; i < m; i++) mask[i] = (1LL<<n) - 1;
		for(int i = 1; i <= Q; i++){
			for(int j = 0; j < m; j++){
				if(b[i-1][j] != b[i][j]) mask[j] &= s[i];
				else mask[j] &= ~s[i];
			}
		}
		
		for(int i = 0; i < m; i++){
			llint pos = -1;
			for(int j = 0; j < n; j++){
				if(mask[i] & (1LL<<j)){
					if(pos != -1) pos = -2;
					else pos = j;
				}
			}
			if(pos == -2) cout << "?";
			else cout << get(pos);
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll H,W,D;
    cin >>H>>W>>D;
    vector<Pi>pos(H*W);

    rep(i,H){
        rep(j,W){
            ll a;
            cin>>a;
            a--;
            pos[a]=mp(i,j);
        }
    }
    vector<vector<ll>>sum(D,vector<ll>((H*W)/D + 2));
    rep(i,D){
        rep(j,(H*W)/D + 10){
            ll now=i+D*j;
            ll next=i+D*(j+1);
            //cout<<next<<endl;
            if(next>=H*W)break;
            ll x=pos[now].second;
            ll y=pos[now].first;
            ll nx=pos[next].second;
            ll ny=pos[next].first;
            sum[i][j+1]=sum[i][j]+abs(nx-x)+abs(ny-y);
            //cout<<sum[i][j+1]<<" ";
        }
        //cout<<endl;
    }

    ll Q;
    cin>>Q;
    rep(i,Q){
        ll l,r;
        cin>>l>>r;
        l--,r--;
        ll inx=l%D;
        ll ans=sum[inx][r/D]-sum[inx][l/D];
        cout<<ans<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 9420
#include<iostream>
using namespace std;
int main()
{
    int h,w;
    cin>>h>>w;
    string arr[h];
    for(int x=0;x<h;x++)
    {
        cin>>arr[x];
    }


    for(int x=0;x<w+2;x++)
    {
        cout<<"#";
    }
    cout<<endl;
     for(int x=0;x<h;x++)
    {
        cout<<"#";
        cout<<arr[x];
        cout<<"#"<<endl;
    }
     for(int x=0;x<w+2;x++)
    {
        cout<<"#";
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define dl long double
#define ff first
#define ss second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAXN 100100
using namespace std;
typedef pair<int,int> pii;

vector<pii> adj[MAXN];
int color[MAXN];

void DFS(int v,int c){
	color[v] = c;
	
	for(int i=0;i<(int)adj[v].size();i++){
		int u = adj[v][i].ff;
		int w = adj[v][i].ss;
		if(color[u]!=-1)continue;
		if(w%2==0){
			DFS(u,c);
		}else DFS(u,c^1);
		
	}
}

int32_t main(){
	fastio;
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		int a,b,p;
		cin>>a>>b>>p;
		adj[a].pb(pii(b,p));
		adj[b].pb(pii(a,p));
	}
	memset(color,-1,sizeof(color));
	DFS(1,1);
	for(int i=1;i<=n;i++){
		cout<<color[i]<<endl;
	}
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
 
typedef long long ll;

using namespace std;
using Graph = vector<vector<int>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int N, M;

void Main()
{
    cin >> N >> M; 
    cout << N * M << endl;
}
 
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;

int32_t main()
{
	IOS;
	int n;
	cin >> n;
	int f=0;
	rep(i,1,n)
	{
		int c=0;
		rep(j,1,i)
		{
			if(i%j==0)
			{
				c++;
			}
		}
		if(c==8 && i%2==1)
		{
			f++;
		}
	}
	cout << f << endl;
}


Measured memory_bytes: 256
N = int(input())
S = input()
R = []
G = []
B = [False] * N
for i, c in enumerate(S):
    if c == "R":
        R.append(i)
    elif c == "G":
        G.append(i)
    else:
        B[i] = True
answer = 0
for r in R:
    for g in G:
        hikuyatsu = 0
        u = max(r,g)
        b = min(r,g)
        if b - (u - b) >= 0 and B[b - (u - b)] == True:
            hikuyatsu += 1
        if (u + b) % 2 == 0 and B[(u+b)//2] == True:
            hikuyatsu += 1
        if u + (u - b) < N and B[u + (u - b)] == True:
            hikuyatsu += 1
        answer += (N - len(R) - len(G) - hikuyatsu)
print(answer)

Measured memory_bytes: 71172
#include <iostream>
#include <vector>
#include <tuple>
#include <utility>

enum color {
    BLACK, WHITE, NA
};

static std::vector<std::pair<int, int>> arr[100001];
static color vertex[100001];

void fill(int cur, int dist)
{
    if (vertex[cur] == NA) {
        vertex[cur] = ((dist % 2) == 0) ? WHITE : BLACK;
        for (auto it = arr[cur].begin(); it != arr[cur].end(); it++) {
            fill(it->first, it->second + dist);
        }
    }
}

int main(int argc, char **argv)
{
    int n;

    std::cin >> n;

    for (int i = 1; i < n; i++) {
        int u, v, w;
        std::cin >> u >> v >> w;
        arr[u].push_back(std::make_pair(v, w));
        arr[v].push_back(std::make_pair(u, w));
    }
    for (int i = 1; i <= n; i++) vertex[i] = NA;
    vertex[1] = WHITE;
    for (auto it = arr[1].begin(); it != arr[1].end(); it++) {
        fill(it->first, it->second);
    }
    for(int i = 1; i <= n; i++) {
        std::cout << ((vertex[i] == WHITE) ? "0" : "1") << std::endl;
    }

    return 0;
}

Measured memory_bytes: 8704
#include <cstdio>

int main(int argc, char const* argv[])
{
	int c;
	while((c = getchar()) != EOF){
			if(c >= 'A' && c <= 'Z')printf("%c", c + 32);
			else if(c >= 'a' && c <= 'z')printf("%c", c - 32);
			else printf("%c", c);
	}
	return 0;
}



Measured memory_bytes: 2508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,c;
            var word = Console.ReadLine();
            a = int.Parse(word);
            c = 0;
            for (int i = 1; i <=a; i++)
            {
              
                c += i;
            
                    
            }
            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
using namespace std;

void solve(){
	int n,k;
	cin>>n>>k;
	cout<<(n-k+1);
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int linearSearch(int*,int,int);
int main(){
  int a,b,i,j,flag=0;
  int aa[10000];
  int bb[500];
  int count=0,judge=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&aa[i]);
  }
  scanf("%d",&b);
  for(j=0;j<b;j++){
    scanf("%d",&bb[j]);
    judge=linearSearch(aa,bb[j],a);
    if(judge!=0){
      count++;
      flag=1;
    }
  }
  if(flag==0){
    printf("0\n");
  }
  else{
    printf("%d\n",count);
  }
  return 0;
}

int linearSearch(int* A,int key,int n){
  int i;
  for(i=0;i<n;i++){
    if(A[i]==key){
      return 1;
    }
  }
  return 0;
}


Measured memory_bytes: 2740
#include<stdio.h>
struct no
{  int p,l,r;
};
no a[1000];
int n,root;
void h1(int u)//前序遍历 
{  if(u==-1)  return;
   printf(" %d",u);
   h1(a[u].l);
   h1(a[u].r);
}
void h2(int u)//中序遍历 
{  if(u==-1)  return;
   h2(a[u].l);
   printf(" %d",u);
   h2(a[u].r);
}
void h3(int u)//后序遍历 
{  if(u==-1)  return;
   h3(a[u].l);
   h3(a[u].r);
   printf(" %d",u);
}
int main()
{  int i,t,v,r,l;
   scanf("%d",&n);
   for(i=0;i<n;i++)  a[i].p=-1;
   for(i=0;i<n;i++)
   {  scanf("%d%d%d",&v,&l,&r);
      a[v].l=l;
      a[v].r=r;
      if(l!=-1)  a[l].p=v;
      if(r!=-1)  a[r].p=v;
   }
   for(i=0;i<n;i++)//求根结点 
     if(a[i].p==-1)  root=i;
   printf("Preorder\n");
   h1(root);
   printf("\n");
   printf("Inorder\n");
   h2(root);
   printf("\n");
   printf("Postorder\n");
   h3(root);
   printf("\n");
   return 0;
}


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

/*
98765432109876543210
58
*/
int sz;
string k;
int D;
vector<vector<vector<int> > >dp;
int countofDig(int pos,int moderatedsum,int tb){
    //cout<<pos<<" "<<moderatedsum<<" "<<tb<<"\n";
    if(pos>=k.size()-1){
        int lmt = tb==1 ? k[pos]-'0' : 9;
        int cnt=0;
        for(int i=0;i<=lmt;i++){
            if(i%D == moderatedsum){
                cnt++;
            }
        }
        return cnt;
    }
    if(dp[pos][moderatedsum][tb]!=-1){
        return dp[pos][moderatedsum][tb];
    }
    int d = k[pos]-'0';
    long long cnt=0;
    if(tb==1){
        for(int i=0;i<d;i++){
            cnt += countofDig(pos+1,(D+moderatedsum-(i%D))%D,0);
            cnt %=mod;
        }
        cnt += countofDig(pos+1,(D+moderatedsum-(d%D))%D,1);
        cnt %=mod;
    }else{
        for(int i=0;i<=9;i++){
            cnt += countofDig(pos+1,(D+moderatedsum-(i%D))%D,0);
            cnt %=mod;
        }
    }
    return dp[pos][moderatedsum][tb] =cnt;
}
void solve(){
   cin>>k>>D;
   sz = k.size();
   dp.resize(sz,vector<vector<int> >(D,vector<int>(2,-1)));
   cout<< (mod + countofDig(0,0,1) -1)%mod<<"\n";

}

int main(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 56320
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

typedef vector<int> vec_score;

double average(const vec_score &scores);
double stdev(const vec_score &scores);

int main(){
    int n;
    for(cin >> n; n; cin >> n){
        vec_score scores(n, 0);
        for(auto &score : scores){
            cin >> score;
        }
        cout << fixed << setprecision(5) << stdev(scores) << endl;
    }
}

double average(const vec_score &scores){
    double sum = 0;
    for (auto score : scores) sum += score;
    return sum / scores.size();
}

double stdev(const vec_score &scores){
    double mean = average(scores);
    double sse = 0;
    for (auto score : scores) sse += (score - mean) * (score - mean);
    return sqrt(sse / scores.size());
}

Measured memory_bytes: 1260
import java.util.Scanner;


public class Main {

	public static void main(String [] args) {
		
		Scanner sc = new Scanner(System.in);
		
		
		
		while(true) {
			
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if(H == 0 && W == 0)break;
			
			
			for(int i = 1;i <= H;i++) {
				for(int j = 1;j <= W;j++) {
					System.out.print("#");
					
				}
				System.out.println("");
				
			}
			
			System.out.println("");
			
		}
				
	}
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ll n;
	cin>>n;
	vector<ll> vl(n);
	const ll mod = 1000000007;
	ll he = 0;
	FOR(i,0,n)
	{
		ll a;
		cin>>a;
		he+=a;
		vl[i] = a;
	} 
	ll ans = 0;
	FOR(i,0,n)
	{
		ll cnt = 0;
		ll ch = (he-vl[i])%mod;
		cnt = ((ch)*vl[i])%mod;
		ans+=cnt;
		ans%=mod;
	}
	if((ans%mod)%2 == 1)
	{
		cout<<(ans+mod)/2<<endl;
	}
	else
	{
		cout<<(ans%mod)/2<<endl;
	}
	return 0;
}


Measured memory_bytes: 4788
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

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 all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int cnt = 0,maxv = 0;
	rep(i,n){
		int h;
		cin >> h;
		if(h >= maxv){
			++cnt;
			maxv = h;
		}
	}
	cout << cnt << '\n';
	return 0;	
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
	  String str = scan.next();      
      int count = str.length();

      for(int i =0; i < count; i++){
		System.out.print("x");
      }
      
    }
}

Measured memory_bytes: 21972
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = [A[i] - B[i] for i in range(0,N)]
C.sort()
p = 0
ans = 0
j = len(A) - 1
for i in range(0,N):
  if C[i] < 0:
    p += C[i]
    ans += 1
  else:
    break
  if p < 0:
    if C[j] > 0:
      p += C[j]
      ans += 1
      C[j] = 0
      j -= 1

if sum(A) < sum(B):
  print(-1)
else:
  print(ans)

Measured memory_bytes: 19508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    string s; cin>>s;
    for(int i=0;i<12;i++){
        if(i==4){
            cout<<" ";
        }
        cout<<s[i];
    }
    cout<<endl;
    
}


Measured memory_bytes: 3640
N,M,C = map(int,input().split())
colors = [int(l) for l in input().split()]
ball = []
#print(len(colors),colors)

for _ in range(0,N):
    c,w = map(int,input().split())
    ball.append([c,w])

ball.sort(key= lambda x:x[1]) #価値でソートした
ball.reverse()
#print(ball)

take = 0 #ボール取った
cost = 0 #合計金額
i = 0 #リストのナンバリング

while (take <= M - 1) and (i <= N - 1):
    if colors[ball[i][0] - 1] == 0:
        i += 1
        #print(i)
        continue
    else:
        cost = cost + ball[i][1]
        colors[ball[i][0] - 1] = colors[ball[i][0] - 1] -1
        take += 1
        i += 1
        #print(i)

print(cost)






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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll n, k;
	cin >> n >> k;
	ll a[n], f[n];
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++) cin >> f[i];
	sort(a, a+n, greater<ll>());
	sort(f, f+n);
 
	ll l=0, r=a[0]*f[n-1];
	while(l!=r){
		ll m=(l+r)/2, s=0;
		for(int i=0; i<n; i++){
			if(a[i]*f[i]>m) s+=a[i]-m/f[i];
		}
		if(s<=k) r=m;
		else l=m+1;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 3328
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.uni;
import std.range;
import std.algorithm;

void main()
{
    readln;
    auto a = readln.strip.split(' ').map!(to!int).array;
    foreach (i, v; a)
    {
        a[0..i + 1].sort;
        a.map!(x => x.to!string).join(" ").writeln;
    }
}



Measured memory_bytes: 2644
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

h,w,m = map(int,readline().split())
xy = [tuple(map(lambda x: int(x)-1,readline().split())) for _ in range(m)]
dic = set(xy)


hnum = [0]*h
wnum = [0]*w

for x,y in xy:
    hnum[x] += 1
    wnum[y] += 1
    
hmax = max(hnum)    
wmax = max(wnum)

hn = [i for i in range(h) if hnum[i]==hmax]
wn = [i for i in range(w) if wnum[i]==wmax]


d = 1
if len(hn)*len(wn) > m:
    d = 0
else:
    for i in hn:
        for j in wn:
            if (i,j) not in dic:
                d = 0
                break


#print(dic)

print(hmax+wmax-d)    







Measured memory_bytes: 187256
#include <cstdio>
#include <algorithm>
#include <cstring>

typedef long long ll;

int n, t, a[100005];

int main() {
	scanf("%d%d", &n, &t);
	for (int i = 1; i <= n; ++i)
		scanf("%d", a + i);
	
	int mxex = 0, mn = a[1], mx;
	int ans1 = 0, ans2 = 0;
	for (int i = 2; i <= n; ++i) {
		mxex = std::max(mxex, a[i] - mn);
		mn = std::min(mn, a[i]);
	}
	if (mxex == 0) return puts("0"), 0;
	mn = a[1];
	for (int i = 2; i <= n; ++i) {
		if (a[i] - mn == mxex) ++ans1;
		mn = std::min(mn, a[i]);
	}
	mx = a[n];
	for (int i = n - 1; i; --i) {
		if (mx - a[i] == mxex) ++ans2;
		mx = std::max(mx, a[i]);
	}
	printf("%d\n", std::min(ans1, ans2));
	
	return 0;
}


Measured memory_bytes: 512
const B=999
function f(X,Y,x,y)
	z=x[:]
	w=y[:]
	for i=1:B
		tx=X+x[i]
		ty=Y+y[i]
		theta=atan2(ty,tx)
		if ty<0
			theta+=2*pi
		end
		id=floor(Int,theta*B/(2*pi))+1
		if hypot(z[id],w[id])<hypot(tx,ty)
			z[id]=tx
			w[id]=ty
		end
	end
	z,w
end
function main()
	x=zeros(Int,B)
	y=zeros(Int,B)
	N=parse(Int,readline())
	for i=1:N
		X,Y=map(x->parse(Int,x),split(readline()))
		if X!=0||Y!=0
			x,y=f(X,Y,x,y)
		end
	end
	ans=0
	for i=1:B
		ans=max(ans,hypot(x[i],y[i]))
	end
	println(ans)
end
main()

Measured memory_bytes: 116368
n=int(input())
s=input()
x=["SS","SW","WS","WW"]

def check0(i):
    if x[i][0]=="S":
        if s[0]=="o":
            if x[i][-1]=="S":
                return x[i][1]=="S"
            else:
                return x[i][1]=="W"
        else:
            if x[i][-1]=="S":
                return x[i][1]=="W"
            else:
                return x[i][1]=="S"
    else:
        if s[0]=="o":
            if x[i][-1]=="S":
                return x[i][1]=="W"
            else:
                return x[i][1]=="S"
        else:
            if x[i][-1]=="S":
                return x[i][1]=="S"
            else:
                return x[i][1]=="W"
def check1(i):
    if x[i][n-1]=="S":
        if s[n-1]=="o":
            if x[i][n-2]=="S":
                return x[i][0]=="S"
            else:
                return x[i][0]=="W"
        else:
            if x[i][n-2]=="S":
                return x[i][0]=="W"
            else:
                return x[i][0]=="S"
    else:
        if s[n-1]=="o":
            if x[i][n-2]=="S":
                return x[i][0]=="W"
            else:
                return x[i][0]=="S"
        else:
            if x[i][n-2]=="S":
                return x[i][0]=="S"
            else:
                return x[i][0]=="W"


for i in range(4):
    for j in range(n-2):
        if x[i][j+1]=="S":
            if s[j+1]=="o":
                if x[i][j]=="S":
                    x[i]+="S"
                else:
                    x[i]+="W"
            else:
                if x[i][j]=="S":
                    x[i]+="W"
                else:
                    x[i]+="S"
        else:
            if s[j+1]=="o":
                if x[i][j]=="S":
                    x[i]+="W"
                else:
                    x[i]+="S"
            else:
                if x[i][j]=="S":
                    x[i]+="S"
                else:
                    x[i]+="W"
    #print(x[i])
    if check0(i) and check1(i):
        print(x[i])
        break
else:
    print(-1)


Measured memory_bytes: 3892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll N; cin >> N;
    ll ans = 0;
    rep(i, N-1){
        ans += (N-1)/(i+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    HashSet<Integer> g = new HashSet<Integer>();
    for (int i=0;i<n;i++){
      g.add(scan.nextInt());
    }

    if (g.size() < n){
      System.out.println("NO");
    }
    else{
      System.out.println("YES");
    }
  }
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<P> xy(n);
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    xy[i] = make_pair(x, y);
  }

  sort(xy.begin(), xy.end());

  long double totalSum = 0.0;
  int permutationCount = 0;
  do {
    long double sum = 0;
    rep(i, n - 1) {
      P p1 = xy[i];
      P p2 = xy[i + 1];
      sum += sqrt(pow(p1.first - p2.first, 2) + pow(p1.second - p2.second, 2));
    }
    totalSum += sum;
    permutationCount++;
  } while (next_permutation(xy.begin(), xy.end()));
  long double result = totalSum / permutationCount;
  cout.precision(10);
  cout << result << endl;

  return 0;
}


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

using namespace std;

const int inf = 1000000000;

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

	int m = 1 << n;

	vector<int> a;
	a.resize(m);

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

	vector<int> dp_1;
	dp_1.resize(m);
	iota(dp_1.begin(), dp_1.end(), 0);

	vector<int> dp_2;
	dp_2.assign(m, -1);

	for(int S = 0; S < m; ++S) {
		for(int i = 0; i < n; ++i) {
			if((S >> i & 1) == 0) {
				if(dp_1[S] != dp_1[S ^ (1 << i)]) {
					if(a[dp_1[S]] >= a[dp_1[S ^ (1 << i)]]) {
						dp_2[S ^ (1 << i)] = dp_1[S ^ (1 << i)];
						dp_1[S ^ (1 << i)] = dp_1[S];
					} else if(dp_2[S ^ (1 << i)] == -1 || a[dp_1[S]] > a[dp_2[S ^ (1 << i)]]) {
						dp_2[S ^ (1 << i)] = dp_1[S];
					}
				}
			}
		}
	}

	int ans = -inf;

	for(int i = 1; i < m; ++i) {
		ans = max(ans, a[dp_1[i]] + a[dp_2[i]]);
		cout << ans << '\n';
	}

	return 0;
}

Measured memory_bytes: 6144
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		int[] points = new int[N];
		
		for(int i = 0; i < ((N*(N-1))/2); i++){
			final int A = sc.nextInt() - 1;
			final int B = sc.nextInt() - 1;
			final int C = sc.nextInt();
			final int D = sc.nextInt();
			
			if(C > D){
				points[A] += 3;
			}else if(C < D){
				points[B] += 3;
			}else{
				points[A] += 1;
				points[B] += 1;
			}
		}
		
		TreeSet<Integer> tree = new TreeSet<Integer>();
		for(int i : points){
			tree.add(i);
		}
		
		ArrayList<Integer> list = new ArrayList<Integer>(tree);
		
		
		int[] dup = new int[list.size()];
		for(int i = 0; i < N; i++){
			dup[Collections.binarySearch(list, points[i])]++;
		}
		
		for(int i = 0; i < dup.length; i++){
			dup[i]--;
		}
		//System.out.println(Arrays.toString(dup));
		for(int i = dup.length - 1; i > 0; i--){
			dup[i-1] += dup[i];
		}
		
		dup[dup.length - 1] = 0;
		for(int i = 0; i < dup.length - 1 ; i++){
			dup[i] = dup[i+1];
		}
		
		//System.out.println(Arrays.toString(dup));
		
		for(int i = 0; i < N; i++){
			System.out.println((list.size() - Collections.binarySearch(list, points[i])) + dup[Collections.binarySearch(list, points[i])]);
		}
	}

}

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

using namespace std;
using u64 = std::uint_fast64_t;

template <typename T>
T gcd(T a, T b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  u64 A, B;
  cin >> A >> B;

  auto f = [](u64 n) {
    vector<u64> res;
    for (u64 i = 1; i * i < n + 1; i++) {
      if (n % i == 0) {
        res.emplace_back(i);
        res.emplace_back(n / i);
      }
    }
    return res;
  };

  vector<u64> diva = f(A), divb = f(B);
  sort(diva.begin(), diva.end());
  sort(divb.begin(), divb.end());
  diva.erase(unique(diva.begin(), diva.end()), diva.end());
  divb.erase(unique(divb.begin(), divb.end()), divb.end());

  vector<u64> com_div;
  set_intersection(diva.begin(), diva.end(), divb.begin(), divb.end(),
                   back_inserter(com_div));

  auto check = [&](int idx) -> bool {
    for (int i = 1; i < idx; i++) {
      if (com_div[idx] % com_div[i] == 0) return false;
    }
    return true;
  };

  u64 res = 0;
  for (int i = 0; i < (int)com_div.size(); i++) {
    if (check(i)) res++;
  }
  cout << res << '\n';
  return 0;
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long ll;
typedef pair<int, int> pi;

int main() {
    //freopen("in.txt", "r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin>>n>>m;

    string s;
    vector<vector<int> > gridH(n, vector<int>());
    vector<vector<int> > gridV(m, vector<int>());
    vector<vector<int> > ans(n, vector<int>(m, 0));

    for (int i=0;i<n;++i){
        cin>>s;
        for (int j=0;j<m;++j){
            if (s[j] == '#'){
                gridH[i].push_back(j);
                gridV[j].push_back(i);
            }
        }
        gridH[i].push_back(m);
    }
    for (int j=0;j<m;++j) gridV[j].push_back(n);

    for (int i=0;i<n;++i){
        int j = 0;
        for (int k = 0; k<(int)gridH[i].size();++k){
            int cnt = gridH[i][k] - j;
            while (j < gridH[i][k]){
                ans[i][j] += cnt;
                j++;
            }
            if (j < m) ans[i][j] = 0;
            j++;
        }
    }

    int maxi = 0;
    for (int j=0;j<m;++j){
        int i = 0;
        for (int k=0; k<(int)gridV[j].size();++k){
            int cnt = gridV[j][k] - i;
            while (i < gridV[j][k]){
                ans[i][j] += cnt;
                maxi = max(maxi, ans[i][j]);
                i++;
            }
            if (i < n) ans[i][j] = 0;
            i++;
        }
    }

    cout<<maxi-1<<endl;

    return 0;
}

Measured memory_bytes: 50048
n, k = list(map(int, input().split()))
sushi = []
for i in range(n):
    sushi.append(list(map(int, input().split())))
point = 0
sushi_kind = set()
duplication = []
sushi.sort(key=lambda x: x[1],reverse = True)
for i in range(k):
    point += sushi[i][1]
    if sushi[i][0] in sushi_kind:
        duplication.append(sushi[i])
    else:
        sushi_kind.add(sushi[i][0])
ans = point + pow(len(sushi_kind),2)
dup_index = len(duplication) - 1
for i in range(k,n):
    if sushi[i][0] in sushi_kind:
        continue
    else:
        if dup_index >= 0:
            point -= duplication[dup_index][1]
            dup_index -= 1
            point += sushi[i][1]
            sushi_kind.add(sushi[i][0])
    ans = max(ans, point + pow(len(sushi_kind),2))
print(ans)



Measured memory_bytes: 30136
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
using namespace std;

string w; int a[26]; string ans;
int main(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << h*(a+b)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using Pib = pair<int, bool>;
using Pibi = pair<pair<int, bool>, int>;
const int M = 1000000007;

int main() {
    while (1) {
        int n, m, k;
        cin >> n >> m >> k;
        if (!n) return 0;
        vector<vector<Pibi>> edge(n);
        for (int j = 0; j < m; ++j) {
            int u, v, w;
            char c;
            cin >> u >> v >> w >> c;
            --u;
            --v;
            edge[u].push_back(Pibi(Pib(w, c == 'A'), v));
            edge[v].push_back(Pibi(Pib(w, c == 'A'), u));
        }
        int l = -200, r = 200;
        int ans = -1;
        while (l <= r) {
            int mid = (l + r) / 2;
            priority_queue<Pibi, vector<Pibi>, greater<Pibi>> q;
            vector<bool> vis(n);
            q.push(Pibi(Pib(0, false), 0));
            int sum = 0;
            int ca = 0;
            int c = 0;
            while (!q.empty()) {
                auto p = q.top();
                q.pop();
                if (vis[p.second]) continue;

                vis[p.second] = true;
                sum += p.first.first;
                ++c;
                ca += p.first.second;
                for (auto a : edge[p.second]) {
                    if (a.first.second)
                        q.push(Pibi(Pib(a.first.first + mid, a.first.second), a.second));
                    else
                        q.push(a);
                }
            }
            if (c != n) {
                ans = -1;
                break;
            }
            if (ca <= k)
                ans = sum - mid * k;
            if (ca == k) {
                break;
            }
            else if (ca < k) {
                r = mid - 1;
            }
            else {
                l = mid + 1;
            }
        }
        if (r < -190 || 190 < l)
            ans = -1;

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



Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vi> g(h, vi(w));
  rep(i, h) rep(j, w) cin >> g[i][j];
  vector<tuple<ll, ll, ll, ll>> ans;
  rep(i, h) {
    rep(j, w - 1) {
      if(g[i][j] % 2 == 0) continue;
      ans.push_back(make_tuple(i + 1, j + 1, i + 1, j + 2));
      g[i][j + 1]++;
    }
    if(g[i][w - 1] % 2 == 0 || i == h - 1) continue;
    ans.push_back(make_tuple(i + 1, w, i + 2, w));
    g[i + 1][w - 1]++;
  }
  cout << ans.size() << '\n';
  for(auto v : ans) {
    ll i, j, ni, nj;
    tie(i, j, ni, nj) = v;
    printf("%d %d %d %d\n", i, j, ni, nj);
  }
}

Measured memory_bytes: 7408
D = int(input())
C = list(map(int, input().split()))
S = [[] for _ in range(D)]
for i in range(D):
    S[i] = list(map(int, input().split()))

def based_b():
    last = [0 for _ in range(26)]
    for i in range(D):
        max_score = 0
        t = 0
        for contest in range(26):
            score = S[i][contest]
            d = i + 1
            last[contest] = d
            for x in range(26):
                score -= C[x] * (d - last[x])
            if max_score < score:
                t = contest
        print(t+1)

based_b()

Measured memory_bytes: 69208
#include <bits/stdc++.h> 
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(long long int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
using namespace std;
signed main() 
{
    fast
   
        ll x,y;
        cin>>x>>y;
        int f=0;
        if(y>(4*x)) cout<<"No\n";
        else
        {
            for(int i=0;i<=x;i++)
            {
                if(y==((2*x)+(2*i))) {cout<<"Yes\n"; f=1; break;}
            }
            if(f==0) cout<<"No\n";
        }
       
}

Measured memory_bytes: 3648
{-# OPTIONS_GHC -Wall #-}

import Control.Monad
import Data.List

readInt :: String -> Int
readInt = read

riffle :: [Int] -> [Int]
riffle xs = (concat . transpose) [ys1,ys2]
    where
        (ys1,ys2) = splitAt (length xs `div` 2) xs

cut :: [Int] -> Int -> [Int]
cut xs k = ys2 ++ ys1
    where
        (ys1,ys2) = splitAt k xs

operate :: [Int] -> Int -> [Int]
operate xs 0 = riffle xs
operate xs k = cut xs k

main :: IO ()
main = do
    n   <- fmap readInt getLine
    m   <- fmap readInt getLine
    -- getContents を使うと空行が1つ余分に読まれてしまうっぽい
    ops <- fmap (map readInt) $ replicateM m getLine
    --print ops

    let xs  = [1..2*n]
    let ans = foldl operate xs ops

    forM_ ans print



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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int rtn = c;
    if(b/a < c) {
       rtn = b / a;  
    }   
    cout << rtn;
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    b = LI()
    r = 0
    for v,c in zip(a,b):
        r += max(0, v-c)

    return r


print(main())



Measured memory_bytes: 7752
#include<bits/stdc++.h>
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl;
using namespace std;

int main(){
    int W, H, x, y, r; cin>>W>>H>>x>>y>>r;

    int right=W-r, top=H-r;

    if(x<r || x>right || y<r || y>top){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}



Measured memory_bytes: 3124
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		while(true){
			int x = scan.nextInt();
			int y = scan.nextInt();

			if(x == 0 && y == 0){
				break;
			}else{
				if(y < x){
					int a;
					a = x;
					x = y;
					y = a;
					System.out.println(x + " " + y);
				}else{
					System.out.println(x + " " + y);
				}
			}
		}
	}
}

Measured memory_bytes: 36760
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int N=1e6+3;
int n,m;
ll s[3];
int main(){
    cin>>n>>m;
    if(n%3==0||m%3==0){
    	cout<<0<<endl;
    	return 0;
    }
    ll ans=inf;
    for(int i=1;i<=n;i++){
    	int j=m/2;
    	s[0]=1LL*i*j;
    	s[1]=1LL*i*(m-j);
    	s[2]=1LL*(n-i)*m;
    	sort(s,s+3);
    	ans=min(ans,s[2]-s[0]);
    }
    for(int i=1;i<=m;i++){
    	int j=n/2;
    	s[0]=1LL*i*j;
    	s[1]=1LL*i*(n-j);
    	s[2]=1LL*(m-i)*n;
    	sort(s,s+3);
    	ans=min(ans,s[2]-s[0]);
    }
    ans=min((ll)min(n,m),ans);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
typedef pair<ll, ll> P;

//const int MAX = 700000;
//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    ll answer;
    ll N;
    string S;

    // input
    cin >> N >> S;

    // process
    for (ll i = 0; i < S.size(); i++) {
        S[i] += N;
        if (S[i] > 'Z') {
            S[i] -= 26;
        }
    }

    cout << S << endl;

    return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;


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

    ll n; cin>>n;
    vll a(n+1), b(n);
    REP(i,n+1) cin >>a[i];
    REP(i,n) cin >>b[i];
    reverse(ALL(a));
    reverse(ALL(b));
    ll ans =0;
    REP(i,n){
        if (a[i]>=b[i]){
            a[i] -= b[i];
            ans += b[i];
            // cout << ans << endl;
        }
        else if (a[i]<b[i]){
            b[i] -= a[i];
            ans += a[i];
            ans += min(b[i], a[i+1]);
            a[i+1] = max(ll(0),a[i+1]-b[i]);
            // cout << ans << endl;
        }
    }

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

Measured memory_bytes: 1792