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

#define endl            "\n"
#define ll              long long
#define ld              long double 
#define ull             unsigned long long int
#define MOD             (ll)(1e9 + 7)
#define vi              vector<int>
#define vl              vector<long>
#define vll             vector<ll>
#define pll             pair<ll,ll>
#define mll             map<ll,ll>
#define len(x)          x.length()
#define all(x)          x.begin(),x.end()
#define deb1(x)         cout<<#x<<" "<<x<<endl;
#define deb2(x,y)       cout<<#x<<" "<<x<<"\t"<<#y<<" "<<y<<endl;
#define deb3(x,y,z)     cout<<#x<<" "<<x<<"\t"<<#y<<" "<<y<<"\t"<<#z<<" "<<z<<endl;
#define debug1(x)       cerr<<#x<<" "<<x<<endl;
#define debug2(x,y)     cerr<<#x<<" "<<x<<"\t"<<#y<<" "<<y<<endl;
#define debug3(x,y,z)   cerr<<#x<<" "<<x<<"\t"<<#y<<" "<<y<<"\t"<<#z<<" "<<z<<endl;
#define info(s)         cerr<<s<<" "<<endl;
#define fr(a,b,c)       for(auto a=b;b<c?a<c:a>=c;b<c?a++:a--)
#define frc(a,b,c)      for(auto a=b;a!=c;a++)
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define lb(v,x)         lower_bound(v.begin(), v.end(), x)
#define ub(v,x)         upper_bound(v.begin(), v.end(), x)
#define clr(x)          memset(x, 0, sizeof(x))
#define GR              (double)(1 + sqrt(5)) / 2
#define fib(n)          (ll)round(pow(GR,n) / sqrt(5))
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define out1(x)         cout<<x<<" "<<endl
#define out2(x,y)       cout<<x<<" "<<y<<endl
#define SORT(a)         sort(all(a));
#define SORTR(a)        sort(all(a),greater<ll>());
#define ARRAY(a,n)      vll a; fr(i,0,n) { ll temp; cin>>temp; a.pb(temp); }  
#define PRINT(a)        for(auto x:a)cout<<x<<" ";cout<<endl
#define MAX             100050
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second


template<typename T>
void output_vector(const vector<T> , bool ,bool ,int ,int );

template<typename T>
ostream& operator<<(ostream &out,const vector<T> &v);

template<typename T>
istream& operator>>(istream &in,vector<T> &v);


void solve()
{   
    int n,k;cin>>n>>k;
    vi v(n);cin>>v;SORT(v);ll sum=0;
    for(int i=0;i<k;i++)
    sum+=v[i];
    cout<<sum<<endl;
}

int main()
{   

    FIO;
    ll test;test=1;
    // cin>>test;
    while(test--)
    solve();
    return 0;
}






template<typename T>
void output_vector(const vector<T> &v, bool debug_print=false,bool add_one = false,int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        (debug_print)?(cerr << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n')):(cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n'));
}   

template<typename T>
ostream& operator<<(ostream &out,const vector<T> &v){
    int i=0;
    for(T x:v){
        out<<x;
        (i++!=v.size())?out<<" ":out<<"\n";    
    }
    return out;
}

template<typename T>
istream& operator>>(istream &in,vector<T> &v){
    for(T &i:v)
        in>>i;
    return in;
}

