akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[,] map = new int[3, 3];
        int[] yoko = new int[3];
        int[] tate = new int[2];
        bool mustBreak = false;
        bool isValid = true;
        for (int i = 0; i < 3; i++) {
            int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            for (int j = 0; j < 3; j++) {
                if(i==0) {
                    if(j>0) {
                        yoko[j - 1] = inpt[j] - inpt[j - 1];
                    }
                } else {
                    if(j>0) {
                        if (inpt[j] - inpt[j - 1] != yoko[j - 1])
                        {
                            mustBreak = true;
                            isValid = false;
                            break;
                        }
                    }
                }
                map[i, j] = inpt[j];
            }
            if(mustBreak) {
                break;
            }
        }
        if(isValid) {
            for (int i = 0; i < 3; i++) {
                for (int j = 1; j < 3; j++) {
                    if(i==0) {
                        tate[j - 1] = map[i, j] - map[i, j - 1];
                    } else {
                        if(map[i, j]-map[i, j-1]!=tate[j-1]) {
                            isValid = false;
                            break;
                        }
                    }
                }
            }
        }
        string ans = isValid ? "Yes" : "No";
        Console.WriteLine(ans);
    }



    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


1 8 6
2 9 7
0 7 7

";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13396
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

n = int(input())
edge = [[] for _ in range(n+1)]
for i in range(n-1):
    a, b = map(int,input().split())
    edge[a].append((b, i))
    edge[b].append((a, i))
colors = 0
for i, line in enumerate(edge):
    colors = max(colors, len(line))
print(colors)
work_q = deque()
work_q.append((1, -1, -1))
color = [-1] * (n - 1)

while work_q:
    here, prev, col = work_q.popleft()
    cnt = 1
    for to, ind in edge[here]:
        if to == prev:
            continue
        if cnt == col:
            cnt += 1
        color[ind] = cnt
        work_q.append((to, here, cnt))
        cnt += 1
print(*color, sep="\n")


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

using namespace std;
typedef long long ll;
int main(){
    ll n;
    ll a;
    ll b, blu;
    cin>>n>>a>>b;
    ll c=a;
    if(n%(a+b)<a){
        c=n%(a+b);
    }
    blu=n/(a+b)*a+c;
    cout<<blu;
    return 0;
}

Measured memory_bytes: 256
primes = (2..10000).to_a
primes.each do |prime|
	primes.reject!{|num| num != prime and num % prime == 0}
end

while (number = gets.chomp.to_i) > 0
	candidates = primes.select{|prime| prime <= number}
	b, e = 0, 0
	answer = 0
	while true
		sum = candidates[b..e].inject(:+)
		if sum < number
			if e == candidates.size - 1
				break
			else
				e += 1
			end
		elsif sum > number
			b += 1
		else
			answer += 1
			if e == candidates.size - 1
				break
			else
				e += 1
			end
		end
	end
	puts answer
end

