akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n, x, t;
    cin >> n >> x >> t;

    int ans;
    ans = n / x;
    ans *= t;
    if(n%x!=0) ans += t;

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


Measured memory_bytes: 3632
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    ans = len(s)
    cnt = 0

    for char in s:
        if char == "S":
            cnt += 1
        else:
            if cnt > 0:
                cnt -= 1
                ans -= 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73576
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

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

	map<string, int> vote;
	int max = 0;
	rep(i, N){
		string s;
		cin >> s;
		vote[s]++;
		if (vote[s] > max) max = vote[s];
	}
	for(auto p: vote){
		if (p.second == max) cout << p.first << endl;
	}
}

Measured memory_bytes: 25216
#include <stdio.h>

int main(){

	int H[100], W[100];
	int i, j, k,p;
	for (k = 0;; k++){
		scanf("%d %d", &H[k], &W[k]);
		if (H[k] == 0 && W[k] == 0)
			break;
	}

	for (p = 0; p < k; p++){
		for (i = 0; i < H[p]; i++){
			for (j = 0; j < W[p]; j++){
				if (i%2==0){ 
					if (j % 2 == 0){
						printf("#");
					}
					else{
						printf(".");
					}
				}
				else{
					if (j % 2 == 0){
						printf(".");
					}
					else{
						printf("#");
					}
				}
				
			}
			printf("\n");
		}
		
			printf("\n");
		
	}
}

Measured memory_bytes: 1000
using System;
using System.IO;
using System.Linq;

namespace _0560
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = int.Parse(Console.ReadLine());
			int[,,] sumsum = new int[3, x[0] + 1, x[1] + 1];
			for (int i = 0; i < x[0]; i++)
			{
				string s = Console.ReadLine();
				int[] sum = new int[3];
				for (int j = 0; j < x[1]; j++)
				{
					switch (s[j])
					{
						case ('J'): { sum[0]++; break; }
						case ('O'): { sum[1]++; break; }
						case ('I'): { sum[2]++; break; }
					}
					for (int k = 0; k < 3; k++)
					{
						sumsum[k, i + 1, j + 1] = sumsum[k, i, j + 1] + sum[k];
					}
				}
			}
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);
			for (int i = 0; i < n; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				a[0]--; a[1]--;
				for (int j = 0; j < 3; j++)
				{
					if (j != 0) Console.Write(" ");
					Console.Write(sumsum[j, a[0], a[1]] - sumsum[j, a[0], a[3]] - sumsum[j, a[2], a[1]] + sumsum[j, a[2], a[3]]);
				}
				Console.WriteLine();
			}
			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 23432
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[100];
main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  int ans=0;
  for(int i=n;i--;)ans+=(n-i)%2?a[i]:-a[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> e[n];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        --a,--b;
        e[a].push_back(b);
    }
    int d[n],prev[n],len=INF;
    vector<int> ans;
    for(int i=0;i<n;i++){
        fill(d,d+n,INF);
        d[i]=0,prev[i]=-1;
        queue<int> q;
        q.push(i);
        while(q.size()){
            int v=q.front();
            q.pop();
            for(int u:e[v]){
                if(u==i){
                    if(len>d[v]+1){
                        len=d[v]+1;
                        ans.clear();
                        int t=v;
                        while(t!=-1){
                            ans.push_back(t+1);
                            t=prev[t];
                        }
                        while(q.size())q.pop();
                        break;
                    }
                }
                else if(d[u]==INF){
                    d[u]=d[v]+1;
                    prev[u]=v;
                    q.push(u);
                }
            }
        }
    }
    if(ans.size()){
        cout<<ans.size()<<endl;
        for(int v:ans)cout<<v<<endl;
    }
    else cout<<-1<<endl;
}


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

int h, w;
vector<vector<char>> grid(100, vector<char>(100));
vector<vector<int>> z(100, vector<int>(100, 1000000));
queue<tuple<int, int, int>> q;

bool inarea(int x, int y)
{
  return 0 <= x && x < w && 0 <= y && y < h;
}

void dfs()
{
  const int dx[] = {1, 0};
  const int dy[] = {0, 1};

  while (!q.empty()) {
    auto t = q.front();
    q.pop();
    int x = get<0>(t);
    int y = get<1>(t);
    int c = get<2>(t);
    if (c > z[y][x]) continue;
    for (int i = 0; i < 2; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (inarea(nx, ny) && z[ny][nx] > z[y][x]) {
        if (grid[y][x] == '.' && grid[ny][nx] == '#') {
          z[ny][nx] = z[y][x] + 1;
        } else {
          z[ny][nx] = z[y][x];
        }
        q.emplace(nx, ny, z[ny][nx]);
      }
    }
  }
}

