akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt(),cAC=0, cRE=0, cTLE=0, cWA=0;
    String a;
    for(int i=0; i<N; i++) {
      a=sc.next();
      switch(a) {
        case "AC":
          cAC++;
          break;
        case "WA":
          cWA++;
          break;
        case "TLE":
          cTLE++;
          break;
        case "RE":
          cRE++;
          break;
      }
    }
    System.out.println("AC x " + cAC);
    System.out.println("WA x " + cWA);
    System.out.println("TLE x " + cTLE);
    System.out.println("RE x " + cRE);

  }
}

Measured memory_bytes: 58212
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
n = onem()

p = l()


a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
    a[p[i]-1] = 3*(10**4)*(p[i])
    b[p[i]-1] = 3*(10**4)*(n-p[i]) + (i+1) 
print(jo(a))
print(jo(b))




Measured memory_bytes: 47896
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) ((a).begin(),(a).end())
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int inf = 1e8;
int n;
int c[1010];
vector<pii> g[1010];

int rec(int v, int prv){
  if(c[v])return inf;

  int ans = 0;
  for(pii e : g[v]){
    int u = e.first, cost = e.second;
    if(u==prv)continue;
    ans += min(cost, rec(u,v));
  }

  return ans;
}

int main(){
  cin >> n;
  c[0] = 0;
  rep(i,n-1)cin >> c[i+1];

  rep(i,n-1){
    int u,v,p;
    cin >> u >> v >> p;
    g[u].push_back(pii(v,p));
    g[v].push_back(pii(u,p));
  }

  cout << rec(0,-1) << endl;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

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

	int n; cin >> n;
	string s; cin >> s;

	int cntR = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == 'R')
			cntR++;
	int result = cntR;
	for (int i = 0; i < cntR; i++)
		if (s[i] == 'R')
			result--;
	cout << result << '\n';

	return 0;
}

Measured memory_bytes: 3760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = 3;
		int[][] f = new int[n][n];
		int[][] rowDiff = new int[n][n];
		int[][] colDiff = new int[n][n];
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				f[i][j] = sc.nextInt();
			}
		}
		int pos = 0;
		for (int i = 0 ; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				for (int k = 0; k < n; k++) {
					rowDiff[pos][k] = f[j][k] - f[i][k];
				}
				pos++;
			}
		}
		
		pos = 0;
		for (int i = 0 ; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				for (int k = 0; k < n; k++) {
					colDiff[k][pos] = f[k][j] - f[k][i];
				}
				pos++;
			}
		}
		
		for (int i = 0; i < n; i++) {
			if ((rowDiff[i][0] != rowDiff[i][1]) || (rowDiff[i][1] != rowDiff[i][2])) {
				System.out.println("No");
				System.exit(0);
			}
			 //System.out.print(Arrays.toString(rowDiff[i]));
		}
		
		for (int i = 0; i < n; i++) {
			if ((colDiff[0][i] != colDiff[1][i]) || (colDiff[1][i] != colDiff[2][i])) {
				System.out.println("No");
				System.exit(0);
			}
			// System.out.print(Arrays.toString(colDiff[i]));
		}
		System.out.println("Yes");
	}
	
	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: 22612
import sys
s=[list(map(int,e.split(',')))for e in sys.stdin]
for i in range(1,len(s)):
 k=len(s[i])
 b=k>len(s[i-1])
 for j in range(k):
  t=j-b
  s[i][j]+=max(s[i-1][t*(j>0):t+2])
print(*s[-1])


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int H,heap[2000001];

void maxHeapify(int i){
  int l,r,largest;
  l=i*2;
  r=i*2+1;

  //左の子、自分、右の子で値が最大のノードを選ぶ

  if(l<=H&&heap[l]>heap[i]) largest=l;
  else largest=i;

  if(r<=H&&heap[r]>heap[largest]) largest=r;

  if(largest!=i){
    swap(heap[i],heap[largest]);
    maxHeapify(largest);
  }
}

int main(){
  scanf("%d",&H);
  for(int i=1;i<=H;++i) scanf("%d",&heap[i]);

  for(int i=H/2;i>=1;i--) maxHeapify(i);

  for(int i=1;i<=H;i++){
    printf(" %d",heap[i]);
  }
  cout<<endl;

  return 0;
}



Measured memory_bytes: 5244
#include <cstdio>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int r, g, b, n;
	int res = 0;
	cin >> r >> g >> b >> n;
	for (int i = 0; i <= n / r; i++) {
		int n2 = n - r * i;
		for (int j = 0; j <= n2 / g; j++) {
			int n3 = n2 - g * j;
			if (n3 % b == 0)
				res++;
		}
	}
	cout << res << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int m=0;
  for(int i=0;i<n-1;i++){
    
    if(vec.at(i)<vec.at(i+1)){
      m+=1;
    }
    else{
    }
  }
  cout << m+1 << endl;
}

