akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        while(true){
        
        int a=sc.nextInt();
        String op=sc.next();
        int b=sc.nextInt();
        
        if (op.equals("?")) break;
        
        switch(op){
  
        case("+"):
        System.out.println(a+b); break;
        case("-"):
        System.out.println(a-b); break;
        case("*"):
        System.out.println(a*b);break;
        case("/"):
        System.out.println(a/b);break;
        
        }
        }
       
        }

    
}


Measured memory_bytes: 26376
/*2019/10/19 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return -1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return 1;}
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return 1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return -1;}
double to_deg(double r) {return r * 180.0 / (atan(1.0) * 4.0);}

int main(){
    int m1,d1,m2,d2;
    scanf("%d %d %d %d",&m1,&d1,&m2,&d2);
    if(d2==1){
        printf("1\n");
    }   else{
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,f,e) for(int (i)=(f); (i)<(e); (i)++)
#define repr(i,e,f) for(int (i)=(e-1); (i)>=(f); (i)--)

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

int main(){
    double N;
    cin >> N;
    cout << int(ceil(N/2)); 
    return 0;
}

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

using namespace std;

#define EPS 1e-10

struct Point{
    double x,y;

    Point(){}
    Point(double x,double y) : x(x),y(y) {}
    Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
    Point operator * (const double &k)const{ return Point(x*k,y*k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }
double dist(const Point &a,const Point &b){
    return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

int ccw(Point p0,Point p1,Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a,b) < -EPS) return CLOCKWISE;
    if(dot(a,b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool sortX(Point p1,Point p2){
    if(p1.x != p2.x){ 
        return (p1.x - p2.x < -EPS);
    }else{
        return (p1.y - p2.y < -EPS);
    }
}

bool sortY(Point p1,Point p2){
    if(p1.y != p2.y){
        return (p1.y - p2.y < -EPS);
    }else{ 
        return (p1.x - p2.x < -EPS);
    }
}

#define prev(G,i) (G[(i-1+G.size())%G.size()])
#define curr(G,i) (G[i%G.size()])
#define next(G,i) (G[(i+1)%G.size()])

typedef vector<Point> Polygon;

Polygon convex_hull(Polygon &ps){
    int N = ps.size(),j = 0;
    Polygon pg(N*2);
    sort(ps.begin(),ps.end(),sortY);
    for(int i = 0 ; i < N ; i++,j++){
        while(j >= 2 && ccw(pg[j-2],pg[j-1],ps[i]) == -1){
            j--;
        }
        pg[j] = ps[i];
    }
    int k = j+1;
    for(int i = N-2 ; i >= 0 ; i--,j++){
        while(j >= k && ccw(pg[j-2],pg[j-1],ps[i]) == -1){
            j--;
        }
        pg[j] = ps[i];
    }
    pg.resize(j-1);
    return pg;
}

double getPolygonDiameter(Polygon &p){
    Polygon np = convex_hull(p);
    int N = np.size();
    if(N == 2) return dist(np[0],np[1]);
    int i = 0,j = 0;
    for(int k = 0 ; k < N ; k++){
        if(!sortX(np[i],np[k])) i = k;
        if(sortX(np[j],np[k])) j = k;
    }
    double res = 0;
    int si = i,sj = j;
    while(i != sj || j != si){
        res = max(res,dist(np[i],np[j]));
        Point p1 = np[(i+1)%N]-np[i];
        Point p2 = np[(j+1)%N]-np[j];
        if(cross(p1,p2) < 0){
            i = (i + 1) % N;
        }else{
            j = (j + 1) % N;
        }
    }
    return res;
}


int main(){
    int N;
    cin >> N;
    Polygon pg(N);
    for(int i = 0 ; i < N ; i++){
        cin >> pg[i].x >> pg[i].y;
    }
    printf("%.12f\n",getPolygonDiameter(pg));
    return 0;
}

Measured memory_bytes: 4896
/*
AizuOnline A0517
Longest Steps
2013/01/01 TE
*/
#include <stdio.h>
// Select Below
#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n;
int data[100000];
//int data2[100000];
int runlen[100000];

