akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
double dp[3000][3000];     //dp[i][j]-> probability of getting j heads out of i coin tosses...

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll n;
	cin>>n;
	double arr[n];
	
	for(ll i=1;i<=n;i++)
	{
	    cin>>arr[i];
	}
	
	memset(dp,0,sizeof(dp));
	dp[0][0]=0;
	dp[1][0]=(1.0-arr[1]);
	dp[1][1]=arr[1];
	dp[2][1]=arr[1]*(1.0-arr[2])+(1.0-arr[1])*arr[2];
	dp[2][2]=arr[1]*arr[2]; dp[2][0]=(1.0-arr[1])*(1.0-arr[2]);
	
	for(ll i=3;i<=n;i++)
	{
	    for(ll j=0;j<=i;j++)
	    {
	        dp[i][j]=dp[i-1][j]*(1.0-arr[i])+dp[i-1][j-1]*arr[i];
	    }
	}
	
	double pro=0;
	for(ll j=(n/2+1);j<=n;j++)
	{
	    pro+=dp[n][j];
	}
	
	cout<<fixed<<setprecision(10)<<pro<<"\n";
}


Measured memory_bytes: 70656
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n"
#define X first
#define Y second
#define pii pair<int,int>
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;

ll poww(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));}

int main(){
	migmig;
	string s;
	cin >> s;
	for(int i = 0 ; i < s.size();i++){
		cout<<"x";
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int ll
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Ford(a, b, c) for(int a = b; a >= c; --a)
#define All(a, b) for(auto &a : b)
#define Rep(a, b, c) for(int a = b; a < c; ++a)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
#define reset(a, b) memset(a, b, sizeof(a))
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define bitone(i) __builtin_popcountll(i)
#define bitl(i) __builtin_clz(i)
#define bitr(i) __builtin_ctz(i)
#define vll vector<ll>
/********************************************************

Digvijay Bahadur Singh
MNNIT

*********************************************************/


const int MOD=998244353;
const int N = 1e6+100;
/********************************************************************/
                 /* GRAPH*/
//vector<vector<ll>> g;
//vector<bool> vis1,vis2;
/*******************************************************************/
ll power(ll a,ll b)
{
   ll ans =1;
   while(b>0){
   if(b&1) ans = (ans%MOD * a%MOD)%MOD;
   a = (a%MOD * a%MOD)%MOD;
   b=b>>1;
   }
   return ans%MOD;
}
struct triple
{
  int f,s,t;
};
bool comp(triple x,triple y)
{
  if(x.f==y.f)
  {
    return x.s>y.s;
  }
  return x.f<y.f;
}
bool isPalindrome(string s)
{
  int n=s.length();
  int l=0,r=n-1;
  while(s[l]==s[r]&&l<r)
  {
    l++;
    r--;
  }
  if(n&1)
  return l==r;
  else
  {
    return r<l;
  }
  

}
signed main(){
  ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
  
  
  ll T=1;
 //cin>>T;
  
   // T=1;
    
    while(T--)
  {
     string s;
     cin>>s;
     int n=s.length();
     string s1=s.substr(0,(n-1)/2);
     if(n==1)
     {
       cout<<"Yes\n";
       return 0;
     }
     if(isPalindrome(s)&&isPalindrome(s1))
     {
       cout<<"Yes\n";
     }
     else
     {
       cout<<"No\n";
     }
    // cout<<s1<<"\n";
       
   
  

   
 


      

  }

  
}


Measured memory_bytes: 256
main(n,k,a,b){for(scanf("%d%d",&n,&k),n--;k;k--){scanf("%d%d",&a,&b);a--,b--;if(a+b>=n)a=n-a,b=n-b;printf("%d\n",(a<b?a:b)%3+1);}exit(0);}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " " <<
#define X first
#define Y second
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

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

const int MAX = 52;

int n;
ll p[MAX];

int check(ll x) {
  if (x < 0) return 0;
  ll kol = 0;
  
  REP(i, n) {
    ll tmp = p[i] + x - n + 1;
    //    if (!x) TRACE(tmp);
    
    if (tmp > 0)
      kol += (tmp - 1) / (n+1) + 1;
  }
  return kol <= x;
}

int main()
{
  scanf("%d", &n);
  REP(i, n)
    scanf("%lld", &p[i]);

  ll lo = 0, hi = 2e18;

  for (; lo<hi; ) {
    ll mid = (lo + hi) / 2;
    if (check(mid))
      hi = mid;
    else
      lo = mid + 1;
  }

  //  TRACE(lo);
  for (ll i=lo-2*n*n; ; i++) {
    if (check(i)) {
      printf("%lld\n", i);
      return 0;
    }
  }

  assert(0);
}


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

int main(){
    string s, n;
    cin >> s >> n;

    for (int i = 0; i < s.size();i++){
        if(s[i]!=n[i]){
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3624
N = int(input())
A = list(map(int,input().split()))
ans = [0]*(N+1)

for i in range(N,0,-1):
    c = 0
    for j in range(i,N+1,i):
        c += ans[j]
    if (A[i-1] == 0 and c % 2 == 1) or (A[i-1] == 1 and c % 2 == 0):
        ans[i] = 1

print(sum(ans))
for i in range(1,N+1):
    if ans[i] == 1:
        print(i,end=" ")

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

int main(void)
{
	char s[100],str[3];
	int n;
	scanf("%s",s);
	n=strlen(s);
	
	str[0]=s[0];
	str[1]=n-2;
	str[2]=s[n-1];
	
	printf("%c",str[0]);
	printf("%d",str[1]);
	printf("%c",str[2]);
	
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include<vector>
#include<map>
#include <set>
#include<string>
#include <queue>
#include <stack>
#include <random>
#define INF 10000001

int main()
{    

    int N;
    std::cin >> N;
    std::vector<int> V_C;
    V_C.resize(N);
    for(int i = 0; i < N; ++i){
        int v;
        std::cin >> v;
        V_C[i] = v;
    }
    for(int i = 0; i < N; ++i){
        int c;
        std::cin >> c;
        V_C[i] -= c;
    }
    int ans = 0;
    for(int i = 0; i < N; ++i){
        if(V_C[i] > 0) ans += V_C[i];
    }
    std::cout << ans << std::endl;
    return 0;
}


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

#define mod 1'000'000'007
typedef long long ll;

template <typename T>
void deb(initializer_list<T> l)
{
    for (auto &e : l)
        cout << e << ' ';
    cout << '\n';
}

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e : a)
        cin >> e;
    int cnt = 1, mx = a[0];
    for (int i = 1; i < n; ++i)
    {
        if (a[i] >= mx)
        {
            mx = a[i];
            ++cnt;
        }
    }
    cout << cnt << '\n';
}

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

    int t { 1 };
    //cin >> t;
    while (t--)
        solve();

    return 0;
}


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

int main() {
  long n;
  cin >> n;
  vector<long> a(n);
  map<long,long> b;
  vector<long> key;
  for(int i=0;i<n;i++) cin >> a[i];

  for(long j=1;j*j<=a[0];j++) {
    if(a[0]%j==0) {
      b[j]++;
      if(b[j]==1) key.push_back(j);
      if(a[0]/j!=j) {
        b[a[0]/j]++;
        if(b[a[0]/j]==1) key.push_back(a[0]/j);
      }
    }
  }
  for(long j=1;j*j<=a[1];j++) {
    if(a[1]%j==0) {
      b[j]++;
      if(b[j]==1) key.push_back(j);
      if(a[1]/j!=j) {
        b[a[1]/j]++;
        if(b[a[1]/j]==1) key.push_back(a[1]/j);
      }
    }
  }
  sort(key.begin(),key.end());
  
  for(long i=2;i<n;i++) {
    for(long j=0;j<key.size();j++) {
      if(a[i]%key[j]==0) b[key[j]]++;
    }
  }

  for(long i=1;true;i++) {
    if(b[key[key.size()-i]]>=n-1) {
      cout << key[key.size()-i] << endl;
      break;
    }
  }
}

Measured memory_bytes: 1024
n = int(input())
ac,wa,tle,re = 0,0,0,0
for i in range(n):
	str = input()
	if  str == "AC":
		ac += 1
	if  str == "WA":
		wa += 1
	if str == "TLE":
		tle += 1
	if str == "RE":
		re += 1
print("AC x", ac)
print("WA x", wa)
print("TLE x",tle)
print("RE x",re)


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

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct LST
{
	vector<ll> node;
	vector<ll> lazy;
	ll N;

	LST(ll* a,ll n)
	{
		N = 1;
		while (N < n)N *= 2;

		node.resize(2 * N - 1, 0);
		lazy.resize(2 * N - 1, 0);

		rep(i, 0, n)node[N - 1 + i] = a[i];
		rrep(i, 0, N - 1)node[i] = node[2 * i + 1] + node[2 * i + 2];
	}

	void eval(int k, int l, int r) {
		if (lazy[k] != 0) {
			node[k] += (lazy[k] * (r - l));

			if (r - l > 1) {
				lazy[2 * k + 1] += lazy[k];
				lazy[2 * k + 2] += lazy[k];
			}

			lazy[k] = 0;
		}
	}

	void update(int a, int b, ll x, int k, int l, int r = -1)
	{
		if (r == -1)
		{
			r = N;
		}
		if (r <= a || b <= l)
		{
			return;
		}

		if (a <= l&&r <= b)
		{
			lazy[k] += x;
			eval(k, l, r);
		}
		else
		{
			node[k] += x*(min(r, b) - max(l, a));
			eval(k, l, r);
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
		}
	}

	ll sum(int a, int b, int k, int l, int r = -1)
	{
		if (r == -1)
		{
			r = N;
		}
		if (r <= a || b <= l)
		{
			return 0;
		}

		eval(k, l, r);

		if (a <= l&&r <= b)
		{
			return node[k];
		}
		else
		{
			ll res = 0;
			res += sum(a, b, 2 * k + 1, l, (l + r) / 2);
			res += sum(a, b, 2 * k + 2, (l + r) / 2, r);
			return res;
		}
	}
};

ll A[100010];

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

	int N, Q;
	int c;
	int l, r;
	ll v;
	cin >> N >> Q;
	rep(i, 0, N)
	{
		//cin >> A[i];
	}
	LST lst(A, N);
	rep(i, 0, Q)
	{
		cin >> c;
		if (c == 0)
		{
			cin >> l >> r >> v;
			lst.update(l - 1, r, v, 0, 0);
		}
		else
		{
			cin >> l >> r;
			cout << lst.sum(l - 1, r, 0, 0) << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 7116
# -*- coding: utf-8 -*-
import copy

N = int(input())
A = list(map(int, input().split()))
ball = copy.copy(A)

for i in range(int(N/2), 0, -1):
    s = 0
    for j in range(2*i, N+1, i):
        s += ball[j-1]
    if A[i-1] == s%2:
        ball[i-1] = 0
    else: ball[i-1] = 1

s = sum(ball)
print(s)
if s != 0:
    out = str(ball.index(1) + 1)
    for i in range(int(out), N):
        if ball[i] == 1: out += ' ' + str(i+1)
    print(out)

Measured memory_bytes: 9584
OP = {
    '+': lambda a,b: int(a) + int(b),
    '-': lambda a,b: int(a) - int(b),
    '*': lambda a,b: int(a) * int(b),
    '/': lambda a,b: int(a) // int(b)
}
while True:
    a, op, b = [x for x in input().split()]
    if op == '?':
        break
    print(OP[op](a, b))



Measured memory_bytes: 5600
while True:
    try:
        x,y,z = map(int,input().split())
    except EOFError:
        break
    cnt = 0
    for i in range(1,10):
        if i == x or i == y or i == z:
            continue
        if x + y + i <= 20:
            cnt += 1
    if cnt >= 4:
        print('YES')
    else:
        print('NO')

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

int main(int argc, char **argv) {
	vector<int> a(4);
	for (int i = 0; i < 4; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
def sel(data,n):
    an = n
    ans = 0
    for i in data:
        t = abs(n - i * 2)
        if t < an:
            an = t
            ans = i
    return(ans)

n = input()
As = list(map(int,input().split()))
As.sort()
l = As[-1]
m = sel(As[:-1],l)
print(l,m)


Measured memory_bytes: 62704
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int main(void){
    int cnt = 0;
    bool AC = true;
    char S[11];
    scanf("%s", S);
    for (int i = 1; i < strlen(S); i++) {
        if (i >= 2 && i < strlen(S) - 1 && S[i] == 'C') cnt++;
        else if (S[i] < 'a' || S[i] > 'z') AC = false;
    }
    if (S[0] != 'A' || cnt != 1) AC = false;
    printf(AC ? "AC" : "WA");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const long long INF = 10000000000;
int main() {
	long long x, y;
	cin >> x >> y;
	long process[4];
	if (y >= x) {
		process[0] = y - x;
	}
	else {
		process[0] = INF;
	}
	if (-y >= x) {
		process[1] = -y - x+1;
	}
	else {
		process[1] = INF;
	}
	if (y >= -x) {
		process[2] = y + x+1;
	}
	else {
		process[2] = INF;
	}
	if (-y >= -x) {
		process[3] = -y + x + 2;
	}
	else {
		process[3] = INF;
	}
	sort(process, process + 4);
	cout << process[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x;cin>>n>>x;
  vector<ll>a(n+1);
  rep(i,n){
    cin>>a[i+1];
  }
  rep(i,n)a[i+1]+=a[i];
  ll res=0;
  rep(i,n+1){
    if(a[i]<=x)res++;
  }
  cout<<res<<endl;
  return 0;

}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s;
    int n, m; cin >> s;
    bool can = 1;
    for (int i = 0; i < s.size(); i += 2) {
        if(!(s[i] == 'h' && s[i+1] =='i')) can = 0;
    }


cout <<          (can ? "Yes ": "No")                    << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

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

		if(a>b) {
			System.out.println("a > b");
		} else if(a<b) {
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17160
N,M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
d = N-M+1
for i in range(d):
    for j in range(d):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l]==B[k][l]:
                    continue
                else:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            break
    if flag:
        break
if flag:
    print('Yes')
else:
    print('No')        

Measured memory_bytes: 38384
import java.util.*;
public class Main {
    Scanner sc = new Scanner(System.in);
    void doIt() {
        StringBuilder sb	= new StringBuilder(sc.next());
	sb.setCharAt(3,'8');
	System.out.println(sb.toString());
    }
    public static void main(String args[]) {
	new Main().doIt();
    }
}


Measured memory_bytes: 23124
//use itertools::Itertools;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::f64::consts::PI;
use std::io::Read;
use std::usize::MAX;

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)*}};}
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)*}};}
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, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        a: f64,
        b: f64,
        x: f64
    }

    let s = x / a;

    if 2.0 * s > a * b {
        // 台形
        println!("{}", ((2.0 * (a * b - s) / (a * a)).atan()) * 180.0 / PI)
    } else {
        // 三角
        println!("{}", ((b * b / (2.0 * s)).atan()) * 180.0 / PI);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
const int N=55;
const int mod=1e9+7;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int C[N][N],n,f[N][N];
	
int main() {
	cin>>n;
	for(int i=0;i<=n;i++) {
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	f[1][0]=f[1][1]=1;
	for(int i=1;i<n;i++)
		for(int j=0;j<=i;j++)
			if(f[i][j])
				for(int x=0;x+i<=n;x++)
					for(int y=0;x+y+i<=n;y++)
						if(x+y&&x+y>=j&&!((x+y-j)&1)) {
							int &t=f[i+x+y][abs(j+(x+y-j)/2-x)];
							t=(t+1ll*f[i][j]*C[x+y+i][x+y]%mod*C[x+y][x])%mod;
						}
	cout<<f[n][0];
	return 0;
}


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

void solve(){
int n,a,b;
cin>>n>>a>>b;
for(int i=a;i<=b;i++){
	if(i%n==0){
		cout<<"OK";
		return ;
	}
}
cout<<"NG";
}

int main() {
solve();


}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"math"
)

var a, s []int
var memo [][]int

func main() {
	var N int
	fmt.Scan(&N)
	a, s = make([]int, N), make([]int, N+1)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
		s[i+1] = s[i] + a[i]
	}
	memo = make([][]int, N)
	for i := 0; i < N; i++ {
		memo[i] = make([]int, N+1)
	}
	fmt.Println(f(0, N))
}

