akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

struct dice{
    int l[6];
    void roll(int a, int b){
        int t = l[0];
        l[0] = l[a];
        l[a] = l[5];
        l[5] = l[b];
        l[b] = t;}
    void north(){
        roll(1, 4);}
    void south(){
        roll(4, 1);}
    void east(){
        roll(3, 2);}
    void west(){
        roll(2, 3);}
    void dir(char a){
        if (a == 'N') north();
        if (a == 'S') south();
        if (a == 'E') east();
        if (a == 'W') west();}
};

int main(){
    dice d;
    REP(i, 6) cin >> d.l[i];
    string s;
    cin >> s;
    REP(i,s.size()) d.dir((char)s[i]);
    cout << d.l[0] << endl;
}

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

int main(){
	int i, j, h, w;
	
	while(1){
		cin >> h >> w;
		if ( h == 0 && w == 0 ) break;
		
		for( i = 0; i < h; i++ ){
			for ( j = 0; j < w; j++ ){
				if ( ( i + j ) % 2 == 0 || ( i == 0 && j == 0 )) 
					cout << "#";
				else 
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N, A, B;
	cin >> N >> A >> B;

	ll saidai = (ll)A * B;
	int saishou = A + B - 1;
	if (N < saishou || N > saidai) {
		co(-1);
		return 0;
	}
	
	int amari = N - B;
	vector<int> K;
	rep(i, B) {
		int kari = min(A - 1, amari);
		K.pb(kari);
		amari -= kari;
	}

	rep(i, B) {
		rep(j, K[i] + 1) {
			cosp(N - K[i] + j);
		}
		N -= K[i] + 1;
	}

	Would you please return 0;
}

Measured memory_bytes: 2932
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int last[40];
int s[400][400];
int c[26];
int d;
int calc(vector<int> &t){
    int ret = 0;
    
        rep(i,d){
            //use t[i];
            ret += s[i][t[i]-1];
            last[t[i]-1] = i+1;
            rep(j,26){
                ret -= c[j]*(i+1-last[j]);
            }
            
    
    
    
                    
        }
        return ret;

}
signed main(){
    cin >> d;
    rep(i,26)cin >> c[i];
    vector<int> ans(d);
    vector<int> t(d);
    rep(i,d)rep(j,26)cin >> s[i][j];
    int cnt = 0;
    int res = 0;
    while(cnt < 100000){
        rep(i,d){
            t[i] = (rand()%26)+1;
        }
        
        if(res < calc(t)){
            res = max(res,calc(t));
            rep(i,d)ans[i] = t[i];
        }
        cnt++;
    }
    rep(i,d)cout << ans[i] << endl;
  //cout << calc(ans) << endl;
    return 0;
}


Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	Int a; cin >> a;
	Int b, c;
	scanf("%lld.%lld", &b, &c);
	Int d = 100*b + c;
	cout << a * d / 100 << "\n";
}

Measured memory_bytes: 3772
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

int t[32][32];
typedef pair<int, int> P;

int main()
{
	int N;
	
	while (scanf("%d", &N) && N){
		for (int i = 0; i < N; i++)
			for (int j = 0; j <= N; j++)
				scanf("%d", &t[i][j]);
		
		bool done[1 << 17] = {0}; //今までどのアイテムを入手したかをbit で.
		
		N++;
		priority_queue<P, vector<P>, greater<P> > pq;
		
		
		for (pq.push(P(0, 1)); pq.size(); pq.pop()){
			P x = pq.top();
			
			if (x.second == (1 << N) - 1){
				printf("%d\n", x.first);
				break;
			}
			
			if (done[x.second]) continue;
			done[x.second] = true;
			
			for (int i = 1; i < N; i++){
				int cand = -1;
				if (!(x.second >> i & 1)){
					for (int j = 0; j < N; j++){
						if (x.second >> j & 1 && (cand == -1 || t[i - 1][cand] > t[i - 1][j])){
							cand = j;
						}
					}
					pq.push(P(x.first + t[i - 1][cand], x.second | (1 << i)));
				}
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    for(int i = 0; i < s.size(); i++){
        string tmp = s[n - 1] + s.substr(0, n - 1);
        s = tmp;
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

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

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll A, B, K;
  cin >> A >> B >> K;
  ll di = min(A, K);
  B -= (K - di);
  A -= di;
  cout << A << " " << max(0LL, B) << endl;
  return 0;
}

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

int main(){

    int n,k;

    while(cin>>n>>k){
        for(int i=0;i<n;i++)
        {
            int a;
            cin>>a;
        }
        int ans;
        if((n-k)%(k-1))
        {
            ans=((n-k)/(k-1))+1;
        }
        else
        {
            ans=(n-k)/(k-1);
        }
        cout<<ans+1<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
n = int(input())
m = 1000000000000000000
num_list = [ int(v) for v in input().split() ]
ans = 1
s = 0
if 0 in num_list:
	ans = 0
for i in num_list:
	ans *= i
	if ans > m:
		s = 1
		break
if s == 0:
	print(ans)
else:
  	print(-1)

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


using namespace std;

int main(){
    int N,a, c_one=0;
    scanf("%d", &N);
    vector<int> A;
    vector<int> max_c;
    for(int i=0;i<N;i++){ 
        scanf("%d", &a);
        A.push_back(a);
    }

    for(int i=0;i<A.size();i++){
        if(A[i]==1) c_one++;
        if(A[i+1]!=1){
            max_c.push_back(c_one);
            c_one = 0;
        }
    }

    printf("%d\n",*max_element(max_c.begin(),max_c.end())+1);

    return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int s, w;
	cin >> s >> w;
	if (s <= w) cout << "unsafe" << '\n';
	else cout << "safe" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
 int N, x, y, b, p;
 cin >> N;
 for(int i = 0; i < N; ++i) {
 cin >> x >> y >> b >> p;
 cout << min(x*b+y*p, (x*max(b,5)+y*max(p,2))*4/5) << endl;
 }
 return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define all(v) (v).begin(),(v).end()
#define endl '\n'
#define int long long
const int INF = (1 << 30);
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
    bool hcao[(int)1e5+5] = {};
    bool hctk[(int)1e5+5] = {};
    bool hc[(int)1e5+5] = {};
void solve(){
    int n;
    cin >> n;
    vi tk(n), ao(n), hoge(n);

    REP(i,n){
        cin >> tk[i];
        if(i && tk[i] != tk[i-1]) hctk[i] = true;
    }
    REP(i,n){
        cin >> ao[i];
        if(i && ao[i] != ao[i-1]){
            hcao[i] = true;
        }
    }
    hcao[0]=hcao[n]=hctk[0]=hctk[n]=true;
    REP(i,n){
        hoge[i] = min(tk[i], ao[i]);
        if(i && hoge[i] != hoge[i-1]){
            hc[i] = true;
        }
    }
    int ans = 1;
    REP(i,n){
        if(hctk[i] && hcao[i+1]){
            if(tk[i] != ao[i]){
                cout << 0 << endl;
                return;
            }
        }
        else if(hctk[i] && !hcao[i+1]){
            if(tk[i] > ao[i]){
                cout << 0 << endl;
                return;
            }
        }
        else if(!hctk[i] && hcao[i+1]){
            if(tk[i] < ao[i]){
                cout << 0 << endl;
                return;
            }
        }
        else{
            ans *= hoge[i];
            ans %= (int)1e9+7;
        }
    }
    cout << ans << endl;
}

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

    solve();
}



Measured memory_bytes: 2816
n,t=map(int,input().split())
l=[[0,0] for _ in range(n)]

for i in range(n):
    l[i][1],l[i][0]=map(int,input().split())
l.sort()
p=[]
for i in range(n):
    if l[i][0]<=t:
        p.append(l[i][::-1])
if len(p)==0:
    print('TLE')
else:
    p.sort()
    print(p[0][0])   

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
int n, a;
vector<int> b, ans;
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a;
        b.push_back(a);
    }
    while(b.size() != 0)
    {
        bool jud = false;
        for (int i = b.size() - 1; i >= 0; i--)
        {
            if (b[i] == i + 1)
            {
                ans.push_back(b[i]);
                b.erase(b.begin() + i);
                jud = true;
                break;
            }
        }
        if (!jud)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i = ans.size() - 1; i >= 0; i--)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] board = new char[h][w];
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < w; j++) {
                board[i][j] = str.charAt(j);
            }
        }
        
        boolean[] ngh = new boolean[h];
        for (int i = 0; i < h; i++) {
            boolean ng = true;
            for (int j = 0; j < w; j++) {
                if (board[i][j] == '#') {
                    ng = false;
                }
            }
            
            if (ng) {
                ngh[i] = true;
            }
        }
        boolean[] ngw = new boolean[w];
        for (int i = 0; i < w; i++) {
            boolean ng = true;
            for (int j = 0; j < h; j++) {
                if (board[j][i] == '#') {
                    ng = false;
                }
            }
            
            if (ng) {
                ngw[i] = true;
            }
        }
        
        for (int i = 0; i < h; i++) {
            if (ngh[i]) continue;
            for (int j = 0; j  <w; j++) {
                if (ngw[j]) continue;
                System.out.print(board[i][j]);
            }
            System.out.println();
        }
        
    }
}

Measured memory_bytes: 24852
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int c=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]%2==1 && i%2==1)
        {
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3640
# Author: cr4zjh0bp
# Created: Sun Mar  1 11:52:26 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from math import ceil

n = ni()

print(ceil(n / 2))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

vector< string> v {"dream", "dreamer", "erase", "eraser"};

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    for(auto& w: v) {
        reverse(w.begin(), w.end());
    }

    for(size_t i = 0; i < s.size(); ) {
        size_t j = i;
        for(auto w: v) {
            size_t pos = s.find(w, i);
            if(pos == i) {
                i += w.size();
                break;
            }
        }
        if(i == j) return !printf("NO\n");
    }

    puts("YES");
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n),b(n),c(m),d(m);
    rep(i,0,n) cin >> a[i] >> b[i];
    rep(i,0,m) cin >> c[i] >> d[i];
    rep(i,0,n){
        int mi=inf,idx=-1;
        rep(j,0,m){
            if(idx==-1 or mi>abs(a[i]-c[j])+abs(b[i]-d[j])){
                idx=j;
                mi=abs(a[i]-c[j])+abs(b[i]-d[j]);
            }
        }
        cout << idx+1 << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int n;
char s[110];
int a[110];
int main(void)
{
	scanf("%s", s);
	n = strlen(s);
	for (int i = 0; i < n; i++)
	{
		a[s[i] - 'a']++;
	}
	if (n < 26)
	{
		printf("%s", s);
		for (int i = 0; i < 26; i++)
		{
			if (!a[i])
			{
				printf("%c\n", i + 'a');
				return 0;
			}
		}
	}
	a[s[25]-'a']--;
	for (int i = 24; i >= 0; i--)
	{
		a[s[i]-'a']--;
		if (s[i] < s[i + 1])
		{
			for (int j = 0; j < i; j++)
			{
				printf("%c", s[j]);
			}
			for (int j = s[i]+1-'a'; j < 26; j++)
			{
				if (!a[j])
				{
					printf("%c\n", j + 'a');
					return 0;
				}
			}
		}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int n = sc.nextInt();

        int x = n % 10;
        switch (x) {
            case 3:
                System.out.println("bon");
                break;
            case 0:
            case 1:
            case 6:
            case 8:
                System.out.println("pon");
                break;
            default:
                System.out.println("hon");
                break;
        }
    }
}


Measured memory_bytes: 35720
N = int(input())

tNow = 1
aNow = 1

for i in range(N) :
    t, a = map(int, input().split())

    n = max(-(-tNow // t), -(-aNow // a))

    tNow = n * t
    aNow = n * a

print(tNow + aNow)

Measured memory_bytes: 3060
def dis(p1,p2):
  return ((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)**0.5
 
n=int(input())
p=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  for j in range(i+1,n):
    ans+=dis(p[i],p[j])
print(ans*2/n)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include<iomanip>
#include<bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
/*bool isPrime(long long n) 
{ long long i;
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false;
  
    return true; 
}

long long factorial(long long n) 
{    if(n==0||n==1)
     return 1;
     else
     return n*factorial(n - 1);  
} 

long long binarySearch(long long arr[], long long l, long long r, long long x) 
{ 
    while (l <= r) { 
        long long  m = l + (r - l) / 2; 
  
        
        if (arr[m] == x) 
            return m; 
  
      
        if (arr[m] < x) 
            l = m + 1; 
  
       
        else
            r = m - 1; 
    } 
    return -1; 
} 
*/
int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s;
    cin>>t;
    ll s1=s.size();
    ll i,j,c=0;
    for(i=0;i<s1;i++)
    { if(s[i]!=t[i])
      {
       c++;
      }
     else 
       continue;
    }
 cout<<c<<endl;
   
    return 0;
}

Measured memory_bytes: 3812
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;

void next_day(int &y, int &m, int &d) {
  if (y%3) {
    if (m%2) { // 大の月
      if (d == 20) {
	d = 1;
	m++;
      }else {
	d++;
      }
    }else { // 小の月
      if (d == 19 && m == 10) {
	y++;
	d = 1;
	m = 1;
      }else if (d == 19) {
	d = 1;
	m++;
      }else {
	d++;
      }
    }   
  }else {
    if (d == 20 && m == 10) {
      y++;
      d = 1;
      m = 1;
    }else if (d == 20) {
      d = 1;
      m++;
    }else {
      d++;
    }
  }
}

bool check(int y, int m, int d) {
  return y == 1000 && m == 1 && d == 1;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int y, m, d;
    cin >> y >> m >> d;
    int ans = 0;
    for (; !check(y, m, d); ans++) {
      next_day(y, m, d);
    }
    std::cout << ans << std::endl;
  }

}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <map>
using namespace std;



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

   cout << (1000 - (n % 1000)) % 1000;

   return 0;
}

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

int n,m,q,a[50],b[50],c[50],d[50];
vector <int> A;
int res=0;

int check(){
    int sum=0;
    for (int i=0; i<q; i++){
        if (A[b[i]]-A[a[i]]==c[i]) sum+=d[i];
    }
    return sum;
}

void dfs (int len, int cur){
    if (len==n){
        res=max(res,check());
    }
    else{
        for (int i=cur; i<=m; i++){
            A.push_back(i);
            dfs(len+1,i);
            A.pop_back();
        }
    }
    
    
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>q;
    
    for (int i=0; i<q; i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
    
    dfs(0,1);
    
    cout<<res;
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 3592
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	bs := make([]int, n-1)
	r := 0
	for i := range bs {
		fmt.Scan(&bs[i])
	}
	if n == 2 {
		fmt.Println(bs[0] * 2)
	} else {
		r += bs[0]
		r += bs[n-2]
		for i := 1; i < n-1; i++ {
			r += min01(bs[i-1], bs[i])
		}
		fmt.Println(r)
	}
}

func min01(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 512
import Data.List

factor :: Int -> [Int]
factor 1 = []
factor n = (prime:) . factor $ n `div` prime
  where divisors = dropWhile ((/=0) . mod n) [2..ceiling . sqrt $ fromIntegral n]
        prime = if null divisors
                then n
                else head divisors

main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine
  print . (+1) . length . group . factor $ gcd a b


Measured memory_bytes: 892
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    int a,b,c;
    string s;
    cin >> a>>b;
    cout << max(a+b,max(a-b,a*b))<<endl;;
    
    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  int l = 0, r = 1001001001;
  while (r - l > 1) {
    int c = (l + r) / 2;
    long long cnt = 0;
    for (int i = 0; i < n; i++) cnt += a[i] / c;
    (cnt <= k ? r : l) = c;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 3976
/*
{

AuThOr Gwj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n=200000+20;
string s[200000+20];
int son[1000000+1][27],cnt[1000000+1][27],old[1000000+1][27];
int root=0;
int cnt_=0;
int have[27];
void go(int now,int is,int t){
	if(is==s[t].length()) return;
	if(son[now][s[t][is]]){
	if(have[s[t][is]]==1){
		old[son[now][s[t][is]]][s[t][is]]++;
		cnt[son[now][s[t][is]]][s[t][is]]++;
	}
	have[s[t][is]]--;
		go(son[now][s[t][is]],is+1,t);
	}
	else{
		son[now][s[t][is]]=++cnt_;
	if(have[s[t][is]]==1){
		old[son[now][s[t][is]]][s[t][is]]++;
		cnt[son[now][s[t][is]]][s[t][is]]++;
	}
	have[s[t][is]]--;
		go(son[now][s[t][is]],is+1,t);
	}	
}
void calc(int now){
	rb(i,1,26){
		if(son[now][i]){
			calc(son[now][i]);
			rb(k,1,26)
				cnt[now][k]+=cnt[son[now][i]][k];
		}
	}
}
int rest(int now,int is,string& s_,int need){	
	if(is==s_.length()) return cnt[now][need]-old[now][need]-1;
	return rest(son[now][s_[is]],is+1,s_,need);
}
int main(){
	fastio;
	R(n);
	rb(i,1,n){
		rb(j,1,26)
			have[j]=0;
		R(s[i]);
		reverse(ALL(s[i]));
		rep(j,s[i].length()){
			s[i][j]-='a'-1;
		}
		rb(j,0,s[i].length()-1)
			have[s[i][j]]++;
		go(root,0,i);
	}	
	calc(root);
	LL res=0;
	rb(i,1,n){
		string ss="";
		rep(j,s[i].length()){
			if(j!=s[i].length()-1) ss+=s[i][j];
		}
		res+=rest(root,0,ss,s[i][s[i].length()-1]);	
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 314572
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int K;
    vector<int> x(3);
    cin >> x[0] >> x[1] >> x[2];
    cin >> K;
    sort(x.begin(), x.end(), greater<int>());

    for (int i = 0; i < K; i++)
    {
        x[0] *= 2;
    }

    cout << x[0] + x[1] + x[2] << endl;

    return 0;
}

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

arr = [int(i) for i in input().split()]

comp_arr = []
for i in range(n):
    comp_arr.append(i+1)

sub_num = 0

for i in range(n):
    if comp_arr[i] != arr[i]:
       sub_num = sub_num + 1

if sub_num <= 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <cstdio>

#define LL long long

using namespace std;

inline LL read() {
    LL x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int k, num[20], lim = 1;
bool vis[20];

void dfs(int j) {
    lim = max(lim, j);
    if(num[j] > num[j + 1]) {
        if(lim == j && num[j] < 9) ++num[j];
        else dfs(j + 1), num[j] = num[j + 1] ? num[j + 1] - 1 : 0;
    }
    else if(num[j] == num[j + 1] - 1) {num[j] = num[j + 1]; return;}
    else {
        if(num[j] < 9) {num[j] = num[j + 1] + 1; return;}
        else dfs(j + 1), num[j] = num[j + 1] ? num[j + 1] - 1 : 0;
    }
}

void output() {
    bool lead = 1;
    for(int j = 12; j; --j) {
        if(lead && !num[j]) continue;
        else {
            lead = 0;
            cout << num[j];
        }
    }
    cout << endl;
}

int main() {
    k = read();
    for(int i = 1; i <= k; ++i) dfs(1);
    output();
    return 0;
}

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

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  vector< vector<int64_t> > a(n, vector<int64_t>(m));
  vector< vector<int64_t> > b(m, vector<int64_t>(l));
  vector< vector<int64_t> > c(n, vector<int64_t>(l));

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) cin >> a.at(i).at(j);
  }
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < l; j++) cin >> b.at(i).at(j);
  }

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < l; j++) {
      for(int k = 0; k < m; k++) {
        c.at(i).at(j) += a.at(i).at(k) * b.at(k).at(j);
      }
    }
  }
  
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < l; j++) {
      if(j < l - 1) cout << c.at(i).at(j) << " ";
      else cout << c.at(i).at(j) << endl;
    }
  }
}


Measured memory_bytes: 3292
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        String s;
        int n,tmp;
        boolean flag;
        flag=true;
        s=scan.next();
        n=s.length();
        for(int i=0;i<n/2;i++){
            if(s.charAt(i)!=s.charAt(n-i-1)){
                flag=false;
                break;
            }
        }
        if(flag==true){
            tmp=(n-1)/2;
            for(int i=0;i<tmp/2;i++){
                if(s.charAt(i)!=s.charAt(tmp-i-1)){
                    flag=false;
                    break;
                }
            }
        }
        if(flag==true){
            tmp=(n+3)/2;
            for(int i=tmp-1;i<(n-tmp)/2;i++){
                if(s.charAt(i)!=s.charAt(n-1-i)){
                    flag=false;
                    break;
                }
            }
        }
        if(flag==true) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
signed main() {
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  vector<int> lower(N), upper(N);
  REP(i,N) {
    upper[i] = lower[i] = i;
  }
  vector<pair<int, int>> B;
  REP(i,M) {
    int a, b; cin >> a >> b;
    b--;
    B.emplace_back(a, b);
  }
  sort(B.begin(), B.end());
  for(const auto &item : B) {
    int k = item.second;
    upper[k] = upper[k + 1] = max(upper[k], upper[k + 1]);
    lower[k] = lower[k + 1] = min(lower[k], lower[k + 1]);
  }
  REP(i,N) {
    if(i > 0) cout << ' ';
    cout << upper[i] - lower[i] + 1;
  }
  cout << endl;
}

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

int main(){
    int startNum, endNum;
    cin >> startNum >> endNum;
    int count = 0;
    for(int i = startNum; i <= endNum; i++){
        string str = to_string(i);
        string str_rev = {str[4], str[3], str[2], str[1], str[0]};
        if( str == str_rev) count++;
    }
    cout << count <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  ll n; cin >> n;
  vector<ll> a(n),b(n);
  vector<pair<ll,ll>> task;
  rep(i,n){
    ll a,b; cin >> a >> b;
    pair<ll,ll> p = make_pair(b,a);
    task.push_back(p);
  }

  sort(all(task));

  ll time = 0;

  bool ans = true;

  rep(i,n){
    ll a = task.at(i).second,b = task.at(i).first;
    if(time + a > b) ans = false;
    time += a;
  }

  if(ans) puts("Yes");
  else puts("No");
}


Measured memory_bytes: 10564
#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 all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    constexpr int mod = 2019;
    int l, r; cin >> l >> r;

    if(r / mod - l / mod >= 1) {
        cout << 0 << endl;
    } else {
        l %= mod; r %= mod;

        int ans = mod + 1;
        FOR(i, l, r+1)FOR(j, i+1, r+1) {
            ans = min(ans, i * j % mod);
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> from(N);
    vector<int> to(N);
    REP(i, M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        if(a==0)from[b] = 1;
        if(b==N-1)to[a] = 1;
    }
    bool res = false;
    REP(i, N)if(from[i] && to[i])res = true;
    cout << (res ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
const double EPS = 1e-9;

bool eq(double a, double b) {
	return abs(a - b) < EPS;
}

int main(void) {
	int x[2], y[2], r[2];
	for (int i = 0; i < 2; i++) cin >> x[i] >> y[i] >> r[i];
	double d = sqrt(pow(x[1] - x[0], 2) + pow(y[1] - y[0], 2));
	if (d > r[0] + r[1]) cout << 4 << endl;
	else if(eq(d, r[0] + r[1])) cout << 3 << endl;
	else {
		int r_small = min(r[0], r[1]);
		int r_large = max(r[0], r[1]);
		if (eq(r_small + d, r_large)) cout << 1 << endl;
		else if (r_small + d > r_large) cout << 2 << endl;
		else cout << 0 << endl;
	}
}

// r0 + r1 > d ==> r0 - d


Measured memory_bytes: 3116
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int A = in.nextInt();
        int B = in.nextInt();

        String S = in.next();

        if (isPostCode(S, A, B))
        System.out.println("Yes");
        else
            System.out.println("No");
    }
    public static boolean isPostCode(String s, int a, int b) {
        if (s == null || s.length() == 0) return false;
        if (s.length() != a + b + 1) return false;
        if (a < 1 || a > 5) return false;
        if (b < 1 || b > 5) return false;
        if (s.charAt(a) != '-') return false;
        for (int i = 0; i < a; i++) {
            int c = s.charAt(i) - '0';
            if (c < 0 || c > 9) return false;
        }
        for (int i = a + 1; i < s.length(); i++) {
            int c = s.charAt(i) - '0';
            if (c < 0 || c > 9) return false;
        }
        return true;
    }
}

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

data = [["",0,0] for i in range(n)]

for i in range(n):
  data[i][0], data[i][1] = input().split()
  data[i][1] = int(data[i][1])
  data[i][2] = i+1

#print(data)

data = sorted(data, key=lambda x: x[1],reverse=True)
data = sorted(data, key=lambda x: x[0])

for i in range(n):
  print(data[i][2])

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

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

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

    for(int i=0; i<n; i++){
        for(int j=i; j<n; j++){
            maximum = max(maximum, abs(a[i] - a[j]));
        }
    }

    cout << maximum << endl;
    return 0;
}

Measured memory_bytes: 256
/*
	Bakul Gaur (caesar1551)
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PrePro ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,n) for(ll i = 0; i < n; i++)
#define fre(i,a,b) for(ll i = a; i <= b; i++)
#define fb(i,n) for(ll i = n; i >= 0; i--)
#define fbe(i,a,b) for(ll i = a; i >= b; i--)
#define umap(x,y) unordered_map<x,y>
#define uset(x) unordered_set<x>
#define vv(x) vector<x>
#define pp(x,y) pair<x,y>
#define prar(a,n) fr(i,n){cout << a[i] << " ";}
#define inar(a,n) fr(i,n){cin >> a[i];}
#define mk make_pair
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define MAX 301
inline ll gcd(ll a, ll b){
	if(b == 0){
		return a;
	}
	return gcd(b,a%b);
}
inline ll pwr(ll a, ll b, ll modulo = mod){
	if(a == 0 && b == 0){
		return 0;
	}
	ll ans = 1;
	while(b > 0){
		if(b&1){
			ans = ((ans%modulo) * (a%modulo))%modulo;
		}
		b >>= 1;
		a = ((a%modulo) * (a%modulo))%modulo;
	}
	return (ans+modulo)%modulo;
}
inline ll modInverse(ll a, ll p){
	// Only if p is prime.
	return pwr(a,p-2,p);
}



/* #############
   START SOLVING 
   ############# */

double dp[MAX][MAX][MAX];

double helper(ll &n, ll one, ll two, ll three){
	if(one < 0 || two < 0 || three < 0){
		return 0;
	}
	if(one == 0 && two == 0 && three == 0){
		return 0;
	}
	if(dp[one][two][three] > 0){
		return dp[one][two][three];
	}
	ll to_divide = one + two + three;
	double get_val = n + one*helper(n,one-1,two,three) + two*helper(n,one+1,two-1,three) + three*helper(n,one,two+1,three-1);
	return dp[one][two][three] = get_val/to_divide;
}

void solve(){
	ll n;
	cin >> n;
	ll one = 0, two = 0, three = 0;
	fr(i,n){
		ll num;
		cin >> num;
		if(num == 1){
			one++;
		}
		else if(num == 2){
			two++;
		}
		else{ 
			three++;
		}
	}
	memset(dp,-1,MAX*MAX*MAX*sizeof(double));
	cout << fixed << setprecision(10) << helper(n,one,two,three) << endl;
}

int main(){
	PrePro
	/* #ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif */
    ll t = 1;
    // cin >> t;
    fr(i,t){
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    	// cout << endl;
    }
	return 0;
} 

Measured memory_bytes: 216932
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <iomanip>
using namespace std;
typedef complex<double> P;
const double EPS = 1e-10;
#define X real()
#define Y imag()

int conv(double c, vector<double> &a){
    vector<double>::iterator it = lower_bound(a.begin(), a.end(), c);
    return 2*(it -a.begin()) +1;
}

int main(){
    for(int ds=1; ; ds++){
        int n;
        cin >> n;
        if(n==0) break;

        vector<P> a(n);
        vector<double> r(n);
        vector<double> x(2*n), y(2*n);
        for(int i=0; i<n; i++){
            double xin,yin;
            cin >> xin >> yin >> r[i];
            a[i] = P(xin, yin);
            x[2*i] = a[i].X -r[i];
            x[2*i+1] = a[i].X +r[i];
            y[2*i] = a[i].Y -r[i];
            y[2*i+1] = a[i].Y +r[i];
        }
        sort(x.begin(), x.end());
        x.erase(unique(x.begin(), x.end()), x.end());
        sort(y.begin(), y.end());
        y.erase(unique(y.begin(), y.end()), y.end());

        vector<vector<bool> > field(2*x.size()+1, vector<bool>(2*y.size()+1, false));
        for(int i=0; i<n; i++){
            int xa = conv(a[i].X -r[i], x);
            int ya = conv(a[i].Y -r[i], y);
            int xb = conv(a[i].X +r[i], x);
            int yb = conv(a[i].Y +r[i], y);
            for(int j=xa; j<=xb; j++){
                for(int k=ya; k<=yb; k++){
                    field[j][k] = true;
                }
            }
        }

        double ans = 0;
        for(int i=2; i<(int)field.size()-2; i+=2){
            for(int j=2; j<(int)field[0].size()-2; j+=2){
                if(field[i][j]){
                    ans += (x[i/2] -x[i/2-1]) *(y[j/2] -y[j/2-1]);
                }
            }
        }
        cout << fixed << setprecision(2);
        cout << ds << " " << ans << endl;
    }
    return 0;
}



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

int main(){
  int n, a;
  cin >> n;
  map<int, int> mp;
  for(int i = 1; i <= n; i++){
    mp[i] = 0;
  }
  for(int i = 1; i < n; i++){
    cin >> a;
    mp[a]++;
  }
  for(int i = 1; i <= n; i++){
    cout << mp[i] << endl;
  }  
  return 0;
}

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

signed main(){

  string s;
  int k;
  cin>>s>>k;

  int n = s.size();
  auto op = [](char c){
    return 'z'-c+1;
  };
  for(int i=0;i<n;++i){
    if(s[i]!='a'){
      if(op(s[i])<=k){
        k -= op(s[i]);
        s[i] = 'a';
      }
    }
  }
  if(k>=1){
    k%=26;
    while(k--){
      if(s.back()=='z')s.back()='a';
      else s.back()++;
    }
  }
  cout<<(s)<<endl;

}

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

using namespace std;

#define ll long long
#define ld long double

signed main() {
	ll a, b, p, q, r;
	cin >> a >> b >> p >> q >> r;
	ld ans = b;
	ans += (b * p - (b - a) * q) / (ld)(q + r);
	cout << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 3292
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  int n;
  cin >> n;
  vl a(n, 0);
  rep(i, n) cin >> a[i];
  ll result = 0;
  for(int i = 1; i < n; i++) {
    ll tmp = a[i - 1] - a[i];
    if (tmp <= 0) continue;
    a[i] += tmp;
    result += tmp;
  }
  cout << result << endl;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

ll k[100010];

int main(){
    ll n;cin>>n;
    rep(i,1,1000){
        if(i*(i+1)/2>100000)break;
        k[i*(i+1)/2]=i;
    }
    if(!k[n]){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl<<k[n]+1<<endl;
    ll Sk=k[n];
    vector<ll> s[1000];
    ll num=1;
    rep(i,0,Sk){
        rep(j,i+1,Sk+1){
            s[i].push_back(num);
            s[j].push_back(num);
            num++;
        }
    }
    rep(i,0,Sk+1){
        cout<<Sk;
        rep(j,0,Sk)cout<<" "<<s[i][j];
        cout<<endl;
    }
    
    
}
    









Measured memory_bytes: 3968
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using ll = long long;
using namespace std;

int h, w, a[88][88], b[88][88], c[88][88];
bool dp[88][88][15000];

int main()
{
	cin >> h >> w;
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j) cin >> a[i][j];
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j) cin >> b[i][j];
	for (int i = 1; i <= h; ++i)
		for (int j = 1; j <= w; ++j) c[i][j] = abs(a[i][j] - b[i][j]);
	
	dp[1][1][c[1][1]] = true;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			for (int k = 0; k < 14000; ++k) {
					dp[i][j][abs(k - c[i][j])] |= dp[i - 1][j][k];
					dp[i][j][k + c[i][j]] |= dp[i - 1][j][k];
					dp[i][j][abs(k - c[i][j])] |= dp[i][j - 1][k];
					dp[i][j][k + c[i][j]] |= dp[i][j - 1][k];
			}
		}
	}
	
	for (int i = 0; i < 14000; ++i) if (dp[h][w][i]) {
		cout << i;
		return 0;
	}
}

Measured memory_bytes: 103424
#include<stdio.h>
#include<stdlib.h>
int max_cal(int a,int b)
{
  if(a>=b) return a;
  else return b;
}
void main(void)
{
  int n,m,d;
  scanf("%d%d",&n,&m);
  int a[n+1];
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  int g[n+1];
  for(int i=1;i<=n;i++) g[i]=0;
  int b,c;
  for(int i=1;i<=m;i++){
    scanf("%d%d",&b,&c);
    if(a[b]>a[c]) g[c]++;
    else if(a[b]==a[c]){
      g[b]++;
      g[c]++;
    }else g[b]++;
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    if(g[i]==0) ans++;
  }
  printf("%d",ans);


}

Measured memory_bytes: 2508
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
	int n,m,ha[110],ta[110],tha,tta;
	while(cin>>n>>m){
		tha=0;
		tta=0;
		if(n==0 && m==0){
			break;
		}
		for(int i=0;i<n;i++){
			cin>>ta[i];
			tta+=ta[i];
		}
		for(int i=0;i<m;i++){
			cin>>ha[i];
			tha+=ha[i];
		}
		sort(ta,ta+n);
		sort(ha,ha+m);
		int ta1=900,ha1=900;
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(tta>=tha && (tta-tha)==((ta[i]-ha[j])*2)){
					ta1=ta[i];
					ha1=ha[j];
					i=200;
					j=200;
					break;
				}
				if(tha>=tta && (tha-tta)==((ha[j]-ta[i])*2)){
					ta1=ta[i];
					ha1=ha[j];
					i=200;
					j=200;
					break;
				}
			}
		}
		if(ta1==900){
			cout<<-1<<endl;
		}
		else{
			cout<<ta1<<" "<<ha1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a<b){
        if(b<c){
            printf("Yes\n");
        }else{
        printf("No\n");
    }
 }else{
        printf("No\n");
    }
    return 0;
}

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