int main()
{
  cin >> h >> w;
  for (int y = 0; y < h; y++) {
    string s;
    cin >> s;
    for (int x = 0; x < w; x++) {
      grid[y][x] = s[x];
    }
  }
  z[0][0] = grid[0][0] == '.' ? 0 : 1;
  q.emplace(0, 0, z[0][0]);
  dfs();
  cout << z[h - 1][w - 1] << endl;
}


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

long long int N;

struct StrangeBank{
    int val[101010];
    int c[12] = {1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049};

    constexpr StrangeBank() : val(){
        val[0] = 0;
        for(int i = 1; i < 101010; ++i){
            val[i] = 9999999;
            for(auto j : c){
                if(i >= j)val[i] = min(val[i],val[i - j] + 1);
            }
        }
    }
};

constexpr StrangeBank sb = StrangeBank();

int main(){
    scanf("%lld", &N);
    cout << sb.val[N] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

int main()
{
    fast;
    double r;
    cin>>r;
    cout<<2*M_PI*r<<endl;
    return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[6],k,f=1;
	for(int i=1;i<=5;i++)
		cin>>a[i];
	cin>>k;
	sort(a+1,a+6);
	for(int i=1;i<5;i++)
		for(int j=i+1;j<=5;j++)
			if(a[j]-a[i]>k){
				f=0; break;
			}
	if(f) cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() { 
    int n, min = 0, ans = 0;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    for(int i = 0; i < n; ++i) {
        if(h[i] >= min) {
            min = h[i];
            ans++;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		double x = 0;
		
		x = 3.14159265358979323*R;
		
		System.out.println(x*2);
		sc.close();
	}
}

Measured memory_bytes: 35904
#include<stdio.h>
int main(){
int a=2000,b=2000,c,i;
for(i=0;i<3;i++){
scanf("%d\n",&c);
if(a>c){
a=c;
}
}
for(i=0;i<2;i++){
scanf("%d\n",&c);
if(b>c){
b=c;
}
}
printf("%d\n",a+b-50);
return 0;
}



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

int x, y, ans;
int main() {
	cin >> x >> y;
	ans = max(0, 4-x) + max(0, 4-y);
	if(x+y==2) ans += 4;
	cout << ans*100000;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
ll A[50];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> A[i];

	int amin=A[0], amax=A[0];
	int imin=0, imax=0;
	for(int i=0; i<N; i++){
		if(A[i]<amin){
			amin=A[i];
			imin=i;
		}
		if(A[i]>amax){
			amax=A[i];
			imax=i;
		}
	}

	vector<pair<int, int>> ans;
	if(abs(amin) < abs(amax)){
		ans.push_back({imax, 1});
		ans.push_back({imax, 1});
		for(int i=2; i<N; i++){
			ans.push_back({i-1, i});
			ans.push_back({i-1, i});
		}
	} else {
		ans.push_back({imin, N-2});
		ans.push_back({imin, N-2});
		for(int i=N-3; i>=0; i--){
			ans.push_back({i+1, i});
			ans.push_back({i+1, i});
		}
	}

	cout << ans.size() << endl;
	for(int i=0; i<ans.size(); i++){
		cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;


char buf[100000+10];
int n;

bool isOK(void) {
  if(buf[n-1] == '1') return false; // 0とnには分けられない
  if(buf[0] == '0' || buf[n-2] == '0') return false; // 葉はある
  REP(i, n-1) {
    if(buf[i] == '1' && buf[n-2-i] == '0') {
      return false;
    }
  }
  return true;
}

int main(void) {
  scanf("%s", buf);
  n = strlen(buf);
  if(!isOK()) {
    puts("-1");
    return 0;
  }
  printf("1 2\n");
  int u = 2; // 今いるところ
  int v = 3; // 次に繋ぐ頂点
  for(int i = 1; i+1 <= n/2; ++i) {
    if(buf[i] == '0') {
      printf("%d %d\n", u, v);
      ++v;
    } else {
      printf("%d %d\n", u, v);
      u = v;
      ++v;
    }
  }
  for(; v <= n; ++v) {
    printf("%d %d\n", u, v);
  }
  
  return 0;
}


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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 96181;

const int N = 2e5 + 20;
int f[N], n, a[N], ans;

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		f[a[i]] = f[a[i] - 1] + 1;
		ans = max(ans, f[a[i]]);
	}
	cout << n - ans << endl;
}



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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

using namespace std;
using ll = long long;

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

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N)
    {
        cin >> A[i];
    }

    REP(j, N)
    {
        cout << (j ? " " : "") << A[j];
    }
    cout << "\n";

    FOR(i, 1, N)
    {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 and A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        REP(j, N)
        {
            cout << (j ? " " : "") << A[j];
        }
        cout << "\n";
    }

    return 0;
}


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

public class Main {
	FastScanner in;
	PrintWriter out;

	long pw(long x, int y) {
		long res = 1;
		for (int i = 0; i < y; i++) {
			if (res * 1.0 * x > 1e16) {
				return (long) 1e16;
			}
			res *= x;
		}
		return res;
	}

	void solve() {
		long n = in.nextLong();
		long a = in.nextLong();
		long res = Long.MAX_VALUE;
		for (int add = 0; add < 100; add++) {
			long cur = add * 1L * a;
			int cnt = add + 1;
			long from = (long) Math.pow(n, 1. / cnt) - 3;
			from = Math.max(from, 1);
			while (pw(from + 1, cnt) <= n) {
				from++;
			}
			long now = pw(from, cnt);
			cur += cnt * from;
			while (now < n) {
				cur++;
				now /= from;
				now *= from + 1;
			}
			res = Math.min(res, cur);
		}
		out.println(res);
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

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

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

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

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().runIO();
			}
		}, "1", 1 << 26).start();
	}
}