Measured memory_bytes: 3672
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N, M = list(map(int, input().split()))

    L = []
    R = []
    id = list(range(N+1))
    for _ in range(M):
        l, r = list(map(int, input().split()))
        L.append(l)
        R.append(r)

    max_l = max(L)
    min_r = min(R)
    if min_r < max_l:
        print("0")
    else:
        print(min_r - max_l + 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14992
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

const int MOD_CONST =  1000000007;

using namespace std;



int main() {
	
		int x, y;


		cin >> x >> y;

		if (x > 2 * y) {
			cout << 0 << endl;
		}
		else if (2 * x < y) {
			cout << 0 << endl;
		}
		else if ((x + y) % 3 != 0) {
			cout << 0 << endl;
		}
		else {
			int n = (2 * y - x) / 3;
			int m = (2 * x - y) / 3;

			vector<long long> inv(n + 1);
			inv[0] = 1;
			inv[1] = 1;
			for (int i = 2; i <= n; i++) {
				inv[i] = (MOD_CONST - (MOD_CONST / i)*inv[MOD_CONST%i]  % MOD_CONST) % MOD_CONST;
				//cout << (inv[i] *i) % MOD_CONST<< endl;
			}
			//cout << n << " " << m << endl;
			long long com = 1LL;
			for (int i = n + m; i > m; i--) {
				com = (com*i) % MOD_CONST;
			}
			for (int i = n; i > 0; i--) {
				com = (com * inv[i]) % MOD_CONST;
			}
			cout << com << endl;

		}


		//cout << (inv_mod(2) )% MOD_CONST<< endl;
}

Measured memory_bytes: 3584
import java.util.*
import java.math.*
import java.lang.Math.*


private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrintln: (String)->Unit = { msg -> System.err.println(msg) }


internal class Position(var x: Int, var y: Int)

fun solveA(G: Array<String>): Int {
    val H = G.size
    val W = G[0].length
    val INF = Int.MAX_VALUE / 2
    val step = Array(H) { IntArray(W) }
    val starts = ArrayList<Position>()
    for (i in 0 until H) {
        for (j in 0 until W) {
            step[i][j] = INF
            if (G[i][j] == '#') {
                starts.add(Position(i, j))
            }
        }
    }
    val dx = intArrayOf(0, 1, 0, -1)
    val dy = intArrayOf(1, 0, -1, 0)
    val que = ArrayDeque<Position>()
    for (i in starts.indices) {
        que.addLast(starts[i])
        step[starts[i].x][starts[i].y] = 0
    }
    var res = 0
    while (!que.isEmpty()) {
        val pos = que.removeFirst()
        val x = pos.x
        val y = pos.y
        for (i in dx.indices) {
            val nx = x + dx[i]
            val ny = y + dy[i]
            if (nx < 0 || H <= nx || ny < 0 || W <= ny) {
                continue
            }
            if (step[nx][ny] > step[x][y] + 1) {
                step[nx][ny] = step[x][y] + 1
                que.addLast(Position(nx, ny))
                res = max(res, step[nx][ny])
            }
        }
    }
    return res
}


fun main(args: Array<String>) {
    val (H, W) = readListInt()
    val A = Array<String>(H){""}
    for (i in 0 until H) {
        A[i] = readString()
    }

    val ans = solveA(A)

    println(ans)
}


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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int p, q, r;
    cin >> p >> q >>r;
    cout << min(p+q,min( q+r, r+p));
}

Measured memory_bytes: 256
#include<stdio.h>

  int n, m;
  int root = 0;
  int memo[9][9] = {0};
  int seen[9] = {0};

void dfs(int x, int y){

  if(seen[y] == 1){
    return;
  }

  seen[y] = 1;
  int flag = 0;
  for(int i = 1; i <=n ; ++i){
    if(seen[i] == 0) flag = 1;
  }
  if(flag == 0) root ++;
  flag = 0;

  for(int i = 1; i <= n; ++i){
    if( (memo[y][i] == 1) && (i != x) ){
      dfs(y,i);
    }
  }
  seen[y] = 0;
  return;
}

int main(){

  scanf("%d %d",&n, &m);
  int a,b;
  for(int i = 0; i < m; ++i){
    scanf("%d %d",&a,&b);
    memo[a][b] = 1;
    memo[b][a] = 1;
  }

  seen[1] = 1;
  for(int vertex = 2; vertex <= n; ++vertex){
    if(memo[1][vertex] == 1){
      dfs(1,vertex);
    }
  }

  printf("%d",root);
  return 0;

}


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

using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n][3];
    int dp[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        cin>>a[i][j];
    }
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(a[i][0]+dp[i-1][1],a[i][0]+dp[i-1][2]);
        dp[i][1]=max(a[i][1]+dp[i-1][0],a[i][1]+dp[i-1][2]);
        dp[i][2]=max(a[i][2]+dp[i-1][0],a[i][2]+dp[i-1][1]);
    }
    cout<<*max_element(dp[n-1],dp[n-1]+3);


}


Measured memory_bytes: 2560
import copy
H,W=map(int,input().split())
C=[list(map(int,input().split()))for _ in range(10)]
A=[list(map(int,input().split()))for _ in range(H)]
d=copy.deepcopy(C)
for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ans=0
for al in A:
    for a in al:
        if a!=-1:
            ans+=d[a][1]
print(ans)

Measured memory_bytes: 3828
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    b, c = map(int, input().split())

    print(c * ((c-1) **(b-1)))

Measured memory_bytes: 3828
nn = int(input())
aa = list(map(int, input().split()))
bb = [0]*(nn-1)
mysum = 0
for i in range(nn):
    mysum += (aa[i] % (10**9 + 7))
mydiff = 0

for i in range(1,nn):
    mydiff += aa[i - 1]
    tete = mysum - mydiff
    if tete >= 0:
        bb[i-1] = tete
    else:
        bb[i-1] = tete + 10**9+7

finalsum = 0
for i in range(nn-1):
        finalsum += aa[i]*bb[i]
        finalsum = finalsum % (10**9 + 7)

print(finalsum)