Measured memory_bytes: 256
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[];
  const outs: Print[] = [];
  const _io = (i = 0) => {
    // eslint-disable-next-line @typescript-eslint/no-var-requires
    const str = require("fs").readFileSync("/dev/stdin", "utf8");
    const lines = str.trim().split("\n");
    const s = () => lines[i++] || "";
    const n = () => Number(s());

    const mn = (v: string[]) => v.map(Number);
    const sp = (v: string) => v.split(" ");

    const ss = () => sp(s());
    const nn = () => mn(ss());
    const nls = () => mn(lines.slice(i));
    const nnls = () => lines.slice(i).map((v: string) => mn(sp(v)));

    return { lines, s, n, ss, nn, nls, nnls };
  };
  const main = (): Print => {
    const r = _io();
    const s = r.nnls();
    // 距離変数
    const distance = s[0][1];
    // 座標集合
    s.shift();
    const coordinates = s;
    // 関数
    return getCoordinatesWithinDistanceFromX(coordinates, distance, [0, 0]);
  };
  // 以下 関数書く
  const getCoordinatesWithinDistanceFromX = (
    coordinates: Array<Array<number>>,
    distance: number,
    xMatrix: Array<number>
  ): number => {
    let counter = 0;
    for (const coordinate of coordinates) {
      if (
        Math.sqrt(
          Math.pow(coordinate[0] - xMatrix[0], 2) +
            Math.pow(coordinate[1] - xMatrix[1], 2)
        ) <= distance
      ) {
        counter = counter + 1;
      }
    }
    return counter;
  };

  outs.push(main());

  console.log(
    outs
      .map((line) => (typeof line === "object" ? line.join(" ") : String(line)))
      .join("\n")
  );
}


Measured memory_bytes: 93568
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;

  if(n == 1){
    cout << "Hello World" << endl;
  }
  else{
    int a, b;
    cin >> a >> b;
    cout << (a + b) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <climits>
#include <vector>
#include <cmath>
#include <cstring>
#include <set>

using namespace std;

int main(void)
{

    int A[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> A[i][j];
        }
    }

    int N;
    cin >> N;

    set<int> B;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        B.insert(tmp);
    }

    // yoko
    for (int i = 0; i < 3; i++)
    {
        bool flag = true;
        for (int j = 0; j < 3; j++)
        {
            if (B.count(A[i][j]) == 0)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            puts("Yes");
            return 0;
        }
    }

    // tate
    for (int i = 0; i < 3; i++)
    {
        bool flag = true;
        for (int j = 0; j < 3; j++)
        {
            if (B.count(A[j][i]) == 0)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            puts("Yes");
            return 0;
        }
    }

    // naname1
    bool flag = true;
    for (int i = 0; i < 3; i++)
    {
        if (B.count(A[i][i]) == 0)
        {
            flag = false;
            break;
        }
    }
    if (flag)
    {
        puts("Yes");
        return 0;
    }

    // naname2
    flag = true;
    for (int i = 0; i < 3; i++)
    {
        if (B.count(A[i][2 - i]) == 0)
        {
            flag = false;
            break;
        }
    }
    if (flag)
    {
        puts("Yes");
        return 0;
    }

    puts("No");
    return 0;
}


