akhauriyash/Code-Regression huggingface dataset:
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)


function main()
N, M = parseMap(split(readline()))

L = []
R = []

max_l = -1
min_r = 10^5 + 1


for _ in 1:M
    l, r = parseMap(split(readline()))
    max_l = max(max_l, l)
    min_r = min(min_r, r) 
end

println(max(min_r - max_l + 1, 0))

end


main()



Measured memory_bytes: 203356
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

template <typename T>
pair<vector<T>, vector<int>> dijkstra(const vector<vector<pair<int, T>>>& graph, int n, int s){
    typedef pair<T, int> PP;

    vector<T> d(n+1, INF);
    d[s] = 0;

    vector<int> p(n+1, -1);
    p[s] =  s;

    priority_queue<PP, vector<PP>, greater<PP>> que;
    que.emplace((T)0, s);

    while(!que.empty()){
        T w = que.top().first;
        int v = que.top().second;
        que.pop();

        if(d[v] < w){
            continue;
        }

        for(pair<int, T> edge : graph[v]){
            int u = edge.first;
            T nw = w + edge.second;
            if(nw < d[u]){
                d[u] = nw;
                p[u] = v;
                que.emplace(nw, u);
            }
        }
    }
    return make_pair(d, p);
}

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

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

    auto edge = initVec2<int>(n * 3 + 1, 0);
    rep(i, m){
        int u, v;
        cin >> u >> v;
        edge[u].push_back(v + n);
        edge[u + n].push_back(v + n * 2);
        edge[u + n * 2].push_back(v);
    }

    int s, t;
    cin >> s >> t;

    vector<int> used(n * 3 + 1, -1);
    queue<P> q;
    q.emplace(s, 0);
    while(not q.empty()){
        int v = q.front().first;
        int d = q.front().second;
        q.pop();
        if(used[v] != -1){
            continue;
        }
        used[v] = d;
        for(int u : edge[v]){
            if(used[u] != -1){
                continue;
            }
            q.emplace(u, d + 1);
        }
    }

    if(used[t] == -1){
        cout << -1 << endl;
    }else{
        cout << used[t] / 3 << endl;
    }

    return 0;
}