int datalen;
int runlenlen;
//
#define DEBUG 1
#define max(x,y) (((x)>(y))?(x):(y))
int comp(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

void make_runlen(int start)
{
  int i;
  int last;
  int runlenindex;
  int dif;

  last=0;runlenindex=0;
  for(i=start;i<datalen;i++)
    {   
      if((dif=(data[i]- last))==1 || last==0)
	{
	  runlen[runlenindex]++;
	  if(i==datalen-1)
	    runlenindex++;
	}
      else
	{
	  runlen[++runlenindex]=dif-1;
	  ++runlenindex;
	  runlen[runlenindex]=1;
	}
      last=data[i];
    }
#ifdef DEBUGx
  printf("***\n");
  for(i=0;i<runlenindex;i++)
    printf("%d\n",runlen[i]);
  printf("---\n");
#endif
  runlenlen=runlenindex;
}

int wild()
{
  int i,maxrunlen;
  maxrunlen=0;
  for(i=1;i<runlenlen;i+=2)
    if(runlen[i]==1 && maxrunlen < runlen[i-1]+runlen[i+1]+1)
      maxrunlen=runlen[i-1]+runlen[i+1]+1;
  //printf("w:%d\n",maxrunlen);
  return(maxrunlen);
}

int no_wild()
{
  int i,maxrunlen;
  maxrunlen=0;
  for(i=0;i<runlenlen;i+=2)
    if(maxrunlen < runlen[i])
      maxrunlen=runlen[i];
  return(maxrunlen);
}
main()
{

  int i,ret;
 
  while(EOF != scanf("%d %d",&n,&datalen) && (n || datalen))
    {
      for(i=0;i<datalen;i++)
	scanf("%d",&(data[i]));

      qsort(data,datalen,sizeof(int),comp);


      
      if(data[0])            // No Zero(wildcard)
	{
	  make_runlen(0);
	  ret=no_wild();
	}
      else
	{
	  make_runlen(1);  
	  ret=max(wild(),no_wild()+1);
	}
      
      
      printf("%d\n",ret);
    }
return(0);
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
//#define P pair<int,int>
#define P pair<double,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to;double cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n;
double xs,ys,xt,yt,x[1010],y[1010],r[1010],d[1010];
vector<edge>v[1010];
void AddEdge(int i,int j){
	double X=x[j]-x[i],Y=y[j]-y[i];
	double dist=max((double)0.0,sqrt(X*X+Y*Y)-(r[i]+r[j]));
	v[i].pb({j,dist});
}
void dijkstra(){
	priority_queue<P,vector<P>,greater<P>>q;
	fill(d,d+n+2,1e18);
	d[0]=0.0;
	q.push({0,0});
	while(!q.empty()){
		P p=q.top();
		q.pop();
		for(edge e:v[p.se]){
			if(d[e.to]>d[p.se]+e.cost){
				d[e.to]=d[p.se]+e.cost;
				q.push({d[e.to],e.to});
			}
		}
	}
}	
signed main(){
	cin>>xs>>ys>>xt>>yt>>n;
	x[0]=xs,y[0]=ys,x[n+1]=xt,y[n+1]=yt;
	for(int i=1;i<=n;i++)cin>>x[i]>>y[i]>>r[i];
	rep(i,n+2){
		rep(j,n+2){
			if(i==j)continue;
			AddEdge(i,j);
		}
	}
	dijkstra();
	cout<<fixed<<setprecision(16)<<d[n+1]<<endl;
	return 0;
}


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

int main(void)
{
    long long n;
    cin >> n;
    long long a[n+1]={},b[n+1]={};
    long long sum=0;

    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        sum^=a[i];
    }
    for(int i=0;i<n;i++)
    {
        b[i]^=sum;
        b[i]^=a[i];
        cout << b[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 6692
if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))
    sunuke_sum = 0
    arai_sum = sum(a)
    ret = 2000000000
    for i in range(0, N - 1):
        sunuke_sum += a[i]
        arai_sum -= a[i]
        tmp_diff = abs(sunuke_sum - arai_sum)
        if tmp_diff < ret:
            ret = tmp_diff

    print(ret)


Measured memory_bytes: 23792
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    int ans = 0, end_flag = 0;
    while(1){
        for (int i = 0; i < N; i++) {
            if(A[i]%2 == 0) A[i]/=2;
            else{end_flag=1;break;}
        }
        if (end_flag == 1) break;
        ans+=1;
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int en(char a, vector<int> b) {
	if (a == 'a')return 0;
	else if (a == 'b')return 1;
	else if (a == 'c')return 2;
	else if (a == 'd')return 3;
	else if (a == 'e')return 4;
	else if (a == 'f')return 5;
	else if (a == 'g')return 6;
	else if (a == 'h')return 7;
	else if (a == 'i')return 8;
	else if (a == 'j')return 9;
	else if (a == 'k')return 10;
	else if (a == 'l')return 11;
	else if (a == 'm')return 12;
	else if (a == 'n')return 13;
	else if (a == 'o')return 14;
	else if (a == 'p')return 15;
	else if (a == 'q')return 16;
	else if (a == 'r')return 17;
	else if (a == 's')return 18;
	else if (a == 't')return 19;
	else if (a == 'u')return 20;
	else if (a == 'v')return 21;
	else if (a == 'w')return 22;
	else if (a == 'x')return 23;
	else if (a == 'y')return 24;
	else if (a == 'z')return 25;
}

int main() {

	string s, t;
	vector<int> S, T,sEN(26,0), tEN(26,0);
	cin >> s >> t;
	int ss = 1, tt = 1, l = s.length();
	FOR(i,l) {
		if (i == l - 1) {
			S.push_back(ss);
			T.push_back(tt);
		}
		else {
			if (s[i] == s[i + 1])ss++;
			else {
				S.push_back(ss);
				ss = 1;
			}
			if (t[i] == t[i + 1])tt++;
			else {
				T.push_back(tt);
				tt = 1;
			}
		}
	}

	bool ans = true;
	if (S.size() != T.size())ans = false;
	else {
		int L = S.size();
		FOR(i, L) {
			if (S[i] != T[i])ans = false;
		}
		FOR(i, l) {
			sEN[en(s[i], sEN)]++;
			tEN[en(t[i], tEN)]++;
		}
		SORT(sEN);
		SORT(tEN);
		FOR(i, 26) {
			if (sEN[i] != tEN[i])ans = false;
		}
	}

	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ld pi=3.141592653589793238;
void solve(){
	ll r;
	cin>>r;
	cout<<setprecision(100)<<(2*r*pi);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>

#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

int main(){
    int n,a[101],cnt=0;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    FOR(i,1,n){
        if(a[i]==a[i-1]){
            a[i]=10000+i;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <tuple>
#include <vector>
#include <algorithm>
#include <queue>

#define mp std::make_pair

typedef std::pair<int,int> P;
typedef std::pair<int,P> Q;

int N, M, L, K, A, H;
bool freeze[100];
std::vector<P> graph[100];
int dist[100][101];

// 0?????§??°?????????????????????

int main(){
    while(scanf("%d %d %d %d %d %d", &N, &M, &L, &K, &A, &H), N || M || L || K || A || H){
        for(int i=0;i<N;i++){freeze[i] = false;}
        for(int i=0;i<N;i++){graph[i].clear();}
        
        freeze[A] = 1;
        freeze[H] = 1;
        for(int i=0;i<L;i++){
            int f;
            scanf("%d", &f);

            freeze[f] = 1;
        }

        for(int i=0;i<K;i++){
            int x, y, t;
            scanf("%d %d %d", &x, &y, &t);

            graph[x].push_back(std::make_pair(y, t));
            graph[y].push_back(std::make_pair(x, t));
        }

        std::fill(&dist[0][0], &dist[0][0]+100*101, 25252125);        
        
        std::priority_queue<Q, std::vector<Q>, std::greater<Q>> queue;
        dist[A][M] = 0;
        queue.push(mp(0, mp(A, M)));
        
        while(!queue.empty()){
            Q q = queue.top();
            queue.pop();

            int t = q.first, x = q.second.first, h = q.second.second;

            if(dist[x][h] < t){continue;}

            if(freeze[x] && h + 1 <= M && dist[x][h+1] > t + 1){
                dist[x][h+1] = t + 1;
                queue.push(mp(t+1, mp(x, h+1)));
            }
        
            for(const P& e : graph[x]){
                int x_ = e.first, t_ = e.second;
                if(h - t_ >= 0 && dist[x_][h-t_] > t + t_){
                    // printf("%d -> %d(%d -> %d, %d)\n", x, x_, t, t+t_, h);
                    dist[x_][h-t_] = t + t_;
                    queue.push(mp(t+t_, mp(x_, h-t_)));
                }
            }
        }
        
        int res = 25252125;
        for(int i=0;i<=M;i++){
            if(dist[H][i] < 25252125){
                res = std::min(res, dist[H][i]);
            }
        }

        // for(int i=0;i<N;i++){
        //     for(int j=0;j<=M;j++){
        //         printf("%3d ", dist[i][j]);
        //     }
        //     puts("");
        // }
        
        if(res == 25252125){
            puts("Help!");
        }else{
            printf("%d\n", res);
        }
    }
}

Measured memory_bytes: 1300
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    a = sorted([A, B, C])
    print(a[2]*10+a[1]+a[0])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  a, b = map(int, readline().split())
  a_low = ceil(a/0.08)
  a_high = ceil((a+1)/0.08)
  s1 = {i for i in range(a_low, a_high)}
  b_low = ceil(b/0.1)
  b_high = ceil((b+1)/0.1)
  s2 = {i for i in range(b_low, b_high)}
  if s1&s2:
    print(min(s1&s2))
  else:
    print(-1)
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5580
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n, arr[1000000],count=0;
    cin>>n;
    for(int i=0;i<n;++i)
    cin>>arr[i];
    for(int i=1;i<n;++i)
    {
        if(arr[i]==arr[i-1])
            {
                count++;
                arr[i]=-1;
            }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
from math import isinf
n, e = map(int, stdin.readline().split())
d = [[float('inf')] * n for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for i in range(e):
    u, v, c = map(int, stdin.readline().split())
    d[u][v] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]
for i in range(n):
    if d[i][i] < 0:
        print("NEGATIVE CYCLE")
        exit(0)
for di in d:
    print(' '.join(('INF' if isinf(dij) else str(dij) for dij in di)))

Measured memory_bytes: 8256
n=int(input())
a=[]
for i in range(n):
    x,l=map(int,input().split())
    a.append([x-l,x+l])
a=sorted(a,key=lambda x: x[1])
ans=n
t=a[0][1]
for i in range(1,n):
    if a[i][0]<t:
        ans-=1
    else:
        t=a[i][1]
print(ans)

Measured memory_bytes: 22104
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int MAXN = 100005;
const int MOD = 1000000007;

int n,m,L,ans;
int x[MAXN];
int sum[MAXN];

bool mark[MAXN];

pair<int,int> l[MAXN];
pair<int,int> t[MAXN];

set<int> S;

bool cmp(const pair<int,int> &a,const pair<int,int> &b)
{
	return a.first == b.first ? a.second > b.second : a.first < b.first;
}

void modify(int p,int v)
{
	while (p <= L)
	{
		(sum[p] += v) %= MOD;
		p += p & -p;
	}
}

int query(int p)
{
	int res = 0;
	while (p >= 1)
	{
		(res += sum[p]) %= MOD;
		p -= p & -p;
	}
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i = 1;i <= n;i++)
		scanf("%d",&x[i]);
	for (int y,i = 1;i <= m;i++)
	{
		scanf("%d",&y);
		S.insert(y);
	}
	S.insert(-1e9);
	S.insert(2e9);
	for (int i = 1;i <= n;i++)
	{
		set<int>::iterator it = S.lower_bound(x[i]);
		l[i].first = (*it) - x[i];
		it--;
		l[i].second = x[i] - (*it);
	}
	for (int i = 1;i <= n;i++)
		if (l[i].first >= 1e9 || l[i].second >= 1e9)
		{
			swap(l[i],l[n]);
			i--;
			n--;
		}
	sort(l + 1,l + n + 1,cmp);
	for (int i = 1;i <= n;i++)
		mark[i] = (l[i].first == l[i - 1].first);
	for (int i = 1;i <= n;i++)
	{
		if (mark[i])
			l[i].first = l[i - 1].first;
		else
			l[i].first = ++L;
	}
	for (int i = 1;i <= n;i++)
		swap(l[i].first,l[i].second);
	sort(l + 1,l + n + 1,cmp);
	memcpy(t,l,sizeof(t));
	int N = 0;
	for (int i = 1;i <= n;i++)
	{
		if (t[i] == t[i - 1] || t[i].first >= 1e9 || t[i].second >= 1e9)
			continue;
		l[++N] = t[i];
	}
	n = N;
	for (int i = 1;i <= n;i++)
		modify(l[i].second,query(l[i].second - 1) + 1);
	printf("%d\n",(query(L) + 1) % MOD);
	return 0;
}

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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
string s;
int c=0;
bool balance(void){
  if(c<SZ(s) && s[c]=='('){
    ++c;
    bool flag=balance();
    if(c<SZ(s) && s[c]==')'){
      ++c;
      return flag&&balance();
    }
    else return false;
  }
  if(c<SZ(s) && s[c]=='['){
    ++c;
    bool flag=balance();
    if(c<SZ(s) && s[c]==']'){
      ++c;
      return flag&&balance();
    }
    else return false;
  }
  if(c<SZ(s) && s[c]!='(' && s[c]!=')' && s[c]!='[' && s[c]!=']'){
    ++c;
    return balance();
  }
  return true;
}
int main(void)
{
  for(;;){
    getline(cin,s);
    if(s==".") return 0;
    c=0;
    if(balance()&&c==SZ(s)) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
 
using namespace std;
 
 
int main(){
	#ifdef EVAL
		freopen("input.txt", "r", stdin);
		//freopen("output.txt", "w", stdout);
	#endif
	string S;
	string T;
	cin >> S >> T;
	set <int> s(S.begin(), S.end()), t(T.begin(),T.end());
	bool ok = true;
	for(char c : T){
		if(s.find(c) == s.end()){
			cout << -1;
			return 0;
		}
	}
	int ans = 1, last_index = -1;
	vector <int> cur(28,0);
	vector <int> adj[28];
	for(int i = 0; i < S.size(); i++){
		adj[S[i] - 'a'].push_back(i);
	}
	for(char c : T){
		int index = c - 'a';
		while(cur[index] < adj[index].size() && last_index >= adj[index].at(cur[index])){
			cur[index]++;
		}
		if(cur[index] == adj[index].size()){
			ans++;
			for(int &i : cur){
				i = 0;
			}
		}
		last_index = adj[index][cur[index]];
		cur[index]++;
	}
	cout << (ans * S.size()) - (S.size() - (last_index + 1));
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;
void solve()
{ll t,n,x,y,z,d=0,p=INT_MAX,q,l=INT_MAX,mini=0,prev;
  cin>>x>>y;
  if((x+y)%2==0)
  cout<<(x+y)/2;
  else
  cout<<"IMPOSSIBLE";
}

int main()
{
  fast
ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint X;
  cin>>X;
  while(X%100>=5)X-=105;
  if(X==0 or X>=100)cout<<1<<endl;
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int N;
	cin >> N;

	ll A[N];
	ll B[N];
	rep(i,N) {
		ll a;
		cin >> a;
		A[i] = B[i] = a;
	}

	sort(B,B+N);

	map<ll,int> mp;

	rep(i,N){
		mp[B[i]] = i % 2;
	}

	int ans = 0;

	rep(i,N){
		ll a = A[i];
		if(mp[a] != i % 2) ans++;
	}

	cout << (ans / 2) << endl;
}

Measured memory_bytes: 8064
#include <cstdio>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    char read[100100];
    int main()
    {
        scanf("%s",read);
        if(strlen(read) >= 4 && read[0] == 'Y' &&  read[1] == 'A' &&  read[2] == 'K' &&  read[3] == 'I')//YAKI
            puts("Yes");
        else puts("No");
    }

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

int N;

struct Book {
    int r,w;
    Book() {}
    Book(int r,int w) : r(r),w(w) {}
    bool operator<(const Book& b) const {
        return this->r < b.r;
    }

};
int dp[1003][1003];

void solve() {
    rep(i,1003) rep(j,1003) dp[i][j] = 0;
    vector<Book> book;
    book.resize(N);

    rep(i,N) {
        int a,b;
        cin>>a>>b;
        book[i] = Book(a,b);
    }
    sort(book.begin(), book.end());
    int sum = 0;
    rep(i,N) if(i!=N-1) sum += book[i].r;
    if(sum >= book[N-1].r) {
        sum += book[N-1].r;
        rep(i,N) sum += book[i].w;
        cout<<sum<<endl;
        return;
    }
    
    // i番目までで,時間jにできるか
    dp[0][0] = 1;
    rep(i,N-1) {
        rep(j,book[N-1].r-sum+1) {
            //cout<<i+1<<","<<j+book[i].w<<endl;
            dp[i+1][j] |= dp[i][j];
            dp[i+1][j+book[i].w] |= dp[i][j];
        }
    }
    int maxi = 0;
    rep(i,book[N-1].r-sum+1) {
        if(dp[N-1][i]) maxi = max(maxi,i);
    }
    
    int t = book[N-1].r - sum;
    t -= maxi;
    rep(i,N) t+=book[i].w;
    cout<<book[N-1].r+sum+t<<endl;

    

}

int main() {
    while(cin>>N) {
        if(N==0) return 0;
        solve();
    }

    return 0;
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

   int m[(1<<('z'-'a' +1))];
vector<pair<int,int>> k;
        signed main() {
     int n,k;
     cin>>n>>k;
     int ans=0;
     if(k==0){
             cout<<n*n;
             return 0;
     }
     for(int i=k+1;i<=n;i++){
             ans+=max(0ll,n%i -k+1)+(i-k)*(n/i);
            // cerr<<ans<<' ';
     }
     cout<<ans;

      
        


      }


        


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;



signed main()
{
    int A, B;
    char op;
    cin >> A >> op >> B;
    
    if (op == '+') {
        cout << A + B << endl;
    } else {
        cout << A - B << endl;
    }
}


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

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  long long int n,m;
  scanf("%lld %lld",&n,&m);
  if(n==1 && m==1){
    printf("%d",1);return 0;
  }
  if(n==1){
    printf("%lld",m-2);return 0;
  }
  if(m==1){
    printf("%lld",n-2);return 0;
  }
  printf("%lld",(n-2)*(m-2));
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
void solve(int T)
{
    int n;
    cin >> n;
    ll _10=1,_9=1,_8=1;
    for(int i=1;i<=n;i++)
    {
        _10 = _10*10%mod;
        _9 = _9*9%mod;
        _8 = _8*8%mod;
    }
    cout << ((_10-2*_9%mod+mod)%mod+_8)%mod;
}



signed main()
{
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main()
{
	int a,b,x;
	cin >> a >> b >> x;
	if(a+b>=x && a<=x)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


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



bool enough( int T, int A, int B, vector<int>& h )
{
    long long numNecessaryAtacks = 0;
    for( int i = 0; i < h.size(); ++i )
    {
        numNecessaryAtacks += max( 0LL, (h[i] - (long long) B*T + (A-B-1)) / (A - B) );
        
    }
    return numNecessaryAtacks <= T;
}



int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> h(N);
    for( int i = 0; i < N; ++i ) cin >> h[i];


    // 二分探索
    int l = 0, r = 1e+9;
    while( r-l > 1 )
    {
        int c = ( l + r ) / 2;
        if( enough(c, A, B, h) ) r = c;
        else l = c; 
    }
    cout << r << endl;

    return 0;
}

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
    long long n,buf,now;
    bool flag;
    int keta=1,cnt,cntt;
    cin>>n;
    buf=n;
    while(buf>=10){
        buf/=10;
        keta++;
    }
    keta*=9;
    //cout<<keta<<endl;
    
    while(true){
        buf=0;
        now=1;
        cnt=0;
        cntt=0;
        while(true){
            cnt++;cntt++;
            buf+=now;
            
            if(buf>n){ // 失敗
                //cout<<buf<<endl;
                flag=false;
                break;
            }
            if(cntt>=9){ // 桁を上がる
                now*=10;
                cntt=0;
            }
            if(cnt==keta){ // 成功
                flag=true;
                //cout<<buf<<endl;
                break;
            }
        }
        if(flag){
            break;
        }
        keta--;
    }
    
    cout<<keta<<endl;
    
    return 0;
}

Measured memory_bytes: 256
let rec solve() = 
  let rec input = function
    | 0 -> []
    | n -> Scanf.scanf "%d\n" (fun x -> x::input (n - 1)) in
  let rec ura i n = function
    | [] -> if i > n then [] else i::ura (i + 1) n []
    | w::d as q -> if i = w then ura (i + 1) n d else i::ura (i + 1) n q in
  let rec last p l a b =
    let rec can n = function
      | [] -> (0,[])
      | w::d -> if n < w then (w,d) else
          let (w1,w2) = can n d in
          (w1,w::w2) in

    let (pp,ll,aa,bb) = if p then
      let (w1,w2) = can l a in
      (false,w1,w2,b)
    else
      let (w1,w2) = can l b in
      (true,w1,a,w2) in
    if aa = [] || bb = [] then (List.length aa,List.length bb) else last pp ll aa bb in

  let n = Scanf.scanf "%d\n" (fun x -> x) in
  if n = 0 then () else begin
    let d1 = List.sort compare (input n) in
    let d2 = ura 1 (n * 2) d1 in
    let (a,b) = last true 0 d1 d2 in
    Printf.printf "%d\n%d\n" b a;
    solve() end

let _ = solve()

Measured memory_bytes: 2772
#include<bits/stdc++.h>    
#define int long long int
#define pb push_back
#define endl "\n"
#define F first
#define S second 
#define mod 1000000007     
using namespace std;

int powm(int x, int y){
    int res=1;
    x%=mod;
    while(y > 0){
        if(y & 1) res*=x, res%=mod;
        x*=x, x%=mod;
        y/=2;
    }
    return res;
}

main()
{    
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    int cnt[k + 1] = {0};
    for(int i = k; i >= 1; i--){
        cnt[i] = powm(k / i, n);
        for(int j = 2 * i; j <= k; j += i){
            cnt[i] -= (cnt[j] - mod);
            cnt[i] %= mod; 
        }
    }
    int fans = 0;
    for(int i = 1; i <= k; i++){
        fans += i * cnt[i];
        fans %= mod;
    }
    cout << fans << endl;
}

Measured memory_bytes: 4388
#include <stdio.h>

int main(void) {
	
	int i;
	int N;
	int a, b, c;
	
	scanf("%d", &N);
	
	for ( i = 0; i < N; i++){
		scanf("%d%d%d", &a, &b, &c);
		if( (a*a + b*b == c * c) || (b*b + c*c == a*a) || (c*c + a*a == b*b) )
			printf("YES\n");
		else
			printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
import sys
input = sys.stdin.readline
n = int(input())
f = []
for i in range(n):
  f.append(list(map(int, input().split())))
p = []
for i in range(n):
  p.append(list(map(int, input().split())))

cand = []
for i in range(1, 2 ** 10):
  cnt = [0] * n
  for j in range(10):
    if i & (1 << j):
      for k in range(n):
        if f[k][j]:
          cnt[k] += 1
  v = 0
  for k in range(n):
    v += p[k][cnt[k]]
  cand.append(v)
    
print(max(cand))
  

Measured memory_bytes: 42224
import bisect
N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
for i in range(N):
    upi = bisect.bisect_left(A, B[i])
    dwi = bisect.bisect_right(C, B[i])
    ans += upi*(N - dwi)

print(ans)

Measured memory_bytes: 23232
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    P = list(int(input()) for _ in range(n))
    cnt = [0] * (n + 1)
    for p in P:
        cnt[p] = cnt[p - 1] + 1

    res = n - max(cnt)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 81900
// https://atcoder.jp/contests/abc141/tasks/abc141_e
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

vector<int> z_algorithm(const string &s) {
    vector<int> prefix(s.size());
    for (int i = 1, j = 0; i < s.size(); i++) {
        if (i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while (i + k < s.size() && s[k] == s[i + k])
                ++k;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (int)s.size();
    return prefix;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string S;
    cin >> N >> S;
    int len = S.length(), maxv = 0;
    REP(d, len) {
        int cnt = 0;
        REP(i, len - d) {
            if (S[i] == S[i + d]) {
                cnt++;
            } else {
                maxv = max(maxv, min(cnt, d));
                cnt = 0;
            }
        }
        maxv = max(maxv, min(cnt, d));
    }
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative

sCal :: String -> String -> String -> Int
sCal a o b
  | o == "+"  = read a + read b
  | o == "-"  = read a - read b
  | o == "*"  = read a * read b
  | otherwise = read a `div` read b


main :: IO()
main = do
  (a:o:b:_) <- words <$> getLine
  unless (o == "?") $ do
    print $ sCal a o b
    main

Measured memory_bytes: 4096
#include<iostream>

using namespace std;

int main(){
	
	long long x;
	cin >> x;

	long long result = x / 11;

	if((x % 11) == 0){
		cout << result*2 << endl;
	}else if((x % 11) < 7){
		cout << result * 2 + 1 << endl;
	}else{
		cout << result * 2 + 2 << endl;
	}

	return 0;
}

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

uint64_t res(uint64_t x)
{
    if(x==1){
        return 1;
    } else if(x%2 == 1){
        return 1 + 2*res((x-1)/2);
    } else {
        return 1 + 2*res(x/2);
    }
}

int main()
{
    uint64_t H;
    cin >> H;
    cout << res(H) << endl;
	return 0;
}


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

const int N = 100;
const long int Max = pow(10, 10);

int setmatrixmulti(int p[], int n){
    int m[N+1][N+1];
    int minval;
    for(int l=1; l<=n; l++){
        for(int i=1; i<=n - l + 1; i++){
            int j = i + l - 1;
            m[i][j] = Max;
            if(i == j){
                m[i][j] = 0;
            } else {
                for(int k=i; k<j; k++){
                    m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
                }
            }
        }
    }
    minval= m[1][n];
    return minval;
}

int main(){
    int n, p1, p2;
    cin >> n;
    int p[n+1];
    for(int i=0; i<n; i++){
        cin >> p1 >> p2;
        if(i == 0){
            p[i] = p1;
            p[i+1] = p2;
        } else {
            p[i+1] = p2;
        }
    }

    // for(int i=0; i<n+1; i++){
    //     cout << p[i] << " " ;
    // }

    int ans = setmatrixmulti(p, n);
    cout << ans << endl;

    return 0;
}


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

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

    int N; cin >> N;

    vector<int> W(N);
    rep(i,N) cin >> W[i];

    int sum = accumulate(W.begin(), W.end(), 0);

    int n = 0;
    int min = 10000000;
    rep(i,N) {
        n += W[i];
        if (min > abs(sum - 2 * n)) min = abs(sum - 2 * n);
    }

    cout << min << endl;
    
    return 0;
}


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

saidai = 0
ans = 0
for i in range(1, N):
    if H[i-1] >= H[i]:
        ans += 1
    else:
        ans = 0
    saidai = max(saidai, ans)
    
print(saidai)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

int check(int N) {
    bool flag = false;
    int k = 2, index = -1;
    repd(i, 1, N + 1) {
        if (i == N) {
            flag = true;
            index = k - 1;
            break;
        }
        i += (k - 1);
        k++;
    }

    return index;
}

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

    int index = check(N);
    if (index != -1) {
        vector<vector<int>> ans(index + 1, vector<int>(index));
        int s = 1;
        rep(i, index) {
            rep(j, i + 1) {
                ans[j][i] = s;
                s++;
            }
        }

        s = 1;
        rep(i, index) {
            rep(j, i + 1) {
                ans[i + 1][j] = s;
                s++;
            }
        }

        cout << "Yes" << endl << index + 1 << endl;
        rep(i, index + 1) {
            cout << index << " ";
            rep(j, index - 1) {
                cout << ans[i][j] << " "; 
            }
            cout << ans[i][index - 1] << endl;
        }
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            decimal iN = decimal.Parse(sS[0]);
            decimal iM = decimal.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            // 結果が偶数になる為には偶偶or奇奇で取らないといけない。
            // 偶数のみから2個取る方法と奇数のみから2個取る方法の加算でよい
            decimal iEvn = 0, iOdd = 0; ;
            if (iN >= 2) { iEvn = iN * (iN - 1) / 2M; }
            if (iM >= 2) { iOdd = iM * (iM - 1) / 2M; }
            decimal iOut = iEvn + iOdd;

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<unsigned long long> L(N+1);
  
  
  L[0] = 2;
  L[1] = 1;
  for(int i = 2; i < N+1; i++){
    L[i] = L[i-1] + L[i-2];
  }
  cout << L[N];
}


Measured memory_bytes: 256
function main(input) {
    var n = input[0].split(" ")[0]-0;
    var k = input[0].split(" ")[1]-0;
    var ans = 0;
    for(var i=1;i<n;i+=k-1) {ans++;}
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));


//1 2 3 4 5 6


Measured memory_bytes: 8012
from sys import stdin
readline = stdin.readline


def main():
    x1, y1, x2, y2 = map(int, readline().split())
    p1, p2 = x1 + y1 * 1j, x2 + y2 * 1j
    for i in range(int(readline())):
        xi, yi = map(int, readline().split())
        pi = xi + yi * 1j
        cross = p1 + (p2 - p1) * projecter(p2 - p1, pi - p1)
        print('{:.10f} {:.10f}'.format(cross.real, cross.imag))


def projecter(a, b):
    return dot(a, b) / dot(a, a)


def dot(a, b):
    return a.real * b.real + a.imag * b.imag
main()

Measured memory_bytes: 6756
#include <stdio.h>

int main(void) {
	int N;
	int a[128];
	int max, min;
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	max = min = a[0];
	for (i = 1; i < N; i++) {
		if (a[i] < min) min = a[i];
		if (a[i] > max) max = a[i];
	}
	printf("%d\n", max - min);
	return 0;
}


Measured memory_bytes: 128
def main(argv)
  (h, w) = gets.chomp.split(' ').map(&:to_i)
  a = [''] * h
  h.times{ |y| a[y] = gets.chomp }

  flag = false
  prev = [nil] * h
  h.times{|y| prev[y] = [nil] * w}
  q = []
  q.push({:x => 0, :y => 0})
  while (not q.empty?) do
    src = q.shift

    if (src[:x] == (w - 1)) and (src[:y] == (h - 1)) then
      flag = true
    end

    [
      {:x => src[:x] + 1, :y => src[:y]    },
      {:x => src[:x],     :y => src[:y] + 1}
    ].each do |dst|
      next unless ((dst[:x] < w) and (dst[:y] < h))
      if a[dst[:y]][dst[:x]] == '#' then
        q.push(dst.dup) 
        prev[dst[:y]][dst[:x]] = src
      end
    end
  end

  unless flag then
    puts 'Impossible'
    return
  end

  b = [''] * h
  h.times{ |y| b[y] = '.' * w }
  b[0][0] = '#'
  cur = {:x => w - 1, :y => h - 1}
  while not ((cur[:x] == 0) and (cur[:y] == 0)) do
    b[cur[:y]][cur[:x]] = '#'
    cur = prev[cur[:y]][cur[:x]]
  end

  if a == b then
    puts 'Possible'
  else
    puts 'Impossible'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 4348
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

/*lld fac[100001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}*/


lld gcd(lld a,lld b)
{
    if(a>b) return gcd(b,a);
    if(b%a==0) return a;
    else return gcd(b%a,a);
}

lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;



void solve()
{
    lld a,b;
    char c;
    cin>>c;
    if(c>='A' && c<='Z') cout<<"A";
    else cout<<"a";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
       cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        boolean[] navail=new boolean[n+1];
        for(int i=0;i<m;i++){
            navail[sc.nextInt()]=true;
        }
        int mod=1000000007;
        long[] ans=new long[n+1];
        ans[0]=1;
        if(!navail[1])ans[1]=1;
        for(int i=2;i<n+1;i++){
            if(navail[i])continue;
            ans[i]=ans[i-1]+ans[i-2];
            ans[i]%=mod;
        }
        System.out.println(ans[n]);
    }
}

Measured memory_bytes: 48108
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n;
	cin>>n;
	ll a[n+1][3];
	for(ll i=1;i<=n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	ll dp[n+1][3];
	memset(dp,0,sizeof(dp));
	for(ll i=1;i<=n;i++){
		dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
		dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
		dp[i][2]=max(dp[i-1][0]+a[i][2],dp[i-1][1]+a[i][2]);
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
	return 0;
}


Measured memory_bytes: 4992
n = int(input())
a = list(map(int, input().split()))
min_ = 1e9
flag = 0
ans = 0
for e in a:
  if e<0:
    flag = (flag+1) % 2
  if min_>abs(e):
    min_ = abs(e)
  ans += abs(e)
if flag:
  print(ans-min_*2)
else:
  print(ans)

Measured memory_bytes: 14412
#include<stdio.h>
main(){
	unsigned int a,b,n,m,c,tmp;
	
	double n1,n2;
	
	while(1){
		if(scanf("%d %d",&a,&b) == EOF) break;
		
		//最大公約数 (n)
		n=a; m=b;
		if(a<b){ n=b; m=a; }
		
		while(m != 0){
			tmp=n%m;
			n=m;
			m=tmp;
		}
		
		//最小公倍数 (c)
		
		c = (a/n) * b;
		
		printf("%d %d\n",n,c);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int a[N];
struct node
{
    int c,x;
    bool operator <(const node& b)const
    {
        return x>b.x;
    }
}b[N];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&b[i].c,&b[i].x);
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+m);
    int p=1;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>=b[p].x || p>m)break;
        a[i]=b[p].x;
        b[p].c--;
        if(b[p].c==0)p++;
    }
    ll sum=0;
    for(int i=1;i<=n;i++)sum+=a[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 1408