akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;
using std::stack;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long ll;
const ll INF = 1e18 + 9UL;

class edge {
   public:
    ll from;
    ll to;
    ll cost;

    edge() {}
    edge(ll from, ll to, ll cost) : from(from), to(to), cost(cost){};
};

vector<ll> solve(ll n, const vector<edge>& es, ll s) {
    vector<ll> d(n, INF);
    d[s] = 0;

    for (ll i = 0; i < n; i++) {
        bool update = false;

        for (const edge& e : es) {
            if (d[e.from] != INF && d[e.from] + e.cost < d[e.to]) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }

        if (!update) {
            break;
        }
    }

    vector<bool> neg(n);
    for(int i = 0; i < n; i++){
        for(const edge &e : es){
            if(d[e.from] == INF){
                continue;
            }
            if(d[e.from] + e.cost < d[e.to]){
                d[e.to] = d[e.from] + e.cost;
                neg[e.to] = true;
            }
            if(neg[e.from]){
                neg[e.to] = true;
            }
        }
    }

    return neg[n-1] ? vector<ll>(0) : d;
}

/*
vector<bool> dfs(int n, const vector<edge>& es, int s) {
    vector<bool> visited(n);

    stack<int> stack;
    stack.push(s);
    while (!stack.empty()) {
        int v = stack.top();
        stack.pop();
        if (visited[v]) {
            continue;
        }
        visited[v] = true;
        for (const edge& e : es) {
            if (e.from == v && !visited[e.to]) {
                stack.push(e.to);
            }
        }
    }

    return visited;
}
*/

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

    vector<edge> es(m);
    for (ll i = 0; i < m; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        es[i] = edge(a - 1, b - 1, -c);
    }

    /*
    vector<bool> visited = dfs(n, es, 0);
    for(size_t i = 0; i < es.size(); i++){
        if(!visited[es[i].to] || !visited[es[i].from]){
            es.erase(es.begin() + i);
        }
    }
    */

    vector<ll> d = solve(n, es, 0);
    if (d.empty()) {
        cout << "inf" << endl;
    } else {
        cout << -d[n - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>

int bubblesort(int* a, int n)
{
	int res = 0;
	for (int i=n-1; i>=0; i--) {
		for (int j=0; j<i; j++) {
			if (a[j] > a[j+1]) {
				std::swap(a[j], a[j+1]); res++;
			}
		}
	}
	return res;
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		int* a = new int[n];
		for (int i=0; i<n; i++) std::cin >> a[i];
		std::cout << bubblesort(a, n) << std::endl;
		delete[] a;
	}
	return 0;
}



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

int N;
map<string, int> m;

int main(){
  cin >> N;

  string s;
  for(int i = 0; i < N; i++){ 
    cin >> s; 
    if(m.count(s)) continue;
    m[s] = 1; 
  }

  cout << m.size() << endl;
  return 0;
}

Measured memory_bytes: 19252
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
using namespace std;
const int maxn=3e3+5;
int n;
long double x,p[maxn][maxn],sum;
int main()
{
	ios::sync_with_stdio(false) , cin.tie(0), cout.tie(0);
	cin>>n;
	p[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		for(int j=0;j<=i;j++)
		{
			if(j==0)p[j][i]+=p[j][i-1]*(1-x);
			else if(j==i)p[j][0]+=p[j-1][0]*x;
			else p[j][i-j]+=p[j-1][i-j]*x+p[j][i-j-1]*(1-x);
		}
	}
	for(int i=n;i>=0;i--)if(i>n-i)sum+=p[i][n-i];
	cout<<fixed<<setprecision(10)<<sum;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    int ans = 0;
    queue<ll> q;
    q.push(3);
    q.push(5);
    q.push(7);

    while(!q.empty())
    {
        ll num = q.front(); q.pop();
        if(num <= N)
        {
            string s = to_string(num);
            vector<int> cnt(10, 0);
            for(auto c : s)
            {
                cnt[c- '0']++;
            }
            if(cnt[3]>0 && cnt[5]>0 && cnt[7]>0) ans++;
        }
        if(num*10 + 3 <= N) q.push(num*10 + 3);
        if(num*10 + 5 <= N) q.push(num*10 + 5);
        if(num*10 + 7 <= N) q.push(num*10 + 7);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3880
#include<iostream>
#include<string>
#include<cmath>
#include<limits.h>

#define LONG_LONG_MAX 9223372036854775807LL

using namespace std;

// numの入る場所の前のindexを返す
int search(long long *arr, int size, long long num) {
	int left = 0;
	int right = size-1;
	int mid;

	if (arr[0] > num) return -1;
	if (arr[size - 1] < num) return size-1;

	while (right >= left) {
		mid = left + (right - left) / 2;
		if (arr[mid] == num) break;
		else if (arr[mid] > num) right = mid - 1;
		else if (arr[mid] < num) left = mid + 1;
	}

	if (arr[mid] < num)return mid;
	else return mid - 1;
}



long long min(long long a, long long b, long long c, long long d) {
	if (a < b && a < c && a < d) return a;
	else if (b < c && b < d) return b;
	else if (c < d) return c;
	else return d;
}

long long max(long long a, long long b) {
	if (a > b)return a;
	else return b;
}

long long max(long long a, long long b, long long c) {

	if (a > b && a > c) return a;
	else if (b > a && b > c) return b;
	else return c;
}

long long max(long long a, long long b, long long c, long long d) {
	if (max(a, b, c) < d) return d;
	else return(max(a, b, c));
}

int main() {

	int A, B, Q;
	cin >> A >> B >> Q;

	long long *s = new long long[A];
	long long *t = new long long[B];
	long long *x = new long long[Q];

	for (int i = 0; i < A; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < Q; i++) {
		cin >> x[i];
	}


	int snum, tnum;
	long long  sd[2], td[2];
	long long  diff[4];
	for (int i = 0; i < Q; i++) {
		snum = search(s, A, x[i]);
		tnum = search(t, B, x[i]);

		sd[0] = sd[1] = td[0] = td[1] = LONG_LONG_MAX;
		diff[0] = diff[1] = diff[2] = diff[3] = LONG_LONG_MAX;

		if (snum >= 0) sd[0] = x[i] - s[snum];
		if (tnum >= 0) td[0] = x[i] - t[tnum];
		if (snum < A - 1) sd[1] = s[snum + 1] - x[i];
		if (tnum < B - 1) td[1] = t[tnum + 1] - x[i];

		diff[0] = max(sd[0], td[0]);
		diff[1] = max(sd[1], td[1]);


		if (snum >= 0 && tnum < B - 1) {
			if (sd[0] < td[1]) sd[0] *= 2;
			else td[1] *= 2;
			diff[2] = sd[0] + td[1];
		}

		if (tnum >= 0 && snum < A - 1) {
			if (td[0] < sd[1]) td[0] *= 2;
			else sd[1] *= 2;
			diff[3] = td[0] + sd[1];
		}

		cout << dec <<  min(diff[0], diff[1], diff[2], diff[3]) << endl;
	}
	





	return 0;

}

Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

typedef pair<int, int> p;

int a, b;

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

int main(int argc, char *argv[]) {
    while (scanf("%d %d", &a, &b) != EOF) {
        int g = gcd(a, b);
        printf("%d %d\n", g, (a / g) * b);
    }
    return 0;
}



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

using namespace std;

int main()
{
    int N;
    string S;

    cin >> N >> S;

    for (int i = 0; i < S.size(); i++) {
        S[i] = char('A' + (S[i] - 'A' + N) % 26);
    }

    cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, temp;
	cin >> n;
	vector<pair<int, int> > a(n);
	for (int i = 0; i < n; i++){
		cin >> temp;
		a[i] = make_pair(temp, i+1);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++){
		cout << a[i].second << " ";
	}
	cout << endl;
	return 0;
}




Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] r = new long[n];
		for (int i = 0; i < r.length; i++) {
			r[i] = sc.nextInt();
		}
		long max = -1000000000;
		long min;
		min = r[0];
		for (int i = 1; i < r.length; i++) {
			if(max < r[i] - min){
				max = r[i] - min;
			}
			if(min > r[i]){
				min = r[i];
			}
		}
		System.out.println(max);
	}
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, x, k, q, m, y, r;
string s;

ll a,b;

// <------------- Implement Functions Here ----------> //

  
long long exponentiation(long long base, 
                        long long exp) 
{ 
    if (exp == 0) 
        return 1; 
  
    if (exp == 1) 
        return base % N; 
  
    long long t = exponentiation(base, exp / 2); 
    t = (t * t) % N; 
  
    // if exponent is even value 
    if (exp % 2 == 0) 
        return t; 
  
    // if exponent is odd value 
    else
        return ((base % N) * t) % N; 
} 

ll NCR(ll n, ll r) {
	if (n < r ) return 0;
	if (r == 0) return 1;
	if (r > n / 2) return NCR(n, n - r);
	ll res = 1;
	for (ll k = 1; k <= r; ++k) {
		res = (res * (n - k + 1))%MOD;
		res *= exponentiation(k,MOD-2);
		res %= MOD;
	}
	return res;
}



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> a >>b;
	ll pos = (exponentiation(2,n) - 1 +MOD)%MOD;
	ll neg = (NCR(n,a) + NCR(n,b))%MOD ;
	ll ans = (pos - neg + MOD)%MOD; 
	cout<<ans;
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 13016
import java.lang.Integer;
import java.lang.String;
import java.io.*;

public class Main{
  public static void main(String args[]) throws IOException{

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = new String(in.readLine());

    String[] li = s.split(" +");

    int A = Integer.parseInt(li[0]);
    int B = Integer.parseInt(li[1]);
    int C = Integer.parseInt(li[2]);

    int i = 0,j = 7;

    while((A*7 + B)*(i+1) < C)i++;

    while((A*7 + B)*i + A * (j - 1) >= C)j--;
    System.out.println(i*7 + j);


  }
}


Measured memory_bytes: 24616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

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

  vector <int> v;
  for(int i=0; i<k && a+i<=b; i++){
    v.push_back(a+i);
  }
  for(int i=0; i<k && b-i>=a; i++){
    v.push_back(b-i);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (auto it = v.begin(); it != v.end(); ++it) {
    cout << *it << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# Problem C - HonestOrUnkind2

# input
N = int(input())
shogen_list = []
for i in range(N):
    A = int(input())
    tmp = []
    for j in range(A):
        x, y = map(int, input().split())
        tmp.append([x, y])
    shogen_list.append(tmp)

# initialization
pattern = []
for i in range(2**N):
    p = [0]*N
    for j in range(N):
        if (i>>j)&1==1:
            p[j] = 1
    pattern.append(p)
max_count = 0

# count
for p in pattern:
    is_ok = True
    num_count = 0
    for i in range(N):
        # 正直者であればチェック
        if p[i]==1:
            num_count += 1
            shogen = shogen_list[i]
            if len(shogen)==0:
                continue
            else:
                for s in shogen:
                    x = s[0]
                    y = s[1]
                    if not p[x-1]==y:
                        is_ok = False
                        break
    if is_ok:
        max_count = max(max_count, num_count)

# output
print(max_count)


Measured memory_bytes: 9460
# 単体ピザで埋めてからハーフピザを買うか、
# ハーフピザで埋めてから単体ピザを足すのが良いはず。

A, B, C, X, Y = map(int, input().split())
a, b = X, Y
est = []

#ハーフ埋め
esth = C * min(X, Y) * 2
a -= min(X,Y)
b -= min(X,Y)
esth += A * a + B * b
est.append(esth)

#全ハーフ
a, b = X, Y
estah = C * max(X, Y) * 2
est.append(estah)

#全単品
a, b = X, Y
estfa = A * a + B * b
est.append(estfa)

print(min(est))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
	int n;
	string j="AGC";
	cin>>n;
	if(n<1200)j="ABC";
	else if(n<2800)j="ARC";
	cout<<j<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}


//ここまでライブラリ
//ここから本文


int main() {
	int n;
	double t, a;
	cin >> n >> t >> a;
	int h;
	double mini = 10000000;
	int number = 0;
	for (int i = 0; i < n; i++) {
		cin >> h;
		if (mini > abs(a - (t - h * 0.006))) {
			mini = abs(a - (t - h * 0.006));
			number = i + 1;
		}
	}
	cout << number << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a,b;cin>>a>>b;
  if(a==b)cout<<a+b<<endl;
  else cout<<max(a,b)*2-1<<endl;
  return 0;
}


Measured memory_bytes: 3564
#include <cstdio>
#include <cmath>
#include <iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
	char a[1000], b[1000];
	cin >> a >> b;
	int a_ = strlen(a);
	int b_ = strlen(b);
	for (int i = 0; i < a_; i++)
	{
		if (a[i] != b[i])
		{
			cout << "No" << endl;
			return 0;
		}
	}
	if (a_ != (b_ - 1))
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3600
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * https://beta.atcoder.jp/contests/abc073/tasks/abc073_c
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		Set<Long> dp = new HashSet<Long>();
		for(int i=0; i<N; i++){
			long a = sc.nextLong();
			if(dp.contains(a)){
				dp.remove(a);
			}else{
				dp.add(a);
			}
		}
		sc.close();

		System.out.println(dp.size());
		
	}

}

