akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;

int64 gcd(int64 a, int64 b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}

void solve(int) {
  cin >> n >> m;
  vector<int> a(n);
  for (int& x : a) {
    cin >> x;
    x /= 2;
  }
  int64 g = a[0];
  for (int i = 1; i < n; ++i) {
    int64 d = gcd(g, a[i]);
    g = g / d * a[i];
    if (g > m) {
      cout << "0\n";
      return;
    }
  }
  for (int i = 0; i < n; ++i) {
    if ((g - a[i]) % (2 * a[i])) {
      cout << "0\n";
      return;
    }
  }
  cout << 1 + (m - g) / (g * 2) << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

int main() {
	string a, b;
	while (cin >> a >> b) {
		int MAX = 0;
		for (int i = -((int)a.length()) + 1; i < (int)(b.length()); i++) {
			int k = 0;
			for (int j = 0; j < a.length(); j++) {
				if (i + j < 0 || i + j >= b.length() || a[j] != b[i + j])k = 0;
				else k++;
				MAX = max(MAX, k);
			}
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 3052
export class Main {
  static main(input): string {
    const [nTmp, str]: string[] = input.split("\n");
    const n: number = Number(nTmp);
    const tmp: string[] = str.split("").slice(0, n);
    return `${tmp.filter(s => s == "R").length * 2 > n ? "Yes" : "No"}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
const TEST = `6 2 3 4`
// A B C K

// inputに入力データ全体が入る
function Main(input) {
  const inputArr = input.trim().split(" ");
  let countA = parseInt(inputArr[0])
  let countB = parseInt(inputArr[1])
  let countK = parseInt(inputArr[3])
  let res = 0
  res = countK > countA ? countA : countK
  countK = countK - countA
  if (0 >= countK) {
    console.log(res)
    return;
  }
  countK = countK - countB
  if (0 >= countK) {
    console.log(res)
    return;
  }
  res = res - countK
  console.log(res)
}
// Main(TEST)

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11


int main()
{
    int n; cin >> n;
    int a[n];
    int m = 0,ans = 0;
    int cnt[1000005];
    rep(i,1000005) cnt[i] = 0;
    rep(i,n){
        cin >> a[i];
        m = max(m,a[i]);
        cnt[a[i]]++;
    }
    bool ok[m+3];
    rep(i,m+3) ok[i] = true;
    sort(a,a+n);

    ok[0] = false;
    rep(i,n){
        if(!ok[a[i]]) continue;
        for(int k = 2 * a[i]; k <= m; k += a[i]){
            ok[k] = false;
        }
    }
    rep(i,n){
        if(ok[a[i]] && cnt[a[i]] == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int x;
int main() {
  ios::sync_with_stdio(false);
  cin>>x;
  cout<<x+x*x+x*x*x<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;



int set_parent(int now, vector<vector<int>> &edges, vector<int> &height, vector<int> &parent) {

    if (height[now] != -1)
        return height[now];

    if (edges[now].size() == 0) {
        parent[now] = -1;
        return 0;
    }
    int maxx = -1;
    int maxto = -1;
    for (int to : edges[now]) {
        int ret = set_parent(to, edges, height, parent);
        if (ret > maxx) {
            maxx = ret;
            maxto = to;
        }
    }
    parent[now] = maxto;
    height[now] = maxx + 1;
    return maxx + 1;
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    vector<vector<int>> invedges(n);
    vector<int> parent(n);
    vector<int> height(n, -1);
    for (int i = 0; i < n+m-1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
        invedges[b].push_back(a);
    }

    vector<bool> visited(n, false);
    for (int i = 0; i < n; i++)
        set_parent(i, invedges, height, parent);

    for (int i = 0; i < n; i++)
        cout << parent[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 18560
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int arr[N];

int solve()
{
    string t,s;
    cin>>s>>t;
    int an=0,ans=1e9+5;
    for(int i=0;i<s.size()-t.size()+1;i++)
    {
        an=0;
        for(int j=0;j<t.size();j++)
        {
            if(s[i+j]!=t[j])
                an++;
        }
        ans=min(ans,an);
    }
    cout<<ans;
    return 0;
}

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt" ,"r" ,stdin);
    freopen("output.txt" ,"w" ,stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // int t;
    // cin>>t;
    // while(t--)
    solve();

    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        int[] candidates = new int[2];
        for (int i = 0; i < s.length(); i++) {
            if (i % 2 == 0) {
                if (s.charAt(i) == '0') {
                    candidates[0]++;
                } else {
                    candidates[1]++;
                }
            } else {
                if (s.charAt(i) == '1') {
                    candidates[0]++;
                } else {
                    candidates[1]++;
                }
            }
        }
        int ans = Math.min(candidates[0], candidates[1]);
        System.out.println(ans);
    }

}


Measured memory_bytes: 24220
using System.Text;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class hello
{
    public static void Main()
    {
        var sb = new StringBuilder();
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var a = new int[n, n];
            makeMS(a, n);
            print(a, n, sb);
        }
        Console.Write(sb);
    }
    static void print(int[,] a, int n, StringBuilder sb)
    {
        var b = new string[n, n];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
                sb.Append(string.Format("{0,4}", a[i, j]));
            sb.Append("\n");
        }
    }
    static P getNXNY(int[,] a, int n, int x, int y)
    {
        var nx = x + 1;
        var ny = y + 1;
        LA1:;
        if (nx >= n) nx = 0;
        if (ny >= n) ny = 0;
        if (ny < 0) ny = n - 1;
        if (a[nx, ny] == 0) return new P { x = nx, y = ny };
        else { nx++; ny--; }
        goto LA1;
    }
    static void makeMS(int[,] a, int n)
    {
        var p = 1;
        var x = n / 2 + 1; var y = n / 2;
        a[x, y] = p++;
        while (p <= n * n)
        {
            var t = getNXNY(a, n, x, y);
            var nx = t.x;
            var ny = t.y;
            a[nx, ny] = p++;
            x = nx; y = ny;
        }
    }
}




Measured memory_bytes: 15956
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve())
}

func resolve() int {
	n, t := scanInt(sc), scanInt(sc)
	sum := 0
	start, last := 0, 0
	for i := 0; i < n; i++ {
		sum += last - start

		ti := scanInt(sc)
		start = ti
		if ti <= last {
			start = last
		}
		last = ti + t
	}
	sum += last - start
	return sum
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,r,x,y,m,n;
        string s;
        cin>>k>>s;
        n=s.size();
        string ans;
        if(n<=k)
        {
            cout<<s;
            return 0;
        }
        for(i=0;i<k;i++)
            ans.pb(s[i]);
        for(i=0;i<3;i++)
            ans.pb('.');
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;


main()
{
	ios_base::sync_with_stdio(false);
	cout.tie(nullptr);
	long double r;
	cin>>r;
	cout<<fixed<<setprecision(5)<<r*2*3.141592653;
}


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

using namespace std;


int main(){
        
        int A[128], N;
        A[0] = 1;
        for(int i=1; i<=32; i++){
                A[i] = A[i-1];
                if(i>=1) A[i] += A[i-2];
                if(i>=2) A[i] += A[i-3];
        }
        while (cin >> N  && N)  cout << (((A[N] + 9)/ 10) + 364) / 365 << endl;

}

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

 int main(){

  int a,b;
  cin>>a>>b;

  if( a < b ) cout<<"a < b"<<endl;
  if( a > b ) cout<<"a > b"<<endl;
  if( a == b ) cout<<"a == b"<<endl;

  return 0;
  }


Measured memory_bytes: 3048
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		//int result = Integer.MAX_VALUE;
		int from = -1;
		int to = -1;
		char x = ' ';
		char y = ' ';
		for(int i = 0; i < s.length(); i++){
		    char c = s.charAt(i);
		    if(c == x){
		        from = i-1;
		        to = i+1;
		        break;
		    }else if(c == y){
		        from = i;
		        to = i+1;
		        break;
		    }else{
		        x = y;
		        y = c;
		    }
		}
		System.out.println(from + " " + to);
		
		// 出力
		//System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



Measured memory_bytes: 28180
#include<bits/stdc++.h>
using namespace std;
#define lb(x) ((x)&(-(x)))
#define int long long
int f[2][200005],tot=1,dp[200005];
char c[200005];
int n;long long l;
void ins(){
	int k=1,z=strlen(c+1);
	for(int j=1;j<=z;++j){
		if(!f[c[j]-'0'][k])f[c[j]-'0'][k]=++tot;
		dp[k=f[c[j]-'0'][k]]=j;
	}
	dp[k]=-1;
}
main(){
	cin>>n>>l;
	for(int i=1;i<=n;++i){
		scanf("%s",c+1);
		ins();
	}
	long long res=0;
	for(int k=1;k<=tot;++k){
		// cout<<k<<' '<<dp[k]<<' '<<f[0][k]<<' '<<f[1][k]<<endl;
		if(dp[k]==-1)continue;
		if(!f[0][k])res^=lb(l-dp[k]);
		if(!f[1][k])res^=lb(l-dp[k]);
	}
	puts((res!=0)?"Alice":"Bob");
	// printf("%d",res);
	return 0;
}

Measured memory_bytes: 3456
n, m = map(int, input().split())
a = input().split()
a = [int(_) for _ in a]

total_amount = sum(a)
threshold = 1/(4*m) * total_amount
clear_a = [_ for _ in a if _ >= threshold]
if len(clear_a) >= m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define itn int
using ll = long long;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

ll f(ll n,ll x) {
	if (n == -1)
		return 0;
	return n / x + 1 ;
}

signed main() {
	long long int ans;
	ll a, b, x;
	cin >> a >> b >> x;
	ans = f(b, x) - f(a - 1, x);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>

using namespace std;

pair<int,int> place[111111];//1:x,2:y

long long v[111111];

int main(){
  int h,w,d;
  cin>>h>>w>>d;
  for(int i = 0;i<h;i++){
    for(int j = 0;j<w;j++){
      int a;
      cin>>a;
      place[a] = make_pair(j+1,i+1);
    }
  }

  int q;
  cin>>q;

  for(int i = d+1;i<=h*w;i++){
    pair<int,int> pos1 = place[i];
    pair<int,int> pos2 = place[i-d];
    v[i] = v[i-d] + abs(pos1.first-pos2.first)+abs(pos1.second - pos2.second);
  }

  for(int i = 0;i<q;i++){
    long long ans = 0;
    int l,r;
    cin>>l>>r;
    
    //cout<<i<<":"<<ans<<endl;
    cout<<v[r]-v[l]<<endl;
    
  }

  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
int main(void) {
  int S,a,b,c,d;
  scanf("%d",&S);
  
  a = S/1000;
  b = (S%1000)/100;
  c = ((S%1000)%100)/10;
  d = ((S%1000)%100)%10;
  
  if (a==b || b==c || c==d) {
    printf("Bad\n");
  } else {
    printf("Good\n");
  }
  return 0;
}

Measured memory_bytes: 128
N = int(input())

q = input()
a = list(q)

if N % 2 == 1:
  print('No')
  
elif N % 2 == 0:
  b = [a] * int(N/2)
  c = [a] * int(N/2)
  for i in range(int(N/2)):
    b[i] = a[i]
  for j in range(int(N/2)):
    c[j] = a[int(j)+int(N/2)]
  if b == c:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 9128
x, n = map(int,input().split())
L = list(map(int,input().split()))
l, r = x-1, x+1

if n == 0 or x not in L:
  print(x)
  exit()

while True:
  flg = True
  if l not in L:
    print(l)
    break
  elif r not in L:
    print(r)
    break
  l -= 1
  r += 1

Measured memory_bytes: 9112
from collections import deque

H, W = list(map(int, input().split()))
c = [input() for _ in range(H)]

moves = [(-1, 0), (1, 0), (0, -1), (0, 1)]

def bfs():
    visited = [[False for _ in range(W)] for _ in range(H)]
    dist = [[0 for _ in range(W)] for _ in range(H)]
    routes = deque()
    routes.append((0, 0))
    visited[0][0] = True

    while len(routes) > 0:
        x, y = routes.popleft()
        for move in moves:
            cx, cy = x + move[0], y + move[1]
            if cx < 0 or cy < 0 or cx >= W or cy >= H or c[cy][cx] == '#' or visited[cy][cx]:
                continue
            if cx == W-1 and cy == H-1:
                return sum([line.count('.')for line in c]) - dist[y][x] - 2
            visited[cy][cx] = True
            routes.append((cx, cy))
            dist[cy][cx] = dist[y][x] + 1
    return -1

print(bfs())

Measured memory_bytes: 3316
#include <stdio.h>

int m[1000][1000];
int kai[1001][1001];

int main()
{
	while(1)
	{
		int h,w,n;
		scanf("%d %d %d",&h,&w,&n);
		if(h == 0)
		{
			break;
		}
		for(int i = 0; i < h + 1; i++)
		{
			for(int ii = 0; ii < w + 1; ii++)
			{
				kai[i][ii] = 0;
			}
		}
		kai[0][0] = n - 1;
		for(int i = 0; i < h; i++)
		{
			for(int ii = 0; ii < w; ii++)
			{
				int w;
				scanf("%d",&w);
				if(kai[i][ii] % 2 == 0)
				{
					kai[i + 1][ii] += kai[i][ii] / 2;
					kai[i][ii + 1] += kai[i][ii] / 2;
					m[i][ii] = w;
				}
				else
				{
					if(w == 0)
					{
						kai[i + 1][ii] += kai[i][ii] / 2 + 1;
						kai[i][ii + 1] += kai[i][ii] / 2;
						m[i][ii] = 1;
					}
					else
					{
						kai[i + 1][ii] += kai[i][ii] / 2;
						kai[i][ii + 1] += kai[i][ii] / 2 + 1;
						m[i][ii] = 0;
					}
				}
			}
		}
		int nowy = 0;
		int nowx = 0;
		while(1)
		{
			if(nowy == h || nowx == w)
			{
				printf("%d %d\n",nowy + 1,nowx + 1);
				break;
			}
			if(m[nowy][nowx] == 0)
			{
				nowy++;
			}
			else
			{
				nowx++;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 8852
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D; vll path;
//***********//
int main() {
	ll D;
	cin >> D;
	vl C(26);
	for (i = 0; i < 26; i++) cin >> C[i];
	vll S(D, vl(26));
	for (i = 0; i < D; i++) {
		for (j = 0; j < 26; j++) {
			cin >> S[i][j];
		}
	}
	vl T(D);
	vl last(26, -1);
	for (i = 0; i < D; i++) {
		ll pre = 0;
		for (j = 0; j < 26; j++) {
			if (S[i][j]-C[j]*105 > S[i][pre]-C[pre]*105) {
				pre = j;
			}
		}
		T[i] = pre;
	}
	//exit(0);
	//debug用
	ans = -INF;
	for (ll loop = 0; loop < 20; loop++) {
		for (k = 0; k < D; k++) {
			ll pre2 = 0;
			for (l = 0; l < 26; l++) {
				T[k] = l;
				ll pre = 0;
				for (i = 0; i < D; i++) {
					pre += S[i][T[i]];
					last[T[i]] = i;
					for (j = 0; j < 26; j++) {
						pre -= C[j] * (i - last[j]);
					}
				}
				//debug(pre);
				if (ans < pre) {
					ans = pre;
					pre2 = l;
				}
			}
			T[k] = pre2;
		}
	}
	debug(ans);
	for (i = 0; i < D; i++) {
		co(T[i]+1);
	}
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) 
{ 
	if (b == 0) 
		return a; 
	return gcd(b, a % b); 
	
} 
int main()
{
  ll a,b;
  cin>>a>>b;
  cout<<(a*b)/gcd(a,b);
  
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int numberOfPerson = Integer.parseInt(scanner.nextLine());
        int[] boss = new int[numberOfPerson];
        for (int i = 0; i < boss.length - 1; i++){
            boss[scanner.nextInt() - 1]++;
        }
        for (int i : boss){
            System.out.println(i);
        }

        /*
        Scanner scanner = new Scanner(System.in);
        int numberOfPerson = Integer.parseInt(scanner.nextLine());
        List<String> boss = Arrays.asList(scanner.nextLine().split(" "));
        Map<String, Integer> map = boss.stream().collect(
                Collectors.groupingBy(
                        Function.identity(),
                        Collectors.summingInt(s -> 1)
                )
        );
        for (int i = 1; i < numberOfPerson + 1; i++){
            if (map.containsKey(String.valueOf(i))) {
                System.out.println(map.get(String.valueOf(i)));
            }else {
                System.out.println(0);
            }
        }



        int[] array = new int[10];
        for (int i = 0; i < array.length; i++){
            System.out.println(array[i]);
        }

         */
    }
}


Measured memory_bytes: 61744
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=1000023;
bool vis[N];
vector <int> adj[N];
int child[N][30];
int nxt=1;
bool isend[N];
vector <int> paths[N];
void solve()
{
    ll n;
    cin>>n;
    vs v;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        reverse(all(s));
        v.pb(s);
        int node=0;
        for(auto ch:s)
        {
            if(child[node][ch-'a']==0)
            {
                child[node][ch-'a']=nxt++;
            }
            node=child[node][ch-'a'];
            paths[i].pb(node);
        }
        isend[node]=1;
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        string s=v[i];
        int cnt[30]={0};
        for(int j=s.length()-1;j>=0;j--)
        {
            cnt[s[j]-'a']++;
            int node=0;
            if(j>0)
                node=paths[i][j-1];
            for(char ch='a';ch<='z';ch++)
            {
                if(cnt[ch-'a']==0)
                    continue;
                int x=child[node][ch-'a'];
                if(x!=0 && isend[x])
                    ans++;
            }
        }
    }
    ans-=n;
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 174948
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
bool is_prime(int tmp){
  for(int j = 3; j < tmp; j+= 2){
    if(tmp%j == 0) return false;
  }

  return true;
}

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

  int tmp = x;
  int ans = 0;
  if (x == 2){
    ans = 2;
  }else{
    for(int i = 0; i < 100000; i++){
      int tmp = x + i;
      if (is_prime(tmp)){
        ans = tmp;
        break;
      }
    }
  }


  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
AB = []
for _ in range(N):
  AB.append([int(input()),True])
for _ in range(N):
  AB.append([int(input()),False])
AB.sort(key = lambda x:x[0])

ans = 1
c = 0
for _,f in AB:
  if f:
    c += 1
  else:
    if c>0:
      ans *= c
      c -= 1
      ans %= 10**9+7
    else:
      c -= 1
      ans *= -1*c
      ans %= 10**9+7
print(ans)

Measured memory_bytes: 87640
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,k,maxn=-100000,minn=100000;
int main()
{
	cin>>n>>m>>x>>y;
	for(int i=1;i<=n;i++){cin>>k;maxn=max(maxn,k);};
	for(int i=1;i<=m;i++){cin>>k;minn=min(minn,k);};
	int minnn=min(min(min(x,y),maxn),minn),maxnn=max(max(max(x,y),maxn),minn);
	for(int z=minnn;z<=maxnn;z++) if(x<z&&z<=y&&maxn<z&&z<=minn){cout<<"No War"<<endl;return 0;};
	cout<<"War"<<endl;
	return 0;
}

Measured memory_bytes: 256
s = int(input())
def func(n):
  if n%2 == 1:
    return 3*n+1
  else:
    return n//2
def prog(N):
  if N == 1:
    return s
  else:
    a=s
    for i in range(1,N):
      a = func(a)
    return a

b=[]
for i in range(1,1000000):
  tmp = prog(i)
  if tmp in b:
    print(i)
    break
  else:
    b.append(tmp)
  



Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var right_top = 0;
            var left_top = 0;

            var n = ReadInt();
            
            for (int i = 0; i < n; i++)
            {
                var input = ReadInts();
                var ans = "YES";

                for (int j = 0; j < input.Length; j++)
                {
                    if (right_top < input[j])
                    {
                        right_top = input[j];
                    }
                    else if (left_top < input[j])
                    {
                        left_top = input[j];
                    }
                    else
                    {
                        ans = "NO";
                    }
                }
                WriteLine(ans);
                right_top = 0;
                left_top = 0;
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 15872
#include <stdio.h>
int main(void)
{
	int W,H,x,y,r;
	int flg=0;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	//chek width
	if(((x-r)>=0) && ((x+r)-W)<=0){
		//check height
		if(((y-r)>=0) && ((y+r)-H)<=0){
			printf("Yes\n");
			flg=1;
		}
	}
	
	if(flg==0)
		printf("No\n");
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;


int main()
{
    int n, tmp;
    string s;
    cin >> n >> s;
    tmp = n/2;
    if (n%2) cout << "No" << endl;
    else {
        for (int i = 0; i < n/2; i++) {
            if (s[i] != s[i+tmp]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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; }

typedef long long ll;
using namespace std;

int main() {
    
    int deg[4] = {};

    REP(i, 3) {
        int a, b;
        cin >> a >> b;
        deg[a-1]++; deg[b-1]++;
    }

    REP(i, 4) {
        if (deg[i] != 1 && deg[i] != 2) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

}

Measured memory_bytes: 256
import sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
MOD=10**9+7
plus=[]
minus=[]
zero=[]
for i in range(n):
  if a[i]>0:
    plus.append(a[i])
  if a[i]<0:
    minus.append(a[i])
  if a[i]==0:
    zero.append(a[i])
if k==n:
  ans=1
  for i in range(k):
    ans=(ans*a[i])%MOD
  print(ans)
  sys.exit()
if len(plus)==0:
  if k%2!=0:
    a.reverse()
  ans=1
  for i in range(k):
    ans=(ans*a[i])%MOD
  print(ans)
  sys.exit()
if len(plus)+len(minus)<k:
  print(0)
  sys.exit()
m=len(minus)
minus.sort()
plus.reverse()
plpointer=k
if k>len(plus):
  plpointer=2*(len(plus)//2)
  if k%2==1:
    if plpointer+1<=len(plus):
      plpointer+=1
    else:
      plpointer-=1
mnpointer=k-plpointer
while mnpointer<m-1 and plpointer>=2 and minus[mnpointer]*minus[mnpointer+1]>plus[plpointer-1]*plus[plpointer-2]:
  mnpointer+=2
  plpointer-=2
ans=1
for i in range(mnpointer):
  ans=(ans*minus[i])%MOD
for i in range(plpointer):
  ans=(ans*plus[i])%MOD
print(ans)


Measured memory_bytes: 107268
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int N;
    cin >> N;
    auto get_num = [](char ch) -> int {
        if(ch == 'U')   return 0;
        else if(ch == 'R')  return 1;
        else if(ch == 'D')  return 2;
        else    return 3;   // ch == 'L'
    };
    vector<int> X(N), Y(N), dir(N);
    for(int i = 0; i < N; ++i){
        char ch;
        cin >> X[i] >> Y[i] >> ch;
        dir[i] = get_num(ch);
    }
    int ans = INF;
    for(int loop = 0; loop < 4; ++loop){
        map<int, vector<P>> mp, manhattan_mp;
        for(int i = 0; i < N; ++i){
            if(~dir[i] & 1) mp[X[i]].emplace_back(Y[i], dir[i]);
            if(dir[i] < 2)  manhattan_mp[X[i] + Y[i]].emplace_back(Y[i], dir[i]);
        }
        for(auto& it : mp){
            vector<P> table = it.second;
            sort(table.begin(), table.end());
            int prev_u = -1;
            for(auto p : table){
                if(!p.second)   prev_u = p.first;
                else if(prev_u != -1)   chmin(ans, (p.first - prev_u) * 5);
            }
        }
        for(auto& it : manhattan_mp){
            vector<P> table = it.second;
            sort(table.begin(), table.end());
            int prev_u = -1;
            for(auto p : table){
                if(!p.second)   prev_u = p.first;
                else if(prev_u != -1)   chmin(ans, (p.first - prev_u) * 10);
            }
        }
        swap(X, Y);
        for(int i = 0; i < N; ++i){
            Y[i] = -Y[i];
            if(++dir[i] == 4)   dir[i] = 0;
        }
    }
    if(ans == INF)  cout << "SAFE\n";
    else    cout << ans << '\n';
}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
		}
		for(int i = 0; i < n; i++) {
			y[i] = stdIn.nextInt();
		}
		for(int p = 1; p <= 3; p++) {
			double dis = 0.0;
			for(int i = 0; i < n; i++) {
				dis += Math.pow(Math.abs(x[i] - y[i]),p);
			}
			System.out.println(Math.pow(dis, 1.0/p));
 		}
		int max = 0;
		for(int i = 0; i < n; i++) {
			max = Math.max(max, Math.abs(x[i] - y[i]));
		}
		System.out.println(max);
		
	}
}

Measured memory_bytes: 20516
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

int main() {
	long long W,H;
	cin>>W>>H;
	vector<long long> p(W);
	vector<long long> q(H);
	for(auto& val:p)
		cin>>val;
	for(auto& val:q)
		cin>>val;

	sort(begin(p),end(p));
	sort(begin(q),end(q));

	int w=0;
	int h=0;

	int i=0,j=0;

	long long ans=0;

	while(1){
		if(i<W && j<H){
			if(p[i]<=q[j]){
				ans+=p[i]*(H-j+1);
				++i;
			}
			else{
				ans+=q[j]*(W-i+1);
				++j;
			}
		}
		else if(i<W && j>=H){
			ans+=p[i];
			++i;
		}
		else if(i>=W && j<H){
			ans+=q[j];
			++j;
		}
		else break;
	}

	cout<<ans<<endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		if (a > b) System.out.println("0");
		else if (n == 1)
			if (a != b) System.out.println("0");
			else System.out.println("1");
		else System.out.println((b - a) * (n - 2) + 1);
	}
}

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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1000000000;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> struct UF {
    vector<int> par;
    vector<T> sz;

    UF(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

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

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

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    UF<int> uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        if (! uf.same(a, b)) uf.unite(a, b); 
    }

    int ans = -1;
    rep(i, n) ans = max(ans, uf.size_of_tree(i));

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4768
#include<iostream>
using namespace std;
int main(){
    int a,b,c,x;
    int count=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            for(int k=0;k<=c;k++)
            {
                if(i*500+j*100+k*50==x)
                {
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    ll x,k;
    cin>>x>>k;
    for(int i=k-x+1;i<k+x-1;i++){
        cout<<i<<" ";
    }
    cout<<k+x-1<<endl;
    
    
}
   



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(a>=b)cout<<"delicious"<<endl;
	else if(x+1<=b-a)cout<<"dangerous"<<endl;
	else cout<<"safe"<<endl;
	return 0;
}

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

using namespace std;

#define fo(i,n) for(int i=0; i<n; i++)
#define Fo(i,k,n) for(int i=k; i<n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int N;
int mx = 408;
vvl dp;
vl a;

ll sum(int l, int r){
    ll s=0;
    for(int i=l; i<=r; i++){
        s+=a[i];
    }
    return s;
}

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

    cin>>N;
    dp.resize(mx,vl(mx));
    a.resize(N);
    Fo(i,0,N)cin>>a[i];
    for(int l=N-1; l>=0; l--){
        for(int r=l; r<N; r++){
            if(l==r){
                dp[l][r]=0;
            }else{
                dp[l][r] = LONG_MAX;
                ll s = sum(l,r);
                // cout<<s<<endl;
                for(int i=l; i<r; i++){
                    dp[l][r] = min(dp[l][r], dp[l][i]+dp[i+1][r]+s);
                }
            }
        }
    }
    cout<<dp[0][N-1]<<endl;
    
    return 0;
}

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

int N, A[100005], B[100005], C[100005], fw[100005];
double m[100005], c[100005], val[100005];
vector< pair<double, double> > V;
vector<double> V2;

void upd(int p, int v) {
	p++;
	for (int i = p; i <= N; i += (i & (-i))) fw[i] += v;
}

int qry(int p) {
	p++;
	int ans = 0;
	for (int i = p; i > 0; i-=(i&(-i))) ans += fw[i];
	return ans;
}

int cnt = 0;

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d%d%d", &A[i], &B[i], &C[i]);
	for (int i = 0; i < N; i++) {
		m[i] = -(double)A[i]/B[i];
		c[i] = (double)C[i]/B[i];
	}
	long long target = (long long)((long long)N * (N - 1) + 2) / 4;
	double bot = -1000000000, top = 1000000000, mid;
	while (bot + 1e-12 < top) {
		cnt++;
		if (cnt > 100) break;
		mid = (bot + top) / 2;
		V.clear();
		V2.clear();
		for (int i = 0; i < N; i++) {
			val[i] = m[i] * mid + c[i];
			V.push_back(make_pair(m[i], i));
			V2.push_back(val[i]);
			//printf("val[%d] = %lf (%lf)\n", i, val[i], m[i]);
		}
		sort(V.begin(), V.end());
		sort(V2.begin(), V2.end());
		memset(fw, 0, sizeof(fw));
		long long ans = 0;
		for (int p = 0; p < N; p++) {
			int i = V[p].second;
			int idx = lower_bound(V2.begin(), V2.end(), val[i]) - V2.begin();
			//printf("%lf %d\n", val[i], idx);
			int found = qry(idx);
			//printf("found: %d\n", found);
			ans += found;
			upd(idx, 1);
		}
		//printf("attempting %lf: %lld\n" , mid, ans);
		if (ans < target) bot = mid;
		else top = mid; 
	}
	double x = bot;
	cnt = 0;
	for (int i = 0; i < N; i++) swap(A[i], B[i]);
	
	
	
	
	for (int i = 0; i < N; i++) {
		m[i] = -(double)A[i]/B[i];
		c[i] = (double)C[i]/B[i];
	}
	target = (long long)((long long)N * (N - 1) + 2) / 4;
	bot = -1000000000;
	top = 1000000000;
	while (bot + 1e-12 < top) {
		cnt++;
		if (cnt > 100) break;
		mid = (bot + top) / 2;
		V.clear();
		V2.clear();
		for (int i = 0; i < N; i++) {
			val[i] = m[i] * mid + c[i];
			V.push_back(make_pair(m[i], i));
			V2.push_back(val[i]);
			//printf("val[%d] = %lf (%lf)\n", i, val[i], m[i]);
		}
		sort(V.begin(), V.end());
		sort(V2.begin(), V2.end());
		memset(fw, 0, sizeof(fw));
		long long ans = 0;
		for (int p = 0; p < N; p++) {
			int i = V[p].second;
			int idx = lower_bound(V2.begin(), V2.end(), val[i]) - V2.begin();
			//printf("%lf %d\n", val[i], idx);
			int found = qry(idx);
			//printf("found: %d\n", found);
			ans += found;
			upd(idx, 1);
		}
		//printf("attempting %lf: %lld\n" , mid, ans);
		if (ans < target) bot = mid;
		else top = mid; 
	}
	printf("%.12lf %.12lf\n", x, bot);
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 23;

char s[N][N];
int d[N][N][N][N];
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

void solve() {
  int h, w; scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      for (int k = 0; k < h; ++k)
	for (int l = 0; l < w; ++l)
	  d[i][j][k][l] = 1e3; // inf
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      scanf(" %c", &s[i][j]);
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) {
      if (s[i][j] == '#') continue;
      d[i][j][i][j] = 0;
      for (int k = 0; k < 4; ++k)
	if (j+dx[k] >= 0 && j+dx[k] < w && i+dy[k] >= 0 && i+dy[k] < h && s[i+dy[k]][j+dx[k]] == '.')
	  d[i][j][i+dy[k]][j+dx[k]] = d[i+dy[k]][j+dx[k]][i][j] = 1;
    }
  for (int m = 0; m < h; ++m)
    for (int n = 0; n < w; ++n)
      for (int i = 0; i < h; ++i)
	for (int j = 0; j < w; ++j)
	  for (int k = 0; k < h; ++k)
	    for (int l = 0; l < w; ++l)
	      d[i][j][k][l] = min(d[i][j][k][l], d[i][j][m][n] + d[m][n][k][l]);
  int ans = 0;
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j)
      if (s[i][j] == '.')
	for (int k = 0; k < h; ++k)
	  for (int l = 0; l < w; ++l)
	    if (s[k][l] == '.')
	      ans = max(ans, d[i][j][k][l]);
  printf("\n%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 1152
import fractions

n,k = map(int,input().split())
a = list(map(int,input().split()))

if k > max(a):
    print("IMPOSSIBLE")
elif n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    minak = min(a)

    gcda = fractions.gcd(a[0],a[1])

    for i in range(0,n):
        gcda = fractions.gcd(gcda,a[i])
        if gcda ==1:
            break

    if gcda == 1 or k % gcda == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 16244
S = list(input())
N = len(S)
k = 0
l = 0

for i in range(N):
	if i % 2 == 0:
		if int(S[i]) == 0:
			k += 0
		else:
			k += 1
	else:
		if int(S[i]) == 1:
			k += 0
		else:
			k += 1

for i in range(N):
	if i % 2 == 0:
		if int(S[i]) == 1:
			l += 0
		else:
			l += 1
	else:
		if int(S[i]) == 0:
			l += 0
		else:
			l += 1
            
print(min(k,l))


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), count(N);
    for (int i = 1; i < N; i++) {
        cin >> A.at(i);
        count.at(A.at(i) - 1)++;
    }

    for (int i = 0; i < N; i++) {
        cout << count.at(i)<< endl;
    }

    return 0;
}

Measured memory_bytes: 4840