Measured memory_bytes: 256
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=200010;
int n,ans[N];
struct node{int id,a;}p[N];
bool operator<(const node a,const node b){return a.a<b.a;}
int main(){
	n=gi();for(int i=1;i<=n;i++)p[i].a=gi(),p[i].id=i;
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++)ans[p[i].id]=(i==n)?p[n-1].a:p[n].a;
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ld a, b, c;
ld rad() {
	ld res = 2;
	ld t1 = sqrt(((ld)2 * a*b + a * a + b * b - c * c) / ((ld)2 * a*b - a * a - b * b + c * c));
	swap(b, c);
	ld t2 = sqrt(((ld)2 * a*b + a * a + b * b - c * c) / ((ld)2 * a*b - a * a - b * b + c * c));
	res += t1 + t2;
	return a / res;
}
int main() {
	ld x[3], y[3];
	rep(i, 3) {
		cin >> x[i] >> y[i];
	}
	a = sqrt(pow(x[1] - x[0], 2) + pow(y[1] - y[0], 2));
	b = sqrt(pow(x[2] - x[1], 2) + pow(y[2] - y[1], 2));
	c = sqrt(pow(x[0] - x[2], 2) + pow(y[0] - y[2], 2));
	ld out = -1;
	out = max(out, rad());
	swap(a, b);
	out = max(out, rad());
	swap(a, b);
	out = max(out, rad());
	cout << fixed << setprecision(10) << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N;
    cin>>N;
    int ans=0;
    vector<int> B(N-1);
    for(int i=0;i<N-1;i++){
        cin>>B.at(i);
    }
    for(int i=0;i<N;i++){
        if(i==0){
            ans+=B.at(0);
        }else if(i==N-1){
            ans+=B.at(N-2);
        }else{
            ans+=min(B.at(i-1),B.at(i));
        }
    }
    cout<<ans<<endl;
}

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

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        long[] l = new long[5] {0,0,0,0,0};
        for(int i = 0; i < n; i ++) {
           string s = Console.ReadLine();
           if(s[0]=='M') l[0] ++;
           if(s[0]=='A') l[1] ++;
           if(s[0]=='R') l[2] ++;
           if(s[0]=='C') l[3] ++;
           if(s[0]=='H') l[4] ++;
       }
       Console.WriteLine(solve(l));
    }
    static long solve(long[] l) {
        long count = 0;
        for(int i = 0; i < 3; i ++) {
            for(int j = i+1; j <= 3; j ++) {
                count += l[i] * l[j] * (l.Where((x,y) => y > j).Sum());
            }
        }
        return count;
    }
}

Measured memory_bytes: 15316
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

bool solve() {
  usize n, a, b, c, d;
  std::cin >> n >> a >> b >> c >> d;
  --a;
  --b;
  --c;
  --d;
  std::vector<char> s(n);
  for (auto &e : s) {
    std::cin >> e;
  }
  const auto reachable = [&s](usize x, usize y) {
    while (x != y) {
      if (s[x + 1] == '.') {
        ++x;
      } else if (s[x + 2] == '.') {
        x += 2;
      } else {
        return false;
      }
    }
    return true;
  };
  if (!reachable(a, c)) {
    return false;
  }
  if (!reachable(b, d)) {
    return false;
  }
  if (d < c) {
    const auto mid = [&s](usize x) {
      if (x == 0 || x + 1 == s.size()) {
        return false;
      }
      return s[x - 1] == '.' && s[x] == '.' && s[x + 1] == '.';
    };
    while (b != d) {
      if (mid(b)) {
        return true;
      }
      if (s[b + 1] == '.') {
        ++b;
      } else {
        b += 2;
      }
    }
    if (mid(b)) {
      return true;
    }
    return false;
  } else {
    return true;
  }
}

void main_() { std::cout << (solve() ? "Yes" : "No") << std::endl; }

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF -1000000000000000000
#define N 1000000007
#define ll long long
using namespace std;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    ll s;
    cin>>s;
    
    ll p[100004];
    p[0]=1;
    for(ll i=1; i<100000; i++){
        p[i]=p[i-1]*i;
        p[i]%=N;
    }
    
    ll l=1;
    ll ans=0;
    while(true){
        ll n=s-3*l;
        if(n<0) break;
        ll q=p[n]*p[l-1];
        q%=N;
        ll sum=p[n+l-1]*modinv(q,N);
        sum%=N;
        ans+=sum;
        ans%=N;
        l++;
    }
    cout<<ans<<endl;
}

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

typedef long long ll;

int N;
string S;

int W[300001],E[300001];

int main() {
    cin>>N;
    cin>>S;

    if(S[0]=='W') W[0]=1;
    else E[0]=1;
    for(int i=1;i<N;i++) {
        if(S[i]=='W') {
            W[i]++;
        } else {
            E[i]++;
        }
        W[i]+=W[i-1];
        E[i]+=E[i-1];
    }

    int res = min(E[N-1]-E[0], W[N-2]);
    for(int i=1;i<N-1;i++) {
        res = min(res, W[i-1]+E[N-1]-E[i]);
    }
    cout<<res;

}

Measured memory_bytes: 2948
import math