Measured memory_bytes: 94028
#include<bits/stdc++.h>
using namespace std;
int a[1000000]={0};
int main(void){
   int n;
   cin>>n;
   double s=0.0;
   while(n--){
        double x;
        string u;
        cin>>x>>u;
        u=="JPY" ? s+=x : s+=380000.0*x;
   }
   cout<<s;
}


Measured memory_bytes: 256
var perm=[];
var flag=[];
for(var i=0;i<9;i++)flag[i]=false;
var cnt=0;
for(var i=0;i<9;i++){flag[i]=true;
for(var ii=0;ii<9;ii++){if(flag[ii])continue;flag[ii]=true;
for(var iii=0;iii<9;iii++){if(flag[iii])continue;flag[iii]=true;
for(var j=0;j<9;j++){if(flag[j])continue;flag[j]=true;
for(var jj=0;jj<9;jj++){if(flag[jj])continue;flag[jj]=true;
for(var jjj=0;jjj<9;jjj++){if(flag[jjj])continue;flag[jjj]=true;
for(var k=0;k<9;k++){if(flag[k])continue;flag[k]=true;
for(var kk=0;kk<9;kk++){if(flag[kk])continue;flag[kk]=true;
for(var kkk=0;kkk<9;kkk++){if(flag[kkk])continue;
perm[cnt]=[i,ii,iii,j,jj,jjj,k,kk,kkk];
cnt++;
}flag[kk]=false;
}flag[k]=false;
}flag[jjj]=false;
}flag[jj]=false;
}flag[j]=false;
}flag[iii]=false;
}flag[ii]=false;
}flag[i]=false;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var t=arr.shift()-0;
while(t--){
   var a=arr.shift().split(" ").map(Number);
   var b=arr.shift().split(" ").map(Number);
   var A=0;
   var B=0;
   perm.forEach(function(V){
      var sumA=0;
      var sumB=0;
      V.forEach(function(v,i){
         if(a[v]>b[i])sumA+=a[v]+b[i];
         else sumB+=a[v]+b[i];
      });
      (sumA>sumB)?A++:B++;
   });
   console.log((A/perm.length).toFixed(5)+" "+(B/perm.length).toFixed(5));
}

Measured memory_bytes: 71344
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

using namespace std;

int main() {
 
   long long int N;
   long long int K;
   long long int R;
   long long int S;
   long long int P;
   string T;
   string U;


   cin >> N >> K;
   cin >> R >> S >> P;
   cin >> T;
   int* J = new int[N];
   U="";
   for(int i=0;i<N;i++){
      switch (T[i]){
         case 's':
            U+="r";
            J[i]=R;
            break;
         case 'p':
            U+="s";
            J[i]=S;
            break;
         case 'r':
            U+="p";
            J[i]=P;
            break;
      }
   }
   for(int i=0;i<N;i++){
       if(i>=K){
          if(U[i]==U[i-K]){
             U[i]='o';
          }
       }
   }
   // cout << U << endl;
   int poi =0;
   for(int i=0;i<N;i++){
      switch (U[i]){
            case 'p':
               poi+=P;
               break;
            case 'r':
               poi+=R;
               break;
            case 's':
               poi+=S;
               break;
            case 'o':
               poi+=0;
               break;
      }
   }
   cout << poi << endl;
}

Measured memory_bytes: 1024
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
int main() {
    int h,w;cin >> h >> w;
    vvc a(h, vc(w));
    rep(i, h) {
        rep(j, w) cin >> a[i][j];
    }
    rep(i, h) {
        rep(j, w) {
            if(a[i][j]=='#') {
                bool ok = false;
                rep(l, 4) {
                    int x = i+dx[l],y = j+dy[l];
                    if(x<0||x>=h||y<0||y>w) continue;
                    if(a[x][y]=='#') ok = true;
                }
                if(!ok) {
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3616
using System;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ');
            var W = Convert.ToInt32(x[0]);
            var H = Convert.ToInt32(x[1]);
            var X = Convert.ToInt32(x[2]);
            var Y = Convert.ToInt32(x[3]);
            var R = Convert.ToInt32(x[4]);

            var Px = new int[] { X + R, X + R, X - R, X - R };
            var Py = new int[] { Y + R, Y - R, Y + R, Y - R };

            var result = true;
            foreach (var px in Px)
            {
                foreach (var py in Py)
                {
                    if (px >= 0 && px <= W && py >= 0 && py <= H)
                    {
                    }
                    else
                    {
                        result = false;
                        break;
                    }
                    if (!result)
                    {
                        break;
                    }
                }
            }
            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  vector<ll> v;
  load(v, n);

  int ma = 0;
  int bef = v[0];
  int c = 0;
  for (int i = 1; i < n; ++i) {
    if (bef >= v[i]) {
      c++;
    } else {
      ma = max(ma, c);
      c = 0;
    }
    bef = v[i];
  }
  ma = max(ma, c);
  p(ma);
}

Measured memory_bytes: 1400
use std::io::{BufRead, Write};
use std::io;
use std::cmp;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let n = split.next().unwrap().parse::<i64>().unwrap();
    let t = split.next().unwrap().parse::<i64>().unwrap();
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let ts = s.split_whitespace()
        .map(|s| s.parse::<i64>().unwrap())
        .collect::<Vec<_>>();
    let mut sum = t;
    for i in 1..ts.len() {
        sum += cmp::min(ts[i] - ts[i - 1], t);
    }
    writeln!(output, "{}", sum).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("2 4
0 3\n",
             "7\n");
    }
    #[test]
    fn case2() {
        test("2 4
0 5\n",
             "8\n");
    }
    #[test]
    fn case3() {
        test("4 1000000000
0 1000 1000000 1000000000\n",
             "2000000000\n");
    }
    #[test]
    fn case4() {
        test("1 1
0\n",
             "1\n");
    }
    #[test]
    fn case5() {
        test("9 10
0 3 5 7 100 110 200 300 311\n",
             "67\n");
    }
}



Measured memory_bytes: 10492
import itertools

N = int(input())

A = list(itertools.combinations_with_replacement(range(1,100),3))

Ans = [0 for i in range(1, N+1)]

for i in range(len(A)):
    f = int(((A[i][0]+A[i][1])**2 + (A[i][1]+A[i][2])**2 + (A[i][2] + A[i][0])**2)/2)
    if f <= N:
        if len(set(A[i])) == 1:
            Ans[f - 1] += 1
        elif len(set(A[i])) == 2:
            Ans[f - 1] += 3
        else:
            Ans[f - 1] += 6

for i in range(N):
    print(Ans[i])

Measured memory_bytes: 21308
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

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

using pqg = priority_queue<ll,vector<ll>, greater<ll> >; // 1,3,5..
using pql = priority_queue<ll,vector<ll> >; //5, 3, 1...

using pqg_p = priority_queue<P,vector<P>, greater<P> >; // 1,3,5..
using pql_p = priority_queue<P,vector<P> >; //5, 3, 1...

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

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

  int N;
  cin >> N;
  int res = 0;
  REP1(i,N+1) {
    int c = 0;
    if ( (i % 2) == 0 ) continue;
    REP1(j,i+1) {
      if (i % j == 0) c++;
    }
    if (c == 8) res++;
  }

  cout << res <<endl;

}


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

int main() {
    int k, i;
    cin>>k;
    cin.ignore();
    string s;
    getline(cin, s);
    int l=s.length();
    if(l>k) {
        for(i=0; i<k; ++i)
            cout << s[i];
        cout << "..." << endl;
    }
    else
        cout << s << endl;
    return 0;
}


Measured memory_bytes: 3560
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

s = input()
n = len(s)
j = 1
while True:
    c = ""
    for i in range(n-j):
        c += s[i]
    if len(c)%2 == 0:
        d = ""
        f = ""
        for i in range(len(c)//2):
            d += c[i]
            f += c[len(c)//2 + i]
        if d == f:
            print(len(c))
            sys.exit()
    j += 1

Measured memory_bytes: 3316
n,d = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        ans = 0
        for k in range(d):
            ans += abs(c[i][k]-c[j][k]) ** 2
        ans = ans**0.5
        #print(ans)
        if ans.is_integer():
            cnt += 1
print(cnt)


Measured memory_bytes: 9344
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define PR       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    string s;
    cin >> s;
    puts(s[0] == '7' || s[1] == '7' || s[2] == '7' ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mypow(ll a, ll b) {
    ll ret = 1;
    while (b--) {
        ret *= a;
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end());
    cout << a[n - 1] - a[0] << "\n";
    return 0;
}

Measured memory_bytes: 3636
def valid?(a, b, c)
  a <= b + c && b <= c + a + 1 && c <= a + b + 1
end
 
def calc(rear, front, west, east, north, south, limit, best)
  path = []
  limit.times do |i|
    a = rear + front
    b = west + east
    c = north + south
 
    if east > 0 && valid?(b - 1, c, a)
      rear, front, west, east = east - 1, west, rear, front
      y = 69
    elsif north > 0 && valid?(c - 1, a, b)
      rear, front, north, south = north - 1, south, front, rear
      y = 78
    elsif south > 0 && valid?(c - 1, a, b)
      rear, front, north, south = south - 1, north, rear, front
      y = 83
    #elsif west > 0 && valid?(b - 1, c, a)
    else
      rear, front, west, east = west - 1, east, front, rear
      y = 87
    end
     
    if best
      x = best[i]
      return best if x < y
      best = nil if x > y
    end
    path << y  
  end
  path
end
 
def find(target, limit)
  best = nil
  target.permutation(6).to_a.uniq.each do |rear, front, west, east, north, south|
    a = rear + front
    b = west + east
    c = north + south
    if valid?(a, b, c)
      best = calc(rear, front, west, east, north, south, limit, best)
    end
  end
  best
end
 
loop do
  target = gets.split.map!(&:to_i)
  break if target.all?(&:zero?)
  p, q = gets.split.map!(&:to_i)
  result = find(target, q)
  puts result ? result[p-1...q].pack('C*') : 'impossible'
end

Measured memory_bytes: 78092
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String[] ary = s.split("");
		int[] intAry = new int[4];
		
		for ( int i = 0; i < 4; i++ ) {
			intAry[i] = Integer.parseInt(ary[i]);
		}
		
		String first = String.format("%01d", intAry[0]);
		if ( intAry[0] + intAry[1] + intAry[2] + intAry[3] == 7) {
			System.out.println(first +"+"+ intAry[1] +"+"+ intAry[2] +"+"+ intAry[3] +"=7");
		} else if ( intAry[0] + intAry[1] + intAry[2] - intAry[3] == 7) {
			System.out.println(first +"+"+ intAry[1] +"+"+ intAry[2] +"-"+ intAry[3] +"=7");
		} else if ( intAry[0] + intAry[1] - intAry[2] - intAry[3] == 7) {
			System.out.println(first +"+"+ intAry[1] +"-"+ intAry[2] +"-"+ intAry[3] +"=7");
		} else if ( intAry[0] - intAry[1] - intAry[2] - intAry[3] == 7) {
			System.out.println(first +"-"+ intAry[1] +"-"+ intAry[2] +"-"+ intAry[3] +"=7");
		} else if ( intAry[0] - intAry[1] + intAry[2] + intAry[3] == 7) {
			System.out.println(first +"-"+ intAry[1] +"+"+ intAry[2] +"+"+ intAry[3] +"=7");
		} else if ( intAry[0] - intAry[1] - intAry[2] + intAry[3] == 7) {
			System.out.println(first +"-"+ intAry[1] +"-"+ intAry[2] +"+"+ intAry[3] +"=7");
		} else if ( intAry[0] - intAry[1] + intAry[2] - intAry[3] == 7) {
			System.out.println(first +"-"+ intAry[1] +"+"+ intAry[2] +"-"+ intAry[3] +"=7");
		} else if ( intAry[0] + intAry[1] - intAry[2] + intAry[3] == 7) {
			System.out.println(first +"+"+ intAry[1] +"-"+ intAry[2] +"+"+ intAry[3] +"=7");
		}
		
	}
}

Measured memory_bytes: 23636
//abc167_c.cpp
//Sun May 10 20:56:12 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;


int main(){
	int n,m,x;
	cin >> n >> m >> x;

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

	int ans = INTINF;
	for (int i=0;i<1<<n;i++){
		int acc[m];
		fill(acc,acc+m,0);
		int tmp = 0;
		for (int j=0;j<n;j++){
			if (i>>j&1){
				tmp+=c[j];
				for (int k=0;k<m;k++){
					acc[k]+=a[j][k];
				}
			}
		}
		if (ans > tmp){
			int flag = 1;
			for (int j=0;j<m;j++){
				if (acc[j]<x){
					flag = 0;
				}
			}
			if (flag){
				ans = tmp;
			}
		}
	}

	if (ans != INTINF){
		cout << ans << endl;
	}else {
		cout << -1 << endl;
	}
//	printf("%.4f\n",ans);
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<vi> d(n,vi(n));
    rep(i,n)rep(j,n){
        cin>>d[i][j];
    }
    rep(k,n)rep(i,n)rep(j,n){
        if (d[i][k]+d[k][j]<d[i][j]){
            cout<<"-1\n";
            return 0;
        }
    }
    ll ans=0;
    rep(i,n)rep(j,n){
        bool ng=false;
        rep(k,n)if(i!=k&&j!=k){
            if (d[i][k]+d[k][j]==d[i][j]){
                ng=true;
                break;
            }
        }
        if (!ng) ans+=d[i][j];
    }
    ans/=2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import numpy as np
a1 = np.array(input().split(),dtype=int)
a2 = np.array(input().split(),dtype=int)
a3 = np.array(input().split(),dtype=int)
n = int(input())
ban = []
for i in range(3):
    ban.append(a1[i])
for i in range(3):
    ban.append(a2[i])
for i in range(3):
    ban.append(a3[i])
b = [0 for i in range(9)]
for i in range(n):
    x = int(input())
    if x in ban:
        b[ban.index(x)] = 1

if b[0]+b[3]+b[6] == 3 or b[2]+b[5]+b[8] == 3 or b[1]+b[4]+b[7] == 3 or b[0]+b[1]+b[2] == 3 or b[3]+b[4]+b[5] == 3 or b[6]+b[7]+b[8] == 3 or b[0]+b[4]+b[8] == 3 or b[2]+b[4]+b[6] == 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 13204
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

N,M,X = inputIL()
A = inputIL()

p = bisect.bisect(A,X)
n = len(A)

print(min(p,n-p))

Measured memory_bytes: 38384
//
//  main_3.cpp
//  beginner20200412_1
//
//  Created by zer0 on 2020/04/12.
//  Copyright © 2020 zer0. All rights reserved.
//

#include <iostream>

int getgcd(int n, int m);
int gcd(int a, int b, int c);

int main(int argc, const char * argv[]) {
    
    int n;
    int total=0;
    std::cin >> n;
    
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int k=1; k<=n; k++){
                total = total+gcd(i, j, k);
            }
        }
    }
    
    std::cout << total;

    return 0;
}

int getgcd(int n, int m)
{
    int r;
    if (n > m) {
        int t = m;
        m = n;
        n = t;
    }
    while ((r = m % n) != 0) {
        m = n;
        n = r;
    }
    
    return n;
}

int gcd(int a, int b, int c)
{
    int g;
    g = getgcd(getgcd(a, b), c);
    return g;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int card[5];
    
    while(scanf("%d" ,&card[0])!=EOF){
        for(int i = 1 ; i < 5 ; i++){
            scanf(",%d" ,&card[i]);
        }
        
        int cnt = 0;
        for(int i = 0 ; i < 5 ; i++){
            for(int j = 0 ; j < 5 ; j++){
                if(card[i] == card[j] && i != j) cnt++;
                
            }
        }
        
        int flg = 0;
        switch(cnt){
            case 2:
                printf("one pair\n");
                flg = 2;
                break;
            case 4:
                printf("two pair\n");
                flg = 2;
                break;
            case 6:
                printf("three card\n");
                flg = 2;
                break;
            case 8:
                printf("full house\n");
                flg = 2;
                break;
            case 12:
                printf("four card\n");
                flg = 2;
                break;
            default:
                flg = 1;
        }
        
        if(flg == 2) continue;
        
        int ct=0;
        if(flg){
            sort(card,card+5);
            for(int i = 1 ; i < 5 ; i++){
                if(card[i]-card[i-1]==1) ct++;
            }
        }
        
        if(ct==4) printf("straight\n");
        else if(card[0]==1&&card[1]==10&&card[2]==11&&card[3]==12&&card[4]==13) printf("straight\n");
        else printf("null\n");
    }

    return 0;
}

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"



void Main()
{
	int N;
	cin>>N;
	vector<ull> A(N);
	rep(i,N){
		cin>>A[i];
		if(!A[i]){
			cout<<0<<_n;
			return;
		}
	}

	ull ans = 1;
	rep(i,N){
		if(ans > ((ll)1e18/A[i])){
			cout<<-1<<_n;
			return;
		}
		ans = (ull)A[i]*ans;
	}
	cout<<ans<<endl;
}



int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[2][N];
    for(int i = 0; i < N; i++)
        cin >> A[0][i];
    for(int i = 0; i < N; i++)
        cin >> A[1][i];
    ll dp[2][N];
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < N; j++) {
            dp[i][j] = 0;
            if(i > 0) {
                dp[i][j] = dp[i - 1][j];
            }
            if(j > 0) {
                dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            }
            dp[i][j] += A[i][j];
        }
    }
    cout << dp[1][N - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  @scala.annotation.tailrec
  def loop(chars: Seq[Char], acc: Seq[Char]): Int = chars match {
    case Seq() => acc.map(_.toString.toInt).sum
    case x :: xs if x == '9' => loop(xs, acc :+ x)
    case xs => xs.length * 9 + acc.map(_.toString.toInt).sum - 1
  }
  val sc = new java.util.Scanner(System.in)
  val x :: xs = sc.next().toCharArray.toList
  println(if (xs.isEmpty) x.toString else loop(xs, Seq(x)))
}


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

