akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int h = in.nextInt();
            int w = in.nextInt();
            String[] a = in.nextStringArray(h);

            char[][] c = new char[h + 2][w + 2];
            for (int i = 0; i <= h + 1; i++) {
                Arrays.fill(c[i], '#');
            }

            for (int i = 1; i <= h; i++) {
                for (int j = 1; j <= w; j++) {
                    c[i][j] = a[i - 1].charAt(j - 1);
                }
            }

            for (int i = 0; i <= h + 1; i++) {
                out.println(new String(c[i]));
            }
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public String[] nextStringArray(int n) {
            String[] res = new String[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextString();
            }
            return res;
        }

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

    }
}



Measured memory_bytes: 22864
#include<cstdio>
inline int in();
inline void wr(int);
const int N=(int)1e1+5;
char s[N];
int main(int argc,char**argv){
	scanf("%s",s+1);
	if(s[3]==s[4]&&s[5]==s[6])
		puts("Yes");
	else puts("No");
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int N;
	cin >> N;

	vector<int> a(N + 1);
	int X = 0;
	int Y = 0;

	for (int i = 1; i <= N; i++)
	{
		cin >> a.at(i);
		if (i == 1) {
			X += a.at(i);
		}
		else {
			Y += a.at(i);
		}
	}

	int min = abs(X - Y);

	for (int i = 2; i < N; i++)
	{
		X += a.at(i);
		Y -= a.at(i);

		int tmp = abs(X - Y);

		if (min > tmp) {
			min = tmp;
		}
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

static const int margin = 1;

int main() {
	char input[128][512];
	int vertex[128][64];
	int line;

	for(line = 0; fgets(input[line], 512, stdin) != NULL; line++);
	memset(vertex, 0, sizeof(vertex));

	for(int i = 0; i < line; i++) {
		for(int j = 0, k = 0; input[i][j] != '\n' && input[i][j] != '\0'; j++, k++) {
			int tmp = 0;

			for(;input[i][j] != ',' && input[i][j] != '\n' && input[i][j]; j++) {
				tmp *= 10;
				tmp += input[i][j] - '0';
			}

			if(i <= line / 2)
				vertex[margin + i][margin + k] = max(vertex[margin + (i - 1)][margin + (k - 1)], vertex[margin + (i - 1)][margin + k]) + tmp;
			else
				vertex[margin + i][margin + k] = max(vertex[margin + (i - 1)][margin + k], vertex[margin + (i - 1)][margin + (k + 1)]) + tmp;
		}
	}

	cout << vertex[margin + line - 1][margin] << endl;

	return 0;
}

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

int main()
{
	int n, n1, n2;
	string str, com;
	cin >> str;
	cin >> n;

	while (n--)
	{
		cin >> com;
		if (com == "replace")
		{
			string rep;
			cin >> n1 >> n2 >> rep;
			str.replace(n1, n2 - n1 + 1, rep);
		}
		else if (com == "reverse")
		{
			cin >> n1 >> n2;
			string s3;
			reverse(str.begin() + n1, str.begin() + n2+1);
		}
		else if (com == "print")
		{
			cin >> n1 >> n2;		
			cout << str.substr(n1,n2-n1+1)<<endl;
		}
	}

	return 0;

}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1LL << 60;

int main()
{
  ll x;
  REP(i, 5)
  {
    cin >> x;
    if (x == 0)
    {
      cout << i + 1 << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

 int main(){

 string a,b;
 cin>>a>>b;

  map<char,int>mp;
  map<char,int>ani;

  for(int i=0;i<a.length();i++){
    mp[a[i]]++;
  }

  for(int j=0;j<b.length();j++){
   ani[b[j]]++;
  }

  for(int j=0;j<a.length();j++)
 {
    if(mp[a[j]] == ani[b[j]] )
     continue;
    else{
        cout<<"No"<<endl;
        return 0;
    }
 }

 cout<<"Yes"<<endl;

  return 0;
 }

Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    bool t=false;
    cin>>s;
    for(int i=97;i<=122;i++){
        t=false;
        for(int j=0;j<s.size();j++){
            if(char(i)==s[j])
                t=true;
        }
        if(t==false){
                cout<<char(i);
                return 0;
            }

    }
    if(t==true)
        cout<<"None";

}



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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int K, X; cin >> K >> X;
    for(int i = max(X-K+1, -1000000); i <= min(X+K-1, 1000000); i++)
    {
        cout << i << " ";
    }
    cout << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

void SelectionSort(int a[],int array_size){
	int i;
	int j;
	int k;
	int min;
	int temp;
	int cnt=0;
	for(i=0;i<array_size-1;i++){
		min=i;
		for(j=i+1;j<array_size;j++){
			if(a[j]<a[min]){
				min=j;
			}
		}
	if(min!=i){cnt++;}	
	temp=a[i];
	a[i]=a[min];
	a[min]=temp;
	}
	for(k=0; k<array_size-1;k++){
		printf("%d ",a[k]);
	}
	for(k=array_size-1; k<array_size;k++){
		printf("%d\n",a[k]);
	}
        printf("%d\n",cnt);
}

int main(void){
	int i,n;
	int a[N];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	SelectionSort(a,n);

  return 0;
}


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

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

    int n;
    cin>>n;
    int k;
    cin>>k;
    string s;
    cin>>s;
    s[k-1]=(char)s[k-1]-'A'+'a';
    cout<<s<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  rep(i, N) cin >> B[i];

  A[0] = B[0];
  B[N - 1] = 200000;
  for (int i = 0; i < N - 1; i++) {
    A[i + 1] = min(B[i], B[i + 1]);
  }
  int ans = 0;
  rep(i, N) {
    ans += A[i];
  }
  cout << ans << endl;
}

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

int main() {
    int n, x;
    while (true) {
        cin >> n >> x;
        if (n == 0 && x == 0) {
            break;
        }

        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                int target = x - i - j;
                if (j + 1 <= target && target <= n) {
                    count++;
                    // cout << i << j << target << "\n";
                }
            }
        }
        cout << count << "\n";
    }
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ELEM(array)  (sizeof (array) / sizeof *(array))
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) a/__gcd(a,b)*b
typedef long long ll;

int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<double> q;
    rep(i,n){
        double a;
        cin>>a;
        q.push(a);
    }
    rep(i,m){
        double k=q.top();
        q.pop();
        q.push(k/2);
    }
    ll ans=0;
    while(!q.empty()){
        double a=q.top();
        
        int k=a;
        ans+=k;
        q.pop();
    }
    cout<<ans;
    return 0;

}

