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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    cout<<a*b<<" "<<a*2+b*2<<endl;
    return 0;
}



Measured memory_bytes: 3160
package main

import (
	"fmt"
)

func main() {
	var a int

	fmt.Scanln(&a)
	fmt.Println(logic(a))
}

func logic(a int) string {
	for i := 1; i <= 9; i++ {
		if a/i < 10 && a%i == 0 {
			return "Yes"
		}
	}

	return "No"
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
int main()
{
	std::ios::sync_with_stdio(0);
	int count=1;
	int n;
	std::cin>>n;
	std::vector<int>a(n);
	std::vector<int>b(n);
	std::map<int,int>map1; 
	for(int i=0;i<n;i++)
	{
		std::cin>>a[i];
	}
	//sort(count,count+100000,std::greater<int>());
	int sum=0;
	sort(a.begin(),a.end());
	for(int i=0;i<a.size();i++)
	{
		if(i)
		{
			if(a[i-1]==a[i])
			{
					count++;
					//std::cout<<"  "<<count<<std::endl;
			}
			else
			{
					if(count<a[i-1])
					{
						sum+=count;
					}
					else if(count>a[i-1])
					{
						sum+=count-a[i-1];
					}
					count=1;
			}
			
		}
	
		//	std::cout<<sum<<' '<<count<<std::endl;
	}
					if(count<a[n-1])
					{
						std::cout<<sum+count;
					}
					else if(count>a[n-1])
					{
						std::cout<<sum+count-a[n-1];
					}
					else std::cout<<sum;
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	int a[n];
	map<int, int> m;

	for( int i = 0; i < n; ++i ){
		cin >> a[i];
		m[a[i]]++;
	}

	int tot = 0;

	for( auto it : m ){
		if( it.second >= it.first )
			tot += it.second-it.first;
		else
			tot += it.second;
	}
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 5120
#Python

l = map(int, raw_input().split())

N=l[0]
K=l[1]
#print N
#print K

a = map(int, raw_input().split())
#print a


a.sort()
a.reverse()

#print a

sum=0
for i in range(K):
	sum+=a[i]

print sum

Measured memory_bytes: 2568
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b = map(int, input().split())

count = 0
for i in range(2):
    if a >= b:
        count+=a
        a -= 1
    else:
        count += b
        b -= 1
print(count)


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

/**
 * Created by Ayushi on 22 Aug 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        st = new StringTokenizer(br.readLine(), " ");
        br.close();
        int p = 0;
        int a;
        long ans = 0;
        while (st.hasMoreTokens()) {
            a = Integer.parseInt(st.nextToken());
            if (a < p) {
                ans += p-a;
            }
            else p = a;
        }
        System.out.println(ans);
    }
}


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

int main(){
  ll n,i;
  cin >> n;
  vector<ll> a(n),r(n);
  r.at(0)=0;
  for(i=0;i<n;i++){
    cin >> a.at(i);
    if(i%2==0){
      r.at(0) += a.at(i);
    }else{
      r.at(0) -= a.at(i);
    }
  }
  
  cout << r.at(0);
  
  for(i=1;i<n;i++){
    r.at(i)=2*a.at(i-1)-r.at(i-1);
    cout << ' ' << r.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 4848
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 1) {
			System.out.println("Hello World");
		} else {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a+b);
		}
	}
}


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

int main() {
  string S; cin >> S;
  for (int i = 0; i < S.size(); i++) {
    for (int j = i; j < S.size(); j++) {
      string str = S.substr(0, i) + S.substr(j);
      if (str == "keyence") {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
//  Suraj Saste
 
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pi pair<double,ll>
#define in insert
#define fe first
#define se second
#define ms(x,i) memset(x,i,sizeof(x))
#define prec(x) cout<<std::setprecision(x)
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll fpow(ll n, ll k, ll p=mod) {ll r=1; n=n%p; while(k>0){ if(k&1){ r=(r*n)%p; } k=k>>1; n=(n*n)%p; } return r;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 || n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0||n%(i+2)==0)return false;}return true;}
 
int main()
{
	fast;
	ll n,w;cin>>n>>w;
	ll v[n],wt[n];
	for(ll i=0;i<n;i++)cin>>wt[i]>>v[i];
	ll sum=0;
    for(auto x:v)sum+=x;
	vector<ll> dp(sum+1,1e18);
    ll ans=0;
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
    	for(ll j=sum-v[i];j>=0;j--)
    	{
    		dp[j+v[i]]=min(dp[j+v[i]],dp[j]+wt[i]);
    	}
    }
    for(ll i=0;i<=sum;i++)
    {
    	// cout<<dp[i]<<" ";
    	if(dp[i]<=w)ans=max(ans,i);
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3972
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_N 100
#define MAX_M (MAX_N * MAX_N)

typedef struct EDGE {
	int to;
	struct EDGE *next;
} edge;

int size;
edge buff[MAX_M];
edge *adj[MAX_N];

void add_edge(int u, int v) {
	edge *e = buff + size++;
	e->to = v;
	e->next = adj[u];
	adj[u] = e;
}

int t;
int d[MAX_N];
int f[MAX_N];

void dfs(int u) {
	edge *e;
	d[u] = t++;
	for(e = adj[u]; e != NULL; e = e->next) {
		if(d[e->to] == 0) dfs(e->to);
	}
	f[u] = t++;
}

int main() {
	int n;
	int u, k;
	int i, j;
	int v[MAX_N];

	scanf("%d", &n);
	for(i = 0; i < n; ++i) {
		scanf("%d %d", &u, &k);
		for(j = 0; j < k; ++j) {
			scanf("%d", v + j);
		}
		for(j = k - 1; j >= 0; --j) {
			add_edge(u - 1, v[j] - 1);
		}
	}

	t = 1;
	for(u = 0; u < n; ++u) {
		if(d[u] == 0) dfs(u);
		printf("%d %d %d\n", u + 1, d[u], f[u]);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 600
use std::io::stdin;

fn main() {
  let mut str = String::new();
  stdin().read_line(&mut str).unwrap();
  let char = str.chars().next().unwrap();
  if(char.is_uppercase()) {
    println!("A");
  } else if(char.is_lowercase()) {
    println!("a");
  }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

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

  int maxv = 0;
  for (int i = 0; i < n - 1; ++i) {
    map<char, bool> exist;
    for (int l = 0; l <= i; ++l) {
      exist[s[l]] = true;
    }
    map<char, bool> shut;
    int cnt = 0;
    for (int r = i + 1; r < n; ++r) {
      if (shut[s[r]]) continue;
      if (exist[s[r]]) {
        ++cnt;
        shut[s[r]] = true;
      }
    }
    chmax(maxv, cnt);
  }

  cout << maxv << "\n";

  return 0;
}

Measured memory_bytes: 256
# joisinoお姉ちゃんは、A op B という式の値を計算したいと思っています。
# ここで、A, Bは整数で、op は、+ または - の記号です。
# あなたの仕事は、joisinoお姉ちゃんの代わりにこれを求めるプログラムを作ることです。

# 制約
# 1 ≦ A, B ≦ 1000000000
# op は、+ または - の記号である。

# 標準入力から A op B を取得する
a, op, b = map(str,input().split())

input_a = int(a)
input_b = int(b)

# opに従い、計算して出力する
result = 0
if op == "+":
    result = input_a + input_b
elif op == "-":
    result = input_a - input_b
else:
    result = "Error"

print(result)


Measured memory_bytes: 9100
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define endl '\n';
typedef long long ll;
typedef long double ld;
using namespace std;

const int N = 1e5 + 10;
int n, m, s, t;
vector<int> g[N];
int dp[N][3];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].pb(v);
  }
  scanf("%d%d", &s, &t);
  memset(dp, -1, sizeof dp);
  dp[s][0] = 0;

  queue<pair<int, int>> bfs;
  bfs.push({s, 0});
  while (bfs.size()) {
    auto p = bfs.front(); bfs.pop();
    int u = p.f, m = p.s;
    for (int v : g[u]) {
      if (dp[v][(m + 1) % 3] == -1) {
        dp[v][(m + 1) % 3] = dp[u][m] + 1;
        bfs.push({v, (m + 1) % 3});
      }
    }
  }
  if (dp[t][0] == -1) {
    printf("-1\n");
  } else {
    printf("%d\n", dp[t][0] / 3);
  }
  return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N; string S; cin >> N >> S;
  int ans = 1;
  for(int i = 1; i < N; i++){
    ans += (S[i]!=S[i-1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<ll> enum_div(ll n){
	std::vector<ll> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
ll n,m; ll ans=0;
int main(){
  cin >> n >> m;
  std::vector<ll> v(enum_div(m));sort(all(v));
  v.push_back(m);
  for (auto itr = v.begin(); itr != v.end(); itr++) {
    if(m%(*itr) == 0 && m/n >= *itr)ans = *itr;
  }
  cout << ans << endl;
}


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

int main() {
  
  int N, D, X; cin >> N >> D >> X;
  
  int ans = N + X; D--;
  
  for (int i = 0; i < N; i++) {
    int A; cin >> A;
    ans += D / A;
  }
  
  cout << ans << endl;
  
}

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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
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; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353




int main() {
    int x; cin >> x;
    if(x == 7 || x == 5 || x == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
}




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

ll n, s;
ll a[N];
ll dp[N][N];
ll inv2;

ll recur(ll pos, ll rem) {

  if (rem < 0)
    return 0;
  if (pos == n + 1) {
    return rem == 0;
  }

  ll &ans = dp[pos][rem];
  if (ans != -1)
    return ans;

  ans = inv2 * recur(pos + 1, rem - a[pos]) % mod + recur(pos + 1, rem);
  if (ans >= mod)
    ans -= mod;
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n >> s;

  for (ll i = 1; i <= n; i++)
    cin >> a[i];

  inv2 = (mod + 1) / 2;

  memset(dp, -1, sizeof(dp));

  ll ans = recur(1, s);
  ans *= power(2, n, mod);
  ans %= mod;
  cout << ans << en;

  return 0;
}


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

int main()
{
	const int max_n=100, max_m = 100;
	int n, m;
	int a[max_n][max_m] = { 0 };
	int b[max_m] = { 0 };
	//input
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	

	for (int i = 0; i < n; i++) {
		int sum = 0;
		for (int j = 0; j < m; j++) {
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}
    return 0;
}

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

using namespace std;

const int N = 1e5 + 5;

int n, q, sum[N], cnt = 0, num[N][26][26];
string s[N];

struct Trie {
    int child[26], total;
    bool id;
    Trie() {
        memset(child, 0, sizeof(child));
        total = id = 0;
    }
}trie[4 * N];

void update(string t) {
    int p = 0;
    for(int i = 0; i < t.length(); i++) {
        if(!trie[p].child[t[i] - 'a'])
            trie[p].child[t[i] - 'a'] = ++cnt;
        p = trie[p].child[t[i] - 'a'];
    }
    trie[p].total = trie[p].id = 1;
}

void prep(int p) {
    for(int i = 0; i < 26; i++) {
        if(!trie[p].child[i]) continue;
        prep(trie[p].child[i]);
        trie[p].total += trie[ trie[p].child[i] ].total;
    }
}

void travel(int id, string s) {
    int p = 0;
    for(int i = 0; i < s.length(); i++) {
        int c = s[i] - 'a';
        for(int j = 0; j < 26; j++) {
            if(j == c) continue;
            if(!trie[p].child[j]) continue;
            num[id][c][j] += trie[ trie[p].child[j] ].total;
        }
        p = trie[p].child[c];
        sum[id] += trie[p].id;
    }
}

int main() {
    cin.tie(0), ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> s[i];
        update(s[i]);
    }
    prep(0);
    for(int i = 1; i <= n; i++)
        travel(i, s[i]);
    cin >> q;
    while(q--) {
        int id; string t;
        cin >> id >> t;
        int ans = sum[id];
        for(int i = 0; i < t.length(); i++) {
            for(int j = 0; j < i; j++)
                ans += num[id][t[i] - 'a'][t[j] - 'a'];
        }
        cout << ans << "\n";
    }
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, X;
    cin >> N >> X;

    vector<int> m(N);
    for(int i = 0; i < N; i++){
        cin >> m[i];
        X -= m[i];
    }

    int ans = N;
    sort(m.begin(), m.end());

    ans += X / m[0];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;


int main(void) {
	int A, B, C;
	cin >> A >> B >> C;
	if (C > A + B) {
		OUT("No");
	}
	else {
		OUT("Yes");
	}
	return 0;
}

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

using namespace std;

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

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[105];

int main()
{
	ll N, x;
	cin >> N >> x;
	REP(i, N)
	{
		cin >> A[i];
	}
	sort(A, A + N);

	int n = 0;
	REP(i, N)
	{
		if (x - A[i] >= 0)n++;
		x -= A[i];
	}
	if (x > 0)n--;
	cout << n << endl;
	return 0;
}

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

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

    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i=0; i<N; ++i) cin >> h[i];

    vector<long long> cost(N, 1e10);
    cost[0] = 0;
    for (int i=0; i<N; ++i) {
        for (int j=1; j<=K; ++j) {
            if (i+j >= N) continue;
            cost[i+j] = min(cost[i+j], cost[i] + (long long)abs(h[i] - h[i+j]));
        }
    }
    
    cout << cost[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1408
N=int(input())-1
A0=[int(i) for i in input().split()]
A1=[int(i) for i in input().split()]
LIST=[]
for i in range(0,N+1):
    candy=0
    for j in range(0,i+1):
        candy+=A0[j]
    for k in range(i,N+1):
        candy+=A1[k]
    LIST.append(candy)
print(max(LIST))

Measured memory_bytes: 3064
// This  Program is made by Jan(Codezebra)
#include<bits/stdc++.h>
#define int long long
#define INF 0x3f3f3f3f
using namespace std;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	int mx=-200, my=200;
	for(int i=0;i<n;i++){
		int p;
		cin>>p;
		mx=max(mx,p);
	}
	for(int i=0;i<m;i++){
		int p;
		cin>>p;
		my=min(my,p);
	}
//	cout<<x<<" "<<y<<"\n";
//	cout<<mx<<" "<<my<<"\n";
	for(int z=-100;z<=100;z++){
		if(x<z and z<=y and mx<z and z<=my){
			cout<<"No War";
			return 0;
		}
	}
	cout<<"War";
	return 0;
}



Measured memory_bytes: 384
import sys
sys.setrecursionlimit(100000000)

n, m, p = map(int, input().split())
routes =[]
bt = [[] for _ in range(n+1)]

for i in range(m):
    a, b, c = map(int, sys.stdin.readline().split())
    routes.append([a, b, -1 * (c - p)])
    bt[b].append(a)

enable = set()
enable.add(n)
for i in range(n):
    for j in range(1, n+1):
        if j in enable:
            for k in bt[j]:
                if not k in enable:
                    enable.add(k)

inf = float('inf')
costs = [inf for _ in range(n+1)]
costs[1] = 0
error = False
for i in range(n):
    for route in routes:
        if route[1] in enable and costs[route[0]] + route[2] < costs[route[1]]:
            costs[route[1]] = costs[route[0]] + route[2]
            if i == n-1:
                error = True
                break
if error == True:
    print(-1)
else:
    print(max(0, -1 * costs[n]))



Measured memory_bytes: 46300
#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];
  vector<int> b(n);
  int count = 0;
  int flag = 0;
  for(int i = 0; i < n - 1; i++) {
    if(a[i] > a[i + 1]) count++;
    if(count > 0) break;
  }
  if(count == 0) flag = 1;
  if(flag == 0) {
    for(int i = 0; i < n - 1; i++) {
      for(int j = i + 1; j < n; j++) {
        for(int k = 0; k < n; k++) b[k] = a[k];
        count = 0;
        int tmp = b[i];
        b[i] = b[j];
        b[j] = tmp;
        /*
        cout << i << " " << j << endl;
        for(int k = 0; k < n; k++) cout << b[k] << " ";
        cout << endl;
        */
        for(int k = 0; k < n - 1; k++) {
          if(b[k] > b[k + 1]) count++;
          if(count > 0) break;
        }
        if(count == 0) {
          flag = 1;
          break;
        }
      }
      if(flag == 1) break;
    }
  }
  if(flag == 0) cout << "NO\n";
  else          cout << "YES\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int ama[101];