func f(l, r int) int {
	if l == r-1 {
		return 0
	}
	if memo[l][r] > 0 {
		return memo[l][r]
	}
	v := math.MaxInt64
	for c := l + 1; c < r; c++ {
		v = Min(v, f(l, c)+f(c, r)+s[r]-s[l])
	}
	memo[l][r] = v
	return v
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
// g++ test.cpp && ./a.out <in
#pragma GCC optimize("O3")
using namespace std;
#define fi first
#define se second
#define pb push_back
#define loop(i, a, b) for (int i=a; i<(b); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef pair<int,int> pi;
const int INF = 1e9;
const int MOD = 1000000007;

void test_case() {	
	int n,k; cin>>n>>k;
	vector<int> v(n);
	for(auto &it: v) cin>>it;
	for(int i=0,j=k;j<n;i++,j++){
		if(v[i] < v[j]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++) {
		test_case();
	}
	return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a;
  ll ar[n];
  rep(i,0,n) cin>>ar[i];
  j=0;
  for(i=a;i<n;i++)
  {
    if(ar[i]>ar[j]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    j++;
  }
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 5176
#include <vector>
#include <set>
#include <functional>
using namespace std;

template<class Node>
struct UnionFind{
  vector<int> par;
  vector<int> rank;
  vector<Node> nodes;
  function<void(Node&,Node&)> f;

  UnionFind(const vector<Node>& init,function<void(Node&,Node&)> func) : par(init.size(),0),rank(init.size(),0),nodes(init) , f(func){
    for(int i = 0;i < init.size();i++){
      par[i] = i;
    }
  }

  int root(int x){
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  int unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y) return 0;

    int r,c;

    int res = 1;

    if(rank[x] < rank[y]){
      par[x] = y;
      r = y;
      c = x;
      res = -1;
    }
    else{
      par[y] = x;
      r = x;
      c = y;
      if(rank[x] == rank[y]) rank[x]++;
      res = 1;
    }

    f(nodes[r],nodes[c]);
    return res;
  }

  bool same(int x,int y){
    return root(x) == root(y);
  }

  Node value(int x){
    return nodes[x];
  }
};

/*
 * UnionFindTree
 *
 * #Node
 * 頂点に置く値の型
 * uniteしたときに更新をする
 *
 * +function<void(Node&,Node&)> f
 * uniteしたときデータの更新を行う
 * 左が根のnode,右が子のnodeである
 * ex...size,max
 *
 * +UnionFind(const vector<Node>& init,function<void(Node&,Node&)> func)
 * init...各頂点の初期値
 * func...fに設定するもの
 *
 * ex...UnionFind<int> uf(vector<int>(N,1),[](int& rn,int& cn){rn += cn;});
 *
 * +int root(int x)
 * 要素の根の頂点を返す
 *
 * +bool unite(int x,int y)
 * 結合する.
 * 元から同じグループであれば0
 * xが根になったときは1
 * yが根になったときは-1を返す
 *
 * +bool same(int x,int y)
 * 同じグループに属しているかを返す
 *
 * +Node value(int x)
 * 頂点の値を返す
 *
 */

template<class Weight = long long>
struct WeightedUnionFind : public UnionFind<Weight>{

  WeightedUnionFind(int size) : UnionFind<Weight>(vector<Weight>(size,0),[](Weight& rn,Weight& cn){}){
  }

  int root(int x){
    if(x == this->par[x]) return x;
    int parent = root(this->par[x]);
    this->nodes[x] += this->nodes[this->par[x]];
    return this->par[x] = parent;
  }

  int unite(int x,int y,Weight w){
    w  = w + weight(x) - weight(y);
    x = root(x);
    y = root(y);
    int res = UnionFind<Weight>::unite(x,y);
    if(res == 0) return 0;
    if(res == -1){
      w = -w;
      swap(x,y);
    }
    this->nodes[y] = w;
    return res;
  }

  Weight weight(int x){
    root(x);
    return this->nodes[x];
  }

  bool same(int x,int y){
    return root(x) == root(y);
  }

  pair<bool,Weight> diff(int x,int y){
    if(!same(x,y)) return {false,0};
    return {true,weight(x) - weight(y)};
  }
};

/*
 * WeightedUnionFind
 *
 * +Weight weight(int x)
 * 頂点の重みを返す
 *
 * +pair<bool,Weight> diff(int x,int y)
 * first...同じグループに属しているかを返す
 * second...yからxの重みの差を返す
 * 
 */


#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N,M;

int main(){
  cin >> N >> M;
  WeightedUnionFind<> uf(N + 1);
  rep(i,0,M - 1){
    int l,r,d;
    cin >> l >> r >> d;
    auto p = uf.diff(r,l);
    if(!p.first){
      uf.unite(l,r,d);
    }
    else if(p.second == d){
      continue;
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 2560
#!python3

# input
N, M, Q = list(map(int, input().split()))
LR = [[0] * 501 for _ in range(501)]
for _ in range(M):
    l, r = list(map(int, input().split()))
    LR[l][r] += 1
pq = [list(map(int, input().split())) for _ in range(Q)]


def main():
    dp = [[0] * 501 for _ in range(501)]
    for i in range(1, 501):
        for j in range(1, 501):
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + LR[i][j]
    
    for p, q in pq:
        ans = dp[q][q] - dp[q][p-1] - dp[p-1][q] + dp[p-1][p-1]
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 36868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,M;
  cin >> N >> M;
 
  if (N*M==1)
    cout << 1 << endl;
  if ((N==1 && M>1) || (M==1 && N>1))
    cout << N+M-3 << endl;
  if (N>1 && M>1)
    cout << (N-2)*(M-2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define cin(a) scanf("%d",&a)
#define pii pair<int,int>
#define ll long long
#define gcd __gcd
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;

map<string,int> mp;
string a[100];
int t[100];

int main()
{
    int n;
    cin(n);
    for(int i = 1; i <= n; i++) 
    {
        cin>>a[i]>>t[i];
        mp[a[i]] = i;
    }
    string str;
    cin>>str;
    int i = mp[str]+1;
    int ans = 0;
    for(;i <= n; i++)
    {
        ans += t[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

int main(){
  int a,b;

  cin >> a>> b;

  if (b % a == 0) {
    cout << a + b << endl;
    return 0;
  }
  cout << b - a << 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;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 llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main()
{
int a,b;
cin>>a>>b;
int ans=0;
for(int i=a; i<=b; i++)
{
int s=i%10,t=i/10000%10;
int u=i/10%10,v=i/1000%10;
if(s==t&&u==v) ans++;
}
cout<<ans<<endl;
}

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

public class Main {

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

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		int edge[] = new int[n];

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");
			int a = Integer.parseInt(str[0]) - 1;
			int b = Integer.parseInt(str[1]) - 1;
			edge[a]++;
			edge[b]++;
		}

		for (int i : edge) {
			if (i % 2 != 0) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}

Measured memory_bytes: 47488
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 100010
ll dp[mx];
vvll v(mx);
ll f(vvll &v,ll i){
	if(dp[i]!=-1)return dp[i];
	ll ans=0;
	for(ll j=0;j<v[i].size();++j){
		ans=max(ans,1+f(v,v[i][j]));
	}
	return dp[i]=ans;
}

int main(){
	IOS;
	ll n,m;cin>>n>>m;
	rep(i,0,n+1)dp[i]=-1;
	rep(i,0,m){
		ll x,y;cin>>x>>y;
		v[x-1].pb(y-1);
	}
	ll ans=-1;
	rep(i,0,n)	ans=max(ans,f(v,i));
	cout<<ans;
	return 0;
}



Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    cin >> N;
    vector<int> a(N);

    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    int search_num = 1;
    int break_block_cnt = 0;

    for(int i = 0; i < N; i++){
        if (search_num != a[i]){
            break_block_cnt++;
        }
        else{
            search_num++;
        }
    }
    if(search_num == 1) cout << -1 << endl;
    else cout << break_block_cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int n,i,j,flag,sum = 0,t;
	int a[100];
	scanf("%d",&n);
	for (i = 0 ; i < n ; i++) scanf("%d",&a[i]);
	
	flag = 1;
	while(flag) 
	{
		flag = 0;
		for (i = n-1 ; i > 0 ; i--)
		{
			if (a[i] < a[i-1])
			{
				t = a[i];
				a[i] = a[i-1];
				a[i-1] = t;
				sum+=1;
				flag = 1;
			}
		}
	}
	for (i = 0 ; i < n ; i++) 
	{
	    if(i != n-1)
	    {
		  printf("%d ",a[i]);
	    }
	    else
	    {
	        printf("%d\n",a[i]);
	    }
	}
	printf("%d\n",sum);
    return  0;
}


Measured memory_bytes: 2148
#include <cstdio>

int main(){
  int N; scanf("%d", &N);

  int t = 1, v = 1;

  for(int i = 1; i <= N; i++){
    int x; scanf("%d", &x);

    if(~x & 1) v *= 2;
    t *= 3;
  }

  printf("%d\n", t - v);
  return 0;
}

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

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

    unordered_set<string> S;

    for (int i = 0; i < N; ++i) {
        string S_i;
        cin >> S_i;
        S.insert(S_i);
    }

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

Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	string s;cin >> s;
	int n = s.size();
	auto check = [&](string t){
		int m = t.size();
		return t.substr(0,m/2) == t.substr(m/2,m/2);
	};
	for(int len = n-1;len >= 0;len--){
		if(len%2)continue;
		if(check(s.substr(0,len))){
			cout << len << endl;
			return 0;
		}

	}
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <map>
#include <vector>

using namespace std;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

string s;
int a[100005];
int n;
int l[100005], r[100005];
int dif[100005];
UnionFind uf(100005);
map<int, int> mp;

int main(void)
{
	cin >> s;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> l[i] >> r[i];
	
	for(int i = 0; i < s.size(); i++){
		a[i+1] = (int)(s[i] - 'a');
	}
	int N = s.size() + 1;
	
	for(int i = 1; i <= N; i++){
		dif[i] = (a[i] - a[i-1] + 26) % 26;
	}
	for(int i = 1; i <= N; i++) uf.unite(i, N-i+1);
	for(int i = 1; i <= n; i++) uf.unite(l[i], r[i]+1);
	
	for(int i = 1; i <= N; i++){
		mp[uf.root(i)] += dif[i];
	}
	for(auto it = mp.begin(); it != mp.end(); it++){
		if(it->second % 26){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e9+7;


int main() {

    int n;
    scanf("%d", &n);
    
    vector<double> p(n+1);
    vector<double> dp(n+1, 0);
    
    // dp[i] - p-bility of having i heads after a specific amount
    // of tosses defined by iteration
    
    for(int i = 1; i <= n; ++i) {
        scanf("%lf", &p[i]);
    }
    
    dp[0] = 1;
    for(int ntosses = 1; ntosses <= n; ++ntosses) {
        vector<double> new_dp(n+1, 0);
        
        for(int heads = 0; heads <= ntosses; ++heads) {
            new_dp[heads] = (heads-1 >= 0 ? dp[heads-1] : 0) * p[ntosses] + dp[heads] * (1 - p[ntosses]);
        }
        
        dp = new_dp;
    }
    
    double ans = 0;
    
    for(int heads = 0; heads <= n; ++heads) {
        int tails = n - heads;
        if(heads > tails) {
            ans += dp[heads];
        }
    }
    
    printf("%.10lf\n", ans);
    
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int ans = 1;
	for (int i = 1; i < n; i++) {
		bool key = 1;
		for (int j = 0; j < i; j++) {
			if (h[i] < h[j]) {
				key = 0;
			}
		}
		if (key == 1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def gusuuhantei(i):
    count = 0
    num = i
    while True:
        if num % 2 ==0 and not num == 0:
            num = num / 2
            count += 1
        else:
            break
    return count
N = int(input())
li = [-1]*(N+1)
for i in range(1, N+1):
    li[i] = gusuuhantei(i)
Maxcount = max(li)
index = li.index(Maxcount)
print(index)

Measured memory_bytes: 9252
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int H, W, ans = 0;
    cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10)), A(H, vector<int>(W));
    rep(i, 10) {
        rep(j, 10) {
            cin >> c[i][j];
        }
    }
    rep(i, H) {
        rep(j, W) {
            cin >> A[i][j];
        }
    }
    rep(k, 10) {
        rep(i, 10) {
            rep(j, 10) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    rep(i, H) {
        rep(j, W) {
            if (A[i][j] == -1) continue;
            ans += c[A[i][j]][1];
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 384
H, W = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(H)]

flag = False
h, w = 1, 1
ans = []


def it_grid(h, w):
    if h % 2:
        if w == W:
            h += 1
        else:
            w += 1
    else:
        if w == 1:
            h += 1
        else:
            w -= 1
    return h, w


while h <= H:
    new_h, new_w = it_grid(h, w)
    if A[h - 1][w - 1] % 2:
        if not flag and new_h <= H:
            ans.append((h, w, new_h, new_w))
        flag = not flag
    else:
        if flag and new_h <= H:
            ans.append((h, w, new_h, new_w))
    h, w = new_h, new_w

print(len(ans))
for t in ans:
    print(*t)


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

static const int MAX_N = 100;
static const int MAX_W = 1e5;

int N, W;
int v[MAX_N];
int w[MAX_N];
long dp[MAX_N + 1][MAX_W + 1];

long dfs(int i, int j) {
  if (i >= N)
    return 0;
  if (dp[i][j] >= 0)
    return dp[i][j];
  long res = dfs(i + 1, j);
  if (j >= w[i]) {
    res = max(res, dfs(i + 1, j - w[i]) + v[i]);
  }
  return dp[i][j] = res;
}

long solve_dfs() {
  fill(dp[0], dp[0] + (MAX_N + 1) * (MAX_W + 1), -1);
  return dfs(0, W);
}

long solve() {
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= W; ++j) {
      if (j < w[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      }
    }
  }
  return dp[N][W];
}

long solve_backward() {
  for (int i = N - 1; i >= 0; --i) {
    for (int j = 0; j <= W; ++j) {
      if (j < w[i]) {
        dp[i][j] = dp[i + 1][j];
      } else {
        dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
      }
    }
  }
  return dp[0][W];
}

int main() {
  cin >> N >> W;
  for (int i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
  }

  long ret = solve();
//  if (ret != solve_dfs())
//    return 1;
//  fill(dp[0], dp[0] + (MAX_N + 1) * (MAX_W + 1), 0);
//  if (ret != solve_backward())
//    return 1;

  cout << ret << endl;
  return 0;
}


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

ll calc(ll x, ll y) {
    ll cnt = x / y;
    ll val = 2 * y * cnt;
    ll ret = (cnt * y == x) ? val - y : val + calc(y, x - y * cnt);
    return ret;
}

int main() {
    ll N, X;
    cin >> N >> X;
    cout << N + calc(X, N - X) << endl;
    return 0;
}



Measured memory_bytes: 256
D, N = map(int, input().split())

count = 0
m = 0
n = 0
c = 0

if D == 0:
  n = 1
  m = 100
elif D == 1:
  n = 100
  m = 10000
else:
  n = 10000
  m = 1000000

while 1:
  c += n
  if c % m == 0:
    pass
  else:
    count += 1
      
  if count == N:
    print(c)
    break
  

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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	




int main(){
	
	int a,b,c;

	
	cin >> a >> b >> c; 
	
	cout << min(min(min(abs(a-b) + abs(b-c),abs(a-c) + abs(c-b)),abs(c-b) + abs(b-a)),abs(c-a) + abs(a-b)) << endl;
	
	
	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 2000005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    ll ans = INF,cnt = 0;
    rep(i,n){
        if (a[i] > b[i]){
            chmin(ans,b[i]);
        }
        cnt += b[i];
    }
    if (ans == INF){
        PRINT(0);
    }
    else{
        PRINT(cnt-ans);
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
#define INF 1000000000
#define pow10 tipa_pow10
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
ll ans = 0;
map<ll , int> cnt;
int n;
int a[200000];
ll pref[200000];
int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    pref[0] = a[0];
    for(int i = 1; i < n; i ++)
        pref[i] = pref[i - 1] + a[i];
    for(int i = 0; i < n; i++)
        cnt[pref[i]]++;
    ll ans = cnt[0];
    for(int i =  0; i < n; i++)
    {
        cnt[pref[i]]--;
        ans += cnt[pref[i]];
    }
    cout << ans;
}


Measured memory_bytes: 15104
<?php
    $a = explode(" ", trim(fgets(STDIN)));
    if(($a[2] - $a[4]) >= 0 && ($a[2] + $a[4]) <= $a[0] &&
       ($a[3] - $a[4]) >= 0 && ($a[3] + $a[4]) <= $a[1]){
        echo "Yes".PHP_EOL;
    }else{
        echo "No".PHP_EOL;
    }


Measured memory_bytes: 9216
while 1:
	n=input()
	if n==0:break
	games=[map(int,raw_input().split()) for i in range(n)]
	ls=[]
	for game in games:
		score,thrw=0,1
		for flame in range(10):
			if game[thrw]==10:
				score+=sum(game[thrw:thrw+3])
				thrw+=1
			elif game[thrw]+game[thrw+1]==10:
				score+=10+game[thrw+2]
				thrw+=2
			else:
				score+=game[thrw]+game[thrw+1]
				thrw+=2
		else:
			ls.append([game[0],score])
	for k,s in sorted(sorted(ls),key=lambda x:x[1],reverse=True):
		print k,s

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

#define jk(i,j,k) for (int i = (j); i <= (k); i++)
#define kj(i,j,k) for (int i = (j); i >= (k); i--)
#define int long long
#define lb long double
#define ul unsigned long long
#define mp std::make_pair
#define pb push_back
#define pr(a,b) printf(a, b)
#define sc(a,b) scanf(a, &b)
#define x first
#define y second
#define al(x) (x).begin(), (x).end()
#define me(a) memset((a), 0, sizeof(a))

inline int rd() { int data = 0, w = 1; char ch = 0; while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar(); (ch == '-') && ( w = -1, ch = getchar() ); while (ch >= '0' && ch <= '9') { data = data * 10 + ch - '0'; ch = getchar(); } return data * w; }
inline void P (int v) { if (v < 0) { putchar('-'); v = -v; } if (v > 9) P(v / 10); putchar(v % 10 + '0'); }

signed main () {
    std::string a, b;
    int d = rd();
    std::cin >> a >> b;
    jk (i, 1, d) {
    	putchar(a[i - 1]); putchar(b[i - 1]);
    }
    return 0;
}

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

int main(void){
  int N;
  cin >> N;
  double p[N];
  double dp[N+1][N+1];
  // dp[i][j]: コインiを振って表がj枚出る確率
  dp[0][0] = 1;
  double tmpP = 1;
  for(int i=0; i<N; i++) {
    cin >> p[i];
    tmpP *= (1-p[i]);
    dp[i+1][0] = tmpP;
  }
  
  
  for(int i=0; i<N; i++){
    for(int j=0; j<=i; j++){
      if(j != i)
        dp[i+1][j+1] = dp[i][j+1]*(1-p[i]) + dp[i][j]*p[i];
      else
        dp[i+1][j+1] = dp[i][j]*p[i];
    }
  }
/*
  for(int i=0; i<N+1; i++){
    for(int j=0; j<N+1; j++){
      cout << dp[i][j] << " ";
    }
    cout << endl;
  }
*/
  double ans = 0;
  for(int i=(N+1)/2; i<=N; i++) ans += dp[N][i];
  
  printf("%.10lf\n", ans);
  
  return 0;
}

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

#define ll long long
#define ld long double
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define ii pair < int, int >
#define vi vector < int > 
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update > ost;
// name.find_by_order( x ) or name.order_of_key( x )

const int maxn = 2e5 + 10, maxv = 1e6 + 10, maxlog = 20;
const int inf = 1e9 + 1;
const int MOD = 1e9 + 7;
const ll INF = 4e18 + 1;
const double eps = 1e-9;

void yes() { cout << "YES\n"; }
void no() { cout << "NO\n"; }

void solve() {
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs( x );
	ll num = x / d;
	ll val1 = x - num * d;
	ll val2 = abs( x - ( num + 1 ) * d );
	if ( k < num ) cout << x - k * d << "\n";
	if ( k == num ) cout << val1 << "\n";
	if ( k > num ) {
		if ( ( k - num ) % 2 == 0 ) cout << val1 << "\n"; else cout << val2 << "\n";
	}
}

int main() {
	int t = 1;
	//cin >> t;
	while ( t-- ) solve();
	return 0;
}


Measured memory_bytes: 3640