Measured memory_bytes: 1400
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

ll pow_(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = (x * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return x;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll dp[100003][3] = {};
int main() {
  ll N;
  vector<ll> A, B, C;
  cin >> N;
  REP(i, N) {
    ll a, b, c;
    cin >> a >> b >> c;
    A.push_back(a);
    B.push_back(b);
    C.push_back(c);
    REP(j, 3) { dp[i][j] = 0; }
  }
  REP(i, N) {
    dp[i + 1][0] = max(dp[i][1] + A[i], dp[i][2] + A[i]);
    dp[i + 1][1] = max(dp[i][0] + B[i], dp[i][2] + B[i]);
    dp[i + 1][2] = max(dp[i][0] + C[i], dp[i][1] + C[i]);
  }
  cout << max(max(dp[N][0], dp[N][1]), dp[N][2]);
  return 0;
}


Measured memory_bytes: 5216
#include<stdio.h>
#define N 9

int main(){
	int i, j;
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			printf("%dx%d=%d\n",i+1, j+1, (i+1)*(j+1));
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int N,K;
  cin>>N>>K;
  int M=N%K;
  int ans=0;
  if(M==0){
    cout<<ans<<endl;
    return 0;
  }
  int H=abs(M-K);
  if(H>=M)ans=M;
  if(H<M)ans=H;
  cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

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



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

using namespace std;

typedef pair<long long, long long> range;

bool ok = true;
#define l first
#define r second

int n, k;	
vector<int> g[100005];
range a[100005];
bool vis[100005];
int h[100005];

bool mergerange(range& a, range b) {
	if (a.l > b.r+1 || a.r < b.l-1) return false;
	if (b.l > a.r+1 || b.r < a.l-1) return false;
	if (a.l == -INT_MAX) {
		a.l = b.l-1;
		a.r = b.r+1;
		return true;
	}
	if ((a.l + b.l-1) % 2 != 0) ok = false;
	range na, nb;
	na = {max(a.l, b.l-1), min(a.r, b.r+1)};
	a = na;
	return true;
}

void dfs(int u) {
	vis[u] = 1;
	for (auto v : g[u]) {
		if (!vis[v]) {
			dfs(v);
			if (a[v].l != -INT_MAX) ok &= mergerange(a[u], a[v]);
		}
	}
}

void getres(int u) {
	vis[u] = 1;
	for (auto v : g[u]) {
		if (!vis[v]) {
			if (h[u]-1 >= a[v].l) {
				h[v] = h[u]-1;
			}
			else {
				h[v] = h[u]+1;
			}
			getres(v);
		}
	}
}

signed main() {
	scanf("%d", &n);
	int x, y;
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}	
	for (int i = 1; i <= n; i++) {
		a[i] = {-INT_MAX, INT_MAX};
	}
	memset(vis, 0, sizeof(vis));
	scanf("%d", &k);
	for (int i = 1; i <= n; i++) {
		h[i] = -100001;
	}
	for (int i = 1; i <= k; i++) {
		scanf("%d%d", &x, &y);
		a[x] = {y, y};
		h[x] = y;
	}
	dfs(1);
	if (!ok) {
		cout << "No";
		return 0;
	}
	else {
		cout << "Yes\n";
		memset(vis, 0, sizeof(vis));
		h[1] = a[1].l;
		getres(1);
		for (int i = 1; i<= n; i++) {
			cout << h[i] << "\n";
		}
	}
}

Measured memory_bytes: 13184
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

struct Card {
	int count;
	ll cost;
	bool operator<(const Card& b) {
		return cost < b.cost;
	}
};

Card B[100010];
ll A[100010];
int main()
{
	int N, M;;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < M; i++) {
		cin >> B[i].count >> B[i].cost;
		B[i].cost *= -1;
	}
	sort(B, B + M);
	for (int i = 0; i < M; i++) {
		B[i].cost *= -1;
	}
	sort(A, A + N);
	int i = 0, j = 0;
	while (true) {
		if (A[i] >= B[j].cost) break;
		else {
			for (int k = 0; k < B[j].count; k++) {
				if (A[i] >= B[j].cost) break;
				else {
					A[i] = B[j].cost;
					i++;
				}
			}
		}
		j++;
	}
	ll ans = 0;
	for (int i = 0; i < N; i++) ans += A[i];
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <stdio.h>
int main(void)
{
	int N;
	int count = 0;

	scanf("%d", &N);

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			if (4 * i + 7 * j == N)
				count++;
		}
	}
	if (count > 0)
		printf("Yes");
	else
		printf("No");

	return 0;

}