Measured memory_bytes: 8532
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <fstream>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <stack>
#include <map>
#include <set>
#if __cplusplus > 199711L
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//	tree<key, mapped = null_type, cmp = less<key>, rb_tree_tag, tree_order_statistics_node_update> name;
//	order_of_key
//	find_by_order
#endif

using namespace std;

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fs first
#define sc second
#define abs(a) ((a) < 0 ? -(a) : (a))
#define sqr(a) ((a) * (a))

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

inline pair<pair<bool, bool>, pair<string, bool> > useinout();

void init() {
#ifdef SOL
	if (useinout().fs.fs)
		freopen("input.txt", "r", stdin);
	if (useinout().fs.sc)
		freopen("output.txt", "w", stdout);
#else
	srand(time(0));
	const string file = useinout().sc.fs;
	if (!file.empty()) {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
	if(useinout().sc.sc) {
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
}

int solve();

void finish(int exitval) {
	fflush(stdout);
#ifdef SOL
	fprintf(stderr, "\nexit value: %d\ntime: %.3lf ms\n", exitval, 1000. * clock() / CLOCKS_PER_SEC);
#endif
}

int main() {
	init();
	int exitval = solve();
	finish(exitval);
	return (0);
}

const double eps = 1e-9;
const int mod = (int) 1e+9 + 7;
const double pi = acos(-1.);
const int maxn = 100100;

inline pair<pair<bool, bool>, pair<string, bool> > useinout() {
	return (mp(mp(0, 0), mp("", 0)));
}

int solve() {

	int n, a, b;
	scanf("%d%d%d\n", &n, &a, &b);
	string s;
	getline(cin, s);
	int c = 0, bb = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'a') {
			if (c < a + b) {
				c++;
				printf("Yes\n");
			} else {
				printf("No\n");
			}
		} else if (s[i] == 'b') {
			if (c < a + b && bb < b) {
				c++;
				bb++;
				printf("Yes\n");
			} else {
				printf("No\n");
			}
		} else if (s[i] == 'c') {
			printf("No\n");
		}
	}

	return (0);
}

// by Andrey Kim


Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
	int a[5];
	int leng;
	int i = 0;
	
	for (i = 0;i < 5; i++){
		scanf("%d", &a[i]);
	}
	scanf("%d", &leng);
	
	if ((a[4] - a[0]) <= leng){
		printf("Yay!\n");
	}
	else{
		printf(":(\n");
	}
	return (0);
	
}

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

typedef long long ll;
const ll MOD = 998244353;
const int MAXN = 1e5 + 10;

int N;
int C[MAXN];

ll my_pow(ll a, ll b){
    ll ret = 1;
    while(b){
        if(b & 1) ret *= a, ret %= MOD;
        a = a * a % MOD;    b /= 2;
    }
    return ret;
}

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

    ll ans = 1;
    cin >> N;
    int m = 0;
    for(int i = 1 ; i <= N ; i++){
        int a;
        cin >> a;
        C[a]++;
        m = max(m, a);
        if(i == 1){
            if(a == 0) continue;
            else return cout << 0, 0;
        }
        else{
            if(a == 0) return cout << 0, 0;
            else continue;
        }
    }

    for(int i = 1 ; i <=m ; i++){
        ans = ans * my_pow(C[i - 1], C[i]) % MOD;
    }

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

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<tuple>
#include<utility>
#include<cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define enter "\n"