Measured memory_bytes: 8932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	int a, b;

	std::cin >> a >> b;

	std::cout << (a - 1) * (b - 1) << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(void) {
  int N, M;
 
  while (1) {
    vector<int> masu, dice;
    cin >> N >> M;
    if (N == 0 && M == 0) break;
 
    for (int i = 0; i < N; i++) {
      int tmp;
      cin >> tmp;
      masu.push_back(tmp);
    }
    for (int i = 0; i < M; i++) {
      int tmp;
      cin >> tmp;
      dice.push_back(tmp);
    }
   
    int pos = 1, turn = 1;
 
    while (turn < M) {
      pos += dice[turn-1];
      pos += masu[pos-1];
      if (pos >= N) break;
      turn++;
    }
 
    cout << turn << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3080
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;


public class Main {
     
	public static void main (String[] args) {
	Scanner s=new Scanner(System.in);
	double pi=3.141592653;
	int r=s.nextInt();
	System.out.println(pi*2*r);
	}
}

Measured memory_bytes: 36000
import java.util.Scanner;
public class Main{
    public static void main(String args[]) {
        //System.out.println("input number");
    
        Scanner inputn_number = new Scanner(System.in);
       
        int num1= Integer.parseInt(inputn_number.next());
        int num2 = Integer.parseInt(inputn_number.next());
     
 
        //System.out.println("output number");
        System.out.println( num1 * num2 );
    
 
 
 
    }
}

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

unsigned long long cases[101][4][4][4][4]; 

void calc_cases(int n, int i, int j, int k, int l) {
  
  if (
    (j==1&&k==2&&l==3) || (j==1&&k==3&&l==2) || (j==2&&k==1&&l==3) || (i==1&&j==2&&l==3) || (i==1&&k==2&&l==3)
  ) {
    
    cases[n][i][j][k][l] = 0;
    
  } else {
    
    for (int m = 0; m < 4; m++) {
      cases[n][i][j][k][l] += cases[n-1][m][i][j][k];
    }
    cases[n][i][j][k][l] %= 1000000007;
  }
}

int main() {
  int n;
  cin >> n;
  cases[0][3][3][3][3] = 1;
  for (size_t a = 1; a <= n; a++) {
    for (size_t i = 0; i < 4; i++) {
      for (size_t j = 0; j < 4; j++) {
        for (size_t k = 0; k < 4; k++) {
          for (size_t l = 0; l < 4; l++) {
            calc_cases(a,i,j,k,l);
          }
        }
      }
    }
  }

  unsigned long long sol = 0; 

  for (size_t i = 0; i < 4; i++) {
    for (size_t j = 0; j < 4; j++) {
      for (size_t k = 0; k < 4; k++) {
        for (size_t l = 0; l < 4; l++) {
          sol += cases[n][i][j][k][l];
        }
      }
    }
  }
  cout << sol % 1000000007 << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n, m, l[100005], r[100005], i, j, a, b;
    cin>>n>>m;
    for(i=0; i<m; i++)
    {
        cin>>l[i]>>r[i];
    }
    sort(l, l+m);
    sort(r, r+m);
    b=r[0]-l[m-1];
    if(b<0)
    {
        a=0;
    }
    else
    {
        a=b+1;
    }
    cout<<a;
    return 0;
}

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

vector<ll> st[100010];
ll p[100010],y[100010];

int main(){
    int N,M;cin>>N>>M;
    rep(i,0,M){
        cin>>p[i]>>y[i];
        st[p[i]].push_back(y[i]);
    }
    rep(i,0,N)sort(st[i+1].begin(),st[i+1].end());
    rep(i,0,M){
        rep(j,0,11-floor(log10(ll(p[i])*1000000+int(lower_bound(st[p[i]].begin(),st[p[i]].end(),y[i])-st[p[i]].begin())+1)))cout<<0;
        cout<<ll(p[i])*1000000+ int(lower_bound(st[p[i]].begin(),st[p[i]].end(),y[i])-st[p[i]].begin())+1<<endl;
    }
    
    
}







Measured memory_bytes: 8576
var lines = [];
var MOD = Math.pow(10, 9) + 7;

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);
    lines.shift();

    var a = Array(N); var result = 0;
    var tmp_1 = lines[0].split(" ")
    for (var i = 0; i < N; i++) {
        result += Number(tmp_1[i]) - 1;
    }

    console.log(result);
});

Measured memory_bytes: 7756
/*author - Aryan Mittal*/
#include<bits/stdc++.h>
using namespace std;

#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"

#define pow2(x) ((x)*(x))
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front

#define mod 1000000007
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)

#define mp make_pair
#define ff first
#define ss second
#define null NULL

#define all(c) (c).begin(),(c).end()
#define nl "\n"

typedef vector<ll> vl;
typedef vector< vl > vvl;
typedef pair< ll,ll> pll;
typedef map< ll,ll> mll;