Measured memory_bytes: 128
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

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

	private void run() throws NumberFormatException, IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++) {
			nodes[i] = new Node();
		}
		for (int i = 0; i < n; i++) {
			int v = scanner.nextInt();
			int l = scanner.nextInt();
			int r = scanner.nextInt();
			nodes[v].l = l;
			nodes[v].r = r;
			if (l != -1)
				nodes[l].p = v;
			if (r != -1)
				nodes[r].p = v;
		}

		int root = 0;
		for (int i = 0; i < n; i++) {
			if (nodes[i].p == -1) {
				root = i;
			}
		}
		System.out.println("Preorder");
		preParse(root, nodes);
		System.out.println();
		System.out.println("Inorder");
		inParse(root, nodes);
		System.out.println();
		System.out.println("Postorder");
		postParse(root, nodes);
		System.out.println();
	}

	private void postParse(int u, Node[] nodes) {
		if (u == -1)
			return;
		postParse(nodes[u].l, nodes);
		postParse(nodes[u].r, nodes);
		System.out.print(" " + u);
	}

	private void inParse(int u, Node[] nodes) {
		if (u == -1)
			return;
		inParse(nodes[u].l, nodes);
		System.out.print(" " + u);
		inParse(nodes[u].r, nodes);
	}

	private void preParse(int u, Node[] nodes) {
		Deque<Integer> deque = new ArrayDeque<Integer>();
		deque.push(u);
		while (!deque.isEmpty()) {
			u = deque.poll();
			System.out.print(" " + u);
			if (nodes[u].r != -1)
				deque.push(nodes[u].r);
			if (nodes[u].l != -1)
				deque.push(nodes[u].l);
		}

	}

	class Node {
		int p = -1, l, r;
	}
}