typedef long long ll;


int abc104_c(){
    //入力
    int n;
    cin >> n;
    ll ans = n*(-1);
    REP(i,n){
        int a;
        cin >> a;
        ans +=a;
    }
    
    //処理
    
    //出力
    cout << ans <<enter;
    return 0;
}

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



Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

int t,n;
bool field[200][200];
int check[200][200];
int sx,sy;
typedef struct point{int x;int y;int d;} p;

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

int main(){
	vector<int> ans;
	while(true){
		cin >> t >> n;
		if(t == 0 && n == 0) break;
		
		memset(field,1,sizeof(field));
		
		for(int i = 0;i < 200;i++){
			for(int j = 0;j < 200;j++){
				check[i][j] = 1e9;
			}
		}
		
		for(int i = 0;i < n;i++){
			int x,y;
			cin >> x >> y;
			field[y + 100][x + 100] = false;
		}
		
		cin >> sx >> sy;
		
		queue <p> q;
		p start = {sx+100,sy+100,0};
		check[start.y][start.x] = 0;
		q.push(start);
		
		while(q.size()){
			p now = q.front(); q.pop();
			//cout << now.x << " " << now.y << " " << now.d << endl;
			for(int i = 0;i < 6;i++){
				int nx = now.x + dx[i];
				int ny = now.y + dy[i];
				int nd = now.d + 1;
				if(nd <= t && check[ny][nx] > nd&& field[ny][nx]){
					p next = {nx,ny,nd};
					q.push(next);
					check[ny][nx] = nd;
				}
			}
		}
		
		int tans = 0;
		for(int i = 0;i < 200;i++){
			for(int j = 0;j < 200;j++){
				if(check[i][j] <= t){
					tans++;
				}
			}
		}
		ans.push_back(tans);
	}
	
	for(int i = 0;i < ans.size();i++){
		cout << ans[i] << endl;
	}
	return 0;
}


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