int main(){
  
    
    int a,b,c;
    cin>>a>>b>>c;
    
    for(int i=1;i<=b;i++){
        int d=(a*i)%b;
        ama[d]=1;
    }
    if(ama[c]==0){puts("NO");}
    else puts("YES");
    
    
return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int E;
    int Y;
    cin>>E>>Y;
    int change[]={0,1867,1911,1925,1988};
    if(E==0){
        if(Y<=1911){
            cout<<"M"<<Y-1867<<endl;
        }else if(Y<=1925){
            cout<<"T"<<Y-1911<<endl;
        }else if(Y<=1988){
            cout<<"S"<<Y-1925<<endl;
        }else{
            cout<<"H"<<Y-1988<<endl;
        }
    }else{
        cout<<change[E]+Y<<endl;
    }
    return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			String S = sc.next();
			
			int L = S.length();
			String Sx;
			
			if("keyence".equals(S)) {
				System.out.println("YES");
				return;
			}
			
			for(int i=0;i<L;i++) {
				for(int j=i+1;j<L;j++) {
					StringBuilder s = new StringBuilder(S);
					s.delete(i, j);
					
						if("keyence".equals(s.toString())){
							System.out.println("YES");
							return;
						}
				}
			}
			
			System.out.println("NO");
			
		}
	}

