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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var q = new Queue<int>();
            string[] line = Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < n; i++) q.Enqueue(int.Parse(line[i]));
            var s = Console.ReadLine().Trim();
            var des = GetData(q, s);
            Console.WriteLine(des);
        }
    }
    public static string GetData (Queue<int> q , string s)
    {
        var des = "";
        var station = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        for (int i = 0; i < s.Length; i++)
        {
            var a = q.Dequeue();    q.Enqueue(a);
            var temp = station.IndexOf(s[i], 52) - a;
            var b = station[temp].ToString();
            des += b;
        }
        return des;
    }
}

Measured memory_bytes: 10260
#include <bits/stdc++.h>
//#include <vector>
using namespace std;
 
 
int main(){
    int64_t n,yoko,tate,ans=10000000000000;
    cin>>n;
    for(int64_t i=1;i<=sqrt(n);i++){
       // if(n%i!=0)continue;
        if(n%i==0){
            yoko=i;
            tate=n/i;
            ans=min(ans,yoko+tate-2);
        }
    }
    cout<<ans<<endl;
  
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

int K;
int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> K;
    if(K % 2 == 1){
        cout << K/2 * (K/2+1) << endl;

    }else{
        cout << pow(K/2,2) << endl;
    }

    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

struct Point
{
    int x, y;
};

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

    int h, w;
    cin >> h >> w;
    vector< string > field(h);
    rep (i, h) cin >> field[i];

    queue< Point > q;
    vector< vs32 > d(h, vs32(w, 1e9));
    rep (i, h)
    {
        rep (j, w)
        {
            if (field[i][j] == '#')
            {
                q.push(Point{.x = j, .y = i});
            }
        }
    }

    int ans = -1;
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, -1, 0, 1};
    while (!q.empty())
    {
        ++ans;
        int s = q.size();
        rep (j, s)
        {
            Point p = q.front(); q.pop();
            int y = p.y;
            int x = p.x;
            rep (i, 4)
            {
                int ny = y + dy[i];
                int nx = x + dx[i];
                if (IN(0, h, ny) && IN(0, w, nx) && field[ny][nx] != '#')
                {
                    q.push(Point{.x = nx, .y = ny});
                    field[ny][nx] = '#';
                }
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 13456
function Main(input) {
    var tmp = input.trim().split('\n');
    var a = tmp[0].split(' ').map(Number);
    var b = tmp[1].split(' ').map(Number);
    var res = b.filter(function(val) {
      return val >= a[1];
    })
    console.log(res.length);
 }
 
/* var input = `1 500
499`;
Main(input);
 */  
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 28620
n,m,l = gets.chomp.split(" ").map &:to_i

matA = Array.new
n.times { matA << (gets.chomp.split(" ").map &:to_i) }

matB = Array.new
m.times { matB << (gets.chomp.split(" ").map &:to_i) }

matC = Array.new
n.times { |r|
    l.times { |c|
        f = 0
        m.times { |i| f += matA[r][i]*matB[i][c] }
        matC << f
    }
}

matC.length.times { |i|
    puts if i%l == 0 and i != 0
    print " " if i%l != 0
    print matC[i]
}
puts

Measured memory_bytes: 9268
#pragma once
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	string S;
	string ans;

	cin >> S;

	char old = S[0];
	ans = "Good";
	rep2(i, 1, S.size()) {
		if (S[i] == old) {
			ans = "Bad";
			break;
		}
		old = S[i];
	}

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

Measured memory_bytes: 256
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
#[fastout]
fn main() {
  input! {
    N:usize,
    A:[usize;N]
  }
  let N: usize = N;
  let mut nmax = 1000_000usize;
  let mut h = vec![0usize; nmax + 1];
  for i in 0..N {
    h[A[i]] += 1;
  }
  let mut mx = 0;
  let mut isprime = vec![true; nmax + 1];
  let mut i = 2;
  while i <= 1000 {
    if isprime[i] {
      let mut j = i * 2;
      while j <= nmax {
        isprime[j] = false;
        j += j;
      }
      let mut f = 0usize;
      let mut j = i;
      while j <= nmax {
        f += h[j];
        j += i;
      }
      mx = max(mx, f);
    }
    i += 1;
  }
  let mut pflag = true;
  for p in i + 1..=nmax {
    if isprime[p] {
      let mut f = 0usize;
      let mut j = p;
      while j <= nmax {
        f += h[j];
        j += p;
      }
      mx = max(mx, f);
    }
  }
  if mx <= 1 {
    println!("pairwise coprime");
    return;
  } else if mx < N {
    println!("setwise coprime");
  } else {
    println!("not coprime")
  }
}


Measured memory_bytes: 25244
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;
string s;

int main() {
	int h,w;cin >> h>>w;
	vector<string> v;
	for (int i=0;i<h;++i){
		string s;cin>>s;
		v.push_back(s);
	}
  bool isconnect = true;
	for (int j=0;j<h;++j){
		for (int k=0;k<w;++k){
      int cnt =0;
			if(v[j].substr(k,1)=="#") {
        if(j-1>=0 && v[j-1].substr(k,1)=="#")++cnt;
        if(j+1<h && v[j+1].substr(k,1)=="#")++cnt;
        if(k-1>=0 && v[j].substr(k-1,1)=="#")++cnt;
        if(k+1<w && v[j].substr(k+1,1)=="#")++cnt;
        if(cnt==0) isconnect = false;
			}
      if(!isconnect) break;
		}
    if(!isconnect) break;
	}
  if (isconnect) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;

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

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

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

	int x = (1<<M);
	vector<int> res;
	for (int i = 0; i < x; ++i) {
		if (i != K) { res.push_back(i); }
	}
	res.push_back(K);
	for (int i = x - 1; i >= 0; --i) {
		if (i != K) { res.push_back(i); }
	}
	res.push_back(K);

	for (int i = 0; i < res.size(); ++i) {
		cout << res[i] << (i == res.size() - 1 ? "\n" : " ");
	}

	return 0;
}


Measured memory_bytes: 2932
using System;
using System.Linq;

internal class Program
    {
        public static void Main(string[] args)
        {
            var count = Console.ReadLine().Split().Select(int.Parse).ToList();
                        var n = count[0];
                        var m = count[1];
                        var right = new bool[n];
                        var wrong = new int[n];
                        var position = 0;
                        while (position < m)
                        {
                            var tmp = Console.ReadLine().Split().ToList();
                            var index = Convert.ToInt32(tmp[0]) - 1;
                            if (tmp[1] == "WA" && !right[index])
                                wrong[index]++;
                            else if (tmp[1] == "AC" && !right[index])
                                right[index] = true;
                            position++;
                        }
            
            //            var correct = right.Count(x => x.Equals(true));
            //            
            //            var incorrect = wrong.Sum();
                        var correct = 0;
                        var incorrect = 0;
                        for (int i = 0; i < n; i++)
                        {
                            if (right[i])
                            {
                                correct++;
                                incorrect += wrong[i];
                            }
                        }
                        
                        Console.WriteLine($"{correct} {incorrect}");
        }
    }

Measured memory_bytes: 17736
N, K = map(int, input().split())
LR = [list(map(int, input().split())) for i in range(K)]
MOD = 998244353

dp = [0] * (N + 1)
dp[1] = 1
dp_sum = [0] * (N + 1)
dp_sum[1] = 1


def get(l, r, i):
    return dp_sum[max((i - l), 0)] - dp_sum[max((i - r-1), 0)]


for i in range(1, N+1):
    for l, r in LR:
        dp[i] += get(l, r, i) % MOD
    dp_sum[i] = (dp_sum[i - 1] + dp[i])%MOD
print(dp[N] % MOD)


Measured memory_bytes: 27408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll INF = 100000007;

int main() {
  IN(string, S);
  IN(string, T);
  ll s = S.size();
  ll t = T.size();
  string ans = "";
  REP(i, s-t+1){
    string check = S;
    REP(j, t){
      if(S.at(i+j) == T.at(j) || S.at(i+j) == '?')
        check.at(i+j) = T.at(j);
      else
        break;
      if(j == t-1)
        ans = check;
    }
  }
  if(ans == "")
    OUT("UNRESTORABLE");
  else{
    replace(ALL(ans), '?', 'a');
    OUT(ans);
  }
}





Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <bits/stdc++.h>
#include <set>
#include <list> //list<???> a; a.push_back ,insert(追加したい要素),a.sort(),参照できない
#include <vector> //vector<???> a; a.push_back,sort(a.begin(),a.end());a[i]
//配列 int a[N];a[i]=追加したい要素;sort(a,a+N);a[i]
const int MOD = 1e9+7;
using namespace std;
typedef long  ll;
#define rep(i,n) for(int i=0;i<(n);i++)


//using namespace std;
//


int main(){
  int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  int dx=tx-sx,dy=ty-sy;
  string ans;

  for(int i=0;i<dy;i++){
    ans+="U";
  }

  for(int i=0;i<dx;i++){
    ans+="R";
  }

  for(int i=dy;0<i;i--){
    ans+="D";
  }

  for(int i=dx;0<i;i--){
    ans+="L";
  }


  ans+="L";
  for(int i=0;i<=dy;i++){
    ans+="U";
  }
  for(int i=0;i<=dx;i++){
    ans+="R";
  }
  ans+="D";
  ans+="R";

  for(int i=dy;0<=i;i--){
    ans+="D";
  }

  for(int i=dx;0<=i;i--){
    ans+="L";
  }
  ans+="U";
  cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int plan1 = T * A;
		
		if(plan1 > B)
			System.out.println(B);
		else
			System.out.println(plan1);
		sc.close();
	}
}


Measured memory_bytes: 21204
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

def main():
    N = int(input())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    count = 0
    for i in range(N):
        if A[i] == B[i]:
            count += 1
            if count == 3:
                print('Yes')
                exit()
        else:
            count = 0
    print('No')



if __name__ == '__main__':
    main()


Measured memory_bytes: 71080
#include<bits/stdc++.h>
#define ll long long int 
#define fori(i,n) for(int i=0; i<n; ++i)
#define ford(i,n) for(int i=n-1; i>=0; --i)
#define vi vector<int> 
#define vs vector<string>
#define vll vector<ll>
#define di deque<int>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define mod1 1000000007
#define mod2 998244353
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gcd __gcd


#define fast_cin() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using namespace std::chrono;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> i_set;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ll_set; 
/* new_data_set p; */
/* *p.find_by_order(3); The value at third place */
/* p.order_of_key(7); The expected index in the set in sorted order */

int ans(vector<int> arr, int n, int val){
    int i,a=0;
    for(i=0; i<n; ++i){
        a+=(int)pow(arr[i]-val,2);
    }
    return a;
}

int main(int argc, char const *argv[]){
	fast_cin();
    int n,i,avg=0;
    cin>>n;
    vi x(n);
    fori(i,n) {
        cin>>x[i];
        avg+=x[i];
    }
    avg=avg/n;
    /* cout<<avg<<"\n"; */
    cout<<min((int)ans(x,n,avg),(int)ans(x,n,avg+1))<<"\n";
    return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    int n,br1=0,br2=0,br3=0,br4=0;
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> s;
        if(s[0]=='A')
            br1++;
        else if(s[0]=='W')
            br2++;
        else if(s[0]=='T')
            br3++;
        else
            br4++;
    }
    cout << "AC x " << br1 << '\n';
    cout << "WA x " << br2 << '\n';
    cout << "TLE x " << br3 << '\n';
    cout << "RE x " << br4 << '\n';
}


Measured memory_bytes: 3588
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    vector<int> d = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int a, b; cin >> a >> b;
    if (d[a] == d[b]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);

        long w = sc.nextLong();
        long h = sc.nextLong();
        long x = sc.nextLong();
        long y = sc.nextLong();

        System.out.println(w * h / (double) 2);
        System.out.println(x == w / (double)2 && y == h / (double)2 ? 1 : 0);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
int N, D;
 
int main() {
 cin >> N >> D;
 int a[N], b[N];
 int count = 0;
 for(int i=0; i < N; i++) {
  cin >> a[i] >> b[i];
  if(pow(a[i], 2) + pow(b[i], 2) <= pow(D, 2)){
    count++;
  }
 }
 cout << count << endl;
}

Measured memory_bytes: 5116
fx = lambda x: int(x/2) if x%2==0 else 3*x + 1
ans = [int(input())]
counter = 1

while True:
    new_x = fx(ans[-1])
    counter += 1
    if (new_x in ans) :
        break
    ans.append(new_x)

print(counter)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
	
	public static int maxProfitWhenSell(int[] arr, int maxP, int index, int min) {
		if(index == arr.length - 1) {
			return Math.max(maxP, arr[index] - min);
		}else {
			maxP = Math.max(maxP, arr[index] - min);
			min = Math.min(min, arr[index]);
			return Math.max(maxP, maxProfitWhenSell(arr, maxP, index + 1, min));
		}
		
	}
	public static int maxProfit(int[] arr) {
		int maxP = Integer.MIN_VALUE;
		int min = Integer.MAX_VALUE;
		for (int index = 0; index < arr.length; index += 1) {
			maxP = Math.max(maxP, arr[index] - min);
			min = Math.min(min, arr[index]);
		}
		return maxP;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int line = Integer.parseInt(sc.nextLine());
		int[] rt = new int[line];
		for (int li = 0; li < line; li += 1) {
			rt[li] = Integer.parseInt(sc.nextLine());
		}
		System.out.println(maxProfit(rt));
	}
}