int main(void) {
    int N;cin>>N;
    map<int, int> mp;
    int result = 0;
    for (int i = 1; i <= N; i++) {
        int a;cin>>a;
        if (mp.find(a) != mp.end()) {
            if (mp[a] == i) result++;
        }
        mp[i] = a;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int n,m,q;
int a[60],b[60],c[60],d[60];
int A[60],ans;

void dfs(int depth,int pre) {
	if(depth==n) {
		int s=0; 
		for(int i=0;i<q;i++) {
			if(A[b[i]-1]-A[a[i]-1]==c[i]) {
				s+=d[i];
			}
		}
		ans=max(s,ans);
		return;
	}
	for(int i=pre;i<=m;i++) {
		A[depth]=i;
		dfs(depth+1,i);
	}
}

int main() {
	cin>>n>>m>>q;
	for(int i=0;i<q;i++) {
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	}
	dfs(0,1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;
 
signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  double a[n + 5], sum = 0;
  rep(i, n){
    cin >> a[i];
    sum += a[i];
  }
  sum /=  (double)(4*m);
  int ans = 0;
  rep(i, n){
    if(a[i] >= sum){
      ans ++;
    }
  }
  if(ans >= m){
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  
  return 0;
}


Measured memory_bytes: 256
$<.readlines.map(&:to_f).each do |x|
  sum = 0
  solve = ->(n, i = 1) {
    sum += n
    return sum if i == 10
    (i + 1).even? ? solve.(n * 2.0, i + 1) : solve.(n / 3.0, i + 1)
  }
  puts solve.(x)
end


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

int modpower(int x,int n,int m){
    long long result=x;
    long long ans=1;
    int ans_int;

    while (n!=0){
        if(n%2==0){

            result = ((result%m)*(result%m))%m;
            n >>= 1;

        }else{
            ans = ((ans%m) * (result%m))%m;
            --n;

        }
    }
    ans_int=ans%m;
    return ans_int;
}

int modmul(int p,int q,int m){
    long long ans,pp=p,qq=q;
    int ans_int;
    ans=((pp%m)*(qq%m))%m;
    ans_int=ans%m;
    return ans_int;
}

int moddiv(int p,int q,int m){
    return modmul(p,modpower(q,m-2,m),m);
}


int main(){
    int p,q;

    int mod=1e9+7;
    int ans=0,add;
    int n,k;
    cin >> n >> k;

    int kaijyou[n+1];


    kaijyou[0]=1;kaijyou[1]=1;
    for (int i = 2; i <= n; i++){
        kaijyou[i]=modmul(kaijyou[i-1],i,mod);
    }

    for (int i = 1; i <= k; i++){

        p = moddiv( kaijyou[k-1] , modmul( kaijyou[k-i] , kaijyou[i-1] ,mod) ,mod);

        if(n-k+1< i){
            q=0;
        }else{
            q=moddiv( kaijyou[n-k+1] , modmul( kaijyou[n-k-i+1] , kaijyou[i] ,mod) ,mod);;
        }

        add = modmul(p,q,mod);

        cout << add << endl;
    }
    



    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,ll>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n;
    ll k; 
    cin >> n >> k;
    map<int,ll> mp;
    rep(i,n) {
        int a, b; cin >> a >> b;
        mp[a] += b;
    }
    ll sum = 0;
    for (P p : mp) {
        sum += p.second;
        if (k <= sum) {
            cout << p.first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> //Algorithm
#include <vector>
#include <map>
//#define ll long long

using namespace std;

const int maxn=1000+10;

vector <int>da[200];
int d1[100],d2[100];
int vis[100];
int a,b;
int dfs(int s,int d)
{
	if(s==d)
	{
		
		return 1;
	}
	
	vis[s]=1;
	int mm=da[s].size();
	for(int i=0;i<mm;i++)
	{
		int v=da[s][i];
		if(s==a&&v==b||s==b&&v==a)
			continue;
		if(!vis[v])
		{
			if(dfs(v,d)==1)
			{
				return 1;
			}
		}
	}
	return 0;
}


int main()
{
	int n,m;
	int ans=0;
	int f;
	scanf("%d%d",&n,&m);
	for(int i=0; i<m; i++)
	{
		scanf("%d%d",&a,&b);
		d1[i]=a;
		d2[i]=b;
		da[b].push_back(a);
		da[a].push_back(b);
	}
	for(int i=0; i<m; i++)
	{
		a=d1[i];
		b=d2[i];
		f=0;
		
		for(int s=1; s<=n; s++)
		{
			for(int d=1; d<=n; d++)
			{
				memset(vis,0,sizeof(vis));
				if(dfs(s,d)==0)
				{
					ans++;
					f=1;
					break;
				}
			}
			if(f)
				break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

namespace atcorder_BeginnerContest_124
{
    class Program
    {

        static void Main(string[] args)
        {

            var s = Console.ReadLine().ToArray();
            int len = s.Length;

            char start0 = '0';
            char start1 = '1';
            int cnt0 = 0;
            int cnt1 = 0;

            for (int i = 0; i < len; i++)
            {

                if (start0 != s[i]) cnt0++;
                if (start1 != s[i]) cnt1++;

                if ('0' == start0) start0 = '1';
                else start0 = '0';

                if ('0' == start1) start1 = '1';
                else start1 = '0';

            }

            int ret = 0;
            if (cnt0 < cnt1)
            {
                ret = cnt0;
            }
            else
            {
                ret = cnt1;            
            }

            Console.WriteLine(ret);

        }

    }
}



Measured memory_bytes: 12128
n, m = map(int, input().split())
edges = [list(map(int, input().split())) for i in range(m)]
ans = 0
for x in edges:
    l = list(range(n))
    for y in edges:
        if y != x:
            l = [l[y[0]-1] if l[i] == l[y[1]-1] else l[i] for i in range(n)]
    if len(set(l)) != 1:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    vc<string> H = {"KIH", "B", "R"};
    string S;
    cin >> S;
    
    bool isok = false;
    rep(bit, 1<<4){
        string tmp;
        rep(i, 3){
            if (bit & 1 << i) tmp += "A";
            tmp += H[i];
        }
        if (bit & 1 << 3) tmp += "A";

        if (tmp == S) isok = true;
    }

    cout << (isok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <memory.h>
int main(void)
{
  int ipt,a[21][6],b[6],m[6],l,i,j,t,k,f,s,cnt;
  while(scanf("%d %d",&ipt,&l),ipt+l){
    cnt=0;
    memset(a,0,sizeof(int)*6*21);
    memset(b,0,sizeof(int)*6);
    memset(m,0,sizeof(int)*6);
    for(i=0;ipt!=0;i++){
      a[0][i]=ipt%10;
      cnt++;
      ipt/=10;
    }
    if(cnt<l){
      for(i=cnt;i<l;i++){
	a[0][i]=0;
      }
    }
    for(i=0;i<20;i++){
      for(j=0;j<l;j++){
	b[j]=a[i][j];
	m[j]=b[j];
      }
      for(j=0;j<l-1;j++){
	for(k=l-1;k>j;k--){
	  if(b[k-1]>b[k]){
	    t=b[k-1];
	    b[k-1]=b[k];
	    b[k]=t;
	  }
	  if(m[k-1]<m[k]){
	    t=m[k-1];
	    m[k-1]=m[k];
	    m[k]=t;
	  }
	}
      }
      for(j=0;j<l;j++){
	t=b[j]-m[j];
	a[i+1][j]+=t;
	if(a[i+1][j]<0){
	  a[i+1][j]+=10;
	  a[i+1][j+1]=-1;
	}
      }
    }
    for(i=1;i<21;i++){
      for(j=0;j<i;j++){
	f=0;
	for(k=0;k<l;k++){
	  if(a[i][k]==a[j][k])
	    f++;
	}
	if(f==l)
	  goto END;
      }
    }END:
    printf("%d ",j);
    s=0;
    for(k=l-1;k>0;k--){
      if(a[i][k]&&k>0){
	s=k;
	break;
      }
    }
    for(k=s;k>=0;k--)
      printf("%d",a[i][k]);
    printf(" %d\n",i-j);
  }
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

vector<ll>seg;
ll N;

void update( int pos, ll val )
{
    pos += N;
    seg[pos] = val;
    for(; pos>1 ; pos>>=1 )
        seg[pos/2] = max( seg[pos], seg[pos^1] );
}

ll query( int l, int r )
{
    l += N;
    r += N+1;
    ll ans = 0;
    for(; l<r; l>>=1, r>>=1 )
    {
        if(l&1)
            ans = max( ans, seg[l++]);
        if(r&1)
            ans = max( ans, seg[--r]);
    }
    return ans;
}

int main() 
{
    #ifdef gupta_samarth
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fastio();

    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];

    N = 300100;
    seg.clear();
    seg.resize(2*N);

    for( ll x : a )
    {
        ll get = query( max(0ll,x-k), min(x+k,N-1) );
        update( x, get+1 );
    }
    cout<<query(0,N-1),nl;


    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

using namespace std;
typedef long long ll;
const int N=2e3+10;
const ll mod=1e9+7;

int n, k;
ll dp[N][N];

int main() {
	cin>>n>>k;
	dp[0][0]=1;
	for(int i=1; i<=2000; i++) {
		for(int j=1; j<=2000; j++) {
			dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
			dp[i][j]%=mod;
		}
	}
	for(int i=1; i<=k; i++) {
		ll ans=dp[k][i]*(dp[n-k][i]+dp[n-k][i]+dp[n-k][i+1]+dp[n-k][i-1]);
		cout<<ans%mod<<endl;
	}
	return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define MOD 1000000009
using namespace std;
typedef long long ll;
int main()
{
  int a,b;
  cin >> a >> b;
  if (a > b*2){
    cout << a - b*2 << endl;
  }
  else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	k := iScan()
	h := iSScan(n)
	ans := 0
	for _, v := range h {
		if v >= k {
			ans++
		}
	}
	fmt.Println(ans)
}


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

const int INF = 1e+9 * 2;
double eps = 1e-10;

int main() {
	int a[4], b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		bool cnt[16] = {0};
		int hit = 0, blow = 0;
		for(int i = 0; i < 4; ++i)
			cnt[a[i]] = true;
		for(int i = 0; i < 4; ++i){
			if(cnt[b[i]]){
				if(a[i] == b[i])
					hit++;
				else
					blow++;
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << std::fixed << std::setprecision(10);

	int n;
	cin >> n;

	cout << (double)((int)(n / 2) + (n % 2)) / n << endl;

	return 0;
}

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

using namespace std;
const int MOD = 998244353;
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  map<int, int> m;
  int L = -1;
  for (auto &x : D) {
    cin >> x;
    ++m[x];
    L = max(L, x);
  }
  if (D[0] != 0 || m[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 1;
  int x = 1;
  for (int x = 1; x < L; ++x) {
    int s = m[x];
    int t = m[x + 1];
    for (int i = 0; i < t; ++i) {
      ans = (ans * s) % MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define int long long
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
int n,a,b;
signed main(){
	cin>>n>>a>>b;
	if(a>b)	swap(a,b);
	int ans=1ll<<62;
	if((b-a)%2==0)	ans=min(ans,(b-a)/2);
	ans=min(ans,max(a-1,b-1));
	ans=min(ans,max(n-a,n-b));
	if((a-1+b-1)%2==0)	ans=min(ans,(a-1+b-1)/2);
	else				ans=min(ans,(a-1+b)/2);
	if((n-a+n-b)%2==0)	ans=min(ans,(n-a+n-b)/2);
	else				ans=min(ans,(n-a+n-b+1)/2);
	print(ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<climits>
#include<algorithm>

using namespace std;

int n;
int w[101];

int main(void){
    scanf("%d", &n);

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

    int m = INT_MAX;
    int s1, s2;

    for(int t = 1; t < n; t++){
        s1 = 0;
        for(int i = 1; i <= t; i++){
            s1 += w[i];
        }
        
        s2 = 0;
        for(int i = t + 1; i <= n; i++){
            s2 += w[i];
        }

        m = min(m, abs(s1 - s2));
    }

    printf("%d\n", m);

    return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0||c>0){
        c=c-b;
        if(c<=0){
            break;
        }
        a=a-d;
        if(a<=0){
            break;
        }
    }
    if(a<=0){
        cout<<"No";
    }else cout<<"Yes";
    }


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

int main() {
    using namespace std;

    unsigned long N;
    cin >> N;

    vector<unsigned long> A(N), B(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    priority_queue<pair<unsigned long, unsigned long>> pq;
    for(unsigned long i = 0; i < N; ++i){
        cin >> B[i];
        if(B[i] != A[i])pq.emplace(B[i], i);
    }

    unsigned long ans{0};
    while(!pq.empty()){
        auto t = pq.top().second;
        pq.pop();
        auto bf = (t + N - 1) % N, nx = (t + 1) % N;
        if(B[t] < B[bf] + B[nx] + A[t])return 0 & puts("-1");
        auto tmp = (B[t] - A[t]) / (B[bf] + B[nx]);
        ans += tmp;
        if((B[t] -= tmp * (B[bf] + B[nx])) > A[t])pq.emplace(B[t], t);
    }

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

Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
// #pragma GCC optimize ("-O3")
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long double PI = 3.14159265358979323846;  /* pi */

int main() {
    int n;
    cin >> n;
    int fans = 0;
    for (int i = 1; i<= n; i++)
    {
        int a;
        cin >> a;
        if (a & i & 1)
            fans ++;
    }
    cout << fans;
    return 0;
}

Measured memory_bytes: 3644
#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];
    sort(a.begin(), a.end());

    bool flag = true;
    for(int i = 0; i < n - 1; i++) {
        if(a[i] == a[i + 1]) {
            flag = false;
            break;
        }
    }

    if(flag) cout << "YES" << endl;
    else     cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 1024
import sys

N,M,X,Y = map(int, input().split())

*x, = map(int, input().split())
*y, = map(int, input().split())

def check_x(x, Z):

    for element in x:
        if element >= Z:
            return False
    
    return True

def check_y(y, Z):

    for element in y:
        if element < Z:
            return False
    
    return True


for Z in range(X+1, Y+1, 1):
    if check_x(x, Z)==True and check_y(y, Z)==True:
        print("No War")
        sys.exit()


print("War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {int a,b,c,s,t,u;
            cin>>a>>b>>c;
            s=max({a,b,c});
            t=min({a,b,c});
            u=a+b+c-s-t;
            cout<<s*10+u+t<<endl;
}

Measured memory_bytes: 256
using System;

namespace ColorfulHats
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String input = Console.ReadLine();
            String[] splitted = input.Split(' ');
            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(splitted[i]);
            }

            long result = 1;
            int[] number = new int[] { 0, 0, 0 };
            for (int i = 0; i < N; i++)
            {
                int count = 0;
                for(int j = 0; j < 3; j++)
                {
                    if (number[j] == A[i])
                    {
                        count++;
                    }
                }
                result = ((result % 1000000007) * count)% 1000000007;
                for(int j = 0; j < 3; j++)
                {
                    if (number[j] == A[i])
                    {
                        number[j]++;
                        break;
                    }
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 16864
n = int(input())
h = list(map(int,input().split()))

cost = [0]*n
cost[0] = 0
cost[1] = abs(h[1] - h[0])
for i in range(2,n):
    cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]))
print(cost[-1])

Measured memory_bytes: 20484
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

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

using namespace std;

int main(int argc, char* argv[]){
  long long int N;
  cin >> N;
  long long int A[200001] = {0};
  rep(i, N - 1){
    cin >> A[i];
  }

  long long int ans[200001] = {0};
  rep(i, N) {
    ans[A[i]]++;
  }
  for(int i = 1; i <= N; i++){
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 6760
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())
s = [input() for _ in range(n)]

m = int(input())
t = [input() for _ in range(m)]

ss = list(set(s))
ans = [0] * len(ss)

for i in range(len(ss)):
    for j in range(n):
        if ss[i] == s[j]:
            ans[i] += 1
    for j in range(m):
        if ss[i] == t[j]:
            ans[i] -= 1

print(max(max(ans), 0))








Measured memory_bytes: 9152
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    a,b=map(int,readline().split())

    for n in range(b*10,b*10+10):
        if n*8//100==a:
            print(n)
            break
    else:
        print(-1)

if __name__=="__main__":
    main()

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String word = sc.next();
        String result = "";
        if (word.equals("a") | word.equals("i") |word.equals("u") |word.equals("e") |word.equals("o")) {
            result = "vowel";
        } else {
            result = "consonant";
        }
        System.out.println(result);
    }
}

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

int main()
{
  int N,K,i,x,ans=0;
  cin >> N >> K;
  for (i=1;i<=N;i++) {
    cin >> x;
    if(x<=K-x) ans+=2*x;
    else ans += 2*(K-x);
  } 
  cout << ans << endl;
  return 0;
}

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

public class Program
{
    public void Proc()
    {
        int[] inpt = ScanInt();

        int kenCount = inpt[0];
        int cityCount = inpt[1];

        StringBuilder ans = new StringBuilder();


        SortedDictionary<int, SortedDictionary<long, int>> dic = new SortedDictionary<int, SortedDictionary<long, int>>();
        for (int i = 0; i < cityCount; i++) {
            long[] tmp = ScanLong();
            int ken = (int)tmp[0];
            long year = tmp[1];
            if(!dic.ContainsKey(ken)) {
                dic.Add(ken, new SortedDictionary<long, int>());
            }
            dic[ken].Add(year, i);
        }

        string[] list = new string[cityCount];
        foreach(int ken in dic.Keys) {
            int serial = 1;
            string kenID = ken.ToString().PadLeft(6, '0');
            foreach(int year in dic[ken].Keys) {
                int key = dic[ken][year];
                string id = kenID + serial.ToString().PadLeft(6, '0');
                list[key] = id;
                serial++;
            }
        }
        foreach(string id in list) {
            ans.AppendLine(id);
        }
        Console.Write(ans.ToString());
    }


    private int[] ScanInt() {
        return Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }

    private long[] ScanLong() {
        return Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
    }

    private string[] ScanStr() {
        return Reader.ReadLine().Split(' ').ToArray();
    }

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


2 3
2 55
2 77
2 99


";
    }

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


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

using namespace std;


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

    double W, H;
    double x, y;
    cin >> W >> H >> x >> y;

    double min_W = min(W - x, x);
    double min_H = min(H - y, y);

    // printf("%.9lf", min_W * H);
    // if (min_W * H > min_H * W) {
    //     printf("%.9lf", min_W * H);
    // } else {
    // }
    printf("%lf", H * W / 2);
    // double min_D = min(H, W);
    // double area = min_D * min_D / 2;
    // printf("%.9lf", area);

     if (min_W / W == 0.5 && min_H / H == 0.5) {
        printf(" 1\n");
    } else {
        printf(" 0\n");
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
mem = [2] * (N+1)
mem[1] = 1
for m in range(2,N//2+1):
    for n in range(m+m,N+1,m):
        mem[n] += 1

ans = 0
for n in range(1,N+1):
    ans += n*mem[n]
print(ans)

Measured memory_bytes: 146116
import java.util.Scanner;

public class Main {

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

	    int w=gi();
	    int h=gi();
	    int n=gi();
	    int xo=0;
	    int yo=0;
	    
	    for (int i=0; i<n;i++) {
	    	int x=gi();
	    	int y=gi();
	    	int a=gi();
	    	if (a==1) {
	    		xo=Math.max(xo,x);
	    	} else if (a==2) {
	    		w=Math.min(w, x);
	    	} else if (a==3) {
	    		yo=Math.max(yo, y);
	    	} else if (a==4) {
	    		h=Math.min(h,y);
	    	}
	    }

        //System.out.println(n.length()-n.replaceAll("1", "").length());
        if (xo>w || yo>h) {
        	System.out.print(0);
        }else {
        	System.out.print((h-yo)*(w-xo));
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 36124
import itertools

while True:
    n = int(input())
    if n == 0:
        break
    else:
        a = [int(input()) for i in range(n)]
        a = list(itertools.accumulate(a))
        a.insert(0, 0)
        ans = -100000
        for j in range(n):
            for k in range(j + 1, n + 1):
                ans = max(ans, a[k] - a[j])
        print(ans)

Measured memory_bytes: 7932
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int vec_x =  x2 - x1;
    int vec_y =  y2 - y1;
    for(int i = 0; i < 2; i++) {
        swap(vec_x, vec_y);
        vec_x *= -1;
        x2 += vec_x;
        y2 += vec_y;
        cout << x2 << " " << y2 <<" ";
    }
    return 0;
}


Measured memory_bytes: 256