Measured memory_bytes: 22996
#include <stdio.h>

int main(){
  char S[4];
  scanf("%s",&S);

  int A = (S[0] - '0')*10 + (S[1] - '0');
  int B = (S[2] - '0')*10 + (S[3] - '0');
  if (A <= 12 && A > 0) {
    if (B <= 12 && B > 0) {
      printf("AMBIGUOUS\n");
    } else {
      printf("MMYY\n");
    }
  } else if (B <= 12 && B > 0) {
    printf("YYMM\n");
  } else {
    printf("NA\n");
  }
  return 0;
}


Measured memory_bytes: 128
#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.at(i);
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 == 0) cnt++;
  }
  cout << pow(3, N) - pow(2, cnt) << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
  }
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;


void func(){
  LL M1,D1;
  LL M2,D2;
  cin >> M1>>D1;
  cin >> M2>>D2;
  if(M1!=M2){
    cout << 1;  
  }
  else{
    cout << 0;  
  }
  
  
  
  //LL N;
  //cin >> N;
  //auto A = cinvll(N);
  //PRINTSP(A);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using str = string;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    str s;
    int k;
    cin >> k >> s;

    if(s.size() <= k) {
        cout << s << endl;
    }
    else {
        for(int i = 0; i < k; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

bool isPrime(ll num) {

	bool flag = true;
	for (int i = 2; i <= sqrt(num); i++) {
		if (num%i == 0) {
			flag = false;
			break;
		}
	}

	return flag;
}

void solve() {

	int N;
	cin >> N;

	vector<int> vec;

	for (int i = 6; i <= 55555; i+=5) {
		if (isPrime(i)) vec.emplace_back(i);
	}

	debug(vec);

	rep(i, N) cout << vec[i] << " ";

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
void swap(int& a, int& b){
    int t = a; a = b; b = t;
}
typedef long long ll;
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    ll t1 = n/k;
    int m;
    if(k % 2 == 0)m = k/2;
    ll t2 = 0;
    if(k % 2 == 0)
    for(int i = m; i <= n; i += k){
        t2++;
    }
    cout << t1*t1*t1 + t2*t2*t2<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

int main(){
  int n,m;
  cin>>n>>m;
  cout<<n-m+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a;
    int b;
    int c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if((a==b) && !(b==c) && !(c==a))
    {
        printf("Yes");
    }
    else if(!(a==b) && (b==c) && !(c==a))
    {
        printf("Yes");
    }
    else if(!(a==b) && !(b==c) && (c==a))
    {
        printf("Yes");
    }
    else {
        printf("No");
    }
}


Measured memory_bytes: 128
#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, k;
  cin >> n >> m >> k;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      if (i * j + (n - i) * (m - j) == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main(void){
  int a,b,c,d,e,f;

  while(cin>>a>>b>>c>>d>>e>>f, (a || b || c || d || e || f)){
    int sum = 100;

     sum += 77 * a;
    f -= 6 * a;

    sum += 51 * b;
    f -= 4 * b;

    sum += 4 * c;
    f -= c;

    //-d : Q[JnÉ3üêÄ, `F[Ìê2ÔÁÄ­é
    sum -= d;
    f -= d;

    //e*3 : Q[JnÌRC
    sum -= e * 3;
    f -= e * 2;

    //3*f : cèQ[ñÅ3¸ÂüµÄ»ëíÈ©Á½
    sum -= 3 * f;

    cout<<sum<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let n: i32 = input();
    for i in 1..10 {
        if n % i == 0 && n / i <= 9{
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF (ll)1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

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

//constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main(void) {
	int a,b;
	cin >> a >> b;
	bool sw = (a <= 8 && b <= 8);
	cout << (sw ? "Yay!" : ":(")<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int h[1 << 17][3]; int n,k;
ll dp[1 << 17][3];
int main() {
	cin >> n;
	rep(i, n) {
		rep(j, 3)cin >> h[i][j];
	}
	rep(i, n) {
		rep(j, 3) {
			rep(k, 3) {
				if (j == k)continue;
				dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + h[i][k]);
			}
		}
	}
	ll ans = 0;
	rep(i, 3)ans = max(ans, dp[n][i]);
	cout << ans << endl;
	//stop
	return 0;
}

Measured memory_bytes: 4608
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    
    string com;
    //char S[100];
    cin >> com;
    
    for(int i=0; i<com.size(); i++){
    if(com[i] == 'S') {
        int tmp = a;
        a = e;
        e = f;
        f = b;
        b = tmp;
    }
    else if(com[i]=='E'){
        int tmp = a;
        a = d;
        d = f;
        f = c;
        c = tmp;
    }
    else if(com[i]=='N'){
        int tmp = a;
        a = b;
        b = f;
        f = e;
        e = tmp;
    }
    else if(com[i]=='W'){
        int tmp = a;
        a = c;
        c = f;
        f = d;
        d = tmp;
    }
    }
    
    cout << a << endl;
    
    return 0;
}

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

const ll INF = 1LL << 60;

ll N;
int main() {
    cin >> N;
    ll ans = INF;
    for (ll i = 1; i * i <= N; i++) {
        // cout << i << endl; 
        if (N % i != 0) continue;

        string b = to_string(N / i); 
        string a = to_string(i);
        ll tmp = max(b.size(), a.size());
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
while True:
  a, op, b = input().split()
  a = int(a)
  b = int(b)
  if op == "+":
    print(a+b)
  elif op == "-":
    print(a-b)
  elif op == "*":
    print(a*b)
  elif op == "/":
    print(a//b)
  else:
    break


Measured memory_bytes: 5592
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] num = new int[n];
      int count = 0;
      for(int i = 0;i < n;i++){
      	num[i] = sc.nextInt();
      }
      
      Arrays.sort(num);
      
      for(int i = 1;i < n;i++){
      	if(num[i-1]<num[i]){
        	count++;
        }
      }
      System.out.println(count+1);
    }
}

Measured memory_bytes: 21972
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int ijk[3000];
bool v[3000];
vector<pair<int,int> > g[3000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<b;i++){
		int d,e,f;
		scanf("%d%d%d",&d,&e,&f);
		g[d-1].push_back(make_pair(e-1,f));
		g[e-1].push_back(make_pair(d-1,f));
	}
	for(int i=0;i<a;i++){
		ijk[i]=999999999;
	}
	priority_queue<pair<int,int>  >Q;
	for(int i=0;i<c;i++){
		int d;
		scanf("%d",&d);
		d--;
		ijk[d]=0;
		Q.push(make_pair(0,d));
	}
	while(Q.size()){
		int at=Q.top().second;
		int cost=-Q.top().first;
		Q.pop();
		if(v[at])continue;
		v[at]=true;
		for(int i=0;i<g[at].size();i++){
			if(!v[g[at][i].first]&&ijk[g[at][i].first]>ijk[at]+g[at][i].second){
				ijk[g[at][i].first]=ijk[at]+g[at][i].second;
				Q.push(make_pair(-ijk[g[at][i].first],g[at][i].first));
			}
		}
	}
	int ret=0;
	for(int i=0;i<a;i++){
		for(int j=0;j<g[i].size();j++){
			ret=max(ret,(ijk[i]+ijk[g[i][j].first]+g[i][j].second));
		}
	}
	printf("%d\n",(ret+1)/2);
}

Measured memory_bytes: 3288
import sys
from sys import stdin

n, m = map(int, stdin.readline().rstrip().split())
x = list(map(int, stdin.readline().rstrip().split()))

x.sort()
tmp = []
for i in range(1, len(x)):
    tmp.append(abs(x[i] - x[i - 1]))

tmp = sorted(tmp)
tmp.reverse()

if len(tmp)+1 <= n:
    print(0)
else:
    print(sum(tmp[n-1:]))

Measured memory_bytes: 13960
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
constexpr auto INF = 2147483647;
typedef long long ll;

int main(){

  vector<int> num = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int k;
  cin >> k;
  cout << num[k-1] << endl;

  return 0;
}

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

int main() {
    int N,M; cin >> N >> M;
    vector<int> a(M),b(M);
    for(int i=0; i<M; i++){
        cin >> a.at(i) >> b.at(i);
    }
    vector<int> order(N);
    for(int i=0; i<N; i++){
        order.at(i)=i+1;
    }
    int ans=0;

    do{
        if(order.at(0)!=1) break;
        int flag=0;
        for(int i=0; i<N-1; i++){
            int cnt=0;
            for(int j=0; j<M; j++){
                
                if((order.at(i)==a.at(j)&&order.at(i+1)==b.at(j)) || (order.at(i)==b.at(j)&&order.at(i+1)==a.at(j))) cnt=1;
           }
           if(cnt==0){
               flag=0;
               break;
           }
           else flag=1;
            
       }
       if(flag==1) ans++;
    }while(next_permutation(order.begin(),order.end()));
    cout << ans << endl;
}


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

void solve(long long N) {
  vector<long long> ans(10001);
  for(long long x = 1; x <=100; x++) {
    for(long long y = 1; y <=100; y++) {

      for(long long z = 1; z <=100; z++) {
        long long v = (pow(x, 2) + pow(y, 2) + pow(z, 2) + (x*y) + (y*z) + (z*x));
        if(v <= 10000) ans[v]++;
      }
    }
  }

  for(long long i = 1; i <= N; i++){
    cout << ans[i] << endl;;
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3772
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    k--;
    if(s[k] == 'A') s[k] = 'a';
    if(s[k] == 'B') s[k] = 'b';
    if(s[k] == 'C') s[k] = 'c';
    cout << s << endl;
    return 0;
}


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

namespace AtCoder.Abc
{
    class A_169_Multiplication1
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long result = inputLongArray[0] * inputLongArray[1];

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28200
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main(){
    ll n, start;
    std::cin >> n >> start;
    ll ans;
    std::cin >> ans;
    ans = std::abs(ans - start);
    for(int i = 1; i < n; i++){
        ll x;
        std::cin >> x;
        x = std::abs(x - start);
        if(x == 0) continue;
        ans = gcd(ans, x);
    } 

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	double r,s,l,PI=3.141592653589;
	cin>>r;
	s=PI*r*r;
	l=2*PI*r;
	printf("%.6lf %.6lf\n",s,l);
	return 0;
}

Measured memory_bytes: 3284
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N;
    string s[10000];
    cin>>N;
    int a=0,b=0,c=0;
    int ans=0;
    rep(i,N) {
        cin>>s[i];
        if(s[i][0]=='B') b++;
        if(s[i][s[i].size()-1]=='A') a++;
        if(s[i][0]=='B' && s[i][s[i].size()-1]=='A') c++;
        Rep(j,s[i].size()-1){
            if(s[i][j-1]=='A' && s[i][j]=='B') ans++;
        }
    }
    a=a-c;
    b=b-c;
    if(a==b){
        if(a==0) cout<<ans+max(0,c-1)<<endl;
        else cout<<ans+c+a<<endl;
    }else cout<<ans+c+min(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
#define NMAX 105
#define WMAX 10005
#define DIAGONAL 1
#define TOP 0

using namespace std;

struct Item {
    int value, weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];

void compute(int &maxValue, vector<int> &selection) {
    for ( int w = 0; w <= W; w++ ) {
        C[0][w] = 0;
        G[0][w] = DIAGONAL;
    }
    
    for ( int i = 1; i <= N; i++ ) C[i][0] = 0;
    
    for ( int i = 1; i <= N; i++ ) {
        for ( int w = 1; w <= W; w++ ) {
            C[i][w] = C[i - 1][w];
            G[i][w] = TOP;
            if ( items[i].weight > w ) continue;
            if ( items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w] ) {
                C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
                G[i][w] = DIAGONAL;
            }
        }
    }
    
    maxValue = C[N][W];
    selection.clear();
    for ( int i = N, w = W; i >= 1; i-- ) {
        if ( G[i][w] == DIAGONAL ) {
            selection.push_back(i);
            w -= items[i].weight;
        }
    }
    
    reverse(selection.begin(), selection.end());
}

void input() {
    cin >> N >> W;
    for ( int i = 1; i <= N; i++ ) {
        cin >> items[i].value >> items[i].weight;
    }
}

int main() {
    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue, selection);
    
    cout << maxValue << endl;
    
    return 0;
}


Measured memory_bytes: 11072
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
LL fac[N];
void init(){
    fac[0]=1;
    fac[1]=1;
    for(int i=2;i<=1E5;i++)
        fac[i]=fac[i-1]*i%MOD;
}
int main(){
    init();
    int n,m;
    scanf("%d%d",&n,&m);
    if(abs(n-m)>1)
        printf("0\n");
    else if(abs(n-m)==0){
        LL res=((fac[n]%MOD*fac[m]%MOD)%MOD)*2%MOD;
        printf("%lld\n",res);
    }
    else{
        LL res=(fac[n]%MOD*fac[m]%MOD)%MOD;
        printf("%lld\n",res);
    }
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

string s;

int main()
{
    _FastIO;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '1')
            cout << '9';
        else
            cout << '1';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3636
#coding:utf-8
n, m = map(int, input().split())
ac = [0] * n
wa = [0] * n
pena = 0


for i in range(m):
    p, s = map(str, input().split())

    if ac[int(p)-1]:
        #すでに正解していれば次の入力へ
        continue
    if s == 'AC':
        ac[int(p)-1] = 1
        #ACが出てからそれまでその問題で出たWAの回数をペナとする
        pena += wa[int(p)-1]
    elif s == 'WA':
        wa[int(p)-1] += 1


print(sum(ac), pena)


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define bug(x) cout << #x << " = " << x << endl
using namespace std;
typedef long long int ll;
ll n,Ti=1e9;
ll f(ll a,ll b){
    ll r1=0,r2=0;
    while(a) r1++,a/=10;
    while(b) r2++,b/=10;
    return max(r1,r2);
}
int main(){
    cin>>n;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            Ti=min(Ti,f(i,n/i));
        }
    }
    cout<<Ti<<endl;
    return 0;
}


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

int main(){
   int n;
   cin >> n;
   vector<int> a;
   bool j = true,k = true;
   int t=1;
   for(int i=0;i<n;i++){
      int brick;
      cin >> brick;

      if(brick == t){
         a.push_back(brick);
         t++;
      }
   }
   if(!a.size()){
      cout << -1 << endl;
      return 0;
   }

   cout << n - a.size()<<endl;

   return 0;
}

Measured memory_bytes: 1400
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int sum = 0;
        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                for (int k = j + 1; k < n; k++) {
                    if (l[i] + l[j] <= l[k]) {
                        break;
                    }
                    if (l[j] + l[k] <= l[i] || l[k] + l[i] <= l[j]) {
                        continue;
                    }
                    sum++;
                }
            }
        }
        System.out.println(sum);
    }

}



Measured memory_bytes: 26672