const int N = 1e6 + 5;

#define st first
#define nd second
#define make(a,b) make_pair(a,b)

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

int deg[N];
vector<int> G[N];

int skad[N];
int odp[N];

int odw[N];

bool vis[N];
bool cyc[N];
int vis2[N];

bool nieparz(int n, int y) {
	for (int x = 1; x <= n; x ++) {
		if (vis2[x] != y) continue;
		for (int y : G[x]) {
			if (odp[y] == odp[x] + 1) return true;
		}
	}
	return false;
}

bool algos(int n, int y) {
	int x = y;
	vis2[x] = x;
	int MIN = odp[x];
	int gdzie = x;
	while(vis2[skad[x]] == 0) {
		x = skad[x];
		vis2[x] = y;
		MIN = min(MIN, odp[x]);
		if (odp[x] == MIN) gdzie = x;
	}
// 	printf("algos\n");
// 	printf("x -- %d %d\n", x, odp[x]);
	x = gdzie;
	cyc[x] = true;
	int ile = 0;
	while(odp[skad[x]] == odp[x]) {
// 		printf("cyc %d\n", x);
		ile ++;
		if (cyc[skad[x]]) {
			if (ile % 2 == 1) {
				return false;
			}
			return true;
		}
		x = skad[x];
		cyc[x] = true;
	}
	while(cyc[skad[x]] == 0) {
		x = skad[x];
		cyc[x] = true;
	}
	return true;
}

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) {
		int a;
		scanf("%d", &a);
		skad[i] = a;
		G[a].push_back(i);
		deg[a] ++;
	}
	queue<int> kol;
	for (int i = 1; i <= n; i ++) {
		if (deg[i] == 0) kol.push(i);
	}
	while(!kol.empty()) {
		int x = kol.front();
		kol.pop();
		for (int y: G[x]) {
			odw[odp[y]] = x;
		}
		int i = 0;
		for (i = 0; odw[i] == x; i ++);
		odp[x] = i;
		deg[skad[x]] --;
		if (deg[skad[x]] == 0) {
			kol.push(skad[x]);
		}
		vis[x] = true;
	}
	int MIN = n + 1;
	for (int x = 1; x <= n; x ++) {
		if (vis[x]) continue;
		for (int y: G[x]) {
			if (vis[y]) odw[odp[y]] = x;
		}
		int i = 0;
		for (i = 0; odw[i] == x; i ++);
		odp[x] = i;
		MIN = min(MIN, i);
	}
	bool ans = true;
	for (int x = 1; x <= n; x ++) {
		if (vis[x] || vis2[x]) continue;
//		if (odp[x] == MIN) {
			if (not algos(n, x)) ans = false;
			//break;
//		}
	}
	printf("%sPOSSIBLE\n", not ans? "IM" : "");
}


