akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
public class Main {
 
    private static final int BIG_NUM  = 2000000000;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int H,W;
 
        String work[] = new String[2];
 
        while(true){
 
            try {
                work = br.readLine().split("[\\s]+");
                if(work[0].equals("0") && work[1].equals("0"))break;
 
                H = Integer.parseInt(work[0]);
                W = Integer.parseInt(work[1]);
 
                for(int row = 0; row < H; row++){
                    for(int col = 0; col < W; col++){
                        System.out.printf("#");
                    }
                    System.out.printf("\n");
                }
 
                System.out.printf("\n");
 
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}



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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int A[N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, l; cin >> n >> l;
	for (int i = 0; i < n; i++) cin >> A[i];
	int x = n;
	for (int i = 0; i + 1 < n; i++) if (A[i] + A[i + 1] >= l) x = i;
	if (x == n) die("Impossible");
	cout << "Possible" << endl;
	for (int i = 0; i < x; i++) cout << i + 1 << endl;
	for (int i = n - 2; i >= x; i--) cout << i + 1 << endl;

	return 0;
}


Measured memory_bytes: 1280
N=int(input())
L=list(map(int,input().split()))
l=sorted(L)
if N%2==0:
  n=int(N/2)
  a=l[n-1]
  b=l[n]
  if a==b:
    print('0')
  else:
    print(b-a)
    
else:
  print('0')

Measured memory_bytes: 14556
#include "bits/stdc++.h"
using namespace std;

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

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 5e5+10;

ll w[N];
ll v[N];
ll dp[N];

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

fill(dp,0);
ll ans = 0;
for(int i=0;i<n;i++) {
    for(int wt = W; wt>=w[i];wt--) {
        dp[wt]=max(dp[wt], v[i]+dp[wt-w[i]]);
        ans=max(ans,dp[wt]);
    }
}

cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 7528
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n;
double r;
double x[100],x2[100],h[100];
double EPS=0.0001;
bool che(double t){


for(int i=-r;i<r;i++){
	int a=i,b=i+1;//aとb両方でのyを求める[a,b]内で最大の高さの長方形を求める
	 int in=-1;
		double ma=-1,y1,y2;
		for(int j=0;j<n;j++){
			if(x[j]<=a&&b<=x2[j]&&ma<h[j]){
				ma=h[j];	
				in=j;
			}
		}
		y1=sqrt(r*r-a*a)+t-r;
		y2=sqrt(r*r-b*b)+t-r;
		//cout<<a<<" "<<b<<" "<<y1<<" "<<y2<<endl;
		if(!(h[in]>=y1&&h[in]>=y2))return 0;
}

	return 1;
}

/*
for(int i=0;i<n;i++){
	double lx=x[i],rx=x2[i];
	if(lx<-r|| rx>r)continue;
	double ny=t-r;
	double y1,y2;
	y1=sqrt(r*r-lx*lx)+ny;
	y2=sqrt(r*r-rx*rx)+ny;

	//cout<<y1<<" "<<y2<<" "<<h[i]<<endl;
	if(!(h[i]>=y1&&h[i]>=y2))return 0;
	}
*/

int main(){
while(cin>>r>>n,r||n){
rep(i,n)cin>>x[i]>>x2[i]>>h[i];



double mid=0,l=0,r=100;
mid=(r+l)/2;
for(int i=0;i<20;i++){
	if(che(mid)){
		l=mid;
	}
	else{
		r=mid;
	}
	mid=(r+l)/2;
}

printf("%.20lf\n",mid);
rep(i,n)x[i]=x2[i]=h[i]=0;

}

	return 0;
}


Measured memory_bytes: 3208
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/






int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int ret = (abs(h1-h2) + 1) * 60;
  ret -= m1;
  ret -= 60 - m2;
  ret -= k;
  cout << ret << endl;






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 3192
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
ll lcm(ll a,ll b)
{
  return (a*b)/__gcd(a,b);
}
int main()
{
  // int x = -1, y = 10000;
  // double z = 0.2;
  // string s2 = "beginner1010";
  // long long b = 1LL << 60;
    
  // // debug(x, y, z, s, b);
    
  // double aux = 1010.0;
  // string code = "code";
    
  // debug(code + "forces",-aux / 10 * 2.3);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,k;
  cin >> n >> k;
  vector <double> v(n);
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin >> a;
    double m = a*(a+1)/2.0;
    m = m/(a*1.0);
    v[i] = m;
  }
  for (int i = 1; i < n; ++i)
  {
    v[i] += v[i-1];
  }
  double ans = v[k-1];
  for (int i = k; i < n; ++i)
  {
    ans = max(ans,v[i]-v[i-k]);
  }
  printf("%.10f",ans);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

double distance(const vector<double>& a, const vector<double>& b)
{
    double d = 0;
    for(size_t i = 0; i < a.size(); ++i)
    {
        d += (a[i] - b[i]) * (a[i] - b[i]);
    }
    return sqrt(d);
}

int main()
{
    int n,d;
    cin >> n >> d;
    vector<vector<double>> xs(n, vector<double>(d, 0.0));
    for(auto& r : xs)
    {
        for(auto& x : r)
        {
            cin >> x;
        }
    }
    
    int count = 0;
    
    for(int i = 0; i < n; i++)
    {
        for(int j = i+1; j < n; j++)
        {
            double d = distance(xs[i], xs[j]);
            if(d == (int)d)
            {
                count += 1;
            }
        }
    }
    
    cout << count << '\n';

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  rep(i, 0, S.size() / 2) {
    if (S[i] != S[S.size() - 1 - i]) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
#define fi first
#define sec second
#define INF 1000000000
const int SIZE = 1<<20;
struct segtree{
	int seg[SIZE*2];
	segtree(){
		for(int i=0;i<SIZE*2;i++){
			seg[i] = INF;
		}
	}
	void update(int k,int x){
		k += SIZE-1;
		seg[k] = min(seg[k],x);
		while(k>0){
			k = (k-1)/2;
			seg[k] = min(seg[k*2+1],seg[k*2+2]);
		}
	}
	int query(int a,int b,int k,int l,int r){
		if(r<=a||b<=l)return INF;
		if(a<=l&&r<=b)return seg[k];
		int mid = (l+r)/2;
		return min(query(a,b,k*2+1,l,mid),query(a,b,k*2+2,mid,r));
	}
}seg;
bool comp(P a,P b){
	if(a.sec!=b.sec)return a.sec < b.sec;
	else return a.fi < b.fi;
}
int N;
ll L;
vector<ll> zip;
vector<P> vec;
int dp[400100];
int rui[400100];
int main(){
	cin >> N >> L;
	zip.pb(L);
	vec.resize(N);
	for(int i=0;i<N;i++){
		cin >> vec[i].fi >> vec[i].sec;
		zip.pb(vec[i].fi);
		zip.pb(vec[i].sec);
	}
	zip.pb(0ll);
	sort(zip.begin(),zip.end());
	zip.erase(unique(zip.begin(),zip.end()),zip.end());
	for(int i=0;i<N;i++){
		vec[i].fi = lower_bound(zip.begin(),zip.end(),vec[i].fi)-zip.begin();
		vec[i].sec = lower_bound(zip.begin(),zip.end(),vec[i].sec)-zip.begin();
		rui[vec[i].fi]++;
		rui[vec[i].sec]--;
	}
	sort(vec.begin(),vec.end(),comp);
	// for(int i=0;i<vec.size();i++){
	// 	cout << vec[i].fi << ' ' << vec[i].sec << endl;
	// }
	for(int i=1;i<=zip.size();i++){
		dp[i] = INF;
	}
	dp[0] = 0ll;
	seg.update(0,dp[0]);
	for(int i=0;i<vec.size();i++){
		int l = vec[i].fi;
		int r = vec[i].sec;
		dp[r] = min(dp[r],seg.query(l,r,0,0,SIZE)+1);
		seg.update(r,dp[r]);
	}
	for(int i=1;i<zip.size();i++){
		rui[i] += rui[i-1];
	}
	int mi = INF;
	for(int i=0;i+1<zip.size();i++){
		mi = min(mi,rui[i]);
	}
	cout << dp[zip.size()-1] << ' ' << N-mi+1 << endl;
	return 0;
}



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

using namespace std;

int main(){
	string a;
	cin >> a;
	for(int i = 0 ; i < a.size(); i++){
		if(a[i] == '1')
			cout << '9';
		else
			cout << '1';
	}
	cout << endl;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  const int N = S.size();
  vector nxt(400, vector(N, 0));
  for (int i = 0; i < N; i++) {
    nxt[0][i] = S[i] == 'R' ? i + 1 : i - 1;
  }
  for (int k = 0; k + 1 < 400; k++) {
    for (int i = 0; i < N; i++) {
      nxt[k + 1][i] = nxt[k][nxt[k][i]];
    }
  }
  vector<int> res(N, 0);
  for (int i = 0; i < N; i++) {
    res[nxt[350][i]]++;
  }
  for (const auto& e : res) {
    cout << e << (&e == &res.back() ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 160656
# -*- coding: utf-8 -*-
"""
Created on Sun Oct  6 07:53:11 2019

@author: avina
"""
from queue import PriorityQueue as Q
n,m = map(int, input().split())
l = []
for i in range(n):
    a,b = map(int, input().split())
    l.append((a,b))
l.sort()
ans = 0
a = Q()
nxt = 0
for i in range(0,m+1):
    while nxt < n and l[nxt][0] == i:
        a.put(-l[nxt][1])
        nxt+=1
    
    if a.qsize() != 0:
        b = a.get()
        ans+=(-1*b)
        #print(b)
        
        
print(ans)


Measured memory_bytes: 21552
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    a = LI()

    print(max(a) - min(a))

if __name__ == '__main__':
    resolve()


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    string s;
    int MIN = 1000;
    cin >> s;
    for(int i = 0; i < s.length() - 2; i++){
        string temp;
        temp = s[i];
        int temp1 = stoi(temp);
        temp = s[i + 1];
        int temp2 = stoi(temp);
        temp = s[i + 2];
        int temp3 = stoi(temp);
        int num = temp1 * 100 + temp2 * 10 + temp3;
        int test = abs(num - 753);
        MIN = min(MIN, test);
    }
    print(MIN);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;
vector<tuple<string, int, int>> v;

int main() {
	cin >> n;
	inc(i, n) {
		string s;
		int p;
		cin >> s >> p;
		v.EB(s, -p, i + 1);
	}
	sort(ALL(v));
	
	inc(i, n) { cout << (get<2>(v[i])) << endl; }
	
	return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 1");
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 -2");
            //6
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("0 0");
            //0
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int A = wkArr[0];
        int B = wkArr[1];
        int Calc1 = A + B;
        int Calc2 = A - B;
        int Calc3 = A * B;

        int Answer = Math.Max(Calc1, Calc2);
        Answer = Math.Max(Answer, Calc3);
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 13396
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        int x = sc.nextInt();
        
        int res = Math.abs(sc.nextInt()-x);
        
        for(int i = 1; i < n; i++){
            res=gcd(res, Math.abs(sc.nextInt()-x));
        }
        
        System.out.println(res);
    }
    
  static int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a%b);
  }

}


Measured memory_bytes: 48320
#include <stdio.h>

int main()
{
  int H,W,j,i;
  
  while(1){
    
    scanf("%d", &H);
    
    scanf("%d", &W);
    
    
    
    if(H == 0 && W == 0)
      break;
    
    
    
    for(i = 1; i <= H; i++)
      {
	for(j = 1; j <= W; j++)
	  { 
	    if(i%2==0 && j%2==0){
	      printf("#");
	    }else if( i%2!=0 && j%2!=0){
	      printf("#");
	    }else
	       {
		 printf(".");
	       }
	  }
	printf("\n");
      }
    printf("\n");
  }      
  
  
  return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#define PI 3.14159265358979

using namespace std;

int main(){
  int n;
  cin >> n;
  double x[n],y[n];
  for(int i=0;i < n;i++){
    cin >> x[i];
  }
  for(int i=0;i < n;i++){
    cin >> y[i];
  }
  double dist1 = 0,dist2 = 0,dist3 = 0,dist_inf = 0;

  //n = 1
  for(int i=0;i < n;i++){
    dist1 += abs(x[i] - y[i]);
  }

  //n = 2
  for(int i=0;i < n;i++){
    dist2 += (x[i] - y[i])*(x[i] - y[i]);
  }
  dist2 = sqrt(dist2);

  //n = 3
  for(int i=0;i < n;i++){
    dist3 += abs((x[i] - y[i])*(x[i] - y[i])*(x[i] - y[i]));
  }
  dist3 = cbrt(dist3);

  //n = ∞
  for(int i=0;i < n;i++){
    dist_inf = max(dist_inf,abs(x[i] - y[i]));
  }
  printf("%.8lf\n",dist1);
  printf("%.8lf\n",dist2);
  printf("%.8lf\n",dist3);
  printf("%.8lf\n",dist_inf);
  
  return 0;
}


Measured memory_bytes: 3416
import math
N,M=list(map(int,input().split()))
x=math.factorial(N)*math.factorial(M)%(10**9+7)
if(abs(N-M)>1):
    print(0)
else:
    if((N%2==0 and M%2==0) or N==M):
        print(x*2%(10**9+7))
    else:
        print(x)

Measured memory_bytes: 5184
#include <iostream>
#include <stack>
#include <vector>
using namespace std;

int main(){
	int n;
	stack<int> t;
	vector<int> a;
	while(cin>>n){
		if(n==0){
			a.push_back(t.top());
			t.pop();
		}
		else{
			t.push(n);
		}
	}
	for(int i=0;i<a.size();i++){
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define ll long long
#define maxn 100005
using namespace std;
int arr[maxn];
int n,a,b;
bool check(ll mid) {
	ll base = (1e9 / b + 1 >= mid ? b * mid : 1e9) , dif = a - b;
	for(int i=1;i<=n;i++)
		if(arr[i] > base)
			mid -= ((ll)arr[i] - base - 1) / dif + 1;
	return mid >= 0;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> a >> b;
	for(int i=1;i<=n;i++)
		cin >> arr[i];
	ll l = 1 , r = (ll)1e14 , mid;
	while(true) {
		if(r - l < 3) {
			for(mid=r;mid>=l && check(mid);mid--);
			mid++;
			break;
		}
		mid = (l+r)>>1;
		if(check(mid))
			r = mid;
		else
			l = mid + 1;
	}
	cout << mid << endl;
	return 0;
}


Measured memory_bytes: 640
/*            AUTHOR - SHIVAM GUPTA
                       Jalpaiguri Govt. Engg College             */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<ll> ve[100005];
const ll p = 1e9+7;

pair<ll,ll> dfs(ll nd,ll par)
{
    if(ve[nd].size()==1 and ve[nd][0]==par)
        return(make_pair(1,1));
    
    ll b=1,w=1;
    for(auto next : ve[nd])
    {
        if(next!=par)
        {
            pair<ll,ll> dp = dfs(next,nd);
            b = (b*dp.second)%p;
            w = (w *( dp.first + dp.second)%p )%p;
        }
    }
    return (make_pair(b,w));
}

void solve()
{
    vector<ll> v;        vector<pair <ll,ll>> vp;
    ll n=0,m=0,i=0,j=0,k=0,c=0,l=0,r=0,q=0,x=0,y=0,z=0,flag=0,sum=0;
    cin>>n;
    for(i=0;i<n-1;i++)
    {
        cin>>l>>r;
        ve[l].push_back(r);
        ve[r].push_back(l);
    }
    pair<ll,ll> ans = dfs(1,-1);
    
    cout<< ( ans.first + ans.second ) % p;
}
bool imp=false;int main()
{
    fio;
    int t=1;
    if(imp)
	cin>>t;
	ll j=t;
    while(t--){
    // cout<<"Case #"<<j-t<<": ";
    solve();}
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll A, B;
    cin >> A >> B;

    REP(i, 100000){
    	ll a = i * 0.08;
    	ll b = i * 0.1;
    	if(a==A && b==B){
    		cout << i << endl;
    		return 0;
    	}
    }
    cout << -1 << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a, max=0, min=1001;
    for(int i=0; i<n; i++) {
        cin >> a;
        if(max<a) max = a;
        if(min>a) min = a;
    }
    cout << max-min << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define endl '\n'
using namespace std;
const int N = 1e5 + 5;
const ll INF = 1e14;

int n, E, T, x[N];
ll dp[N];

ll val[4 * N], lazy[4 * N];
void refresh(int pos, int low, int high)
{
    if(!lazy[pos])
        return;

    val[pos] += lazy[pos];
    if(low < high)
    {
        lazy[pos * 2] += lazy[pos];
        lazy[pos * 2 + 1] += lazy[pos];
    }
    lazy[pos] = 0;
}

void add_interval(int pos, int low, int high, int l, int r, ll d)
{
    refresh(pos, low, high);
    if(l > high || r < low)
        return;
    if(l <= low && r >= high)
    {
        lazy[pos] += d;
        refresh(pos, low, high);
        return;
    }

    int mid = (low + high) / 2;
    add_interval(pos * 2, low, mid, l, r, d);
    add_interval(pos * 2 + 1, mid + 1, high, l, r, d);

    val[pos] = min(val[pos * 2], val[pos * 2 + 1]);
}

void upd_at(int pos, int low, int high, int id, ll x)
{
    refresh(pos, low, high);
    if(low == high)
    {
        val[pos] = x;
        return;
    }

    int mid = (low + high) / 2;
    if(id <= mid)
        upd_at(pos * 2, low, mid, id, x);
    else
        upd_at(pos * 2 + 1, mid + 1, high, id, x);

    val[pos] = min(val[pos * 2], val[pos * 2 + 1]);
}

ll query(int pos, int low, int high, int l, int r)
{
    refresh(pos, low, high);
    if(l > high || r < low)
        return INF;
    if(l <= low && r >= high)
        return val[pos];

    int mid = (low + high) / 2;
    return min(query(pos * 2, low, mid, l, r), query(pos * 2 + 1, mid + 1, high, l, r));
}

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

    cin >> n >> E >> T;
    for(int i = 1; i <= n; i++)
        cin >> x[i];

    upd_at(1, 0, n, 0, T);
    for(int i = 1; i <= n; i++)
        upd_at(1, 0, n, i, INF);


    int leftmost_waiting = 0;
    for(int i = 1; i <= n; i++)
    {
        if(leftmost_waiting < i)
            add_interval(1, 0, n, leftmost_waiting, i - 1, 2LL * (x[i - 1] - x[i]));

        while(leftmost_waiting < i)
        {
            if((ll)T + 2LL * x[leftmost_waiting + 1] - 2LL * x[i] <= 0)
            {
                ll current_val = query(1, 0, n, leftmost_waiting, leftmost_waiting);
                current_val -= (ll)T + 2LL * x[leftmost_waiting + 1] - 2LL * x[i];
                upd_at(1, 0, n, leftmost_waiting, current_val);

                leftmost_waiting++;
            }
            else
                break;
        }


        dp[i] = query(1, 0, n, 0, i - 1) + 3LL * x[i];
        ll optimizing = dp[i] - (2LL * x[i + 1] + x[i]) + T + 2LL * (x[i + 1] - x[i]);
        upd_at(1, 0, n, i, optimizing);
    }


    cout << dp[n] + E - x[n] << endl;


    return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
 
#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
 
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  LL N, M;
while(
  cin >> N >> M,N){
  VL xs(N);
  REP(i,N) cin >> xs[i];
  ++N;
  xs.PB(0);
 
  VL cand;
  REP(i,N) REP(j,N){
	cand.PB(xs[i] + xs[j]);
  }
  SORT(cand);
 
  LL ans = 0;
  for(LL x: cand){
	if(x > M) continue;
	auto it = upper_bound(ALL(cand), M-x);
	--it;
	maxi(ans, x + *it);
  }
  cout << ans << endl;
 }
  return 0;
}

Measured memory_bytes: 19056
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int H, W;
    scan(H, W);
    int h, w;
    scan(h, w);
    auto ans = (H - h) * (W - w);
    writeln(ans);
}





















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        string s;
        cin >> s;

        if(s[0] == '7' || s[1] == '7' || s[2] == '7')
            cout << "Yes\n";
        else
            cout << "No\n";
        
    }
    
    return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
static const int INF = 1 << 24;

int N, L;
vector<string> S;

bool comp(string s, string t) {
	for (int i = 0; i < L; i++) {
		if (s[i] < t[i]) return true;
		if (s[i] > t[i]) return false;
	}
	return false;
}

signed main() {
	cin >> N >> L;
	S.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	sort(S.begin(), S.end(), comp);
	for (int i = 0; i < N; i++) {
		cout << S[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int a[30],sum;
string s;
int main(){
	cin>>s;
	for(int i=0;s[i];i++){
		a[s[i]-'A']++;
	}
	for(int i=0;i<26;i++){
		if(a[i]==2)sum++;
	}
	if(sum==2)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
 
 
while True:
    N,X = map(int,input().split())
    if N == 0 and X == 0:
        break
    ans = 0
    for a in range(1,N+1):
        for b in range(1,N+1):
            if b <= a:
                continue
            c = X-(a+b)
            if c > b and c <= N:
                ans += 1
    print("%d"%(ans))


Measured memory_bytes: 5608
N = int(input())
A = list(map(int,input().split()))
cum = [0] * (N-1)
now = 0
for i in range(N-1):
    now += A[-(i+1)]
    cum[i] = now
ans = 0
for i in range(N-1):
    ans += A[i] * cum[-(i+1)]
    ans %= (10**9+7)
print(ans % (10**9+7))

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

int main()
{
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n);
    rep(i, n) cin >> a.at(i);

    long long MOD = 1000000007l;

    long long cnt1 = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < i; j++)
        {
            if (a.at(j) > a.at(i))
                cnt1++;
        }
    }

    long long cnt2 = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (a.at(j) > a.at(i))
                cnt2++;
        }
    }

    long long answer = (((cnt1 % MOD) * (k % MOD)) % MOD + (cnt2 % MOD) * ((k * (k - 1) / 2l) % MOD) % MOD) % MOD;
    cout << answer << endl;
}

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

int main(){
	int N, M;
	cin >> N >> M;
	int K[N], A[N][31];
	vector<int> a(M+1, 0);
	for(int i=0; i<N; i++){
		cin >> K[i];
		for(int j=0; j<K[i]; j++){
			cin >> A[i][j];
			a[A[i][j]]++;
		}
	}
	int cnt = 0;
	for(int i=1; i<=M; i++){
		if(a[i] == N){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

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

    long long y = (x / 11) * 2;
    long long z = x % 11;
    if (z == 0) {
    } else if (z < 7) {
        y += 1;
    } else {
        y += 2;
    }
    cout << y << endl;
    return 0;
}

Measured memory_bytes: 384
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define p 1000000007
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans;
char c[100010];int a[100010];
int f[100010],la[100010][3];
int main(){
	scanf("%s",c+1);n=strlen(c+1);
	la[0][1]=la[0][2]=0;
	for(rt i=1;i<=n;i++){
		la[i][0]=la[i-1][0],la[i][1]=la[i-1][1],la[i][2]=la[i-1][2];
		a[i]=(a[i-1]+(c[i]=='b')+1)%3;la[i][a[i]]=i;
	}
	bool fla=0;
	for(rt i=2;i<=n;i++)if(c[i]==c[i-1])fla=1;
	if(!fla)return cout<<1,0;
	bool vis[3]={0,0,0};
	for(rt i=1;i<=n;i++){
		if(a[i])f[i]=1,vis[a[i]]=1;
	}
	for(rt i=1;i<=n;i++){
		f[i]+=((ll)f[la[i][0]]+f[la[i][1]]+f[la[i][2]]-f[la[i][a[i]]])%p;
		(f[i]+=p)%=p;
	}
	cout<<f[n];
	return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<pair<pair<int, int>, ll>> edges(M);
  int a, b, c;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d %d", &a, &b, &c);
    edges[i] = make_pair(make_pair(a, b), c);
  }
  ll LLMIN = -1 * (ll)1e18;
  vector<ll> dist(N + 5, LLMIN), pred(N + 5, -1);
  dist[1] = 0;
  for (int i = 0; i < N - 1; ++i) {
    for (int j = 0; j < M; ++j) {
      int u = edges[j].first.first, v = edges[j].first.second;
      ll cost = edges[j].second;
      if (dist[v] < dist[u] + cost) {
        dist[v] = dist[u] + cost;
        pred[v] = u;
      }
    }
  }

  pred[1] = -1;
  vector<int> path(N + 5, 0);
  for (int u = N; u != -1; u = pred[u]) {
    if (path[u]) { break; }
    path[u] = 1;
  }

  for (int j = 0; j < M; ++j) {
    int u = edges[j].first.first, v = edges[j].first.second;
    ll cost = edges[j].second;
    if (dist[v] < dist[u] + cost and path[v]) {
      printf("inf\n");
      return 0;
    }
  }
  ll ans = dist[N];
  printf("%lld\n", ans);
  return 0;
}


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

int n;
double p,sol=0;
double arr[3000];
double dp[3000][3000];

int main(){
    cin >> n;
    for (int i=1;i<=n;i++) {cin >> arr[i];}
    dp[0][0]=1;
    for (int i=1;i<=n;i++) {
        dp[i][0]=dp[i-1][0]*(1-arr[i]);
        for (int j=1;j<=n;j++) {
            dp[i][j]=dp[i-1][j]*(1-arr[i]) + dp[i-1][j-1]*arr[i];
        }
    }

    for (int j=n/2+1;j<=n;j++) {sol+=dp[n][j];}
    cout << fixed << setprecision(10) << sol << endl;

}




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

int main(){
  int N;
  string S,T;
  cin >> N >> S >> T;
  vector<char> U(2*N);
  
  for (int i; i<2*N; i++) {
    if (i%2==0) U.at(i) = S.at(i/2);
    else U.at(i) = T.at(i/2);
  }
  
  for (int i; i<2*N; i++) {
    cout << U.at(i);
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;

string s[1000];
int h,w;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};


int main(){
  int n; cin >> n;
  cout << n*n << "\n";
}

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

/* define const */

/* finish defineing const */

int n;
string s[55];
int cnt[55][30] = {};
int ans[30] = {};

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    // input

    for (int j = 0; j < n; j++)
    {
        for (int i = 0; i < s[j].length(); i++)
        {
            cnt[j][s[j][i] - 'a']++;
        }
    }

    for (int i = 0; i < 26; i++)
    {
        int ct = 100;
        for (int j = 0; j < n; j++)
        {
            ct = min(ct, cnt[j][i]);
        }
        ans[i] = ct;
    }

    for (int i = 0; i < 26; i++)
    {
        while (ans[i] > 0)
        {
            cout << (char)(i + 'a');
            ans[i]--;
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
 
int main(){
    int n,i;
    cin >> n >> i;
    cout << n-i+1 << endl;

    
    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

num = p[0]
ans = 1
#res = []
# res.append(num)
for i in range(1, n):
    if num >= p[i]:
        ans += 1
        num = p[i]
#        res.append(num)

# print(res)
print(ans)


Measured memory_bytes: 75344
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(' ').map(String::toInt)
    val egs = Array(N){
        //ArrayList<Int>(0)
        HashSet<Int>()
    }
    repeat(M) {
        var (a, b) = readLine()!!.split(' ').map(String::toInt)
        a--; b--
        egs[a].add(b)
        egs[b].add(a)
    }

    var ans = 0
    var vis = BooleanArray(N){false}

    fun dfs(x:Int, px:Int=-1) {
        if (vis[x]) return
        vis[x] = true

        if (vis.filter{it}.size == N) ans++

        for(nx in egs[x]) {
            if (nx == px) continue
            dfs(nx, x)
        }

        vis[x] = false
    }

    dfs(0)

    println(ans)
}


Measured memory_bytes: 39160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		
		long count = 0;
		
		if(N == 1 && M == 1) {
			count = 1;
		} else if(N == 1 && M > 1) {
			count = M - 2;
		} else if(N > 1 && M == 1) {
			count = N - 2;
		} else {
			count = N * M - (2 * N + 2 * M - 4);
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23636
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N = sys.stdin.readline().rstrip()

if N[0] == N[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 64236
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	int n,sc;
	vi x;
	map<int,int> data;
	for(int i=0;;i++){
		scanf("%d,%d",&n,&sc);
		if(n==0 && sc==0) break;
		data[n]=sc;
		x.push_back(sc);
	}

	sort(all(x));
	x.erase(unique(all(x)),x.end());
	//reverse(all(x));
	int a;
	while(cin>>a){
		//o(data[a]);
		int ans=lower_bound(all(x),data[a])-x.begin();
		o(x.size()-ans);
	}
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int main() {
	ll n;cin>>n;
	ll res=0;
	for(ll i=1;i*i<=n-1;i++){
		if((n-1)%i==0){
			if(i>1) res++;
			if((n-1)/i!=i) res++;
		}
	}
	auto check=[&](ll a){
		ll x=n;
		while(x%a==0) x/=a;
		if(x%a==1) res++;
	};
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			if(i>1) check(i);
			if(i!=n/i) check(n/i);
		}
	}
	cout<<res<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long inf=1e9+7;

int main() {
	int n;
    while (cin >> n){
        if(n==0) break;

        vector<int> a(n);
        int m=inf;
        for (int i = 0; i < n; i++) cin >> a[i];

        sort(a.begin(), a.end());
        for (int i = 0; i < n-1; i++){
            m=min(m, a[i+1]-a[i]);
        }
        cout << m << endl;
    }
    
}
//g++ -o a.exe aa.cpp


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

typedef long long int lli;
typedef vector<long long int> vlli;
typedef vector<vector<long long int>> vvl;
typedef pair<long long int, long long int> pll;
typedef map<long long int, long long int> mll;
#define pb push_back
#define fin for (lli i = 0; i < n; i++)
#define fi(n) for (lli i = 0; i < (n); i++)
#define fj(n) for (lli j = 0; j < (n); j++)
#define fiv for (lli i = 0; i < v.size(); i++)
#define fis for (lli i = 0; i < s.size(); i++)
#define vs v.size()
#define ss s.size()

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli TC = 1;
    // cin >> TC;
    for (lli TT = 1; TT<=TC; TT++) {
        // cout << "Case #" << TT << ": ";
        lli n,a;
        cin >> n;
        vlli v, m(n);
        fin{
            cin >> a;
            v.pb(a);
        }
        m[n-1] = 0;
        m[n-2] = abs(v[n-1] - v[n-2]);
        for(lli i=n-3; i>=0; i--){
            m[i] = min(abs(v[i+1]-v[i])+m[i+1], abs(v[i+2]-v[i])+m[i+2]);
        }
        cout << m[0];
    }
    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#include <stdio.h>
#include <ios>     
#include <iomanip> 

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll GCD(ll a, ll b){
  return b ? GCD(b,a%b) : a;
}

class SegmentTree{
  const ll ELE = 0;
  ll N, size;
  
  public:
  vector<ll> node;
  
  SegmentTree(vector<ll> v){
    size = v.size();
    N = 1;
    while(N<size){ N *= 2; }//最後にはsizeを超える最小の2冪が代入される。
    node.assign(2*N-1, ELE);
    
    for(ll i=0; i<size; i++){ node[(N-1)+i] = v[i]; }
    for(ll i=N-2; i>=0; i--){ node[i] = GCD(node[2*i+1], node[2*i+2]); }//変更点
  }
  
  void update(ll x, ll val){
    x += N-1; //最下段にアクセス
    node[x] = val;
    while(x > 0){//最後に0になる。
      x = (x-1)/2;
      node[x] = GCD(node[2*x+1], node[2*x+2]);//変更点
    }
  }
  
  ll query(ll ql, ll qr, ll k=0, ll nl=0, ll nr=-1){
    if(nr<0){nr = N;}
      
    if(ql <= nl && nr <= qr){//区間が被覆されている時
      return node[k];//=にしないといけないのは何故？
    }else if(nr <= ql || qr <= nl){//区間が重なっていない時
      return ELE; 
    }else{//区間が一部重なっている時
      ll gcdl = query(ql,qr,2*k+1,nl,(nl+nr)/2);//変更点
      ll gcdr = query(ql,qr,2*k+2,(nl+nr)/2,nr);//変更点
      return GCD(gcdl,gcdr);
    }
  }
};

int main()
{
  //セグメントツリーを実装しよう！！
  //input
  int N; cin >> N;
  vector<ll> a(N,0);
  for(int i=0; i<N; i++){ cin >> a[i]; }
  
  //main
  SegmentTree st(a);
  
  ll ans = 0;
  for(int i=0; i<N; i++){
    st.update(i,0);
    ans = max(ans,st.query(0,N));
    st.update(i,a[i]);
  }
  
  // output
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int X,Y; cin >> X >> Y;
    if(X*2>Y || X*4<Y || Y%2) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
   int x,y,z; cin>>x>>y>>z;
   int a;
   a=x; x=y; y=a;
   a=x; x=z; z=a;
   cout<<x<<" "<<y<<" "<<z<<endl;
   return 0;
}



Measured memory_bytes: 256