typedef long long int ll;

int main () {


    ll n;
    cin >> n;

    string s;
    cin >> s;

    ll ans = 0;

    for (ll i=0 ; i<n ; i++) {
    	char p = s[i];
    	while (s[i]==p && i<n) {
    		i++;
    	}
    	i--;
    	ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			total += arr[i];
		}
		int min = Integer.MAX_VALUE;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += arr[i];
			int x = Math.abs(total - sum * 2);
			if (min > x) {
				min = x;
			}
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 23636
sa = [c for c in input()]
sb = [c for c in input()]
sc = [c for c in input()]
flag = "a"
while True:
  if flag == "a":
    if sa == []:
      print("A")
      break
    flag = sa.pop(0)
  elif flag == "b":
    if sb == []:
      print("B")
      break
    flag = sb.pop(0)
  else:
    if sc == []:
      print("C")
      break
    flag = sc.pop(0)


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

using namespace std;
int q;
struct point
{
    double x;
    double y;
};
point vt(point a,point b)
{
    point vt;
    vt.x=b.x-a.x;
    vt.y=b.y-a.y;
    return vt;
}
double scalar(point a,point b)
{
    double scalar=0;
    scalar=sqrt((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y));
    return scalar;
}
double mul1(point a,point b)
{
    double mul=a.x*b.x+a.y*b.y;
    return mul;
}
point mul2(point a,double b)
{
    point c;
    c.x=a.x*b;
    c.y=a.y*b;
    if (c.x==-0) c.x=0;
    if (c.y==-0) c.y=0;
    return c;
}
int main()
{
    point p1,p2;
    cin>>p1.x>>p1.y;
    cin>>p2.x>>p2.y;
    cin>>q;
    while (q--)
    {
        point p;
        cin>>p.x>>p.y;
        point v=vt(p1,p);
        point u=vt(p1,p2);
        //cout<<v.x<< " "<<v.y<<endl;
        //cout<<u.x<< " "<<u.y<<endl;
        double su=scalar(p1,p2);
        //cout<<su<<endl;
        point ans;
        ans=mul2(u,mul1(u,v)/(su*su));
        cout<<setprecision(10)<<fixed<<ans.x+p1.x<<" "<<ans.y+p1.y<<endl;
    }
    return 0;
}



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

namespace Atc_0035
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            int A = int.Parse(s.Split(' ')[0]);
            int B = int.Parse(s.Split(' ')[1]);

            for (int i = 1; i <= 3; i++)
            {
                if ((A * B * i) % 2 == 1)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            Console.WriteLine("No");

        }
    }
}


Measured memory_bytes: 27228
import numpy as np

dish = []
for _ in range(5):
    tmp = int(input())
    dish.append([tmp, (10-tmp%10)%10])

dish = np.array(dish)
dish = dish[np.argsort(dish[:, 1])]

count = 0
print(np.sum(dish) - dish[4, 1])


Measured memory_bytes: 21344
from sys import stdin

# input
k,x = [int(x) for x in stdin.readline().rstrip().split()]

# output
res = []
for i in range(k-1):
    n = x-(i+1)
    if -1000000 <= n and n <= 1000000:
        res.append(n)
res.append(x)
for i in range(k-1):
    n = x+(i+1)
    if -1000000 <= n and n <= 1000000:
        res.append(n)
res.sort()
res = map(str, res)
print(" ".join(res))


Measured memory_bytes: 3064
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		boolean ok = true;
		for(int i = 0; i < S.length(); i++)
			if(S.charAt(i) != T.charAt(i))
				ok = false;
		System.out.println(ok ? "Yes" : "No");
	}

}

Measured memory_bytes: 35644