Measured memory_bytes: 45312
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int M1,D1,M2,D2;
  cin >> M1 >> D1 >> M2 >> D2;
  if(D2 == 1) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cmath>
#include<complex>
#include<utility>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define mp         make_pair
#define pb         push_back

const int N = 10010;

class st{
public:
  short beg,end;
  bool operator<(const st &)const;
};

bool st::operator<(const st & a)const{
  if (beg != a.beg)return beg < a.beg;
  return end < a.end;
}

short  isexist[N]={0};
short testcase=0;
int x[N];
vector<st> inx[N];

int req[N];

void makedata(int n,int *x1,int *x2,int *y1,int *y2,
	      int &px,int *xd,vector<st> *IN){
  testcase++;
  rep(i,n){
    isexist[x1[i]]=testcase;
    isexist[x2[i]]=testcase;
  }
  rep(i,N)if (isexist[i]==testcase)x[px]=i,IN[px++].clear();
  //cout <<"allx ";rep(i,px)cout << x[i]<<" ";cout << endl;

  rep(i,n){
    int j=lower_bound(xd,xd+px,x1[i])-xd;
    while(j < px && xd[j] < x2[i]){
      bool isin=false;
      rep(k,IN[j].size()){
	short Y1 = y1[i],Y2=y2[i];
	short &Y3=IN[j][k].beg;
	short &Y4=IN[j][k].end;
	if (Y4 <= Y1 || Y2 <= Y3)continue;
	isin=true;
	Y3=min(Y1,Y3);
	Y4=max(Y2,Y4);
	break;
      }
      if (!isin)IN[j].pb((st){y1[i],y2[i]});
      j++;
    }
  }

}