int main(){

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

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

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

	// cout<<a<<" "<<b<<"\n";
	// cout<<"Aryan"<<"\n"; 
	// cerr<<"Aryan "<<a;

	ll a,b,c,d;
	cin>>a>>b>>c>>d;

	ll ans = 0;
	while(a>0 && c>0){
		ans++; // k turn if ans = odd
		if(ans%2!=0){
			c = c - b;
		}else{
			a = a - d;
		}

		if(a<=0 || c<=0){
			break;
		}
	}

	if(ans%2!=0){
		cout<<"Yes"<<"\n";
	}else{
		cout<<"No"<<"\n";
	}
	


	return 0;
}


Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

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

        int work = n;
        long sum = 0;

        while (work != 0) {
            sum += work % 10;
            work /= 10;
        }

        if (n % sum == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
n, x = [int(i) for i in input().split()]

if x == 1 or x == 2*n-1:
    print('No')
    exit()

A = [i for i in range(0, 2*n)]

A[n], A[x] = x, A[n]
i = A.index(x-1)
A[n-1], A[i] = A[i], A[n-1]
i = A.index(x+1)
A[n+1], A[i] = A[i], A[n+1]

print('Yes')

for i in range(1, 2*n):
    print(A[i])

Measured memory_bytes: 12496
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define LLIandI pair<long long int , int>
#define ll long long

int main(){
    int N;
    scanf("%d",&N);
    int x[101];
    int y[101];
    int h[101];
    int map[101][101];
    int maxmap[101][101];//10^9
    bool fmap[101][101];//otozure
    rep(i,101){
        rep(j,101){
            map[i][j]=-100;//not otozure
            maxmap[i][j]=1001001001;
        }
    }
    int cx,cy,ch;
    // max(H−|X−CX|−|Y−CY|,0)
    rep(i,N){
        scanf("%d %d %d", &x[i] , &y[i] , &h[i]);
        rep(j,101){
            rep(k,101){
                int kyori=abs(j-x[i] )+abs(k-y[i]);
                if(map[j][k]==-1)continue;
                if(h[i]>0){
                    if(map[j][k]==-100)map[j][k]=h[i]+kyori;
                    else if(map[j][k]!=h[i]+kyori ){map[j][k]=-1;}//not here
                }else{
                    if(map[j][k]>=0&&map[j][k]-kyori>0)map[j][k]=-1;
                    maxmap[j][k]=min(maxmap[j][k],kyori);
                }
            }
        }
    }
    /*rep(i,101){
        rep(j,101){
            printf("%d ",map[i][j]);
        }
        printf("\n");
    }*/
    rep(i,101){
        rep(j,101){
            if(maxmap[i][j]>=map[i][j]&&map[i][j]>0){
                printf("%d %d %d\n",i,j,map[i][j]);
                //printf("%d %d %d %d\n",i,j,map[i][j],maxmap[i][j]);
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    while (true){
        if ((x == 0) & (y == 0)){
            break;
        } else if (x <= y){
            cout << x << " " << y << endl;
        } else if (x > y){
            cout << y << " " << x << endl;
        }
        cin >> x >> y;
    }
    return 0;
}


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

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	for (auto& e : h) {
		cin >> e;
	}
	cout << count_if(h.begin(), h.end(), [&](auto a) {return a >= k;});
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);
        if (N == M) { Console.WriteLine("Yes"); }
        else Console.WriteLine("No");
    }
}


Measured memory_bytes: 13140
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let N = readInt()!
var L = [2, 1]
for i in 2...86 {
    L += [L[i-1] + L[i-2]]
}
print(L[N])


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
char sym[128];
   
void init() {
  sym['i'] = 'i';
  sym['w'] = 'w';
  sym['('] = ')';
  sym[')'] = '(';
}
   
int main() {
  init();
     
  string str;
  getline(cin, str);
     
  int n = str.size();
  int cnt = 0;
  for(int i=0; i<n/2+1; i++) {
    if(sym[str[i]] != str[n-i-1]) cnt ++;
    str[n-i-1] = sym[str[i]];
  }
  cout << cnt << endl;
     
  return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1001001001;
vector<int> to[100005];

int main()
{
	int n, m;
	cin >> n >> m;
	rep(i, m)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a); //to[0] 1; to[1] 0,2,3;�@to[2] 1,3; to[3] 1,2;
	}
	queue<int> q;
	vector<int> dist(n, INF);//dist{INF,INF,...,INF}
	vector<int>pre(n, -1);//pre{-1,-1,...,-1}
	dist[0] = 0;//dist{0,INF,...}
	q.push(0); //q {0}
	while (!q.empty())//q�ɗv�f�������Ƃ�
	{
		int v = q.front();	q.pop();//v=0 //v=1 //v=2,3�̎������l�ɂ���
		for (int u : to[v])//u=1�@//u=0,2,3
		//to[v]�Ɋ܂܂��邷�ׂĂ�u�ɑ΂���
		{
			if (dist[u] != INF) continue; //dist��1�����X�V�����ĂȂ��Ƃ��ɓ������s��
			dist[u] = dist[v] + 1;//dist{0,1,INF,...}�@//dist{0,1,2,2}
			pre[u] = v;// pre{-1,0,...}//pre{-1,0,1,1}
			q.push(u);//q{0,1}//q{0,1,2,3}
		}
	}
	auto result = find(dist.begin(), dist.end(), INF);
	if (result == dist.end()) {
		cout << "Yes" << endl;
		rep(i, n)
		{
			if (i == 0)continue;
			int ans = pre[i];
			++ans;
			cout << ans << endl;
		}
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 10612
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, k := scanInt(), scanInt()
	p := scanInts(n)
	c := scanInts(n)

	ans := -1 << 60

	for i := 0; i < n; i++ {
		ss := make([]int, n)
		tt := make([]int, n)

		s := 0
		t := 0
		u := i

		for tt[p[u]-1] == 0 && p[u]-1 != i && t < k {
			u = p[u] - 1
			t++
			tt[u] = t
			s += c[u]
			ss[u] = s
			ans = max(ans, ss[u])
		}

		u = p[u] - 1
		cyc := t - tt[u] + 1
		tot := s - ss[u] + c[u]
		if tot > 0 {
			b := u
			ans = max(ans, ss[u]+tot*((k-tt[u])/cyc))

			for p[u]-1 != b {
				u = p[u] - 1
				ans = max(ans, ss[u]+tot*((k-tt[u])/cyc))
			}
		}
	}

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 6364
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

int main() {
    lli N, X;
    cin >> N >> X;

    vector<lli> L(N);
    for (int i = 0; i < N; ++i) {
        cin >> L[i];
    }

    lli D = 0;
    lli counter = 1;
    for (int i = 0; i < N; ++i) {
        D = D + L[i];
        if (D <= X) {
            ++counter;
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
N,L = map(int,input().split())
azi = list(range(L,L+N))
if(L >= 0):
    ans = sum(azi) - L
elif(L <= 0 and L+N-1 >= 0):
    ans = sum(azi)
else:
    ans = sum(azi) - (L+N-1)
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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;
}

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll lcm(ll a, ll b) {
	return a*b/gcd(a,b);
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int a,b,k; cin>>a>>b>>k;
	int res,j;
	for(res=min(a,b), j=0; j<k; res--) {
		if(!(a%res)&&!(b%res)) j++;
	}
	cout<<res+1<<endl;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  int x1, x2, dx;
  int y1, y2, dy;
  std::cin >> x1 >> y1 >> x2 >> y2;
  dx = x2 - x1;
  dy = y2 - y1;
  std::cout << (x2 - dy) << " " << (y2 + dx) << " "
	    << (x1 - dy) << " " << (y1 + dx) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;//1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class Rng>
void in(Rng& x) {
	cin >> x;
}

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class Rng>
void in(vector<Rng>& v, LL st = -1, LL en = -1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, M;
	cin >> N >> M;
	VVLL map;
	map.resize(N);
	for (LL m = 0; m < M; m++) {
		LL a, b;
		cin >> a >> b;
		a--; b--;
		map[a].push_back(b);
		map[b].push_back(a);
	}
	VLL res(N, 3);
	struct query {
		LL i, n;
	};
	queue <query> q;
	q.push({ 0,0 });
	res[0] = 0;
	while (!q.empty()) {
		LL pos = q.front().i;
		LL n = q.front().n;
		q.pop();
		if (n >= 2)continue;
		if (res[pos] != n)continue;
		for (LL next : map[pos]) {
			if (res[next] <= n)continue;
			res[next] = n + 1;
			q.push({ next,n + 1 });
		}
	}
	if (res.back() <= 2)cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 15976
def main():
    S = input()

    if S.find("RRR") > -1:
        print(3)
    elif S.find("RR") > -1:
        print(2)
    elif S.find("R") > -1:
        print(1)
    else:
        print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9100
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
static const int MAX_M = 100000;
struct Interval{int s, t;};

int N, M;
Interval a[MAX_M];

bool comp(const Interval &a, const Interval &b){
	return a.t < b.t;
}

int main(){
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		cin >> a[i].s >> a[i].t;
	}
	sort(a, a + M, comp);
	int cnt = 0;
	for(int i = 0; i < M; i++){
		Interval b = a[i];
		while(i < M && a[i + 1].s < b.t){
			i++;
		}
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
AB=sorted(AB,key=lambda x:x[0])
ans=0
for i in range(N):
  if M-AB[i][1]>=0:
    M-=AB[i][1]
    ans+=AB[i][1]*AB[i][0]
  else:
    if M>0:
      ans+=AB[i][0]*M
    break
print(ans)

Measured memory_bytes: 29788
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    string S;
    read(S);
    string ans = "YES";
    int i = S.size() - 1;
    while(i >= 0){
        string s5 = (i - 4 >= 0)? S.substr(i - 4, 5) : "";
        string s6 = (i - 5 >= 0)? S.substr(i - 5, 6) : "";
        string s7 = (i - 6 >= 0)? S.substr(i - 6, 7) : "";
        if(s5 == "dream" || s5 == "erase"){
            i -= 5;
        }
        else if(s6 == "eraser"){
            i -= 6;
        }
        else if(s7 == "dreamer"){
            i -= 7;
        }
        else {
            ans = "NO";
            break;
        }
    }
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 512
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    string s;
    ll k,ss;
    cin>>s>>k;
    ss = s.size();
    rep(i,ss){
        if(k<=0) break;
        else{
            if((s[i]!='a')&&('z'-s[i]+1)<=k){
                k -= 'z' - s[i] +1;
                s[i] = 'a';
            }
        }
    }
    k %= 26;
    rep(i,ss){
        if(k<=0) break;
        else{
            if(('z'-s[ss-1-i])<=k){
                k -= 'z' - s[ss-1-i];
                s[ss-1-i] = 'z';
            }else{
                s[ss-1-i] += k;
                k = 0;
            }
        }
    }
    cout<<s<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>

using namespace std;

#define open  freopen("input.txt","r",stdin)
#define close  freopen ("output.txt","w",stdout)
#define db double
#define ll long long
#define llu unsigned long long
#define loop(i,a,n) for(int i=a;i<=n;i++)
#define sf scanf
#define sf1(a) sf("%d",&a)
#define sf2(a,b) sf("%d %d",&a,&b)
#define sf3(a,b,c) sf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) sf("%d %d %d %d",&a,&b,&c,&d)
#define sfd(a) sf("%lf",&a)
#define sfd2(a,b) sf("%lf %lf",&a,&b)
#define sfl1(a) sf("%lld",&a)
#define sfl2(a,b) sf("%lld %lld",&a,&b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pf printf
#define pfi(x) pf("%d",x)
#define pfl(x) pf("%lld",x)
#define NL puts("")
#define bug pf("here is bug\n")
#define pft(tc) printf("Case %d:",tc++)
#define PI (2.0*acos(0.0))
//#define PI acos(-1.0)
#define mem(a,v) memset(a,v,sizeof a)
#define endl '\n'
#define pb push_back
#define xx first
#define yy second
#define mp make_pair
#define all(a) a.begin(),a.end()


template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T lcm(T a,T b)
{
    return (a/gcd(a,b))*b;
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}   // M is prime}
template <class T> inline T bpow(T p,T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}




//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={0,1,0,-1};int dy[]={1,0,-1,0}; //4 Direction


#define inf 99999999
#define MX 1000006
#define mod (ll) 1000000007
#define eps 1e-6
#define ub upper_bound // return the right most index of x<val
#define lb lower_bound // return the right most index of x<=val



struct data
{
    int e1,e2,e3;
    data() {}
    data(int a,int b,int c)
    {
        e1=a,e2=b,e3=c;
    }
    bool friend operator<(data a,data b)
    {
        return  a.e1> b.e1;// sort decreasingly but increasingly for priority_queue
    }
};


int n,m,k;
ll N,M,K;


int main()
{
    int t,tc=1;
	sf2(n,m);
	n+=m;
	n%=24;
	pf("%d\n",n);

    return 0;
}

/*




*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 struct UnionFind {
     vector<int> par;

     UnionFind(int n) : par(n, -1) { } //初期化
     
     int root(int x) {
         if (par[x] < 0) return x;
         else return par[x] = root(par[x]);
     }

     bool issame(int x, int y) {
         return root(x) == root(y);
     }

     bool merge(int x, int y) {
         x = root(x); y = root(y);
         if (x == y) return false; //root同じ場合
         if (par[x] > par[y]) swap(x, y); // merge technique
         par[x] += par[y];
         par[y] = x;
         return true;
     }

     int size(int x) {
         return -par[root(x)];
     }
 };

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

     UnionFind uf(N);
     ll cur = N * (N-1) / 2;
     vector<ll> res;
     for (int i = 0; i < M; ++i) {
         res.push_back(cur);
         int a = A[M-1-i], b = B[M-1-i];
         if (uf.issame(a, b)) continue;

         ll sa = uf.size(a), sb = uf.size(b);
         cur -= sa * sb;
         uf.merge(a, b);
     }

     reverse(res.begin(), res.end());
     for (int i = 0; i < res.size(); ++i) cout << res[i] <<endl;
 }


Measured memory_bytes: 3444
n = int(input())
res = n

for i in range(n+1):
    c = 0
    t = i
    while t>0:
        c += t%6
        t = int(t/6)

    t = n-i

    while t>0:
        c += t%9
        t = int(t/9)

    if res>c:
        res = c


print(res)


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m,x=mii()
chk=False
ansmoney=10**100
c=[]
arr=[]

for i in range(n):
    mat=limii()
    c.append(mat[0])
    arr.append(mat[1:])

for i in product([0,1],repeat=n):
    total=0
    chkarr=[0]*m
    for j in range(n):
        if i[j]==1:
            total+=c[j]
            for k in range(m):
                chkarr[k]+=arr[j][k]
            
    
    cnt=0
    for p in range(m):
        if chkarr[p]>=x:
            cnt+=1
    if cnt==m:
        chk=True
        ansmoney=min(ansmoney,total)
if chk:
    print(ansmoney)
else:
    print(-1)

Measured memory_bytes: 79084
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>
using namespace std; 
int main(void){

  int n, sum;
  double result = 0;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i) >> y.at(i);
    sum += i;
  }
  
  for (int i = 0; i < n-1; i++){
    for (int j = i + 1; j < n; j++){
      result += hypot(x.at(i) - x.at(j), y.at(i) - y.at(j));
    }
  }
  cout << setprecision(15) << result*(n-1)/sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        long K = sc.nextLong();
        List<Long> aSum = new ArrayList<>();
        aSum.add((long) 0);
        List<Long> bSum = new ArrayList<>();
        bSum.add((long) 0);
        long tmp = 0;
        for (int i = 0; i < N; i++) {
            tmp += sc.nextLong();
            aSum.add(tmp);
        }
        tmp = 0;
        for (int i = 0; i < M; i++) {
            tmp += sc.nextLong();
            bSum.add(tmp);
        }
        int aInd = 0;
        int bInd = 0;
        long ans = 0;
        while (bSum.get(bInd) <= K) {
            bInd += 1;
            if (bInd == M) {
                break;
            }
        }

        while (true) {
            while (aInd <= N && aSum.get(aInd) + bSum.get(bInd) <= K) {
                aInd += 1;
            }
            if (aInd != 0) aInd -= 1;
            if (aSum.get(aInd) + bSum.get(bInd) <= K) {
                ans = Math.max(ans, aInd + bInd);
                if (aInd == N)
                    break;
                aInd += 1;
            }
            if (bInd == 0)
                break;
            while (aSum.get(aInd) + bSum.get(bInd) > K) {
                bInd -= 1;
                if (bInd == -1) {
                    bInd += 1;
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 73812
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int L = Integer.parseInt(sc.next());
        
        
        ArrayList<String> dictionary = new ArrayList<String>();
        for(int i=0; i<N; i++){
            dictionary.add(sc.next());
        }
        
        Collections.sort(dictionary);
        
        String ans = "";
        for(int i=0; i<N; i++){
            ans += dictionary.get(i);
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 26068
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second > b.second; }

int main(){
    ll n;cin>>n;
    rep(i,9){
        rep(j,9){
            if((i+1)*(j+1)==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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; }

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

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

vector<ll> pros(vector<ll> &A){
    ll N = A.size();
    vector<ll> B(N+1, 0);
    REP(i, N){
        ll lb = max(i-A[i], 0ll);
        ll ub = min(i+A[i], N-1);
        B[lb]++;
        B[ub+1]--;
    }
    REP(i, N) B[i+1] += B[i];
    return B;
}

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    REP(t, K){
        auto B = pros(A);
        //cout << B << endl;
        REP(i, N) A[i] = B[i];

        bool ok = true;
        REP(i, N){
            if(A[i] != N) ok = false;
        }
        if(ok) break;
    }

    REP(i, N) cout << A[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 6308
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, L;
int A[100100];

signed main() {
    cin >> N >> L;
    rep(i, N) {
        cin >> A[i];
    }
    rep(i, N - 1) {
        if (A[i] + A[i + 1] >= L) {
            cout << "Possible" << endl;
            for (int k = 1; k < i + 1; ++k) {
                cout << k << endl;
            }
            for (int k = N - 1; k > i + 1; --k) {
                cout << k << endl;
            }
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 1536
N = int(input())
s = []
t = []
for i in range(N):
    ss, tt = map(str, input().split())
    s.append(ss)
    t.append(tt)
X = input()

for i in range(N):
    t[i] = int(t[i])

for i in range(N):
    if s[i] == X:
        index = i
        break

time = 0
for i in range(index + 1, N):
    time = time + t[i]

print(time)


Measured memory_bytes: 3064
s = input() [::-1]

cnts = [0] * 2019

cnts[0] = 1

sum_of_digits = 0

d = 1

for c in s:
    sum_of_digits += int(c) * d
    d *= 10
    d %= 2019 # これは d = d % 2019 と同じ
    sum_of_digits %= 2019
    cnts[sum_of_digits] += 1

ans = 0

for cnt in cnts:
    ans += cnt * (cnt - 1)  //  2

print(ans)


Measured memory_bytes: 9328
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

cnt=Counter(a)
if cnt[0]==n:
    print("Yes")
    quit()
if n%3!=0:
    print("No")
    quit()
a.sort()
if cnt[0]==n//3 and cnt[a[-1]]==2*n//3:
    print("Yes")
    quit()

# print(1)
lst=[]
for i in range(n):
    if cnt[a[i]]==n//3:
        if a[i] in lst:
            continue
        else:
            lst.append(a[i])
    else:
        print("No")
        quit()
if lst[0]^lst[1]^lst[2]==0:
    print("Yes")
    quit()
else:
    print("No")

Measured memory_bytes: 97520
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,L; cin >> N >> L;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    int k;
    ll l = 0;
    rep(i,N-1) {
        if (chmax(l,A[i]+A[i+1])) k = i;
    }
    if (l < L) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    rep(i,k) cout << i+1 << endl;
    for (int i = N-2; i >= k; i--) cout << i+1 << endl;

}

Measured memory_bytes: 1664
#include <iostream>
using namespace std;
 
int main(){
    int l[4][3][10];
    for(int p = 0; p < 4; p++){
        for(int q = 0; q < 3; q++){
            for(int r = 0; r < 10; r++){
                l[p][q][r] = 0;
            }
        }
    }
 
    int n;
    cin >> n;
 
    for(int i = 0; i < n; i++){
        int p, q, r, s;
        cin >> p >> q >> r >> s;
        l[p-1][q-1][r-1] += s;
    }
 
    for(int p = 0; p < 4; p++){
        for(int q = 0; q < 3; q++){
            for(int r = 0; r < 10; r++){
                cout << ' ' << l[p][q][r] << flush;
            }
            cout << endl;
        }
        if(p == 3){
            break;
        }
        cout << "####################" << endl;
    }
 
    return(0);
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

const int mod = 1e9+7;

int main(){ 
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  REP(i, H){
    cin >> S[i];
  }
  vector<vector<pair<int, int>>> g(H, vector<pair<int,int>>(W, {0,0}));
  vector<vector<pair<int, int>>> g2(H, vector<pair<int,int>>(W, {0,0}));

  REP(i, H){
    int l = -1;
    REP(j, W){
      if(S[i][j] == '#'){
        l = j;
      }
      g[i][j].first = l;
    }
    int r = W;
    REPR(j, W-1){
      if(S[i][j] == '#'){
        r = j;
      }
      g[i][j].second = r;
    }
  }
  REP(j, W){
    int h = -1;
    REP(i, H){
      if(S[i][j] == '#'){
        h = i;
      }
      g2[i][j].first = h;
    }
    int u = H;
    REPR(i, H-1){
      if(S[i][j] == '#'){
        u = i;
      }
      g2[i][j].second = u;
    }
  }
  int ans = 0;
  REP(i, H){
    REP(j, W){
      int cnt = g[i][j].second - (g[i][j].first+1) + g2[i][j].second - (g2[i][j].first+1) - 1;
      if(S[i][j] == '.' && cnt > ans){
        ans = cnt;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 67072
#include"iostream"
using namespace std;
int main()
{
	int n;
	cin >> n;
	int dp[50];
	int i;
	dp[0] = dp[1] = 1;
	for (i = 2; i < 50; ++i)
		dp[i] = dp[i - 1] + dp[i - 2];
	cout << dp[n] << endl;
	return 0;
}


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

#define ll long long
#define pb push_back
#define lb(a) ((a)&(-(a)))

const int maxn = 1e5 + 20;
const int mod = 1e9 + 7;

ll s[maxn];

int dp[maxn][2] , fen[2][maxn];

inline void mkay(int &a)
{
	if(a >= mod)
		a -= mod;
	else if(a < 0)
		a += mod;
}

void add(int p , int val , int id)
{
	mkay(dp[p][id] += val);
	for(p += 5; p < maxn; p += lb(p))
		mkay(fen[id][p] += val);
}

int get(int p , int id)
{
	int res = 0;
	for(p += 5; p > 0; p -= lb(p))
		mkay(res += fen[id][p]);

	return res;
}

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

	int n;
	ll a , b;
	cin >> n >> a >> b;

	for(int i = 1; i <= n; i++)
		cin >> s[i];
	s[0] = -1e18;

	add(0 , 1 , 0);
	add(0 , 1 , 1);
	int last0 = 0 , last1 = 0;
	for(int i = 2; i <= n; i++)
	{
		int ind0 = upper_bound(s , s + n , s[i] - b) - s - 1;
		int ind1 = upper_bound(s , s + n , s[i] - a) - s - 1;

		int s0 = get(ind0 , 0);
		int s1 = get(ind1 , 1);

		if(s[i] - s[i - 1] < a)
			while(last0 < i - 1)
				add(last0 , -dp[last0][0] , 0) , last0++;
		add(i - 1 , s1 , 0);

		if(s[i] - s[i - 1] < b)
			while(last1 < i - 1)
				add(last1 , -dp[last1][1] , 1) , last1++;

		add(i - 1 , s0 , 1);
	}

	int res = 0;
	mkay(res = get(n , 0) + get(n , 1));
	cout << res << endl;
}












Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>

char purple[505];

char color[2][500][505];

int main(){
  int H,W;
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++){
    scanf("%s",purple);
    std::fill(color[0][i],color[0][i]+W,'.');
    std::fill(color[1][i],color[1][i]+W,'.');
    for(int j=1;j<W-1;j++){
      color[i%2][i][j]='#';
      if(purple[j]=='#'){
	color[(i+1)%2][i][j]='#';
      }
    }
    color[0][i][0]='#';
    color[1][i][W-1]='#';
  }
  for(int c=0;c<2;c++){
    for(int i=0;i<H;i++){
      printf("%s\n",color[c][i]);
    }
    if(c==0){
      printf("\n");
    }
  }
  
  return 0;
}


Measured memory_bytes: 1152
from collections import deque
import copy

# グラフの作成(無向グラフでは#を消す)
n, q = map(int, input().split())
graph = [deque([]) for _ in range(n+1)]
for _ in range(n-1):
    a, b  = [int(x) for x in input().split()]
    graph[a].append(b)
    graph[b].append(a) # 無向グラフ
#print(graph)
q_sum_list = [0 for _ in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    q_sum_list[p-1] += x
#print(q_sum_list)
arrive_rireki = [-1] * (n + 1)

score = [0]*n
score_temp = 0

# 深さ優先探索
def dfs(v):
    global score_temp
    #arrive_rireki = [-1] * (n + 1)
    #print("check", graph_temp, arrive_rireki) #deepcopy の確認
    stack = [v]
    arrive_rireki[v] = 1
    score_temp += q_sum_list[v-1]
    while stack:
        #print("stack", stack)
        v = stack[-1]
        if graph[v]:
            w = graph[v].popleft()
            if arrive_rireki[w] < 0:
                arrive_rireki[w] = 1
                stack.append(w)
                score_temp += q_sum_list[w-1]
        else:
            stack.pop()
            #score[v-1] += q_sum_list[v-1]
            score[v-1] = score_temp
            score_temp -= q_sum_list[v-1]
            #print("stack pop", v, stack)
            #for i in range(len(stack)):
            #    score[v-1] += q_sum_list[stack[i]-1]
                #print(score, q_sum_list[stack[i]-1])
    return score

dfs(1)
#print(eda_list)
print(* score)


Measured memory_bytes: 161900