Measured memory_bytes: 168864
n = input()
A = map(int, raw_input().split())
B = [0]*(n+1)
for i in xrange(n):
    B[i+1] = B[i] + A[i]
res = 10**18+7
for i in xrange(1, n):
    res = min(res, abs(B[n] - B[i]*2))
print res


Measured memory_bytes: 18440
"use strict";
function main(input) {
  let kari = input[0].trim().split(" ").map(i => parseInt(i));
  const n = kari[0];
  const m = kari[1];
  let a = input[1].trim().split(" ").map(i => parseInt(i));

  a.sort(function(a, b) {
    return b - a;
  });

  let sum = 0;
  for(let i=0;i<n;i++){
    sum += a[i];
  }

  let judge = false;
  for(let i=0;i<m;i++){
    if((sum/(4*m)) > a[i]){
      judge = true;
    }
  }

  console.log(judge?"No":"Yes");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

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

vector<int> eraAry, sosu;
void Eratosthenes(int N) {
	for(int i=0; i<N; i++) {
		eraAry.push_back(1);
	}
	for(int i=2; i<sqrt(N); i++) {
		if(eraAry[i]) {
			for(int j=0; i*(j+2)<N; j++) {
				eraAry[i*(j+2)] = 0;
			}
		}
	}

	for(int i=2; i<N; i++) {
		if(eraAry[i]) {
			sosu.push_back(i);
		}
	}
}
bool isMod5(int num) {
	return num % 5 == 1;
}

int main() {
	int count, MAX;
	count = 0;
	cin >> MAX;
	Eratosthenes(55555);
	for(int i=0; i<sosu.size(); i++) {
		if(isMod5(sosu[i])) {
			cout << sosu[i] << ' ';
			count++;
		}
		if(count == MAX)
			break;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long 
#define MOD 1000000007
using namespace std;

int32_t main()
{
	string h;
	cin>>h;
	int n=h.length();

	int i=0,j=n-1,ans=0;

	while (i<=j){
		if (h[i]!=h[j])ans++;
		i++;
		j--;
	}

	cout<<ans;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\s");
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		int mx = x-r;
		int Mx = x+r;
		int my = y-r;
		int My = y+r;
		if (mx >= 0 && Mx <= W && my >= 0 && My <= H) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 26380
#include<stdio.h>
#define N 100

int main(){
  int i,j,k,array[N],n,key;

   scanf("%d",&n);
  
  for(j=0;j<n;j++)scanf("%d",&array[j]);
  
  for(i=0;i<n-1;i++)printf("%d ",array[i]);
  printf("%d\n",array[i]);

  for(i=1;i<n;i++){
    key=array[i];
    j=i-1;
    while(j>=0 && array[j]>key){
      array[j+1]=array[j];
      j--;
    }
    array[j+1]=key;
    for(k=0;k<n-1;k++){
      printf("%d",array[k]);
      printf(" ");
    }
    printf("%d\n",array[k]);
  }
  
  return 0;
}

Measured memory_bytes: 604
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val h = sc.nextInt()
  val w = sc.nextInt()
  val a = (1..h).map { sc.next() }

  val ans = mutableListOf<String>()
  val line = "#".repeat(w + 2)
  ans.add(line)
  for (ai in a) {
    val tmp = "#" + ai + "#"
    ans.add(tmp)
  }
  ans.add(line)

  println(ans.joinToString("\n"))

}


Measured memory_bytes: 31388
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int N = 1000000;
		boolean[] primes = new boolean[N + 1];

		primes[0] = true;
		primes[1] = true;
		for (int i = 2; i < N / 2 + 1; i++) {
			for (int j = 2; j < N / i + 1; j++) {
				primes[i * j] = true;
			}
		}

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line);
			if (n == 0) {
				break;
			}
			int count = 0;
			for (int i = n; i > n / 2 - 1; i--) {
				if (!primes[i] && !primes[n - i]) {
					count++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 22052
MOD = 998244353
N = gets.to_i
D = gets.split.map(&:to_i)

list = Hash.new(0)

D.each do |d|
  list[d] += 1
end

if D[0] != 0 || list[0] >= 2
  puts 0
  exit
end

ans = 1

1.upto(D.max) do |d|
  n = list[d]

  if n == 0
    ans = 0
    break
  else
    ans = (ans * (list[d-1] ** n)) % MOD
  end
end

puts ans


Measured memory_bytes: 14596
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
#print(a)
for k in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[k]:
                a[i][j] = -1
ans = "No"
for i in range(3):
    if a[i][0] == -1 and (a[i][1] == -1 and a[i][2] == -1):
        ans = "Yes"
for i in range(3):
    if a[0][i] == -1 and (a[1][i] == -1 and a[2][i] == -1):
        ans = "Yes"
if a[0][0] == -1 and (a[1][1] == -1 and a[2][2] == -1):
    ans = "Yes"
if a[0][2] == -1 and (a[1][1] == -1 and a[2][0] == -1):
    ans = "Yes"
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    ll n,w;
    cin>>n>>w;

    vector<ll> weight(n),value(n);
    for(ll i=0;i<n;i++)
    cin>>weight[i]>>value[i];

    ll max_val = 0;
    for(ll&x : value)
    max_val += x;

    vector<ll> dp(max_val+1,INT_MAX);
    dp[0] = 0;

    for(ll i=0;i<n;i++)
    {
        for(ll j=max_val-value[i];j>=0;j--)
        {
            dp[j+value[i]] = min(dp[j+value[i]], dp[j]+weight[i]);
        }
    }
    ll ans = INT_MIN;
    for(ll i=0;i<=max_val;i++)
    {
        if(dp[i] <= w)
        ans = max(ans, i);
    }

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    ll N;
    cin >> N;
    vll A(N);
    cin >> A;
    deque<ll> que;
    REP(i,N){
        if(0 == i%2){
            que.push_back(A[i]);
        }else{
            que.push_front(A[i]);
        }
    }
    while(!que.empty()){
        if(0 == N%2){
            cout << que.front() << " ";
            que.pop_front();
        }else{
            cout << que.back() << " ";
            que.pop_back();
        }
    }
    cout << endl;
}

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

struct card {
    char suit;
    int value;
};

int bubbleSort(card C[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N-1; j > i; j--) {
            if (C[j].value < C[j-1].value) {
                swap(C[j], C[j-1]);
            }
        }
    }
    return 0;
}

int selectionSort(card C[], int N) {
    int minj;
    for (int i = 0; i < N; i++) {
        minj = i;
        for (int j = i; j < N; j++) {
            if (C[j].value < C[minj].value) {
                minj = j;
            }
        }
        swap(C[i], C[minj]);
    }
    return 0;
}

void printCards(card C[], int N) {
    for (int i = 0; i < N-1; i++) {
        cout << C[i].suit << C[i].value << " ";
    }
    cout << C[N-1].suit << C[N-1].value << endl;
}

bool isStable(card C1[], card C2[], int N) {
    for (int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit) {
            return false;
        }
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    card C1[N], C2[N];
    for (int i = 0; i < N; i++) cin >> C1[i].suit >> C1[i].value;
    for (int i = 0; i < N; i++) C2[i] = C1[i];
    
    bubbleSort(C1, N);
    printCards(C1, N);
    cout << "Stable" << endl;

    selectionSort(C2, N);
    printCards(C2, N);
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
}


Measured memory_bytes: 3068
#include <cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = gcd(a[0], a[1]);
	for (int i = 2; i < n; i++) {
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  cin>>N>>S;
  vector<pair<int,int>> A(26,make_pair(N,N));
  for(int i=0;i<N;i++){
    if(A[S[i]-'a'].first==N)
      A[S[i]-'a'].first=i;
    A[S[i]-'a'].second=i;
  }
  vector<int> B(N+1,0);
  for(int i=0;i<26;i++){
    B[A[i].first]++;
    B[A[i].second]--;
  }
  int ma=B[0];
  for(int i=0;i<N-1;i++){
    B[i+1]+=B[i];
    ma=max(ma,B[i+1]);
  }
  cout<<ma<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
     int n, m;
     cin >> n >> m;
     set<int> A;
     rep(i, m) {
         int tmp;
         cin >> tmp;
         A.insert(tmp);
     }

     vector<int> F(100010, 0);
     F.at(0) = 1;
     if(A.count(1)) F.at(1) = 0;
     else F.at(1) = 1;

     for(int i = 2; i <= n; i++){
        if(!A.count(i)) F.at(i) = (F.at(i-2) + F.at(i-1)) % INF;
     }

     cout << F.at(n) << endl;

}

Measured memory_bytes: 5376
N,K=map(int,input().split())
a=[int(i) for i in input().split()]
S=[0]
p=[0]


for i in range(1,N+1):
  S.append(S[i-1]+a[i-1])
  if a[i-1]>0:
    p.append(p[i-1]+a[i-1])
  else:
    p.append(p[i-1])

ans=0
for i in range(1,N-K+2):
  res=0
  res+=max(S[i+K-1]-S[i-1],0)
  res+=p[i-1]
  res+=p[-1]-p[i+K-1]
  ans=max(res,ans)
print(ans)
  
  
  
     
    

Measured memory_bytes: 76960
#include<bits/stdc++.h>
#define TRACE
#ifndef TRACE
#define tcout 0 && cout
#else
#define tcout cout << "Debug: "
#endif
#define in inline
#define reg register
#define int long long
#define MAX 20030813
using namespace std;
namespace qwq{
	in void read(int &o)
	{
		o=0;
		int w=1;
		char c=getchar();
		while(c<'0'||c>'9')
		{
			if(c=='-')w*=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9')
		{
			o=(o<<3)+(o<<1)+(c^48);
			c=getchar();
		}
		o*=w;
	}
	in void write(int x)
	{
	   	if(x<0)putchar('-'),x=-x;
    	if(x>9)write(x/10);
    	putchar(x%10+48);
	}
	in int max(int x,int y)
	{
		return x>y?x:y;
	}
	in int min(int x,int y)
	{
		return x<y?x:y;
	}
}
using namespace qwq;
int N,a[MAX],b[MAX],c[MAX],ans;
signed main()
{
	read(N);
	for(reg int i=1;i<=N;++i)read(a[i]);
	for(reg int i=1;i<=N;++i)read(b[i]);
	for(reg int i=1;i<N;++i)read(c[i]);
	for(reg int i=1;i<=N;++i)
	{
		ans+=b[a[i]];
		if(a[i+1]==a[i]+1)ans+=c[a[i]];
	}
	write(ans);
	return 0;
}



Measured memory_bytes: 4352
def merge(targ,first,mid,last):
    left = targ[first:mid] + [10 ** 9 + 1]
    right = targ[mid:last] + [10 ** 9 + 1]

    leftcnt = rightcnt = 0
    global ans
    for i in range(first,last):
        ans += 1
        #print(left,right,left[leftcnt],right[rightcnt],targ,ans)
        if left[leftcnt] <= right[rightcnt]:
            targ[i] = left[leftcnt]
            leftcnt += 1
        else:
            targ[i] = right[rightcnt]
            rightcnt += 1

def mergesort(targ,first,last):

    if first +1 >= last:
        pass
    else:
        mid = (first + last) // 2
        mergesort(targ,first,mid)
        mergesort(targ,mid,last)
        merge(targ,first,mid,last)


ans = 0
num = int(input())
targ = [int(n) for n in input().split(' ')]
mergesort(targ,0,num)
print(" ".join([str(n) for n in targ]))
print(ans)

Measured memory_bytes: 69024
#include <iostream>
#include <algorithm>
using namespace std;
void display(int N, int* arr) {
    for(int i = 0; i < N-1; i++) cout << arr[i] << " ";
    cout << arr[N-1] << endl;
}
void bubbleSort(int N, int* arr) {
    int cnt = 0;
    for(int i = 0; i < N-1; i++) {
        for(int j = N-1; j >= 0; j--) {
            if(arr[j-1] > arr[j]) {
                swap(arr[j-1], arr[j]);
                cnt++;
            }
        }
    }
    display(N, arr);
    cout << cnt << endl;
}
int main(void){
    int N; cin >> N;
    int arr[N];
    for(int i = 0; i < N; i++) cin >> arr[i];
    bubbleSort(N, arr);
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;
    int a, c;
    int M;
    for(int i = 0; i < N;i ++){
        M = B[i];
        a = lower_bound(A.begin(), A.end(), M) - A.begin();
        c = C.end() - upper_bound(C.begin(), C.end(), M);
        ans += (long long)a*c;
    }
    cout << ans << endl;
    
    
    return 0;
}

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

int main(){

    int a,b;
    string s;
    cin >> a >> b >> s;

    if(s[a] == '-'){
        for(int i = 0;i < a-1;i++){
            if(s[i] == '-'){
                cout << "No" << endl;
                return 0;
            }
        }

        for(int i = a+1;i < s.length();i++){
            if(s[i] == '-'){
                cout << "No" << endl;
                return 0;
            }
        }

        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

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

int K, N, A[200100], m;

int main () {
	cin >> K >> N;
	m = 0;
	for(int i=0; i<N; i++)
		cin >> A[i];
	for(int i=1; i<N; i++) {
		m = max(m, A[i]-A[i-1]);
	}
	m = max(m, A[0]+K-A[N-1]);
	cout << K-m << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;


int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	int n;
	cin>>n;
	vi g(n, 0);

	rep(i, 1, n-1)
	{
		int x;
		cin>>x;
		x--;
		g[x] ++;
	}
	rep(i, 0, n-1)
		cout<<g[i]<<"\n";
}


Measured memory_bytes: 4032
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main(void)
{
  int i,j,k,m[101],n[101],h[101][101];
  string s[101]={},sf,st;

  k = 1;
  do{
    cin >> s[k];
    m[k] = s[k].size();
    if(s[k] == "-")
      break;
    cin >> n[k];
    for(i = 1; i <= n[k]; i++)
      cin >> h[k][i];
    k = k + 1;
  }while(1);

  for(i = 1; i <= k-1; i++){
//    cout << i << " : " << s[i] << endl;
    for(j = 1; j <= n[i]; j++){
      st = s[i].substr(0,h[i][j]);
      sf = s[i].substr(h[i][j],m[i]-h[i][j]);
      s[i] = sf + st;
//      cout << " " << j << " " << s[i] << endl;
    }
    cout << s[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3168
#include<time.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}

int main(void){
    string s;
    cin>>s;
    int ans=700;
    
    for (auto i:s){
        if (i=='o')ans+=100;
    }
    cout<<ans;
}



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

int main(){
	int N, K, S, i;
	scanf("%d%d%d", &N, &K, &S);
	if(S < (int)(1e9)){
		for(i = 0; i < K; i++){
			printf("%d ", S);
		}
		for(i = K; i < N; i++){
			printf("%d ", S + 1);
		}
		printf("\n");
	}
	else{
		for(i = 0; i < K; i++){
			printf("%d ", S);
		}
		for(i = K; i < N; i++){
			printf("%d ", 1);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1280
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll n=in();
    vector<ll>a(n);for(ll i=0;i<n;++i)a[i]=in();
    ll money=1000,stock=0;
    for(ll i=0;i!=n-1;){
        for(;i!=n-1&&a[i]>=a[i+1];++i);
        stock+=money/a[i];
        money-=money/a[i]*a[i];
        for(;i!=n-1&&a[i]<=a[i+1];++i);
        money+=stock*a[i];
        stock=0;
    }
    cout<<money<<endl;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
			var max = 0;

			for (var i = 0; i < s.Length; i++)
			{
				var isAcgt = true;

				for (var j = i; j < s.Length; j++)
				{
					if(s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T')
					{
						max = Math.Max(max, j - i);
						isAcgt = false;
						break;
					}
				}

				if(isAcgt)
				{
					max = Math.Max(max, s.Length - i);
				}
			}
			
			Console.WriteLine(max);
		}
	}
}


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

// why am I so weak

char s[100055];
bool used[100055];

int main() {
	scanf("%s", s);

	int n = strlen(s);
	int l = 0;

	for (int i = 0; i + 2 < n; i += 2) {
		if (s[i + 2] == s[0]) {
			l = i + 2;	
		} else break;
	}

	int r = n - 1;

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

	if (r <= l) {
		puts("Second");
		return 0;
	}

	puts((n + (s[0] == s[n - 1]) + 2) % 2 == 0 ? "Second" : "First");

	return 0;
}


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

int d, ans, m, x, q;
int c[30], s[370][30], t[370], lst[30];

int calc(int p, int q) {
	int i, sum = s[p][q];
	for(i=1; i<=26; i++) {
		if(i==p) continue;
		sum -= c[i] * (p-lst[i]);
	}
	return sum;
}

int main() {
	int i, j, re, mx, mj;
	cin >> d;
	for(i=1; i<=26; i++) cin >> c[i];
	for(i=1; i<=d; i++) for(j=1; j<=26; j++) cin >> s[i][j];
	for(i=1; i<=d; i++) {
		mx = -1e9;
		for(j=1; j<=26; j++) {
			re = calc(i, j);
			if(re > mx) {
				mx = re;
				mj = j;
			}
		}
		ans += s[i][mj];
		lst[mj] = i;
		for(j=1; j<=26; j++) ans -= c[j] * (i-lst[j]);
		cout << mj << endl;
	}
}

Measured memory_bytes: 3572
eval'N,K,*A='+`dd`.split*?,
A.sort!
b=s=K%2<1?1:A.pop
(x,y=A[0]*A[1],A[-2]*A[-1]
s*=x*b>y*b ?(A.shift 2;x):(A.pop 2;y)
s%=10**9+7
K-=2)while K>1
p s

Measured memory_bytes: 54800
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000000

int main() {
	
	int X,Y,Z;
	cin>>X>>Y>>Z;
	swap(X,Y);
	swap(X,Z);
	
	cout<<X<<' '<<Y<<' '<<Z<<endl;
	
	
	
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  int64_t n;
  cin>>n;


  int64_t min_wk = 10000000000;
  int64_t max_wk = -10000000000;
  for(int i=0;i<n;i++){
    int64_t r;
    cin>>r;


    max_wk = max(max_wk,r-min_wk);
    min_wk = min(r,min_wk);
  }

  cout<<max_wk<<endl;

	return 0;
}


Measured memory_bytes: 3096
import sys
def input(): return sys.stdin.readline().strip()
 
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))
 
N, X = mi()
L = li()
 
count = 1
D = 0
for i in range(N):
  D += L[i]
  if X >= D:
    count += 1
  else:
    break
 
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    double a,b,x;
    scanf("%lf%lf%lf",&a,&b,&x);
    if(a*a*b<=2*x)
    printf("%.10lf",((atan2(2*(b-(x/(a*a))),a))*180/M_PI));
    else
    printf("%.10lf",atan2(a*b*b,2*x)*180/M_PI);
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
char enl = '\n';
#define rep(i, from, to) for (int i = from; i < (to); ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<pair<int, int>> vii;

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

    int n;
    cin >> n;

    int sum = 0;

    vi l(n);
    rep(i,0,n) {
        int s;
        cin >> s;
        l[i] = s;
        sum += s;
    }

    if (sum % 10 == 0) {
        sort(l.begin(), l.end());
        rep(i,0,n) {
            if (l[i] % 10 != 0) {
                sum -= l[i];
                break;
            }
        }
        if (sum % 10 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << sum << endl;


    return 0;
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

int func(int a, int b, int c, int d){
    return abs(a-c) + abs(b-d);
}

signed main() {

    int N, M;
    cin>>N>>M;
    vector<string> A(N), B(M);
    rep(i,N) cin >> A[i];
    rep(i,M) cin >> B[i];
    
    rep(i,N-M+1)rep(j,N-M+1){
        bool f=true;
        rep(k,M)rep(l,M){
            if(A[k+i][l+j]!=B[k][l]) f=false;
        }
        if(f){Yes; return 0;}
    }
    No;
    
    return 0;
}


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

void swap(int& x, int& y)
{
	int t = x;
		x = y;
		y = t;
}

int main()
{
	for (int i = 0; i < 3000; i++) {
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x > y) swap(x, y);
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int type = 3;
		long happiness[][] = new long[type][num];
		for(int i = 0; i < num; i ++) {
			for(int j = 0; j < type; j ++) {
				happiness[j][i] = sc.nextLong();
			}
		}

		long dp[][] = new long[3][num];
		for(int j = 0; j < type; j ++) {
			dp[j][0] = happiness[j][0];
		}
		for(int i = 1; i < num; i ++) {
			for(int j = 0; j < type; j ++) {
				dp[j][i] = happiness[j][i]
					+ Math.max(dp[(j + 1) % 3][i - 1], dp[(j + 2) % 3][i - 1]);
			}
		}

		long max = 0;
		for(int j = 0; j < type; j ++) {
			max = Math.max(max, dp[j][num - 1]);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 96276
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>

using namespace std;

const double PI=acos(-1.0);

struct complex
{
    double r,i;
    complex(double _r=0,double _i=0)
    {
        r=_r;
        i=_i;
    }
    complex operator+(const complex&b)
    {
        return complex(r+b.r,i+b.i);
    }
    complex operator-(const complex&b)
    {
        return complex(r-b.r,i-b.i);
    }
    complex operator*(const complex&b)
    {
        return complex(r*b.r-i*b.i,r*b.i+i*b.r);
    }
};

void change(complex y[],int len)
{
    int i,j,k;
    for(i=1,j=len/2;i<len-1;i++)
    {
        if(i<j)
            swap(y[i],y[j]);
        k=len/2;
        while(j>=k)
        {
            j-=k;
            k/=2;
        }
        if(j<k)
            j+=k;
    }
}
void fft(complex y[],int len,int on)
{
    change(y,len);
    for(int h=2;h<=len;h<<=1)
    {
        complex wn(cos(-on*2*PI/h),sin(-on*2*PI/h));
        for(int j=0;j<len;j+=h)
        {
            complex w(1,0);
            for(int k=j;k<j+h/2;k++)
            {
                complex u=y[k];
                complex t=w*y[k+h/2];
                y[k]=u+t;
                y[k+h/2]=u-t;
                w=w*wn;
            }
        }
    }
    if(on==-1)
        for(int i=0;i<len;i++)
            y[i].r/=len;
}

const int MAXN=400040;
complex x1[MAXN];
int a[MAXN/4];
long long num[MAXN];//100000*100000会超int
long long sum[MAXN];

int main()
{
    int T;
    int n;

    scanf("%d",&n);
    memset(num,0,sizeof(num));
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        num[a[i]]++;
    }
    sort(a,a+n);
    int len1=a[n-1]+1;
    int len=1;
    while(len<2*len1)
        len<<=1;
    for(int i=0;i<len1;i++)
        x1[i]=complex(num[i],0);
    for(int i=len1;i<len;i++)
        x1[i]=complex(0,0);
    fft(x1,len,1);
    for(int i=0;i<len;i++)
        x1[i]=x1[i]*x1[i];
    fft(x1,len,-1);
    for(int i=0;i<len;i++)
        num[i]=(long long)(x1[i].r+0.5);
    len=2*a[n-1];
    //减掉取两个相同的组合
    for(int i=0;i<n;i++)
        num[a[i]+a[i]]--;
    //选择的无序，除以2
    for(int i=1;i<=len;i++)
    {
        num[i]/=2;
    }
    sum[0]=0;
    for(int i=1;i<=len;i++)
        sum[i]=sum[i-1]+num[i];
    long long cnt=0;
    for(int i=0;i<n;i++)
    {
        cnt+=sum[len]-sum[a[i]];
        //减掉一个取大，一个取小的
        cnt-=(long long)(n-1-i)*i;
        //减掉一个取本身，另外一个取其它
        cnt-=(n-1);
        //减掉大于它的取两个的组合
        cnt-=(long long)(n-1-i)*(n-i-2)/2;
    }
    //总数
    long long tot=(long long)n*(n-1)*(n-2)/6;
    printf("%lld\n",cnt);

    return 0;
}

Measured memory_bytes: 11392
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <unordered_map>

#define div 1000000000+7

using ll = long long;
using namespace std;

void solve() {
    int n;
    int max = 0, min = 1000000;
    vector<int> a;

    cin >> n;

    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
        if(max < a[i]){
            max = a[i];
        }
        if(min > a[i]){
            min = a[i];
        }
    }
    cout << max-min << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int a = 0;
	int b = 0;
	int kake;

	for (int i=1; i<10; i++) {
		for (int j=1; j<10; j++) {
			kake = i * j;
			cout << i << "x" << j << "=" << kake << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	ll := 0
	rr := 0
	for i := 0; i < m; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		if ll == 0 || ll < l {
			ll = l
		}
		if rr == 0 || rr > r {
			rr = r
		}
	}
	ans := rr - ll + 1
	if ans < 0 {
		ans = 0
	}
	fmt.Printf("%v\n", ans)
}


Measured memory_bytes: 5504