pair<int,int> solve(int n,vector<st> *in,int *c){
  int area=0;
  int len=0;
  rep(i,n-1){
    if (in[i].size() == 0)continue;
    sort(in[i].begin(),in[i].end());
    short l=-1,h=-1;
    short width;
    width=c[i+1]-c[i];
    rep(j,in[i].size()){
      short &nowl=in[i][j].beg,&nowh=in[i][j].end;
      //cout << nowl <<" "<< nowh <<" " << l<<" " << h << endl;
      if (nowl > h){
	len+=2*width;
	//cout << c[i]<<" " << c[i]<<" " << nowh<<" " << nowl << endl;
	area+=(nowh-nowl)*width;
      }else if (nowl == h){
	//cout << c[i]<<" " << c[i]<<" " << nowh<<" " << nowl << endl;
	area+=(nowh-nowl)*width;
      }else if (nowh > h){
	//cout << c[i]<<" " << c[i]<<" " << nowh<<" " << h << endl;
	area+=(nowh-h)*width;
      }
      l=nowl;
      h=max(h,nowh);
    }
  }
  return mp(area,len);
}

main(){
  int n,q;
  static int x1[N],y1[N],x2[N],y2[N];
  while(cin>>n>>q && n){
    rep(i,n){
      cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
    }
    int px=0,py=0;
    makedata(n,x1,x2,y1,y2,px,x,inx);
    pair<int,int> ansx=solve(px,inx,x);

    cout << ansx.first << endl;
    if (q == 2){
      px=0;
      makedata(n,y1,y2,x1,x2,px,x,inx);
      pair<int,int> ansy= solve(px,inx,x);      
      cout << ansx.second+ansy.second << endl;
    }
    rep(i,px)inx[i].clear();
  }
  return false;
}