Measured memory_bytes: 18164
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int n;
    queue<int> q;   
    while(cin >> n){
        if(n==0) break;
        map<int,ll> data;
        vector<int> memo(n);
        rep(i,n){
            int number;
            cin >> number;
            memo[i] = number;
            ll p,q;
            cin >> p >> q;
            data[number] += (p*q);
        }
        bool ok = false;
        rep(i,n){
            if(data[memo[i]] >= 1000000){ q.push(memo[i]); ok = true; data[memo[i]]=0; }
        }
        if(!ok) q.push(-1);
    }
    while(!q.empty()){
        if(q.front()<0) cout << "NA" << endl;
        else cout << q.front() << endl;
        q.pop();
    }
    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ull gcd(ull a,ull b){return b?gcd(b,a%b):a;}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    int n;
    cin >> n;
    ull t[105] = {};
    ull ans = 0;
    rep(i,0,n){
        cin >> t[i];
        ans = max(ans,t[i]);
    }

   
    ans = t[0];
    rep(i,1,n){
        ans = lcm(ans,t[i]);
    }
    P(ans);
    /*
    ull tmp = ans;
    
    while(1){
        int flag = 0;
        
        rep(i,0,n){
            if(ans % t[i] != 0){
                flag = 1;
                break;
            }
        }

        if(flag == 0){
            P(ans);
            return 0;
        }
        ans += tmp;
    }
   */ 
	return  0;
}

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

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<n; i++)


int main() {
    int A,  B, C, D;
    cin >> A >> B >> C >> D ;

    if (A*B >= C*D){
        cout << A*B << endl;
    }else{
        cout << C*D << endl;
    }

}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<long long> a(n);
    for (auto &x: a) cin >> x;
    long long ans = 0;
    auto calc = [&](auto &v) {
        map<long long, int> m;
        for (int i = 0; i < n; i++) m[a[i]-i]++;
        for (int i = 0; i < n; i++) {
            m[a[i]-i]--;
            ans += m[-(a[i]+i)];
        }
    };
    calc(a);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 27368