Measured memory_bytes: 19704
#include <stdio.h>
int main(void){
    int N;
    int d[50],s[50][50];
    
    //標準入力
    scanf("%d", &N);
    for(int i = 0;i < N; i++) {
       scanf("%d", &d[i]);
    }
    
    //計算
    int sum = 0;
    for(int i = 1; i < N; i++) {
       for(int j = 0; j < i; j++) {
         s[i-1][j] = d[j] * d[i];
         sum += s[i-1][j];
       }
    }
   
    //出力
    printf("%d\n", sum);
  
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int k,n,a[500000],s=1200000;

int main(){
    cin>>k>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i+n]=a[i]+k;
    }
    for(int i=0;i<n;i++){
        int b=a[i+n-1]-a[i];
        if(b<s)s=b;
        
    }
    cout<<s<<endl;
}


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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll x; cin>>x;
	ll cur = 100;
	ll days=0;
	while(cur<x)
	{
		cur=floor(ld(cur)*ld(1.01));
		days++;
	}
	cout<<days<<'\n';
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	string s;
	long long int k;
	cin >> s >> k;
	
	int n = s.length();

	// n == 1
	if(n == 1){
		cout << n * k / 2;

		return 0;
	}

	//全ての文字が一致しているか？
	char c = s[0];
	bool acc = true;

	REP(i, 1, n){
		if(c == s[i]) continue;

		else{
			acc = false;
			break;
		}
	}

	if(acc){
		cout << n * k / 2;

		return 0;
	}

	//先頭の文字 == 末尾の文字か否か
	if(s[0] == s[n-1]){
		long long ans = 0;

		int front = 1;
		char c = s[0];
		REP(i, 1, n){
			if(s[i] == c){
				front++;
			}
			else{
				break;
			}
		}

		int back = 1;
		c = s[n-1];
		for(int i = n-2; i > 0; i--){
			if(c == s[i]){
				back++;
			}
			else{
				break;
			}
		}

		c = s[front];
		int con = 1;
		REP(i, front + 1, n - back){
			if(s[i] == c){
				con++;
			}
			else{
				ans += con / 2;

				con = 1;
				c = s[i];
			}

			if(i == n - back - 1){
				ans += con / 2;
			}
		}

		cout << ans * k + front/2 + back/2 + (front + back) / 2 * (k - 1);
	}
	else{
		int con = 1;
		char c = s[0];
		long long ans = 0;

		REP(i, 1, n){
			if(s[i] == c){
				con++;
			}
			else{
				ans += con / 2;

				con = 1;
				c = s[i];
			}

			if(i == n-1){
				ans += con / 2;
			}
		}

		cout << ans * k;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int dp[3005][3005];
string s,t;
string printlcs(int i,int j){
    if (i == 0 || j == 0) return "";
    if (s[i-1] == t[j-1]) return printlcs(i-1,j-1)+s[i-1];
    else{
        if (dp[i-1][j] >= dp[i][j-1]) return printlcs(i-1,j);
        else return printlcs(i,j-1);
    }
}
int main(){
    cin >> s >> t;
    dp[0][0] = 0;
    dp[1][0] = 0;
    dp[0][1] = 0;
    rep(i,1,s.length()+1){
        rep(j,1,t.length()+1){
            if (s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    PRINT(printlcs(s.length(),t.length()));
}

Measured memory_bytes: 35968
N,X = list(map(int, input().split()))
L = list(map(int, input().split()))
D = []
D.append(0)

for i in range(1,N+1):
  aaaa = D[i-1] + L[i-1]
  D.append(aaaa)
n = sum(x<=X for x in D)
print(n)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll h, w, ans; cin>>h>>w;
  	if(h==1 || w==1) ans=1;
    else if(h%2==0) ans=h/2*w;
    else if(w%2==0) ans=w/2*h;
    
    else ans=(w/2)*h+((h+1)/2);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	if len(s)%2 != 0 {
		fmt.Fprintln(writer, "No")
		return
	}
	for i := 0; i < len(s); i += 2 {
		if s[i:i+2] != "hi" {
			fmt.Fprintln(writer, "No")
			return
		}
	}
	fmt.Fprintln(writer, "Yes")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long int
#define MOD(x) ((x % MOD_N) + MOD_N) % MOD_N
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,v) for(auto i=v.begin();i!=v.end();++i)
#define REACH(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
#define LB(c,x) distance((c).begin(),lower_bound(ALL(c),x))
#define UB(c,x) distance((c).begin(),upper_bound(ALL(c),x))
#define COUNT(c,x) (lower_bound(ALL(c),x)-upper_bound(ALL(c),x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;
#define NL cerr<<endl;
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T sum(vector<T>&v){return accumulate(ALL(v),T());}
template<typename T>T sum(vector<T>&v,int a,int b){return accumulate(v.begin()+a,v.begin()+b,T());}
template<typename T>T max(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T min(vector<T>&v){return *max_element(ALL(v));}
template<typename T>T max_index(vector<T>&v){return distance((v).begin(),max_element(ALL(v)));}
template<typename T>T min_index(vector<T>&v){return distance((v).begin(),min_element(ALL(v)));}

struct edge { int to, cost; };

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}

const int INF = 1e18;
const int MOD_N = 1e9+7;

signed main()
{
   int N; cin >> N;
   V<double> v(N);
   REP(i, N) {
      double x; string s;
      cin >> x >> s;
      if (s == "JPY") {
         v[i] = x;
      } else {
         v[i] = x * 380000.0;
      }
   }
   double ans = sum(v);
   printf("%.5lf\n", ans);

   return 0;
}


Measured memory_bytes: 256
def main():
  n=int(input())
  a = list(map(int,input().split()))
  ans=a[0]
  if 0 in a:
    ans=0
  else:
    for i in range(1,n):
      ans*=a[i]
      if ans >1000000000000000000:
        ans=-1
        break
  print(ans)
main()

Measured memory_bytes: 21596
using System;
using System.Collections.Generic;

namespace kozaiyApp
{
    public class keyence2020b
    {
        static void Main(string[] args)
        {

            int ans = 0;
            int N = int.Parse(Console.ReadLine());
            List<Tuple<int, int>> robots = new List<Tuple<int, int>>(); // start, goal

            for (int i = 0; i < N; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]) - int.Parse(input[1]);
                int g = int.Parse(input[0]) + int.Parse(input[1]);
                robots.Add(new Tuple<int, int>(s, g));
            }

            robots.Sort((a, b) => a.Item2 - b.Item2);　// gが早い順にソート
            int nowX = -1000000000;

            // gが早い順にロボットを残すか決めていく
            for (int i = 0; i < N; i++)
            {
                if (robots[i].Item1 >= nowX)
                {
                    ans += 1;
                    nowX = robots[i].Item2;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 21060
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

int solve(string& s, char foot){
    int l = 0, r = 10, res = 0;
    rep(i, (int)s.size()){
        int now = s[i] - '0';
        while(3 < now)now -= 3;
        if(foot == 'R'){
            if(r < now)r = now, res++;
            else l = now, foot = 'L';
        }
        else{
            if(now < l)l = now, res++;
            else r = now, foot = 'R';
        }
    }
    return res;
}

int main(){
    for(string in; cin >> in, in != "#";){
        cout << min(solve(in, 'L'), solve(in, 'R')) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1316
import java.io.*;
public class Main {
 public static void main(String[] args){
 try{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
  while(true){
   int ac=0,bc=0,r=0,n=0,x=0;
   int a[];
   a=new int[100];  
   int b[];
   b=new int[100];  
   int c[];
   c=new int[100]; 
   int ans[];
   ans= new int[100];
  for(int i=0;i<100;i++)ans[i]=i;
   String str[];
   str= new String[100];
   str=br.readLine().split(" ");
   n=Integer.parseInt(str[0]);
   r=Integer.parseInt(str[1]);
   str=br.readLine().split(" ");
   for(int l=0;l<r;l++){
    x=Integer.parseInt(str[l]);
    for(int i=0;i<n/2;i++){b[i]=ans[i];bc=i+1;}
    b[bc]=-1;
    ac=n-bc;
    for(int i=0;i<ac;i++){a[i]=ans[bc+i];}
    a[ac]=-1;
    int j=0;int w=0;int k=0;

    while(true){//シャッフル
     if(ac==0 && bc==0)break;
     int cnt=0;
     while(true){
      if(cnt==x || a[j]==-1)break;
      c[k]=a[j]; cnt++; ac--; k++; j++;
     }
    cnt=0;
     while(true){
      if(cnt==x || b[w]==-1)break; 
      c[k]=b[w]; k++;cnt++;bc--; w++;
     }
    }
    for(int i=0;i<n;i++)ans[i]=c[i]; 
   }
   System.out.println(ans[n-1]);   
  }
 }
  catch(Exception e){return ;}
 }
}


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

int main() {
    string S, T; cin >> S >> T;
    int ans = 2000;
    for (int i = 0; i <= S.size()-T.size(); i++) {
        int cnt = 0;
        for (int j = 0; j < T.size(); j++) {
            if (S.at(i+j) != T.at(j)) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#!/usr/bin/env python3
import math
N, H = map(int, input().split())
a = [0] * N
b = [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())

b.sort(reverse=True)
m = max(a)
s = 0
for i in range(N):
    b[i] = max(b[i], m)
    s += b[i]
    if s >= H:
        print(i + 1)
        break
else:
    print(N + math.ceil((H - s) / m))


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

using namespace std;

//int dirs[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
//int dirs[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("inp.in","r",stdin);
    //freopen("outp.out","w",stdout);
    char ch;
    scanf("%c", &ch);
    ch+=1;
    cout << ch << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n >> k;
  cout<<6-n-k<<endl;
  return 0;
}

Measured memory_bytes: 764
//@trueno
//The purpose of computation is insight, not numbers...
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll m=1e9+7;
int main()
{
	int H,W;
	cin>>H>>W;
	char ch[H][W];
	ll dp[H][W];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			cin>>ch[i][j];
	for(int i=1;i<H;i++)
		if(ch[i][0]=='.')
			dp[i][0]=1;
		else break;
	for(int i=1;i<W;i++)
		if(ch[0][i]=='.')
			dp[0][i]=1;
		else break;
	for(int i=1;i<H;i++)
	{
		for(int j=1;j<W;j++)
		{
			if(ch[i][j]=='.')
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%m;
		}
	}
	cout<<dp[H-1][W-1];

	return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	int num1,num2;
	cin>>num1>>num2;
	string p;
	cin>>p;
	if(p==s)
	 cout<<num1-1<<" "<<num2;
	else if(p==t)
	 cout<<num1<<" "<<num2-1;
	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main() {
    int n,i=0;
    cin >> n;
    while (++i <= n) {
            int x = i;
            if (i % 3 == 0)cout << " " << i;
            else{
                while (x != 0) {
                    if (x % 10 == 3) {
                        cout << " " << i;
                        break;
                    }
                    x /= 10;
                }
            }    
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1160
import sys

def main():
    n = int(input().replace('\n',''))
    x = input().replace('\n','').split(' ')
    x = [int(i) for i in x]
    x_sort = sorted(x)
    min = -1
    for i in range(x_sort[len(x_sort)-1]+1):
      res=0
      for j in x_sort:
        res += (j-i) ** 2
      if min > res or min == -1:
        min = res
    print(min)
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
struct Combination {
    vector<ll> fac, finv, inv;

    Combination(ll maxN) {
        maxN += 100; // for safety
        fac.resize(maxN + 1);
        finv.resize(maxN + 1);
        inv.resize(maxN + 1);
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (ll i = 2; i <= maxN; ++i) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    ll operator()(ll n, ll k) {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

int main() {
    int n;
    cin >> n;
    vi a(n + 1);
    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }
    vi place(n + 1, -1);
    int left, right;
    for (int i = 0; i < n + 1; ++i) {
        if (place[a[i]] == -1)
            place[a[i]] = i;
        else {
            left = place[a[i]];
            right = i;
            break;
        }
    }
    Combination nck(1000000);
    for (int k = 1; k <= n + 1; ++k) {
        ll ret = 0;
        // not use nums between repeated num
        ret = (ret + nck(n + 1 - 2, k)) % MOD;
        // use both repeated num
        ret = (ret + nck(n + 1 - 2, k - 2)) % MOD;
        // use one of the repeated num
        ret = (ret + nck(n + 1 - 2, k - 1) * 2) % MOD;
        ret -= nck(n + 1 - (right - left + 1), k - 1);
        if (ret < 0)
            ret += MOD;
        cout << ret << "\n";
    }

    return 0;
}

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

using Field=vector<string>;
using vi=vector<int>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
void cmax(int& lhs,int rhs){
    lhs=max(lhs,rhs);
}
int e0[]={1,0};
int e1[]={0,1};
int solve(int h,int w){
    Field f(h);
    for(int i=0;i<h;i++) cin>>f[i];
    vector<vector<int>> hs(26);
    vector<vector<int>> ws(26);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(isalpha(f[i][j]) && isupper(f[i][j])){
                hs[f[i][j]-'A'].push_back(i);
                ws[f[i][j]-'A'].push_back(j);
            }
        }
    }
    vvvvi dp(h,vvvi(w,vvi(h,vi(w,-1e9))));
    for(int i=0;i<h;i++)for(int j=0;j<w;j++) if(f[i][j]!='#') dp[i][j][i][j]=0;
    auto isRange=[&](int i,int j){return 0<=i && i<h && 0<=j && j<w;};
    for(int dh=0;dh<h;dh++){
        for(int dw=0;dw<w;dw++){
            for(int t=0;t<h;t++){
                for(int l=0;l<w;l++){
                    int b=t+dh,r=l+dw;
                    if(!isRange(b,r)) continue;
                    if(f[t][l]=='#' || f[b][r]=='#') continue;
                    if(t+1<=b) cmax(dp[t][l][b][r],dp[t+1][l][b][r]);
                    if(t<=b-1) cmax(dp[t][l][b][r],dp[t][l][b-1][r]);
                    if(l+1<=r) cmax(dp[t][l][b][r],dp[t][l+1][b][r]);
                    if(l<=r-1) cmax(dp[t][l][b][r],dp[t][l][b][r-1]);
                    if(isalpha(f[t][l]) && islower(f[t][l])){
                        for(int k=0;k<hs[f[t][l]-'a'].size();k++){
                            int hp=hs[f[t][l]-'a'][k],wp=ws[f[t][l]-'a'][k];
                            if(t<=hp && hp<=b && l<=wp && wp<=r){
                                cmax(dp[t][l][b][r],dp[t][l][hp][wp]+dp[hp][wp][b][r]);
                            }
                        }
                    }
                    if(isalpha(f[t][l]) && islower(f[t][l]) && toupper(f[t][l])==f[b][r]){
                        if(b-t+r-l==1) dp[t][l][b][r]=1;
                        else{
                            for(int x=0;x<2;x++){
                                for(int y=0;y<2;y++){
                                    int nt=t+e0[x],nl=l+e1[x];
                                    int nb=b-e0[y],nr=r-e1[y];
                                    if(nt<=nb && nl<=nr) cmax(dp[t][l][b][r],dp[nt][nl][nb][nr]+1);
                                }
                            }
                        }
                    }
                    // cerr<<"#"<<t<<" "<<l<<" "<<b<<" "<<r<<endl;
                    // cerr<<dp[t][l][b][r]<<endl;
                }
            }
        }
    }
    
    return dp[0][0][h-1][w-1];
}
int main(){
    int h,w;
    while(cin>>h>>w,h){
        int ret=solve(h,w);
        cout<<(ret<0 ? -1 : ret)<<endl;
    }
    return 0;
}


Measured memory_bytes: 31892
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
static const int MAX = 100000;
static const int NIL = -1;

int main(void) {
    ll n, z, w, i, ans=0;
    cin >> n >> z >> w;
    ll a[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    
    if(n==1)
        ans=abs(a[0]-w);
    else
        ans=max(abs(a[n-1]-w), abs(a[n-1]-a[n-2]));
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(N: Int, M: Int, X: IntArray, Y: IntArray, Z: IntArray){
    val uf = UnionFind(N + 1)
    repeat(M){
        uf.unite(X[it], Y[it])
    }
    var nodes = (1..N).toList()
    var ans = (1..N).toList().map{ uf.findRoot(it) }.distinct().size
    println(ans)
    return
}
class UnionFind(n: Int) {
    data class Node(var parent: Int, var size: Int)
    val nodes = Array<Node>(n) { Node(parent = it, size = 1) }
    fun findRoot(x: Int): Int {
        if (x == this.nodes[x].parent) return x
        nodes[x].parent = findRoot(nodes[x].parent)
        return nodes[x].parent
    }
    fun unite(x: Int, y: Int) {
        var xRoot = findRoot(x)
        var yRoot = findRoot(y)
        if (xRoot == yRoot) return
        if (getSize(xRoot) < getSize(yRoot)) {
            nodes[xRoot].parent = yRoot
            nodes[yRoot].size += nodes[xRoot].size
        } else {
            nodes[yRoot].parent = xRoot
            nodes[xRoot].size += nodes[yRoot].size
        }
    }
    fun getSize(x: Int) = nodes[findRoot(x)].size
    fun isSame(x: Int, y: Int) = findRoot(x) == findRoot(y)
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val M = sc.next().toInt()
    val X = IntArray(M)
    val Y = IntArray(M)
    val Z = IntArray(M)
    for (i in 0 until M.toInt()) {
        X[i] = sc.next().toInt()
        Y[i] = sc.next().toInt()
        Z[i] = sc.next().toInt()
    }
    solve(N, M, X, Y, Z)
}



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

int main() {
  ll x;
  cin >> x;
  ll ans = x / 500 * 1000;
  x %= 500;
  ans += x / 5 * 5;
  cout << ans << endl;
}

Measured memory_bytes: 3608
/*
{By GWj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n,k,x[200000+20],q,f[200000+20][19],ff[200000+20][19];
LL s[200000+20][19],ss[200000+20][19];
LL solve(int l,int r){
	int can=0;
	int now=l;
	rl(i,18,0)
		if(f[now][i]<=r) now=f[now][i],can|=1<<i;
	if(can==0) return r-l+1;
	LL one,two;
	one=two=0;
	now=l;
	rl(i,18,0)
		if((can>>i)&1){
			one+=s[now][i];
			now=f[now][i];	
		}
	now=r;
	rl(i,18,0)
		if((can>>i)&1){
			two+=ss[now][i];
			now=ff[now][i];
		}
	one+=l;
	two+=r;
	return two-one+can+1;
}
int main(){
	fastio;
	R2(n,k);
	rb(i,1,n)
		R(x[i]);
	rb(i,1,n+1)
		fill(f[i],f[i]+19,n+1);
	int is=n+1;
	rl(i,n,1){
		while(x[is-1]-x[i]>=k){
			is--;
		}
		f[i][0]=is;
		s[i][0]=is;
	}
	is=0;
	rb(i,1,n){
		while(x[i]-x[is+1]>=k){
			is++;
		}
		ff[i][0]=is;
		ss[i][0]=is;
	}
	rb(i,1,18)
		rb(j,1,n)
			f[j][i]=f[f[j][i-1]][i-1],ff[j][i]=ff[ff[j][i-1]][i-1],s[j][i]=s[f[j][i-1]][i-1]+s[j][i-1],ss[j][i]=ss[ff[j][i-1]][i-1]+ss[j][i-1];
	R(q);
	while(q--){
		int l,r;
		R2(l,r);
		cout<<solve(l,r)<<endl;
	}
	return 0;
}
/** 程序框架：
  * f_{i,j}=f_{f_{i,j-1},j-1}\\
  * s_{i,j}=s_{i,j-1}+s_{f_{i,j-1},j-1}
  * 
  * 
  *
  **/


Measured memory_bytes: 93480
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    
    ll n,sum=0;
    cin>>n;
    ll a[n-1];
    for(int i=0;i<n-1;i++) cin>>a[i];
    sum+=a[0]+a[n-2];
    for(int i=0;i<n-2;i++){
        if(a[i]<a[i+1]) sum+=a[i];
        else sum+=a[i+1];
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=100000+10,mo=1000000007;
int fac[maxn*2],inv[maxn*2];
int i,j,k,l,t,n,m,a,b,ans;
int qsm(int x,int y){
    if (!y) return 1;
    int t=qsm(x,y/2);
    t=(ll)t*t%mo;
    if (y%2) t=(ll)t*x%mo;
    return t;
}
int C(int n,int m){
    if (n<m||m<0) return 0;
    return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int F(int n,int m){
    return C(n+m,n);
}
int main(){
    scanf("%d%d%d%d",&n,&m,&a,&b);
    fac[0]=1;
    fo(i,1,n+m) fac[i]=(ll)fac[i-1]*i%mo;
    inv[n+m]=qsm(fac[n+m],mo-2);
    fd(i,n+m-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
    fo(i,1,b)
        (ans+=(ll)F(n-a-1,i-1)*F(a-1,m-i)%mo)%=mo;
    ans=(F(n-1,m-1)-ans)%mo;
    (ans+=mo)%=mo;
    printf("%d\n",ans);
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
	int N, T, A;
	cin >> N >> T >> A;
	int resultIndex;
	double min = 10<<6;
	for(int index = 0; index < N; index++){
		int H;
		cin >> H;
		if(abs((T - H * 0.006f) - A) < min){
			min = abs((T - H * 0.006f) - A);
			resultIndex = index;
		}
	}
	cout << resultIndex + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n,w;
    int dp[110][10010];
    int value[110],weight[110];

    cin>>n>>w;
    for(int i=0; i<n; i++) cin>>value[i]>>weight[i];

    for(int i=0; i<=w; i++)dp[0][w]=0;

    for(int i=0; i<n; i++){
        for(int j=0; j<=w; j++){
            if(j>= weight[i]) dp[i+1][j] = max(dp[i][j-weight[i]]+value[i],dp[i][j]);
            else dp[i+1][j] = dp[i][j];
        }
    }

    cout<< dp[n][w]<<endl;
    return 0;
}


Measured memory_bytes: 7012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

    static int N, M;
    static String S, T;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        S = sc.next();
        T = sc.next();

        System.out.println(solve());
    }

    static long solve() {
        int g = gcd(M, N);
        long l = (long)N * M / g;

        Map<Long, Character> m1 = toMap(S, l, N);
        Map<Long, Character> m2 = toMap(T, l, M);

        for (Long i : m1.keySet()) {
            if( m2.containsKey(i) && m2.get(i) != m1.get(i) ) {
                return -1;
            }
        }
        return l;
    }
    
    static Map<Long, Character> toMap(String s, long l, int n) {
        Map<Long, Character> map = new HashMap<>();
        long q = l/n;
        for (int i = 0; i < n; i++) {
            map.put(i * q, s.charAt(i));
        }
        return map;
    }

    static int gcd(int a, int b) {
        while (b > 0) {
            int c = a;
            a = b;
            b = c % b;
        }
        return a;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 37948
#include <stdio.h>
int main(void){
    int a,b,i,k,W,H;
    for(;;){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0)break;
        for(i=1;i<=H;i++){
            if(i==1 || i==H){
                b=1;
            }
            else{
                b=0;
            }
            for(k=1;k<=W;k++){
                if(k==1 || k==W){
                    a=1;
                    
                }
                else{
                    a=0;
                }
                if(a==1 || b==1){
                    printf("#");
            }
            else{
                printf(".");
            }
                
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1808
//Problem: JSC2019 Qual A
//Progress: Working
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m, ans = 0;
    cin >> n >> m;
    for(ll i=22; i<=m; i++)
        if(i%10 >= 2 && (i/10) >= 2 && i%10 * (i/10) <= n)
            ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"io"
	"os"
	"strconv"
)

var pri = fmt.Println
var scan = fmt.Fscanln
var scanone = fmt.Fscan

func main() {
	solve(os.Stdin)
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] {
			res = a[i]
		}
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] {
			res = a[i]
		}
	}
	return res
}

const MAX = 1000000
const MOD = int(1e9 + 7)

var fac [MAX]int
var inv [MAX]int
var facinv [MAX]int
var mod int

func init() {
	fac[0] = 1
	fac[1] = 1
	inv[0] = 1
	inv[1] = 1
	facinv[0] = 1
	facinv[1] = 1

	for i := 2; i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		facinv[i] = facinv[i-1] * inv[i] % MOD
	}
}

func combmod(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (facinv[k] * facinv[n-k] % MOD) % MOD
}

func mustint(a string) int {
	i, _ := strconv.Atoi(a)
	return int(i)
}

type P struct {
	x, y int
}

func (p *P) add(q *P) *P {
	return &P{p.x + q.x, p.y + q.y}
}

const huge = 1e10

func solve(rd io.Reader) {
	var x, y int
	scan(rd, &x, &y)
	if (x+y)%3 != 0 {
		pri(0)
		return
	}
	a := -x/3 + (2*y)/3
	b := 2*x/3 - y/3
	pri(combmod(a+b, a))
}


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

using namespace std;

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

    // 自明な場合
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }

    // 26文字未満の場合
    if (s.length() < 26) {
        for (char c = 'a'; c <= 'z'; c++) {
            if (s.find(c) == -1) {
                cout << s + c << endl;// 未使用の文字を末尾に追加
                return 0;
            }
        }
    }

    // 26文字の場合
    string s_org = s;
    next_permutation(s.begin(), s.end());

    for (unsigned int i = 0; i < s.size(); ++i) {
        if (s[i] != s_org[i]) {
            cout << s.substr(0, i + 1) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long int n,k,m,l;
  cin >> n >> k;
  if(k%2==1){
    m=n/k;
    cout << m*m*m << endl;
  }else{
    m=n/k;
    l=(n+(k/2))/k;
    cout << m*m*m+l*l*l << endl;
  }
}


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

int main(){
    int N, K; cin >> N >> K;
    //F_set := 各ネタで一番基礎ポイントが高いもの
    //S_set := F_set以外
    vector<int> F_set, S_set;
    unordered_map<int,int> MP;

    //F_setとS_setに分類します。
    for(int i = 0 ; i < N; i++){
        int t, d;
        cin >> t >> d;
        //ps[i] = {t, d};
        if(MP[t] == 0) MP[t] = d;
        else{
            if(MP[t] < d){
                S_set.push_back(MP[t]);
                MP[t] = d;
            }else{
                S_set.push_back(d);
            }
        }
    }
    //(mapを全部表示するならunordered_mapの方が良い)
    for(auto e: MP){
        F_set.push_back(e.second);
    }
    sort(S_set.begin(), S_set.end(), greater<int>());
    sort(F_set.begin(), F_set.end(), greater<int>());

    //　各種類ポイントの時の最大値を求めて満足ポイント最大値をansとする
    ll ans = 0;
    ll pref = 0;    // 前のF_setの和を表示
    ll pres = 0;    // 前のS_setの和を表示
    // KとS_setの大小関係で場合分け
    if(K <= S_set.size()){
        for(int i = 0; i < K; i++){
            pres += S_set[i];
        }
        ans = pres;
        //iは種類数
        for(int i = 1; i <= K; i++){
            if(i - 1 >= F_set.size()) break;
            ll tmp = 0;
            tmp = (ll)i * (ll)i;
            pres -= S_set[K - i];
            pref += F_set[i-1];
            tmp += pres + pref;
            ans = max(ans, tmp);
        }
    }else{
        for(int i = 0; i < S_set.size(); i++){
            pres += S_set[i];
        }
        for(int i = 0; i < K - S_set.size(); i++){
            pref += F_set[i];
        }
        ans = pres + pref + pow((K - S_set.size()), 2);
        for(int i = K - S_set.size() + 1; i <= K; i++){
            if(i - 1 >= F_set.size()) break;
            ll tmp = 0;
            tmp = (ll)i * (ll)i;
            pres -= S_set[K - i];
            pref += F_set[i-1];
            tmp += pres + pref;
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5284
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    L,R=map(int,input().split())
    if R-L<2018:
        print(min([(i*j)%2019 for i in range(L,R) \
                   for j in range(i+1, R+1)]))
    else:
        print(0)

resolve()

Measured memory_bytes: 112596
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
    char ch[4] = {'N', 'S', 'W','E'};
  	string S;

    bool T[4];
    for(int i=0;i<4;i++) T[i] = false;

    cin >> S;
    int n = S.size();

    for(int j=0;j<4;j++){
        for(int i=0;i<n;i++){
        if(S[i]==ch[j]){
          T[j] = true;
          break;
        }
      }
    }
    
    if(T[0]!=T[1] || T[2]!=T[3]){
      cout << "No" <<endl;
      return 0;
    }
    cout << "Yes" <<endl;


  	return 0;
}


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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.length();
    string ans(n, 'x');
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
ji, hun, H, M = input().split()
ji = int(ji)
hun = int(hun)
H = int(H)
M = int(M)
ji_rad = 30 * H + 0.5 * M
hun_rad = 6 * M
diff = abs(ji_rad - hun_rad)
if diff == 0:
  answer = abs(ji - hun)
elif diff == 180:
  answer = ji + hun
else:
  if diff > 180:
      diff = abs(360 - diff)
  answer = math.sqrt((ji ** 2) + (hun ** 2) - 2 * ji * hun * math.cos(math.radians(diff)))
print(answer)

Measured memory_bytes: 62624
from itertools import compress

def main():
    N = int(input())
    F = tuple(tuple(map(int, input().split())) for _ in [0] * N)
    P = tuple(tuple(map(int, input().split())) for _ in [0] * N)

    profits = -float('inf')
    mask = 1
    while mask < (1 << 10):
        n = 0
        sel = list(map(int, format(mask, '010b')))
        for i, f in enumerate(F):
            j = sum(compress(f, sel))
            n += P[i][j]
        profits = max(profits, n)
        mask += 1

    print(profits)

main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define bug(x) cerr<<#x<<"="<<x<<endl;
#define el printf("\n");
const ll mod = 1e7;




inline ll nxt() {
	ll x;
	scanf("%lld\n",&x);
	return x;
}
inline void print(int n){
    printf("%d ",n);
}
inline void prints(string  s){
    printf("%s",s.c_str());
}


ll nCr(ll n ,ll k){
    if( k==n || k==0 )return 1;
    return (nCr(n-1,k-1)%mod+nCr(n-1,k)%mod)%mod;
}

int main(){

    ll n,r;
   cin>>n>>r;
   ll a=0,b=0;
   if(n>=2)a=nCr(n,2LL);
   if(r>=2)b=nCr(r,2LL);

  cout<<a+b<<endl;





}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define coyes cout << "Yes" << endl;
#define cono cout << "No" << endl;
#define coYes cout << "YES" << endl;
#define coNo cout << "NO" << endl;
using namespace std;
using ll = long long int;
string large_al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string small_al = "abcdefghijklmnopqrstuvwxyz";
using Graph = vector<vector<int>>;
using i64 = int64_t;


int main() {
  int a, b;
  cin >> a >> b;
  bool flag = true;
  for (int i = 1; i < 1263; i++) {
    //cout << (int)(i * 0.08) / 1 << "  " << (int)(i * 0.1) / 1 << endl;
    
    if (((int)(i * 0.08) / 1 == a) && ((int)(i * 0.1) / 1 == b)) {
      cout << i << endl;
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
sa = gets.chomp.split('')
sb = gets.chomp.split('')
sc = gets.chomp.split('')
target = 'a'

while !target.nil? do
  case target
  when 'a' then
    ans = 'A' if sa.length.zero?
    target = sa.shift
  when 'b' then
    ans = 'B' if sb.length.zero?
    target = sb.shift
  when 'c' then
    ans = 'C' if sc.length.zero?
    target = sc.shift
  end
end

puts ans

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

struct edge{
    ll to,cost;
   // edge(ll to,ll cost):to(to),cost(cost){}
};
vector<vector<edge>>g;
vector<ll>d;
void dfs(ll v,ll now,ll p=-1){
    d[v]=now;
    for(auto &u:g[v]){
        if(p==u.to)continue;
        dfs(u.to,now+u.cost,v);
    }
}

int main(){
    ll n;cin >>n;
    d.resize(n);
    g.resize(n);
    for (int i = 0; i < n-1; ++i) {
        ll a,b,c;cin >>a>>b>>c;
        a--,b--;
        g[a].push_back({b,c});
        g[b].push_back({a,c});
    }
    ll q,k;cin >>q>>k;
    k--;
    dfs(k,0);
    for (int i = 0; i < q; ++i) {
        ll x,y;cin >>x>>y;
        x--;y--;
        cout <<d[x]+d[y]<<endl;
    }
    return 0;
}

Measured memory_bytes: 14336
#include <stdio.h>
#include <string>
#include <iostream>
 
using namespace std;
 
int main(int argc, char** argv) {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == b && a != c) ||
      (a == c && a != b) ||
      (b == c && a != b)) {
    cout << "Yes\n";
    return 0;
  }
  cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++) ans += i;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 892
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

int main(void)
{
	//変数の宣言
	int n,m;
	static int a[100010];
	static int under[100010];
	static int upper[100010];
	static ll int ruiseki[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	ll int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;



	//データの読み込み


	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
//		scanf_s("%d",&a[i]);
	}


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

  	
	for(i=0;i<100010;i++){
		under[i]=0;
		upper[i]=0;
		ruiseki[i]=0;
	}

  
	temp=0;
	temp2=0;
	for(i=1;i<n;i++){
		under[a[i-1]]++;
		upper[a[i]]++;
		ruiseki[a[i]+1]=ruiseki[a[i]+1]+(a[i]-a[i-1]-1+m)%m;

		if(a[i-1]>a[i]){
			temp=temp+m-a[i-1];
			temp2++;
		}

	}

	ans=temp;

	for(i=2;i<=m;i++){
		temp2=temp2-upper[i-1];
		temp=temp+temp2-ruiseki[i];
		temp2=temp2+under[i-1];
		ans=max(ans,temp);
	}

	ans=-ans;
	for(i=1;i<n;i++){
		ans=ans+(a[i]-a[i-1]+m)%m;
	}

	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 2176