Measured memory_bytes: 63144
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

vector<int> count_divisor(int n) {
    vector<int> divisors;
    for(int i = 2; i <= (int)sqrt(n) + 1 ; ++i) {
        if (n % i == 0) {
            divisors.push_back(i);
            while (n % i == 0)
                n /= i;
        }
    }
    if (n > 1)
        divisors.push_back(n);
    return divisors;
}

signed main() {
    int a, b;
    cin >> a >> b;
    int d = __gcd(a, b);
    int result = count_divisor(d).size() + 1;
    cout << result << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define repdown(i, j, k) for(int (i)=(j);(i)>=(j);(i)--)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using ll = long long;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;

const int Mod = 1e9 + 7;
const int max_n = 3 * 1e5 + 1;
const int max_m = 83 * 1e5 + 1;
const ll INF = 10241024;
long double INFD = 100100100;

//_________template______________
inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

//_____________________array calc____________________________________//
/*
vvi mul(vvi &A, vvi &B){
  vvi C(A.size(), vi(B.size()))
  rep(i,A.size()){
    rep(j,B.size()){
      rep(k,B[0].size()){
        C[i][j] = (C[i][j] A[i][k] + B[k][j]) % Mod;
      }
    }
  }

  return C;
}

vvi pow(vvi A, ll n){
  vvi B(A.size(), vi(A.size()));
  rep(i=0;i<A.size();i++){
    B[i][i] = 1;
  }

  while (n >0){
    if (n & 1) B = mul(B, A);
    A = mul(A, A);
    n = n >> 1;
  }
  return B;
}
*/
//_____________________Bynary Indexed Tree __________________________//
/*
const max_st = (1 << 15) - 1;
int bit[max_st];
int sum (int i){
  int s = 0;
  while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x){
  while(i <= n){
    bit[i] += x;
    i += i & -i;
  }
}
*/
//_____________________　following sorce code_________________________//
int n;
vi mou;
int sum = 0;
void input(){
  IN(n);
  mou.resize(n);
  rep(i,n){
    IN(mou[i+1]);
    sum += mou[i+1];
  }
}

void solve(){
  input();
  for(int i=2;i<n;i += 2){
    sum -= 2*mou[i];
  }
  int x = sum;
  vi ans;ans.pb(x);
  for(int i=1;i<n;i++){
    int y = mou[i] - x/2;
    x = 2*y;
    ans.pb(x);
  }

  rep(i,n){
    OUT(ans[i]);
  }
}

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





Measured memory_bytes: 2296
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

#define repi(i,a,b) for(ll i = (a); i < (b); i++)
#define rep(i, n) for(ll i = 0; i < (n); ++i)

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


int main() {
	vector<vector<int>> mp(201);
	repi(i, 1, 201) {
		mp[i].resize(201);
		repi(j, 1, 201) {
			mp[i][j] = gcd(i, j);
		}
	}
	int K;
	cin >> K;
	ll sum = 0;
	repi(a,1,K+1)
		repi(b, 1, K + 1)
		repi(c, 1, K + 1) {
		sum += mp[mp[a][b]][c];
	}
	cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 305

double f[MAXN][MAXN][MAXN];
double t;
int    n, x, r;
int    a[4];

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

    for(int z = 0; z < MAXN; ++z)
        for(int j = 0; j < MAXN; ++j)
            for(int i = 0; i < MAXN; ++i) {
                if (i + j + z == 0) {
                    f[i][j][z] = 0.0;
                    continue;
                }

                r = n - i - j - z;
                if (r < 0) continue;

                t = 0.0;
                if (i) t += i * 1.0 / n * (1 + f[i - 1][j][z]);
                if (j) t += j * 1.0 / n * (1 + f[i + 1][j - 1][z]);
                if (z) t += z * 1.0 / n * (1 + f[i][j + 1][z - 1]);

                f[i][j][z] = (t + r * 1.0 / n) / (1 - r * 1.0 / n);
                //printf("f(%i, %i, %i) = %.12f  t=%.12f\n", i, j, z, f[i][j][z], t);

            }

    printf("%.12f\n", f[a[1]][a[2]][a[3]]);
    return 0;
}

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


Measured memory_bytes: 3708
#include <stdio.h>
#include <float.h>
 
int main()
{
float x[4], y[4], AB, CD;
int i, j, n;
     
scanf("%d", &n);
for (i = 0; i < n; i++){
for (j = 0; j < 4; j++){
scanf("%f %f", &x[j], &y[j]);
}
         
if (x[1] == x[0]){
AB = DBL_MAX;
}
else {  
AB = (y[1] - y[0]) / (x[1] - x[0]);
}
if (x[3] == x[2]){
CD = DBL_MAX;
}
else {
CD = (y[3] - y[2]) / (x[3] - x[2]);
}
if (AB == CD){
printf("YES\n");
}
else {
printf("NO\n");
}
}
return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[1000000]={},b,max=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b;
    a[b]++;
    a[b+1]++;
    if(b!=0)a[b-1]++;
    if(max<a[b])max=a[b];
    if(max<a[b+1])max=a[b+1];
    if(max<a[b-1])max=a[b-1];
  }
  cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 4224
n=int(input())
a=list(map(int,input().split()))

b=[0]

for i in range(1,n):
    if a[i]>a[i-1]:
        b.append(1)
    else:
        b.append(0)

ans=1000
for j in range(n-1):
    if b[j]==0:
        if b[j+1]==1:
            kabu=ans//a[j]

            ans+=(a[j+1]-a[j])*kabu
    else:
        if b[j+1]==1:
            kabu=ans//a[j]
            ans+=(a[j+1]-a[j])*kabu
print(ans)


Measured memory_bytes: 9208
// 後ろから貪欲に。

#include <bits/stdc++.h>

#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define all(a) (a).begin(),(a).end()

using namespace std;

using ll = long long;
using pii = pair<int, int>;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int T;
    cin >> T;
    while (T--) {
        int N;
        cin >> N;
        vector<pii> v1, v2;
        ll result = 0;
        REP(i, N) {
            int K, L, R;
            cin >> K >> L >> R;
            int D = L - R;
            if (D > 0) {
                v1.emplace_back(K - 1, D);
            } else {
                if (N - K - 1 >= 0) {
                    v2.emplace_back(N - K - 1, -D);
                }
            }
            result += min(L, R);
        }

        function<ll(vector<pii>)> f = [&](vector<pii> v) {
            /*
            REP(i, v.size()) {
                printf("v[%d] = (%d, %d)\n", i, v[i].first, v[i].second);
            }
            */
            sort(all(v));
            ll ret = 0;
            int cnt = 0;
            priority_queue<int> q;
            RREP(i, N) {
                while (!v.empty() && v.back().first == i) {
                    q.push(v.back().second);
                    v.pop_back();
                }
                if (!q.empty()) {
                    ret += q.top();
                    q.pop();
                    ++cnt;
                }
            }
            return ret;
        };

        result += f(v1) + f(v2);
        cout << result << '\n';
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 5932
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()
r = []
b = []
g = []
for i, si in enumerate(s):
    if si == 'R':
        r.append(i + 1)
    elif si == 'G':
        g.append(i + 1)
    elif si == 'B':
        b.append(i + 1)
count = 0
for i in range(n):
    for j in range(i + 1, n):
        k = j + j - i
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            count += 1
print(len(r) * len(g) * len(b) - count)


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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int main(){
    
    int n,m,l;
    cin >> n >> m>> l;
    int a = max({n,m,l}) - min({n,m,l}) ;


    cout << a;

}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            Console.WriteLine(a * b + " " + (a +b )* 2);
        }
    }
}