const WIDTH: usize = 32;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n = sc.read();
    let x: Vec<u64> = sc.vec(n);
    let l = sc.read();
    let mut go = vec![vec![0; n]; WIDTH];

    let mut tail = 0;
    for head in 0..n {
        while tail < n && (head > tail || x[tail] - x[head] <= l) {
            tail += 1;
        }
        go[0][head] = tail - 1;
    }

    for t in 1..WIDTH {
        for i in 0..n {
            go[t][i] = go[t - 1][go[t - 1][i]];
        }
    }

    let q: usize = sc.read();
    for _ in 0..q {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        let (mut a, b) = if a > b { (b, a) } else { (a, b) };
        let mut ng = 0;
        for i in (0..WIDTH).rev() {
            let cost = 1 << i;
            if go[i][a] < b {
                ng += cost;
                a = go[i][a];
            }
        }
        println!("{}", ng + 1);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main() {
    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;



void _main() {
    int N;
    cin >> N;
    FOR(i, 1, 10) FOR(j, 1, 10) {
        if (i * j == N) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 384
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mini(vec) return *std::min_element(vec.begin(), vec.end());
#define maxi(vec) return *std::max_element(vec.begin(), vec.end());

int main() {
    string a,b;
    cin>>a>>b;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),std::greater<int>());
    if(a<b){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static int N;
	public static int[] x;
	public static int[] y;
	public static double distance;

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		N = Integer.parseInt(scan.next());
		x = new int[N];
		y = new int[N];
		for (int i = 0;i < N ;i++ ) {
				x[i] = Integer.parseInt(scan.next());
				y[i] = Integer.parseInt(scan.next());
		}
		System.out.println(sumdistance());
	}

	private static double sumdistance() {
		distance = 0;
		double ans = 0;

		for (int i = 0;i < N ;i++ ) {
			for (int j = i + 1;j < N ;j++ ) {
				 double X = Math.pow(x[i] - x[j],2);
				 double Y = Math.pow(y[i] - y[j],2);
				 distance += Math.sqrt(X + Y);
			}
		}
		ans = distance*2/N;

		return ans;
	}

}


Measured memory_bytes: 35832
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e6 + 7;

int dp[N][2];

signed main()
{
	IO_OP;

	string s;
	cin >> s;
	s = '0' + s;
	int n = s.size();
	memset(dp, 0x3f, sizeof dp);
	dp[n][0] = 0;
	for(int i=n-1;i>=0;i--) {
		for(int j=0;j<2;j++) {
			if(j == 0) {
				for(int k=s[i]-'0';k<10;k++) {
					if(k == s[i]-'0') {
						dp[i][j] = min(dp[i][j], dp[i+1][0] + k);
					} else {
						dp[i][j] = min(dp[i][j], dp[i+1][0] + k + k - (s[i]-'0'));
						dp[i][j] = min(dp[i][j], dp[i+1][1] + k + k - (s[i]-'0')-1);
					}
				}
			} else {
				for(int k=s[i]-'0';k>=0;k--) {
					if(k == s[i]-'0') {
						dp[i][j] = min(dp[i][j], dp[i+1][1] + k + 9);
					} else {
						dp[i][j] = min(dp[i][j], dp[i+1][0] + k + (10 + k - (s[i]-'0')));
						dp[i][j] = min(dp[i][j], dp[i+1][1] + k + (10 + k - (s[i]-'0'))-1);
					}
				}
			}
		}
	}

	int ans = 0;
	for(char c:s) ans += c - '0';
	int cur = 0;
	for(int i=0;i<n;i++) {
		if(s[i] != '9') {
			int ccur = cur + s[i] - '0' + 1;
			ans = min(ans, ccur + dp[i+1][1]); 
			ans = min(ans, ccur + dp[i+1][0] + 1); 
		}
		cur += s[i] - '0';
	}
	cout << ans << endl;
}





Measured memory_bytes: 9160
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;

  int ans = a*b;

  if(a <= 9 && b<= 9){
    cout << ans;
    return 0;
  }
  cout << -1;
}

  

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    ll a, b;
    cin >> a >> b;
    if(a%4 == 2) {
        a = 1LL;
    } else if(a%4 == 1) {
        a--;
    } else if(a%4 == 0) {
        a = 0;
    }
    if(b%4 == 1) {
        b = 1LL;
    } else if(b%4 == 2) {
        b++;
    } else if(b%4 == 3) {
        b = 0;
    }

    cout << (a^b) << endl;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<vector<char>> a(N,vector<char>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> a.at(i).at(j);
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (j == M-1) {
        cout << a.at(i).at(j) <<endl;
      }
      else {
        cout << a.at(i).at(j);
      }
    }
    for (int j = 0; j < M; j++) {
      if (j == M-1) {
        cout << a.at(i).at(j) <<endl;
      }
      else {
        cout << a.at(i).at(j);
      }
    }
  }
  
}


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

int main(){

	int N;
	scanf("%d", &N);

	int A[N];
	for( int i=0; i<N; i++ ){
		scanf("%d", &A[i]);
	}

	int ans[N];
	for( int j=1; j<=N; j++ ){
		int k=0;
		int count=0;
		do{
			count++;
			k++;
		}while( A[k-1]!=j );

		ans[j-1] = count;
	}	

	for( int l=0; l<N; l++ ){
		printf("%d ", ans[l]);
	}

	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>

int main(){
    double a,b,c,d,e,f;
    double x,y;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
        x=(c*e-b*f)/(a*e-b*d);
        y=(c*d-a*f)/(b*d-a*e);
        if(x==0)x=0;
        if(y==0)y=0;
        printf("%.3f %.3f\n",x,y);
    }
    return 0;
}


