akhauriyash/Code-Regression huggingface dataset:
use std::io;
use std::cmp;


fn main() {
    let n = read_one::<f64>();
    let mut w = read_one::<usize>();
    w = cmp::min(w, read_one::<usize>());
    w = cmp::min(w, read_one::<usize>());
    w = cmp::min(w, read_one::<usize>());
    w = cmp::min(w, read_one::<usize>());
    println!("{}", 4 + (n / w as f64).ceil() as usize);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+7;
int a[500005], b[500005];
int dp[1<<20][2], last[1<<20];
int sum[500005];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=0;i<(1<<20);i++) dp[i][0] = 1;
    for(int i=1;i<=n;i++) scanf("%d", &a[i]), b[i] = b[i-1]^a[i];
    for(int i=1;i<=n;i++){
        if(b[i] == 0) sum[i]++;
        sum[i] += sum[i-1];
    }

    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(b[i] == 0){
            if(i != n) cnt++;
        }
        else{
            int s = sum[i]-sum[last[b[i]]];
            dp[b[i]][0] = (dp[b[i]][0] + s*1ll*dp[b[i]][1])%mod;
            dp[b[i]][1] = (dp[b[i]][1] + dp[b[i]][0])%mod;
        }
        last[b[i]] = i;
    }

    int ans = 0;
    if(b[n] == 0){
        int res = 1;
        for(int i=0;i<cnt;i++) res = (res*2)%mod;
        for(int j=1;j<(1<<20);j++){
            if(last[j] == 0) continue;
            res = (res + dp[j][1])%mod;
        }
        ans = (ans + res)%mod;
    }
    else{
        ans = dp[b[n]][0];
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 18432
#include<bits/stdc++.h>
using namespace std;
int main(void){
    while(true){
        int num;
        cin >> num;
        if(num==0) break;
        num=1000-num;
        int sum=0;
        sum+=num/500;
        num%=500;
        sum+=num/100;
        num%=100;
        sum+=num/50;
        num%=50;
        sum+=num/10;
        num%=10;
        sum+=num/5;
        num%=5;
        sum+=num;
        cout << sum << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int n = sc.nextInt();
	  double res = 0.0;
	  for (int i = 0; i < n; i++) {
		  res += 1/sc.nextDouble();
	  }
	  System.out.println(1/res);
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


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


int main() {
    ll a, b; cin >> a >> b;
    ll halfa = sqrt(a), halfb = sqrt(b);
    // cout << "a=" << halfa << "b=" << halfb << endl;
    vector<ll> sa, sb;
    for(ll i = 2; i <= halfa; i++){
        if(a % i == 0) sa.push_back(i);
        while(a % i == 0) a /= i;
    }
    if(a > 1) sa.push_back(a);
    for(ll i = 2; i <= halfb; i++){
        if(b % i == 0) sb.push_back(i);
        while(b % i == 0) b /= i;
    }
    if(b > 1) sb.push_back(b);
    ll count = 1;
    // cout << sa.size() << " " << sb.size() << endl;
    for(auto &x: sa){
        for(auto &y: sb){
            if(x == y) count++;
            // cout << x << " " << y << endl;
        }
    }
    cout << count << endl;


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  int cnt = 0;
  FOR(i,0,n){
    int a; cin >> a;
    cnt++;
    if(a==0){
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  cnt++;
  ans = max(ans, cnt);
  cout << ans << endl;
}


Measured memory_bytes: 3140
package main

import (
	"fmt"
)

func TestCase(n []int) {
	for i := 0; i < len(n); i++{
		fmt.Printf("Case %d: %d\n", i + 1, n[i])
	}
}

func main(){
	var dataInt []int
	var inp int
	
		for {	
			fmt.Scan(&inp)
				if inp == 0 {
					break
				}
			dataInt = append(dataInt, inp)
		}

	TestCase(dataInt)
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0, 1};
vector<int> dx = {0, -1, 0, 1, 0};
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<char>> S(N + 2, vector<char>(M + 2, '#'));
  for (int i = 1; i <= N; i++){
    for (int j = 1; j <= M; j++){
      cin >> S[i][j];
    }
  }
  int gy, gx;
  for (int i = 1; i <= N; i++){
    for (int j = 1; j <= M; j++){
      if (S[i][j] == 'G'){
        gy = i;
        gx = j;
      }
    }
  }
  S[gy][gx] = '.';
  int sy, sx, sd;
  for (int i = 1; i <= N; i++){
    for (int j = 1; j <= M; j++){
      if (S[i][j] != '#' && S[i][j] != '.'){
        sy = i;
        sx = j;
        if (S[i][j] == 'v'){
          sd = 0;
        }
        if (S[i][j] == '<'){
          sd = 1;
        }
        if (S[i][j] == '^'){
          sd = 2;
        }
        if (S[i][j] == '>'){
          sd = 3;
        }
      }
    }
  }
  S[sy][sx] = '.';
  vector<vector<bool>> used(N + 2, vector<bool>(M + 2, false));
  used[sy][sx] = true;
  int y = sy, x = sx, d = sd;
  int cnt = 0;
  bool ok = true;
  int ans = 0;
  while (1){
    cnt++;
    if (cnt >= 5000){
      ok = false;
      break;
    }
    if (S[y + dy[d]][x + dx[d]] == '#'){
      d = (d + 3) % 4;
    } else {
      y += dy[d];
      x += dx[d];
      used[y][x] = true;
      if (gy == y && gx == x){
        break;
      }
      if (S[y + dy[d + 1]][x + dx[d + 1]] == '.'){
        d = (d + 1) % 4;
        y += dy[d];
        x += dx[d];
        used[y][x] = true;
        if (gy == y && gx == x){
          break;
        }
      }
    }
  }
  if (!ok){
    cout << -1 << endl;
  } else {
    int ans = 0;
    for (int i = 1; i <= N; i++){
      for (int j = 1; j <= M; j++){
        if (used[i][j]){
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3176
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;

int main(){
  int n;
  long long a[100005];
  multiset< long long > s;

  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i];
  s.insert(a[0]);
  for(int i=1; i<n; i++){
    auto itr = s.lower_bound(a[i]);
    if(itr != s.begin()){
      itr--;
      s.erase(itr);
    }
    s.insert(a[i]);
    //cout << "size : " << s.size() << endl;
  }

  cout << s.size() << endl;

}

Measured memory_bytes: 8960
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 10**9+7
    ans = 1
    s, t = [], []
    for i in range(n):
        if a[i] < 0:
            t.append(a[i])
        else:
            s.append(a[i])

    S, T = len(s), len(t)
    ok = False

    if S > 0:
        if n == k:
            ok = (T % 2 == 0)
        else:
            ok = True
    else:
        ok = (k % 2 == 0)

    if not ok:
        a.sort(key=abs)
        for i in range(k):
            ans *= a[i]
            ans %= mod
    else:
        s.sort()
        t.sort(reverse=True)
        if k % 2 == 1:
            ans *= s.pop()
            ans %= mod
        p = []
        while len(s) >= 2:
            x = s.pop()
            x *= s.pop()
            p.append(x)
        while len(t) >= 2:
            x = t.pop()
            x *= t.pop()
            p.append(x)
        p.sort(reverse=True)
        for i in range(k//2):
            ans *= p[i]
            ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 115472
#!/usr/bin/python3
# -*- coding: utf-8 -*-
k, n = map(int, input().split())
a_list = list(map(int, input().split()))
d_list = [a_list[0] + k - a_list[n - 1]]
max_d = a_list[0] + k - a_list[n - 1]
for i in range(0, n - 1):
    d_list.append(a_list[i + 1] - a_list[i])
    if max_d < a_list[i + 1] - a_list[i]:
        max_d = a_list[i + 1] - a_list[i]
print(sum(d_list) - max_d)


Measured memory_bytes: 26436
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

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

    // 素数である
    return true;
}

int main(){
  ll x; cin >> x;
  // for (ll i = x; i < count; i++)
  // {
  //   /* code */
  // }
  
  while(true){
    if(IsPrime(x)){
      say(x);
      return 0;
    }else{
      x += 1;
    }
  }
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		
		var a = p[0];
		var b = p[1];
		var h = p[2];
		var m = p[3];
		
		var time = h * 60 + m;
		var sa = time/720d*2*Math.PI;
		var la = m / 60d * 2 * Math.PI;
		
		
		var q = a*a+b*b-2*a*b*Math.Cos(la - sa);
		Console.WriteLine(Math.Sqrt(q));
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

bool ro[100];
int n;

bool check(){
    REP(i,n){
        if(!ro[i]){
            return true;
        }
    }
    return false;
}

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    cin >> n;
    vector<PINT> re(n),bl(n);
    REP(i,n){
        int a,b;
        cin >> a >> b;
        re[i] = {a,b};
    }
    REP(i,n){
        int a,b;
        cin >> a >> b;
        bl[i] = {a,b};
    }
    vector<vector<bool>> ju(n,vector<bool>(n,false));
    REP(i,n){
        REP(j,n){
            if(re[i].f1<bl[j].f1 && re[i].s2<bl[j].s2) ju[i][j]=true;
        }
    }
    vector<bool> co(n,false);
    REP(i,n) ro[i]=false;
    int ans=0;
    while(check()){
        int a,b=INF;
        bool flg=false;
        REP(i,n){
            if(!ro[i]){
                a=i;
                break;
            }
        }
        REP(i,n){
            if(ro[i]) continue;
            int c=0;
            REP(j,n){
                if(ju[i][j]) ++c;
            }
            if(c>0&&c<b){
                b=c;
                a=i;
            }
        }

        int ra,rb=INF;

        for(int i=n-1;i>=0;--i){
            if(!co[i] && ju[a][i]){
                flg=true;
                int rbb=0;
                for(int j=n-1;j>=0;--j){
                    if(ju[j][i]) ++rbb;
                }
                if(rbb<rb){
                    rb=rbb;
                    ra=i;
                }
            }
        }
        if(flg){
            co[ra] = true;
            ++ans;
            ju[a][ra] = false;
        }
        ro[a] = true;
    }

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


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll(i) = 0; i < (ll)(n); ++(i))
#define INF 10e12
#define MOD 1000000000 + 7
#define MX 51000
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    vector<vector<ll>> dp(s.size() + 1, vector<ll>(t.size() + 1, 0));
    for (ll i = 0; i < s.size(); ++i)
    {
        for (ll j = 0; j < t.size(); ++j)
        {
            if (s[i] == t[j])
                dp[i + 1][j + 1] = dp[i][j] + 1;
            else
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
        }
    }

    string ans = "";
    ll i = s.size(), j = t.size();
    while (i > 0 && j > 0)
    {
        if (dp[i - 1][j] == dp[i][j])
            --i;
        else if (dp[i][j - 1] == dp[i][j])
            --j;
        else
        {
            ans = s[i - 1] + ans;
            --i;
            --j;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 70784
a,b = [int(s) for s in input().split()]
count = 0
for j in range(a):
  j += 1
  for i in range(b):
    i += 1
    if i <= 20:
      pass
    else:
      p = i % 10
      q = int((i - p)/10)
      if j == p * q and p != 1:
        count += 1
print(count)
    

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 要素の入力、格納
		int X = sc.nextInt();
		int Y = sc.nextInt();
		long ans = -1;
		long max = (long) Math.pow(10, 18);

		if ((X >= Y) && (X % Y == 0)) {
		} else {
			for (long i = 1; i <= max / X; i++) {
				if ((X * i) % Y != 0) {
					ans = X * i;
					break;
				}
			}
		}
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 25044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        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); }

        static int Solve(int N, int A, int B, int C, int[] L)
        {
            int M = 1 << N;
            var sums = new int[M];
            var nums = new int[M];
            for (int i = 1; i < M; ++i)
            {
                int sum = 0;
                int num = 0;
                for (int n = 0; n < N; ++n)
                {
                    if ((i & (1 << n)) != 0)
                    {
                        sum += L[n];
                        ++num;
                    }

                }
                sums[i] = sum;
                nums[i] = num;
            }
            int min = int.MaxValue;
            for (int i = 1; i < M; ++i)
            {
                for (int j = 1; j < M; ++j)
                {
                    if ((i & j) != 0) { continue; }
                    for (int k = 1; k < M; ++k)
                    {
                        if (((i | j) & k) != 0) { continue; }
                        int value = Math.Abs(A - sums[i])
                                  + Math.Abs(B - sums[j])
                                  + Math.Abs(C - sums[k])
                                  + (nums[i] - 1) * 10
                                  + (nums[j] - 1) * 10
                                  + (nums[k] - 1) * 10;
                        min = Math.Min(value, min);
                    }
                }
            }
            return min;
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int N = V[0];
            var L = new int[N];
            for (int i = 0; i < N; ++i) { L[i] = ReadInt(); }
            Console.WriteLine(Solve(N, V[1], V[2], V[3], L));
        }
    }
}


Measured memory_bytes: 13268
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author phantom11
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        long ans = 0;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            String s = in.next();
            recur(s, 0, s.length(), 0);
            out.printLine(ans);
        }

        public void recur(String s, int index, int length, long cum) {
            //DebugUtils.debug(s, index, length, cum);
            if (index == length) {
                if (s.length() == 0)
                    ans += cum;
                //DebugUtils.debug(cum, s);

                return;
            }
            recur(s, index + 1, length, cum);
            cum += Long.parseLong(s.substring(0, index + 1));
            s = s.substring(index + 1);
            recur(s, 0, s.length(), cum);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tokenizer = null;

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(in.readLine());
                }
                return tokenizer.nextToken();
            } catch (IOException e) {
                return null;
            }
        }

    }
}



Measured memory_bytes: 8660
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> L(M), R(M);
  // グリッド
  vector<vector<int>> a(N, vector<int>(N));
  for (int i = 0; i < M; i++)
  {
    cin >> L[i] >> R[i];
    L[i]--, R[i]--;
    a[L[i]][R[i]]++;
  }

  // 二次元累積和の構築
  vector<vector<int>> s(N + 1, vector<int>(N + 1));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      s[i + 1][j + 1] = s[i][j + 1] + s[i + 1][j] - s[i][j] + a[i][j];
    }
  }

  // 各クエリの計算((x1, x2], * (y1, y2]の長方形区間の和)
  for (int i = 0; i < Q; i++)
  {
    int p, q;
    cin >> p >> q;
    p--, q--;
    cout << s[q + 1][q + 1] - s[p][q + 1] - s[q + 1][p] + s[p][p] << endl;
  }
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;
using ll = long long;