Measured memory_bytes: 15820
import java.util.Scanner;

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

    long N = scanner.nextInt();
    long A = scanner.nextInt();
    long B = scanner.nextInt();
    long max = A + B * (N - 1);
    long min = A * (N - 1) + B;
    System.out.println(Math.max(0, max - min + 1));
  }
}


Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    int n,k;
    cin >> n >> k;
    k--;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    sort(a.begin(),a.end());
    ll sum=0;
    rep(i,n){
        if(i>=k){
            sum = sum + a[i]%MOD * COM(i,k) % MOD;
            //cout << "i=" << i << " sum=" << sum << endl;
        }
    }
    ll t=0;
    rep(i,n){
        if(n-i-1>=k){
            t = (t + a[i]%MOD * COM(n-i-1,k)%MOD) % MOD;
        }
    }
    //cout << "sum=" << sum << "t=" << t << endl;
    sum = ( sum - t + MOD) % MOD;
    cout << sum << endl;
}

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

const int maxn=110;
const int inf=0x3f3f3f3f;

int main(){
	int n;
	cin>>n;
	int a[maxn];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int ans=inf;
	for(int i=1;i<=100;i++){
		int num=0;
		for(int j=0;j<n;j++){
			num+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,num);
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


int main(void){
	ll N,A,B,v[52],c=0,d=0,e=0;
	double sum=0;
	scanf("%lld%lld%lld",&N,&A,&B);
	reg(i,1,N){
		scanf("%lld",&v[i]);
	}
	sort(v+1,v+N+1);//1-originだから
	reg(i,N-A+1,N){
		sum+=v[i];
	}
	sum /= A;
	reg(i,1,N-A){
		if(v[i]==v[N-A+1])c++;
	}
	reg(i,N-A+1,N){
		if(v[i]>v[N-A+1]){//以上のやつが無ければ例外処理
			e++;
		}else if(v[i]==v[N-A+1]){
			c++;//使える数
			d++;//使う数
		}
	}
	ll dp[51][51];//選んだ,選ばない
	reg(i,1,50)dp[i][0]=1;
	reg(j,1,50)dp[0][j]=1;
	dp[0][0]=0;
	reg(i,1,50){
		reg(j,1,50){
			dp[i][j]=dp[i][j-1]+dp[i-1][j];
		}
	}
	printf("%f\n",sum);
	if(e==0){
		// printf("e==0\n");
		//cCA+cC(A+1)+..cCmin(B,c)
		ll f=0;
		reg(i,A,min(B,c)){
			f+=dp[i][c-i];
			// printf("%d,%lld,%lld\n",i,c-i,dp[i][c-i]);
		}
		printf("%lld\n",f);
	}else{
		printf("%lld\n",dp[d][c-d]);
	}
	return 0;
}

Measured memory_bytes: 256
"use strict"
function main(arg) {
    const [N,M,X] = arg.trim().split("\n")[0].split(" ").map(Number)
    const A = arg.trim().split("\n").slice(1).map(e => e.split(" ").map(Number)).sort((a,b) => {
        return a[0] - b[0]
    })
    // console.log(JSON.stringify(A))
    let total = -1
    for (let i = 1;; i++) {
        let idx = i.toString(2).padStart(N, '0')
        if (idx.length > N) {
            break
        }
        idx = idx.split("").map(Number).reverse()
        let p = new Array(M).fill(0)
        let hasError = false
        let tmp = 0
        for (let j = 0; j < idx.length; j++) {
            if (idx[j] === 0) {
                continue
            }
            for (let k = 0; k < p.length; k++) {
                p[k] += A[j][k + 1]
            }
            tmp += A[j][0]
        }
        p.forEach(e => {
            if (e < X) {
                hasError = true
            }
        })
        if (!hasError) {
            if (total === -1) {
                total = tmp
            }
            total = Math.min(tmp, total)
        }
    }
    console.log(total)
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 33924
#include <iostream>
using namespace std;
int main(){
	int n,total,min=-1;
	cin>>n>>total;
	int tmp;
	for (int i = 0 ; i<n ; i++){
		cin>>tmp;
		if (tmp<min || min==-1)	min=tmp;
		total-=tmp;
	}
	if (total)
		cout<<total/min+n;
	else	cout<<n;
	return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

#define pv(a)	{rep(i,a.size())	cout<<a[i]<<" "; cout<<endl;}
#define mark(v)	cout<<"Here--"<<v<<endl;

const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
ll w[100005],c[100005],dp[101][100005];
ll n , C;
ll solve(ll type,ll weight){
   if(type==n+1)
      return 0;

   if(weight==0)
      return 0;
   
   if(dp[type][weight]!=-1){
      return dp[type][weight];
   }

   if( w[type] > weight )
      return solve(type+1,weight);
   else{
      dp[type][weight] = max(solve(type+1,weight),c[type]+solve(type+1,weight-w[type]));
      return dp[type][weight];
   }

}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout << setprecision(12);

	
	cin >> n >> C;
   memset(dp,-1,sizeof(dp));
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> c[i];
	}
   ll ans = solve(1,C);
	cout << ans;
   return 0;
}  

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

namespace AGC034
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int A = input[1] - 1;
            int B = input[2] - 1;
            int C = input[3] - 1;
            int D = input[4] - 1;
            string s = Console.ReadLine();

            if (C < D || C < B)
            {
                int index = B;
                int goal = D;
                int count = 0;
                while (count < 2)
                {
                    while (index < goal)
                    {
                        if (index + 2 < s.Length && s[index + 2] == '.') { index += 2; }
                        else if (index + 1 < s.Length && s[index + 1] == '.') { index += 1; }
                        else { Console.WriteLine("No"); return; }
                    }
                    count++;
                    index = A;
                    goal = C;
                }
                Console.WriteLine("Yes");
            }
            else
            {
                for (int i = B; i <= D; i++)
                {
                    if (i + 1 < s.Length && s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') { Console.WriteLine("Yes"); return; }
                }
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13792
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<set>
#define sqr(x) (x)*(x)
using namespace std;
string st;
int n,m,i,j,nxt[1000005],l[1000005],r[1000005],ans;
void getnxt(string st)
{
	int i,j=0;
	for (i=2;i<st.length();i++)
	{
		while (j&&st[i]!=st[j+1]) j=nxt[j];
		if (st[i]==st[j+1]) j++;
		nxt[i]=j;
	}
}
set<char> used;
int main()
{
	cin>>st;
	st=" "+st; 
	for (i=1;i<st.length();i++) used.insert(st[i]);
	if (used.size()==1)
	{
		cout<<st.length()-1<<endl<<1;
		return 0;
	}
	getnxt(st);
	for (i=1;i<st.length()-1;i++)
	{
		j=i-nxt[i];
		if (i!=j&&i%j==0)
		{
			l[i]=1;
		}
	}
	i=st.size()-1;
	j=i-nxt[i];
	if (i!=j&&i%j==0);
	else
	{
		cout<<1<<endl<<1;
		return 0;
	}
	reverse(st.begin()+1,st.end());
	getnxt(st);
	for (i=1;i<st.length();i++)
	{
		j=i-nxt[i];
		if (i!=j&&i%j==0)
		{
			r[i]=1;
		}
	}
	reverse(r+1,r+st.length());
	for (i=1;i<st.length()-1;i++)
	{
		if ((!(l[i]))&&(!(r[i+1]))) ans++;
	}
	cout<<2<<endl<<ans;
	return 0;
}


Measured memory_bytes: 11416
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//素数かどうかを判定する関数.
int isprime(long long int n){
	if (n == 1) return 0;
    for (long long int i=2;i*i <= n;i++){
        if (n % i == 0) return 0;
    }
    return 1;
}
int main()
{
	int n, k;
	cin >> n >> k;
	int r, s, p;
	cin >> r >> s >> p;
	string t;
	cin >> t;
	vector<string> ds(k);
	rep(i,t.size()){
		ds[i % k] += t[i];
	}
	long long int ans = 0;
	//r:0,s:1,p:2
	rep(i, ds.size())
	{
		vector<vector<long long int>> dp(ds[i].size(), vector<long long int>(3, 0));
		if (ds[i][0] == 'r')
			dp[0][2] = p;
		if (ds[i][0] == 's')
			dp[0][0] = r;
		if (ds[i][0] == 'p')
			dp[0][1] = s;

		rep(j,ds[i].size() - 1){
			if(ds[i][j+1] == 'r'){
				dp[j + 1][0] = max(dp[j][1], dp[j][2]);
				dp[j + 1][1] = max(dp[j][0], dp[j][2]);
				dp[j + 1][2] = max(dp[j][0] + p, dp[j][1] + p);
			} else if (ds[i][j+1] == 's'){
				dp[j + 1][0] = max(dp[j][1] + r, dp[j][2] + r);
				dp[j + 1][1] = max(dp[j][0], dp[j][2]);
				dp[j + 1][2] = max(dp[j][0], dp[j][1]);
			} else {
				dp[j + 1][0] = max(dp[j][1], dp[j][2]);
				dp[j + 1][1] = max(dp[j][0] + s, dp[j][2] + s);
				dp[j + 1][2] = max(dp[j][0], dp[j][1]);
			}
		}
		ans += max({dp[ds[i].size() - 1][0], dp[ds[i].size() - 1][1], dp[ds[i].size() - 1][2]});
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == 5 && b == 5 && c == 7){
        cout << "YES" << endl;
    }else if(a == 7 && b == 5 && c == 5){
        cout << "YES" << endl;
    }else if(a == 5 && b == 7 && c == 5){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define mem(a, v) memset(a, v, sizeof(a))
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> matrix;
const ll MOD = 1000000007LL;

bool dp[100100];
set<string> S;

int main()
{
    S.insert("erase");
    S.insert("eraser");
    S.insert("dream");
    S.insert("dreamer");
    string str;
    cin>>str;
    str = '#' + str;
    dp[0] = 1;
    int n = str.length();
    for(int i=1; i<n; i++) {
        string tmp = "";
        if(i - 4 >= 1) {
            for(int j=i-4; j<=i; j++) {
                tmp += str[j];
            }
            if(S.count(tmp)) dp[i] |= dp[i-5];
        }
        tmp = "";
        if(i - 5 >= 1) {
            for(int j=i-5; j<=i; j++) {
                tmp += str[j];
            }
            if(S.count(tmp)) dp[i] |= dp[i-6];
        }
        tmp = "";
        if(i - 6 >= 1) {
            for(int j=i-6; j<=i; j++) {
                tmp += str[j];
            }
            if(S.count(tmp)) dp[i] |= dp[i-7];
        }
    }       
    if(dp[n-1]) cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}

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

using namespace std;
typedef long long int ll;

#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll l, r;
    cin >> l >> r;
    if (r - l >= 2019)
    {
        cout << 0 << endl;
    }
    else if (r % 2019 <= l % 2019)
    {
        cout << 0 << endl;
    }
    else 
    {
        ll min = 3000;
        for (ll i = l; i < r; i++)
        {
            for (ll k = i + 1; k <= r; k++)
            {
                if (i * k % 2019 < min)
                {
                    min = i * k % 2019;
                }
            }
            
        }
        cout << min << endl;
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

int main(){
	ll N,M; cin>>N>>M;
    
	printf("%.5f",N/(double)M);
}

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

int main() {
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
   
  if (N <= K){
   cout << N * X << endl;
  }
  
  else {
    cout << K * X + (N-K) * Y << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
S = input()
ans = 0

for i in range(N - 1):
	# 文字列を2つに分割する
	S1 = S[:i + 1]
	S2 = S[i + 1:]
	s = []
	count = 0

	# S1に存在する文字がS2に存在する場合、その文字をlistに格納する
	for j in range(i + 1):
		if S2.count(S1[j]) != 0:
			s.append(S1[j])

 	# list内の文字種数を算出する
	count = len(set(s))

	# 文字種数がいままでの最大数より大きい場合は入れ替える
	ans = max(ans, count)

print(ans)

Measured memory_bytes: 3064
import sys
cap=int(input())
word_list=[str(input()) for i in range(cap)]

#check Duplication
li_uniq = list(set(word_list))
if( not len(li_uniq)==len(word_list) ):
    print ('No')
    sys.exit()
lastc=word_list[0][0:1]
for string in word_list:
    if(not string[0:1]==lastc):
        print('No')
        sys.exit()
    lastc = string[-1:]
print('Yes')


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

#define M 1046527
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
}
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n;
	cin >> n;

	int p[n+1];
	rep(i,n) cin >> p[i+1];

	int ans = 0;

	FOR(i,1,n){
		if(i == p[i]){
			swap(p[i],p[i+1]);
			ans++;
		}
	}

	if(n == p[n]) {
		swap(p[n-1],p[n]);
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main() {
	int sX, sY, tX, tY;
	scanf("%d%d%d%d", &sX, &sY, &tX, &tY);
	for (int i = 0; i < tY - sY; i++) {
		printf("U");
	}
	for (int i = 0; i < tX - sX; i++) {
		printf("R");
	}
	for (int i = 0; i < tY - sY; i++) {
		printf("D");
	}
	for (int i = 0; i < tX - sX + 1; i++) {
		printf("L");
	}

	for (int i = 0; i < tY - sY + 1; i++) {
		printf("U");
	}
	for (int i = 0; i < tX - sX + 1; i++) {
		printf("R");
	}
	printf("DR");
	for (int i = 0; i < tY - sY + 1; i++) {
		printf("D");
	}
	for (int i = 0; i < tX - sX + 1; i++) {
		printf("L");
	}
	printf("U\n");
	return 0;
}

Measured memory_bytes: 384
import numpy as np 

N, W = map(int, input().split())
w_all = np.zeros(W + 1, dtype=int)

for i in range(N):
  w, v = map(int, input().split())
  w_all[w:] = np.maximum(w_all[w:], w_all[:-w] + v)

print(w_all[W])


Measured memory_bytes: 22272