Measured memory_bytes: 1480
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	int n = M/N;
	int m = (int) (floor(sqrt(M)));
    
    int ans = 1;
    int i = 1;
    while(i<=n && i<=m)
    {
      if(M%i==0){
        if(M/i<=n) ans = max(ans,max(i,M/i));
        else ans = max(ans,i);
      }
      i++;
    }

    cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
from operator import mul
from functools import reduce
n,k = map(int,input().split())
ans = 0
mod = 10**9+7
def cmb(n, r):
    if r > n:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under
for i in range(1,k+1):
    cnt = cmb(n-k+1,i)* cmb(k-1, i-1)
    print(cnt%mod)

Measured memory_bytes: 70492
# お尻から見ていってはやく終わるを数え上げれば良い
N = int(input())
data = []
for _ in range(N):
    X, L = map(int, input().split())
    data.append((X-L, X+L))
data = sorted(data, key=lambda x: x[1])
count = 1
j = 0
for i in range(1, N):
    if data[i][0] >= data[j][1]:
        j = i
        count += 1
print(count)


Measured memory_bytes: 24724
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    for(int i = 1; i <= N; ++i){
        if(i*(i+1)/2 >= N){
            for(int j = 1; j <= i; j++){
                if(j == i*(i+1)/2 - N) continue;
                cout << j << endl;
            }
            return 0;
        }
    }
    return 0;
}
//Saw the editorial