map<long long, long long> prime_factor(long long n) {
    map<long long, long long> res;
    for (long long i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

void Main() {
	ll A, B; cin >> A >> B;
	auto a_pf = prime_factor(A);
	auto b_pf = prime_factor(B);
	ll res = 1;
	for (auto p : a_pf) {
		if (b_pf.count(p.first)) ++res;
	}
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int n;
int v[20], c[20];
int main(){
    cin >> n;
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    int ans = 0;
    rep(i, n) if(v[i]-c[i] > 0) ans+=v[i]-c[i];
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int sum = 0;
    int n;
    cin >> n;
    rep(i,n) sum += i+1;
    cout << sum << endl;
    return 0;
}

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

#define ff first
#define ss second
#define mp make_pair
#define MOD 1000000007
#define oo 1000000000000000000

using namespace std;

int n;
long long v[200005];

int main(){

    scanf("%d", &n);

    for(int i = 0; i < n; i++)
        scanf("%lld", v+i);

    if(n == 2) return printf("%lld\n", abs(v[0] - v[1])), 0;

    long long sum = 0;
    for(int i = 1; i < n; i++)
        sum += v[i];

    long long tmp = v[0];
    long long ans = oo;
    for(int i = 1; i < n; i++){
        ans = min(ans, abs(tmp - sum));
        tmp += v[i];
        sum -= v[i];
    }

    printf("%lld\n", ans);



    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
  int ans = 0;
  int minmod10 = 10;
  for(int i=0;i<5;i++){
    int a; cin>>a; ans+=((a+9)/10)*10;
    minmod10=min(minmod10, a%10==0?10:a%10);
  }
  ans=ans-10+minmod10;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

int main() {
  int M, K;
  cin >> M >> K;

  if (M == 0) {
    if (K == 0)
      cout << "0 0" << endl;
    else
      cout << -1 << endl;
    return 0;
  }

  if (M == 1) {
    if (K == 0)
      cout << "0 0 1 1" << endl;
    else
      cout << -1 << endl;
    return 0;
  }

  int N = 1;
  rep(i, M) {
    N *= 2;
  }

  if (K >= N) {
    cout << -1 << endl;
    return 0;
  }

  rep(i, N) {
    if (i == K)
      continue;
    cout << i << ' ';
  }

  cout << K << ' ';

  rep(i, N) {
    int j = N - 1 - i;
    if (j == K)
      continue;
    cout << j << ' ';
  }

  cout << K << endl;
}

Measured memory_bytes: 1792
import numpy as np

input_str  = list(input())
count = 0



if len(input_str) == 1:
    input_str[0] = 'D'
else:
    if input_str[0] == '?':
        if input_str[1] == 'P':
            input_str[0] = 'D'
        else:
            input_str[0] = 'P'

    if input_str[-1] == '?':
        input_str[-1] = 'D'

    for i in range(1,len(input_str)-1):
        if input_str[i] == '?':
            if input_str[i-1] == 'P':
                input_str[i] = 'D'
            elif input_str[i+1] == 'D':
                input_str[i] = 'P'
            elif input_str[i+1] == '?':
                if input_str[i-1] == 'P':
                    input_str[i] = 'D'
                else:
                    input_str[i] = 'P'
            else:
                input_str[i] = 'D'

ans = ''.join(input_str)

print(ans)


Measured memory_bytes: 28668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,N;
  cin>>K>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
  cin>>A.at(i);
  
  }
  vector <int> D(N);
  for(int i=0;i<N-1;i++){
  D.at(i)=A.at(i+1)-A.at(i);
  }
  D.at(N-1)=K-A.at(N-1)+A.at(0);
  int M=0;
  for(int i=0;i<N;i++){
  if(M<=D.at(i)) M=D.at(i);
  
  }cout<<K-M<<endl;
  

return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
 
 
int main(){
    ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
ll n;cin>>n;
  vector<char> ans;
  while(n>0){
n--;
    ll u=n%26;
    ans.push_back(u+'a');
    n/=26;
  }
  rrep(i,ans.size()-1,0)cout<<ans[i];
  cout<<endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<cstdlib>
#include<math.h>
using namespace std;
int main(void){
    int a,b,c,d,temp,ans=0;
    cin >> a >> b >> c >> d;
    
    if(a>c){
        temp=a;
        a=c;
        c=temp;
        temp=b;
        b=d;
        d=temp;
    }
    ans=b-c;
    if(d<b){
        ans=d-c;
    }
    if(b<=c){
        ans=0;
    }
    
    printf("%d",ans);
    return 0;
}

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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  if(B-A>2*(K-1)){
    for(int i=A;i<A+K;++i) cout << i << endl;
    for(int i=B-K+1;i<=B;++i) cout << i << endl;
  }
  else{
    for(int i=A;i<=B;++i) cout << i << endl;
  }
}


Measured memory_bytes: 764
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        
        while(true){
            String str = in.next();
            if(str.equals("-"))break;

            int n = in.nextInt();
            for(int i = 0; i < n ; i++){
                int cutIndex = in.nextInt();
                String sub1 = str.substring(0, cutIndex), sub2 = str.substring(cutIndex);
                str = sub2 + sub1;
            }

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


Measured memory_bytes: 26488
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n;
  cin >> n;

  ld sum1 = 0;
  for (ll i = 1; i <= n; i++) {
    ld x;
    cin >> x;
    sum1 += 1 / x;
  }

  sum1 = 1 / sum1;
  cout << fixed << setprecision(10) << sum1 << en;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

template <typename T = ll> struct TreeBFS {
    vector<T> dist;
    vector<vector<pair<int, T>>> edges;
    TreeBFS(int n) : dist(n, -1), edges(n) {}
    void addEdge(int f, int t, T w) {
        edges[f].emplace_back(t, w);
        edges[t].emplace_back(f, w);
    }
    void bfs(int start) {
        dist[start] = 0;
        deque<int> node;
        node.push_back(start);
        while (node.size() != 0) {
            int n = node.front();
            node.pop_front();
            for (auto e : edges[n]) {
                if (dist[e.first] == -1) {
                    dist[e.first] = dist[n] + e.second;
                    node.push_back(e.first);
                }
            }
        }
    }
};

int main() {
    int n;
    cin >> n;
    vl u(n - 1), v(n - 1), w(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        cin >> u[i] >> v[i] >> w[i];
    }
    TreeBFS<ll> tr(n);
    for (int i = 0; i < n - 1; ++i) {
        tr.addEdge(u[i] - 1, v[i] - 1, w[i]);
    }
    tr.bfs(0);
    for (int i = 0; i < n; ++i) {
        int c = 0;
        if (tr.dist[i] % 2LL == 1LL)
            c = 1;
        cout << c << endl;
    }

    return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,k,a[SZ],r[SZ];
ll qzh[SZ],pp[SZ];
int sm[SZ];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",a+i);
		a[i]-=k;
		qzh[i]=qzh[i-1]+a[i];
		pp[i]=qzh[i];
	}
	sort(pp,pp+n+1);
	for(int i=0;i<=n;i++)
		r[i]=lower_bound(pp,pp+n+1,qzh[i])-pp+1;
	//<=对数
	ll ans=0;
	for(int i=0;i<=n;i++)
	{
		for(int x=r[i];x;x-=x&-x) ans+=sm[x];
		for(int x=r[i];x<SZ;x+=x&-x) sm[x]++;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 13312
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define var auto
#define ll long long
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++) 
#define inp(a) int a; cin >> a;
#define inps(s) std::string s; cin >> s;
#define out(a) cout<<a<<endl;
#define pb(a) push_back((a))
#define endl "\n"
#define vi vector<int>


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

	int Q;
	cin >> Q;
	vector<int> A;
	rep(i, Q){
		int query;
		cin >> query;

		if(query == 2) {
			A.pop_back();
		} else if (query == 1) {
			inp(tmp);
			cout << A[tmp] << endl;
		} else {
			inp(tmp);
			A.push_back(tmp);
		}
	}

	return 0;
}


Measured memory_bytes: 3944
#include<iostream>

using namespace std;

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

	
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,a,b) for(int i=int(a),nn=int(b);i<=nn;++i)
 
typedef long long ll;
 
const int N=200005;
const int M=600005;
const ll INF=(1ll<<60);
 
int n,m,e,P,a[N]; ll sum;
 
struct Seg {
	ll A[M];
	void build() {
	  	for(int i=e-1; i>=1; --i)
		  	A[i]=min(A[i<<1],A[i<<1|1]);
	}
	void modify(int t,ll d) {
		t+=e, A[t]=d;
		for(int i=t>>1; i; i>>=1)
			A[i]=min(A[i<<1], A[i<<1|1]);
	  }
	ll query(int l,int r) {
		ll res=INF;
		l=(l-1+e),r=(r+1+e);
		for(; l^r^1; l>>=1,r>>=1) {
			if(~l&1) res=min(res,A[l^1]);
			if( r&1) res=min(res,A[r^1]);
		  }
		return res;
	  }
} F,G;
int main() {
	int i; ll u,v;
	scanf("%d %d %d %d",&n,&m,&a[0],&P);
 
	for(i=1;i<=m;++i) scanf("%d",&a[i]);
	for(i=1;i<=m;++i) sum+=abs(a[i]-a[i-1]);
	for(e=1;e<=n+1;e<<=1);
 
	for(i=1;i<=n;++i) F.A[i+e]=G.A[i+e]=INF;
	F.A[P+e]=-P,G.A[P+e]=P;
	F.build(),G.build();
 
	for(i=1;i<=m;++i) {
		u=min(F.query(1,a[i])+a[i], G.query(a[i],n)-a[i])
		 - abs(a[i]-a[i-1]);
		v = F.A[a[i-1]+e]+a[i-1];
		if(u<v) F.modify(a[i-1],u-a[i-1]),G.modify(a[i-1],u+a[i-1]);
	}
	ll ans=INF;
	for(i=1; i<=n; ++i) ans=min(ans,sum+F.A[i+e]+i);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9344
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	Int a;
	vector<vector<Int>> temp(N, vector<Int>(2, 0));
	for (Int i = 0; i < N; i++) {
		cin >> a;
		temp[i][0] = a;
		temp[i][1] = i + 1;
	}

	sort(temp.begin(), temp.end());

	for (Int i = 0; i < N; i++) {
		cout << temp[i][1] << " ";
	}
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(int, N);
	ll sum = 0;
	in_v(ll, s, N);
	bool all10 = true;
	ll ms = INF;
	loop(i, N){
		sum += s[i];
		if(s[i] % 10){
			all10 = false;
			ms = min(ms, s[i]);
		}
	}
	if(all10)
		cout << 0 << endl;
	else if(sum % 10)
		cout << sum << endl;
	else
		cout << sum-ms << endl;
}



Measured memory_bytes: 256
from itertools import permutations
n = int(input())
p = list(permutations([str(x) for x in range(1, n+1)], n))
arr = tuple(input().split())
idx = p.index(arr)

[print(' '.join(p[idx+i])) for i in range(-1, 2) if 0 <= (idx+i) < len(p)]


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

int gcd(int a, int b) {
	if (a == 0) return b;
	if (b == 0) return a;
	return a % b ? gcd(b, a%b) : b;
}

int main(){
	int n, a, ans = 0;
	stack<int> s;
	cin >> n;
	vector<int> l(n + 1), r(n + 2);
	l[0] = 0;
	r[n + 1] = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a;
		s.push(a);
		l[i] = gcd(l[i - 1], a);
	}
	for (int i = n; i >= 1; --i) {
		r[i] = gcd(r[i + 1], s.top());
		s.pop();
		ans = max(gcd(l[i - 1], r[i + 1]), ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
char c;
int main(){
  c=getchar();
  switch(c){
    case '1': c='9'; break;
    case '9': c='1'; break;
  }
  putchar(c);
  c=getchar();
  switch(c){
    case '1': c='9'; break;
    case '9': c='1'; break;
  }
  putchar(c);
  c=getchar();
  switch(c){
    case '1': c='9'; break;
    case '9': c='1'; break;
  }
  putchar(c);
  c=getchar();
  switch(c){
    case '1': c='9'; break;
    case '9': c='1'; break;
  }
  putchar(c);
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int h = saori.saori_hayami()*60;
		int m = saori.saori_hayami();
		int h2 = saori.saori_hayami()*60;
		int m2 = saori.saori_hayami();
		int k = saori.saori_hayami();
		int num = h2 + m2 - h - m;
		System.out.println(num - k);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32328
x,y = map(int,input().split())
mod = 10**9+7

if (x+y)%3:
    print(0)
    exit()

n = (x+y)//3
x,y = x-n,y-n
if x < 0 or y < 0:
    print(0)
    exit()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = x+y
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a = cmb(x+y,x,mod)
print(a)

Measured memory_bytes: 82388