Measured memory_bytes: 2060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<' '<<y<<endl
#define p3(x,y,z)               out<<x<<' '<<y<<' '<<z<<endl
#define p4(x,y,z,w)             out<<x<<' '<<y<<' '<<z<<' '<<w<<endl
#define pl(x)                   out<<x
#define pll(x)                  out<<x<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}

const int CMOD = 1e9 + 7;
void ssolve(std::istream& in, std::ostream& out){
    int n; s(n);
    vector<int> a(n);
    f(i, 0, n){
        s(a[i]);
    }
    int ans = 0;
    int x = 0;
    for(int i = 0; i < n; i++){
        ans += (a[i]*x)%CMOD;
        ans %= CMOD;
        x += (a[i]);
        x %= CMOD;
    }
    p(ans);
}

class CSumOfProductOfPairs {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    CSumOfProductOfPairs solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
bool cmp(char a,char b)
{
	return a>b;
}
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	sort(s1.begin(),s1.end());
	sort(s2.begin(),s2.end(),cmp);
	if(s1<s2)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h>
using namespace std;   
int main()
{
	int a,b,c,k,mx,sum=0;
	cin>>a>>b>>c>>k;
	sum=a+b+c-max(a,max(b,c));
	mx=a+b+c-sum;
	for (int i=1;i<=k;i++) mx*=2;
	cout<<sum+mx<<endl;
	return 0;
} 

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

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

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};
vector<long long> divisor(long long n)
{
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end()); // 昇順に並べる
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  vector<int> cnt(1000010);
  for (int i = 0; i < N; i++)
    cnt[A[i]]++;
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    vector<ll> div = divisor(A[i]);
    bool exist = false;
    if (cnt[A[i]] != 1)
      exist = true;
    for (auto it : div)
    {
      if (it == A[i])
        continue;
      if (cnt[it] > 0)
        exist = true;
    }
    if (!exist)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8688
#[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)*}
    };
}
 
#[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, 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")
    };
}
 
use std::cmp::Ordering;
 
use std::cmp;
use std::cmp::min;
use std::collections::BTreeMap;
use std::process;
use std::cmp::Ord;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::collections::BTreeSet;
use std::mem;
 
use std::ops::{Deref, DerefMut, Index, IndexMut};
use std::any::{Any, TypeId};