Measured memory_bytes: 3616
//In the name of God

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

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

const int N = 50 , mod = 1e9+7 , L = 60;

#define int ll

int n , k;

typedef int Mat[N][N];

void print(Mat a){
   for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++)
         cout << a[i][j] << " ";
      cout << endl;
   }
}

Mat mat[L] , ret , hlp;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   cout << fixed << setprecision(9);
   cin >> n >> k;
   for(int i = 0 ; i < n ; i++)
      for(int j = 0 ; j < n ; j++){
         cin >> mat[0][i][j];
      }
   for(int i = 0 ; i < n ; i++)
      ret[i][i] = 1;
   if((k & 1) > 0)
      for(int i = 0 ; i < n ; i++)
         for(int j = 0 ; j < n ; j++)
            ret[i][j] = mat[0][i][j];
   for(int i = 1 ; i < L ; i++){
      for(int j = 0 ; j < n ; j++)
         for(int p = 0 ; p < n ; p++)
            for(int q = 0 ; q < n ; q++)
               (mat[i][j][p] += 1ll * mat[i - 1][j][q] * mat[i - 1][q][p] % mod) %= mod;
      if((1ll << i) > k)
         break;
      if((1ll << i) & k){
         for(int j = 0 ; j < n ; j++)
            for(int p = 0 ; p < n ; p++)
               hlp[j][p] = ret[j][p] , ret[j][p] = 0;
         for(int j = 0 ; j < n ; j++)
            for(int p = 0 ; p < n ; p++)
               for(int q = 0 ; q < n ; q++)
                  (ret[j][p] += 1ll * mat[i][j][q] * hlp[q][p] % mod) %= mod;
      }
   }
   int ans = 0;
   for(int i = 0 ; i < n ; i++)
      for(int j = 0 ; j < n ; j++)
         (ans += ret[i][j]) %= mod;
   cout << ans;
   return 0;
}


Measured memory_bytes: 1536
a = input().split()

n = int(a[0])
m = int(a[1])

b = input().split()

x = [int(i) for i in b]

s = sum(x)
lim = s / (m*4)

c = 0

for i in range(0,n):
    if(x[i] >= lim):
      c = c + 1
    else:
      continue

if(c >= m):
  print("Yes")
else:
  print("No")
      


Measured memory_bytes: 38256
import java.util.*;
class Main{
    public static void main(String[] a){
        StringBuilder buf = new StringBuilder();
        for(int i = 1; i < 10; i++) {
            for(int j = 1; j < 10; j++) {
                buf.append(i).append("x").append(j).append("=").append(i*j).append("\n");
            }
        }
        System.out.printf(buf.toString());
    }
}

Measured memory_bytes: 11000