def main():
  A, B = list(map(str, input().split()))
  A = int(A)
  d, f = B.split('.')
  d = int(d)

  ans = 0

  ans += A * d

  fl = A * int(f)

  print(ans + (fl // 100))



if __name__ == "__main__":
  main()

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>


void test_case()
{
    int x;
    cin >> x;
    if(x >= 30)
		cout<<"Yes";
	else cout << "No";
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
using namespace std;
int main(){
  int k,x;
  cin>>k>>x;
  int s,e;
  s=x-k+1;
  e=x+k-1;
  for(int i=s;i<=e;i++){
    cout<<i<<" ";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#define MAX_N 100
#define MAX_M 100

using namespace std;

int T[MAX_N];
int _T[MAX_M];

int main() {
  int N;
  cin >> N;
  int t = 0;
  for (int i = 0; i < N; ++i) {
    cin >> T[i];
    t += T[i];
  }
  int M;
  cin >> M;
  for (int i = 0; i < M; ++i) {
    int p, x;
    cin >> p >> x;
    _T[i] = t - T[p - 1] + x;
  }
  for (int i = 0; i < M; ++i) {
    printf("%d\n", _T[i]);
  }
}

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

int main(){
  int n;
  cin >> n;
  
  int x;
  x = 0;
  
  for(int i = 0; i < n; i ++){
    int l,r;
    cin >> l>>r;
    x += r-l+1;
  }
  cout << x <<endl; 
}


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

int main() {
  string n;

  cin >> n;
  for (int i = 0; i < n.length(); i++) {
    if (n[i] == '1') {
      n[i] = '9';
    } else if (n[i] == '9') {
      n[i] = '1';
    }
  }
  cout << n << endl;
}


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

int main() {
  int S;
  cin >> S;
  int s1 = S / 100;
  int s2 = (S % 100) / 10;
  int s3 = (S % 100) % 10;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 3576
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int A,B;
    bool odd = false;
    cin >> A >> B;

    for(int i = 1; i <= 3; i++)
        if(A*B*i % 2 == 1) odd = true;
    
    if(odd)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            long n = Long.parseLong(strArr[0]);
            long k = Long.parseLong(strArr[1]);
            TreeMap<Long, Long> map = new TreeMap<Long,Long>();
            for (int i = 0; i < n; i++) {
                strArr = br.readLine().split(" ");
                long num = Long.parseLong(strArr[0]);
                long count = Long.parseLong(strArr[1]);
                if (map.containsKey(num)) {
                    long before = map.get(num);
                    map.put(num, count + before);
                } else {
                    map.put(num, count);
                }
            }
            long temp = 0;
            for (long nKey : map.keySet()) {
                temp = temp + map.get(nKey);
                if (temp >= k) {
                    System.out.println(nKey);
                    break;
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N, M; cin >> N >> M;
    int A[N]; rep(i, N) cin >> A[i];
    int B[M]; rep(j, M) cin >> B[j];
    sort(A, A+N); reverse(A, A+N);
    sort(B, B+M); reverse(B, B+M);
    int idx_A = 1, idx_B = 1;
    ll ans;
    rep(i, N-1){
        if(A[i] == A[i+1]){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, M-1){
        if(B[i] == B[i+1]){
            cout << 0 << endl;
            return 0;
        }
    }

    if(A[0] == B[0] && A[0] == N*M){
        ans = 1;
        ll op = N*M-1;
        ll tate = 1, yoko = 1;
        ll kouten = 1, put_kouten = 1;
        while(idx_A < N || idx_B < M){
            if(idx_A == N){
                if(op > B[idx_B]){
                    ans = (ans * (kouten-put_kouten)) % mod;
                    put_kouten++;
                }
                else{
                    kouten += yoko; tate++;
                    ans = (ans * yoko) % mod;
                    put_kouten++;
                    idx_B++;
                }
            }
            else if(idx_B == M){
                if(op > A[idx_A]){
                    ans = (ans * (kouten-put_kouten)) % mod;
                    put_kouten++;
                }
                else{
                    kouten += tate; yoko++;
                    ans = (ans * tate) % mod;
                    put_kouten++;
                    idx_A++;
                }
            }
            else{
                if(op > A[idx_A] && op > B[idx_B]){
                    ans = (ans * (kouten-put_kouten)) % mod;
                    put_kouten++;
                }
                else if(op == A[idx_A] && op == B[idx_B]){
                    //一意に決まる
                    kouten += tate; yoko++;
                    kouten += yoko; tate++;
                    put_kouten++;
                    idx_A++; idx_B++;
                }
                else if(op == A[idx_A]){
                    kouten += tate; yoko++;
                    ans = (ans * tate) % mod;
                    put_kouten++;
                    idx_A++;
                }
                else{
                    kouten += yoko; tate++;
                    ans = (ans * yoko) % mod;
                    put_kouten++;
                    idx_B++;
                }
            }
            op--;
        }
        //1以上op以下の数は好きなとこにおける -> ans *= fac[op];
        ll fac[op+1]; fac[0] = 1;
        rep(i, op){
            fac[i+1] = (fac[i]*(i+1)) % mod;
        }
        ans = (ans * fac[op]) % mod;
    }
    else{
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 1e6 + 6;
const int M = 1e9 + 7;
const int inf = 1e17;



int A[N];
int n,a,b;
int dp[101][N];

int alpha(int i , int k)
{  
  // if(k < 0)return 0;
      // cout << i << " " << k << endl;
  if(i == n+1 && k == 0 )return 1;
  if(i == n+1)return 0;

  int &abstergo = dp[i][k];
  if(abstergo != -1)return abstergo;
  int ans = 0;
  ans += alpha(i+1,k), ans%=M;
  if(k-1 >= 0) ans += alpha(i,k-1),ans%=M;
  if(k-1 >= A[i]) ans -= alpha(i+1,k-1-A[i]),ans%=M;
  if( ans < 0 ) ans += M;



  return abstergo = ans;

}

void solve()
{
  cin >> n >> a;

  loop(i,1,n+1)cin >> A[i];

  mset(dp,-1);

  cout << alpha(1,a);
}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    
   
   int t = 1;
   // cin >> t;
   while(t--)solve();
  
}

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

using namespace std;
#define ll long long int
#define ull unsigned long long int
#define module 1000000007
  
int  Count(vector <int>A,int n){  
  
    
  
    sort(A.begin(), A.end());  
  
    int count = 0; 
      
    for( int i=n-1; i>=1; i--)
    { 
        int l= 0,r=i-1; 
        while( l<r)
        { 
            if( A[l]+A[r]>A[i])
            { 
  
                count+=r-l ;  
                r--;   
            } 
            else 
                l++;   
        } 
    } 
    return count;
} 
int main(){ 
  
  int n;
  cin>>n;
  vector<int>A(n);
  for(int i=0;i<n;i++)
  {
      cin>>A[i];
  }
  
    cout<<Count(A,n)<<endl; 
    
}     

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

/**
 * Created by Santa on 2016/10/16.
 */
public class Main {
    static String[][] map = new String[50][50];
    static int H;
    static int W;
    static int ans = -1;

    static class pair {
            public int a;
            public int b;
            public int n;

            pair(){
                this.a = 0;
                this.b = 0;
                this.n = 0;
            }

            pair(int a, int b, int n){
                this.a = a;
                this.b = b;
                this.n = n;
            }

            public void set(int a, int b, int n) {
                this.a = a;
                this.b = b;
                this.n = n;
            }

        @Override
        public String toString() {
            return this.a + ":" + this.b + ":" + this.n;
        }
    }

   static  ArrayList<pair> q = new ArrayList();

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        H = scanner.nextInt();
        W = scanner.nextInt();
        int cnt = 0;

        for (int i = 0; i < H; i++) {
            map[i] = scanner.next().split("");
            for (int j = 0; j < W; j++) {
                if(map[i][j].equals("."))cnt++;
            }
        }

        q.add(new pair(0, 0, 1));
        iter();

        if(ans != -1) {
            System.out.println(cnt - ans);
        }else{
            System.out.println(-1);
        }
    }

    static public void iter() {


        while (q.size() > 0 && ans == -1) {
            pair now = q.get(0);q.remove(0);




            if(now.a == W - 1 && now.b == H - 1){
                ans = now.n;
                continue;
            }



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

            for (int i = 0; i < 4; i++) {
                int xx = now.a + dx[i];
                int yy = now.b + dy[i];

                if (xx >= 0 && xx < W && yy >= 0 && yy < H) {
                    if(map[yy][xx].equals(".")) {
                        map[yy][xx] = "#";
                        q.add(new pair(xx, yy, now.n + 1));
                    }

                }
            }
        }

    }


}




Measured memory_bytes: 22484
from collections import deque
N = int(input())
S = []
for _ in range(N):
  S.append(input())
  
G = [[] for _ in range(N)]
for i in range(N):
  for j in range(i+1,N):
    if S[i][j] == '1':
      G[i].append(j)
      G[j].append(i)

# 2部グラフ判定
visited = [False] * N
willSearch = [False] * N
Color = [-1] * N
Q = deque()
Q.append((0,0))
while Q:
  now, c = Q.pop()
  visited[now] = True
  Color[now] = c
  for nxt in G[now]:
    if Color[nxt] >= 0 and c == Color[nxt]:
      #隣接色が一致してしまった
      print(-1)
      exit(0)
    if visited[nxt] or willSearch[nxt]:
      continue
    Q.append((nxt,1-c)) # 1-cで0/1を交換
    willSearch[nxt] = True
    
INF = 1000
D = [[INF for _ in range(N) ]  for _ in range(N)]
for i in range(N):
  for nxt in G[i]:
    D[i][nxt] = 1
    D[nxt][i] = 1
    
#Warshall-Floyd
for k in range(N):
  for i in range(N):
    for j in range(N):
      #print(i,j,k)
      D[i][j] = min(D[i][j], D[i][k] + D[k][j])
      
#print(*D, sep="\n")

ans = 0
for i in range(N):
  for j in range(i+1,N):
    ans = max(ans, D[i][j])
    
print(ans+1)

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

int main() {
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    int ans = 0;
    for (int i = 0; i < K; i++) {
        char last = '.';
        for (int j = i; j < N; j += K) {
            if (T[j] == last) {
                last = '.';
            } else {
                if (T[j] == 'r') ans += P;
                else if (T[j] == 's') ans += R;
                else ans += S;
                last = T[j];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3788
#include<stdio.h>
#define MAX 100
#define INF -1

int n;

int MatrixChainOrder(int *);

int main()
{
  int i;
  int m[MAX][2],p[MAX];

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

  for(i = 0;i <= n;i++){
    p[i] = m[i][0];
    if(i == n) p[i] = m[i-1][1];
  }

  printf("%d\n",MatrixChainOrder(p));

  return 0;
}

int MatrixChainOrder(int *p)
{
  int i,j,k,l,q,x;
  int M[MAX][MAX];

  for(i = 1;i <= n;i++){
    M[i][i] = 0;
  }

  for(l = 2;l <= n;l++){
    for(i = 1;i <= n-l+1;i++){
      j = i + l - 1;
      M[i][j] = M[i][i] + M[i+1][j] + (p[i-1] * p[i]* p[j]);
      for(k = i;k <= j-1;k++){
        q = M[i][k] + M[k+1][j] + (p[i-1] * p[k] * p[j]);
        if(q < M[i][j]) M[i][j] = q;
      }
    }
  }

  return M[1][n];
}

Measured memory_bytes: 632
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var a = int.Parse(line[1]);
        var b = int.Parse(line[2]);
        Console.WriteLine(getAns(h, a, b));
    }
    static int getAns(int h, int a, int b)
    {
        var ans = 0;
        for (int i = a; i <= b; i++)
            if (h % i == 0) ans++;
        return ans;
    }
}


Measured memory_bytes: 18004
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap



@mt
def slv(M, K):
    if K >= 2**(M+1):
        return [-1]

    if K == 0:
        ans = []
        for i in range(2**M):
            ans.append(i)
            ans.append(i)
        return ans

    p = []
    done = set()
    for a in range(2**M):
        if a in done:
            continue
        b = K ^ a
        if b >= 2**M:
            return [-1]
        p.append((a, b))
        done.add(a)
        done.add(b)

    if len(p) % 2 != 0:
        return [-1]

    ans = []
    for i in range(0, len(p), 2):
        a, b = p[i]
        c, d = p[i+1]
        ans.append(a)
        ans.append(b)
        ans.append(c)
        ans.append(d)
        ans.append(b)
        ans.append(a)
        ans.append(d)
        ans.append(c)

    return ans



def main():
    M, K = read_int_n()
    print(*slv(M, K))


if __name__ == '__main__':
    main()


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

class Program
{
    static void Main(string[] args)
    {

        List<int> a = new List<int>();
        List<int> b = new List<int>();

        //long[] a = new long[n];


        //string[] s = Console.ReadLine().Split(' ');

        // int a = int.Parse(Console.ReadLine());


        while (true)
        {
            string[] s = Console.ReadLine().Split(' ');
            int c = int.Parse(s[0]);
            int d = int.Parse(s[1]);

            if (c == 0 && d == 0) break;

            a.Add(c);
            b.Add(d);

        }

        for (int i = 0; i < a.Count; i++)
        {
            for (int y = 0; y < a[i]; y++)
            {
                for (int x = 0; x < b[i]; x++)
                {
                    if (x%2==y%2)
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }

                }
                Console.WriteLine("");
            }
            Console.WriteLine("");
        }

        //Console.WriteLine("");


    }
}

Measured memory_bytes: 8944
N = int(input())
MM = input().split()
a = int(MM[0])
b = int(MM[1])
c = int(MM[2])
list1 = [a,b,c]
count = 0
for i in range(N-3):
  aaa =sorted(list1)
  if aaa[1] == b:
    count +=1
  
  a = b
  b = c
  c = int(MM[i+3])
  list1 =[a,b,c]
  
bbb = sorted(list1)
if bbb[1] == b:
  count +=1
print(count)
              

Measured memory_bytes: 9204
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}
 
template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}
 
template<class T>
vector<T> reads(size_t n)
{
    vector<T> a;
    a.reserve(n);
    times_do(n, [&](){
        a.push_back(read<T>());
    });
    return a;
}

struct data_t {
    int id;
    int order;
};

int main()
{
    const auto n = read<int>();
    vector<data_t> data(n);
    for(int i = 0; i < n; ++i)
    {
        data[i].id = i + 1;
        cin >> data[i].order;
    }
    sort(begin(data), end(data), [](auto&& x, auto&& y){ return x.order < y.order; });
    for(auto d : data)
    {
        cout << d.id << ' ';
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<string.h>

int main()
{
    char s[200],t[200];
    int i,j,l;
    scanf("%s %s", s, t);
    l=strlen(s);
    int flag=0;
    for(i=0;i<l;i++) {
        if(s[i]==t[0]) {
            for(j=i+1;j!=i;j++) {
                if(j==l) j=0;
                char x;
                if(j>i) x=t[j-i];
                else x=t[j-i+l];

                if(s[j]!=x) break;
            }
            //printf("%d %d\n", i, j);
            if(j==i) flag=1;
        }
    }
    if(flag) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 128
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=1e20
for i in range(n-k+1):
  r=i+k-1
  p1=abs(l[i])+abs(l[r]-l[i]);p2=abs(l[r])+abs(l[i]-l[r])
  ans=min(ans,p1,p2)
print(ans)


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

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if(i != n-1){
            cout << a[i] << " ";
        }else{
            cout << a[i] << endl;
        }
    }

    int v;
    int j;
    for(int i=1; i<n; i++){
        v = a[i];
        j = i-1;
        while(j>=0 and v<a[j]){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        for(int k=0; k<n; k++) {
            if(k != n-1){
                cout << a[k] << " ";
            }else{
                cout << a[k] << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3100
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        i: usize,
    }
    let ans = n - i + 1;
    println!("{}", ans);
}


Measured memory_bytes: 4352
// You got a dream , you gotta protect it .
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
const int INF = 1e9 + 10;
int main(){
    FAST
    ll n , cnt = 0 , r, t;
    cin >> n;
    vector<ll>p(n) , q(n) , v(n);
    for(ll &c : p) cin >> c;
    for(ll &c : q) cin >> c;
    for(ll i = 1; i <= n; i++) v[i - 1] = i;
    do{
        bool b =true , e = true;
        for(ll i = 0; i < n; i++){
            if(v[i] != q[i])b = false;
            if(v[i] != p[i])e = false;
        }
        cnt++;
        if(b)r = cnt;
        if(e)t = cnt;
    }while(next_permutation(v.begin() , v.end()));
    cout << abs(r - t) << endl;
    return 0;
}


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

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

        int m = Integer.parseInt(a.substring(5,7));
        int d = Integer.parseInt(a.substring(8,10));

        if (m<=4 && d <= 30)
            System.out.println("Heisei");
        else
            System.out.println("TBD");
    }
}


Measured memory_bytes: 35756
//けんちょんさんのはてなブログ
//https://atcoder.jp/contests/abc054/tasks/abc054_c

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

// グラフを隣接行列で管理する
bool G[10][10];

int main() {
    int N, M; cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a][b] = G[b][a] = true;
    }

    // 順列
    vector<int> ord(N);
    for (int i = 0; i < N; ++i) ord[i] = i;

    // 順列を全部試すa
    int res = 0;
    do {
        if (ord[0] != 0) break;

        bool ok = true;
        for (int i = 0; i + 1 < N; ++i) {
            int from = ord[i];
            int to = ord[i+1];
            if (!G[from][to]) ok = false;
        }
        if (ok) ++res;
    } while (next_permutation(ord.begin(), ord.end()));

    cout << res << endl;
}

Measured memory_bytes: 256
def main():
    input1 = input()
    input1 = input1.split()
    N = int(input1[0])
    M = int(input1[1])

    aisle = {}
    result = [0]*(N-1)
    record = [1]
    count = N-1
    in1 = 0
    in2 = 0

    for i in range(M):
        input2 = input()
        input2 = input2.split()
        in1 = int(input2[0])
        in2 = int(input2[1])
        aisle.setdefault(in1,[]).append(in2)
        aisle.setdefault(in2,[]).append(in1)

    while count != 0 and len(record) != 0:
        pop1 = record.pop(0)
        if pop1 in aisle:
            for i in aisle[pop1]:
                if result[i-2] == 0 and i >= 2:
                    result[i-2] = pop1
                    record.append(i)
                    count = count -1

    if count == 0:
        print("Yes")
        for i in range(len(result)):
            print(result[i])
    else:
        print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 38232
<?php

while (true) {
    fscanf(STDIN, '%d %d', $n, $x);

    if (isEnd($n, $x)) { break; };

    $count = 0;
    for ($i = 1; $i <= ($x / 3) - 1; $i ++) {
        for ($j = $i + 1; $j <= ($x / 2) - 1; $j++) {
            $remainder = $x - ($i + $j);
            if ($remainder <= $n && $remainder > 0 && $remainder > $j) {
                $count++;
            }
        }
    }
    $result[] = $count;
}

echo implode(PHP_EOL, $result), PHP_EOL;

function isEnd($n, $x)
{
    return !($n || $x);
}

Measured memory_bytes: 6608
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K;
  cin>>N>>K;
  if(N+1<2*K) {
    cout<<-1<<endl;
    return 0;
  }
  map<ll, ll>amap; 
  if(K+K+2*N-1<=K+2*N) {
    for(ll i=0;i<N;++i) {
      cout<<K+i<<" "<<K+2*N-1-i<<" "<<K+2*N+i<<endl;
    }
    return 0;
  }
  ll index;
  ll maxi=2*N, mini;
  for(ll i=0;i<N;++i) {
    if(K+2*i>=K+2*N-K-i) {
      mini = K+2*N-K-i;
      index = i;
      break;
    }
    amap[K+2*N-K-i]++;
    amap[K+2*i]++;
    cout<<K+2*i<<" "<<K+2*N-K-i<<" "<<K+2*N+i<<endl;
  }
  bool change = false;
  ll index1;
  vector<ll> arr;
  for(ll i=0;i<N;++i) {
    if(K+2*N+index+i>=K+3*N) break;
    if(K+2*N-1-i<=maxi && !change) {
      change = true;
      for(ll j=K;j<=K+2*N-1;++j) {
        if(amap[j]==0) arr.push_back(j);
      }
      index1 = 0;
    }
    if(change) {
      cout<<arr[index1]<<" "<<arr[arr.size()-1-index1]<<" "<<K+2*N+index+i<<endl;
      index1++;
    }
    else {
      amap[K+2*N-1-i]++;
      amap[K+2*i+1]++;
      cout<<K+2*i+1<<" "<<K+2*N-1-i<<" "<<K+2*N+index+i<<endl;
    }
  }
}



Measured memory_bytes: 16056
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	map<int,int> mp;
	for(int i=0;i<n;i++)
	{
		int k;
		cin>>k;
		for(int j=0;j<k;j++)
		{
			int a;
			cin>>a;
			mp[a]++;
		}
	}
	int sum = 0;
	for(map<int,int>::iterator it = mp.begin();it!=mp.end();it++)
	{
		if(it->second == n)
		{
			sum++;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
 
int pi[233][233];
char ps[233][233];
 
int main()
{
	int n,m; scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++) scanf("%s",ps[i]+1);
	for(int i=1; i<=n; i++)
	{
		pi[i][0]=n*m; ps[i][0]='.';
	}
	for(int i=1; i<=m; i++)
	{
		pi[0][i]=n*m; ps[0][i]='.';
	}
	pi[1][0]=0; pi[0][1]=0;
	for(int i=1; i<=n; i++) for(int j=1; j<=m; j++)
	{
		int a=pi[i-1][j],b=pi[i][j-1];
		if(ps[i-1][j]=='.'&&ps[i][j]=='#') a++;
		if(ps[i][j-1]=='.'&&ps[i][j]=='#') b++;
		pi[i][j]=min(a,b);
	}
	printf("%d",pi[n][m]);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
Ai = input().split()
Ai = [int(n) for n in Ai]
Ai = sorted(Ai, reverse=True)
Alice = 0
Bob = 0
i = 0
while True:
  if i+1 <= N-1:
    Alice += Ai[i]
    Bob += Ai[i+1]
  if i == N-1:
    Alice += Ai[i]
  if i > N-1:
    break
  i = i + 2

print(Alice - Bob)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    //cout.tie(NULL);
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++)
            cin>>v[i];

    for(int i=n-1;i>0;i--)
    {
        if(v[i]<v[i-1])
            v[i-1]--;
    }

    for(int i=0;i<n-1;i++)
    {
        if(v[i]>v[i+1])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;


    return 0;
}


Measured memory_bytes: 640
MOD=10**9+7
s=int(input())
ans=0
factorials=[1]
temp=1
for i in range(1,s+1):
  temp=temp*i
  factorials.append(temp)
inverses=[]
for i in range(s+1):
  inverses.append(pow(factorials[i],MOD-2,MOD))
for i in range(1,s//3+1):
  extra=s-i*3
  ans=(ans+factorials[i-1+extra]*inverses[i-1]*inverses[extra])%MOD
print(ans)

Measured memory_bytes: 75376