fn main(){
    input!{
        n:usize,
    }
    let MOD = 1000000007;
    let mut dp = vec![vec![vec![vec![0;5];5];5];101];
    dp[0][4][4][4] = 1;
    for i in 0..n{
        for x in 0..5{
            for y in 0..5{
                for z in 0..5{
                    for j in 0..4{
                        if y==0 && z == 1 && j == 2{continue;}
                        if y == 0 && z == 2 && j == 1 {continue;}
                        if y == 1 && z == 0 &&j==2{continue;}
                        if x == 0&& y==1 && j==2{continue;}
                        if x==0 && z==1 &&j ==2 {continue;}
                        dp[i+1][y][z][j] += dp[i][x][y][z];
                        dp[i+1][y][z][j]%=MOD;
                    }
                }
            }
        }
    }
    let mut res = 0;
    for i in 0..5{
        for j in 0..5{
            for k in 0..5{
                res += dp[n][i][j][k];
                res %=MOD;
            }
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int N,x;
    cin >> N >> x;
    vector<int>a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < N-1; i++) {
        if(a[i]+a[i+1] > x) {
            ans+=(a[i]+a[i+1])-x;
            a[i+1] = max(a[i+1]-(a[i]+a[i+1]-x),0LL);
        }
    }
    cout << ans << endl;
}

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

using ll = long long;
using P = pair<int, int>;
using edge = struct
{
  int to;
  ll cost;
};

#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

const int di[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dj[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int INF = 1001001001;

const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
  int a, b, x;
  cin >> a >> b >> x;
  if(0 <= x - a && x - a <= b) cout << "YES" << "\n";
  else cout << "NO" << "\n";
}

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


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <chrono>

#define ll long long

void change(int &a, int &b)
{
    int tmp = a;
    a = b;
    b = tmp;
}

int main()
{
    int X, Y, Z;
    std::cin >> X >> Y >> Z;

    change(X, Y);
    change(X, Z);

    std::cout << X << " " << Y << " " << Z << std::endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007;

ll a[110];
ll dp[110][110000];
ll sum[110][110000];

int main() {
  ll n, k;
  cin >> n >> k;
  for(int i = 1; i<=n; i++) cin >> a[i];
  dp[0][0] = 1;
  for(int i = 0; i<=k; i++) sum[0][i] = 1;
  for(int i = 1; i<=n; i++) {
     for(int j = 0; j<=k; j++) {
       dp[i][j] = sum[i-1][j];
       if(j-a[i]-1>=0) dp[i][j] -= sum[i-1][j-a[i]-1];
       if(j-1>=0) sum[i][j] = sum[i][j-1] + dp[i][j];
       else sum[i][j] = dp[i][j];
       dp[i][j] %= mod;
       sum[i][j] %= mod;
     }
  }
  if(dp[n][k]<0) dp[n][k] += mod;
  cout << dp[n][k] << endl;
  return 0;
}

Measured memory_bytes: 176256
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  getLine
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute as
  print ans

compute :: [Int] -> Int
compute (a:as) = ans where (ans,_,_) = foldl' step (1,EQ,a) as

-- カウント、上昇中/下降中/不明、前の値
type Acc = (Int,Ordering,Int)
step :: Acc -> Int -> Acc
step (n,o,z) a = case (o,compare z a) of
  (EQ, o') -> (n, o', a)
  (LT, GT) -> (succ n, EQ, a)
  (GT, LT) -> (succ n, EQ, a)
  _        -> (n, o, a)


Measured memory_bytes: 7256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

long long f(long long n) {
	long long ret = 0;
	if (n % 2 == 0) {
		ret = n;
		if (n / 2 % 2 == 1)
			ret ^= 1;
	} else {
		ret = (n + 1) / 2 % 2;
	}
	return ret;
}

int main() {
	long long A, B;
	cin >> A >> B;
	long long ans = f(A - 1) ^ f(B);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
n = int(input())

deck = {}
suits = ['S', 'H', 'C', 'D']
for suit in suits:
    deck[suit] = list(range(1, 14))

for _ in range(n):
    suit, rank = input().split()
    deck[suit].remove(int(rank))

for suit in suits:
    for rank in deck[suit]:
        print(suit, rank)



Measured memory_bytes: 5600
#include<cstdio>
using namespace std;
int main()
{
    int n,x[105],sum=0,p1,p2,s1=0,s2=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x[i]);
        sum+=x[i];
    }
    p1=sum/n;
    p2=p1+1;
    for(int i=1;i<=n;i++)
    {
        s1+=(p1-x[i])*(p1-x[i]);
        s2+=(p2-x[i])*(p2-x[i]);
    }
    if(s1>s2)
        printf("%d\n",s2);
    else
        printf("%d\n",s1);
    return 0;
}


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

int main() {

  int a, b;
  cin >> a >> b;
  
  int S, l;
  S = a * b;
  l = 2*a + 2*b;
  
  cout << S << ' ' << l << endl;
  
  
  return 0;
}


Measured memory_bytes: 3092
def check(n, m):
    l = n // 2
    r = l + (n % 2 == 1)

    return min(abs(l - m), abs(r - m))


N = int(input())
A = list(map(int, input().split()))

A.sort()
n = A[-1]
pd = float('inf')
for i in range(N - 1):
    a = A[i]
    d = check(n, a)
    if d < pd:
        b = a
        pd = d
print(n, b)


Measured memory_bytes: 20068
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int series_sum(long long int);

int main(){
    ll a,b1,b2,b100;
    scanf("%lld %lld.%lld",&a,&b1,&b2);
    b100=b1*100+b2;
    a=a*b100/100;
    cout<<a<<endl;
}

Measured memory_bytes: 3732