akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            long L = long.Parse(line[0]);
            long R = long.Parse(line[1]);

            long ans = 2019;
            
            if(R - L > 2019)
            {
                R = L + 2019;
            }

            for(long i=L; i<R; i++)
            {
                for(long j=i+1; j<=R; j++)
                {
                    if(i * j % 2019 < ans)
                    {
                        ans = i * j % 2019;
                    }
                }

            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll a,b,c,d; cin >> a >> b >> c >> d;
	ll ans = max({a*c,a*d,b*c,b*d});
	cout << ans << "\n";
}

Measured memory_bytes: 3628
#include <string>
#include <functional>
#include <stdlib.h>
#include <climits>
#include <algorithm>
#include <iostream>

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	string S, a;
	cin >> S;
	long long s[26] = { 0 };
	for (i = 0; S[i]; i++) {
		s[S[i]-'a']++;
	}

	if (S.length() == 26) {
		if (S == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
			return 0;
		}

		char right;
		for (i = 24; i >= 0; i--) {
			if (S[i+1] > S[i]) {
				right = S[i+1];
				break;
			}
		}
		for (j = i + 1; j < 26; j++) {
			if (S[i] < S[j])
				right = min(right, S[j]);
		}
		for (j=0; j < i; j++) {
			a += S[j];
		}
		a += right;
		cout << a << endl;
		return 0;
	}

	for (i = 0; i < 26; i++) {
		if (s[i] == 0) {
			S += i + 'a';
			break;
		}
	}

	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	int H = in();
	int W = in();
	int fours = (H / 2) * (W / 2);
	int twos = (H % 2 * (W / 2)) + (W % 2 * (H / 2));
	int ones = (H % 2) * (W % 2);
	pr(fours);
	pr(twos);
	pr(ones);
	
	vint alpha(26, 0);
	rep(y, H) {
		string s;
		cin >> s;
		rep(x, W) alpha[s[x] - 'a']++;
	}
	sort(alpha.begin(), alpha.end(), greater<int>());
	
	for (auto a : alpha) {
		pr(a);
		if (a % 2 == 1) {
			ones--;
			a--;
			if (ones < 0) goto NG;
		}
		while (a >= 4 && fours > 0) {
			a -= 4;
			fours--;
		}
		while (a >= 2) {
			a -= 2;
			twos--;
			if (twos < 0) goto NG;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
	
	NG:;
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int h, w, n; cin >> h >> w >> n;
    h = max(h, w);
    cout << (n + h - 1) / h << endl;
}


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

int main() {
int N; cin >> N;
double ans = 0;
for (int i = 0; i < N; i++) {
    double A; cin >> A;
    ans += 1.0 / A;
}
cout << fixed << setprecision(10);
cout << 1.0 / ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;



int main(){
    int n,w;
    cin>>n>>w;
    int a[100000],b[100000];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    
    int dp[100000]={};
    for(int i=1;i<=w;i++){
        for(int t=0;t<n;t++){
            if(i-b[t]>=0){dp[i]=max(dp[i],dp[i-b[t]]+a[t]);}
        }}
    
    cout<<dp[w]<<endl;
    
    return 0;
}


Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	map<map<char,ll>,ll> mp;
	map<map<char,ll>,bool> used;
	ll n;
	cin>>n;
	vector<string> vs(n);
	for(int i=0;i<n;i++)
	{
		cin>>vs[i];
		map<char,ll> tmp;
		for(int j=0;j<vs[i].size();j++)tmp[vs[i][j]]++;
		mp[tmp]++;
	}
	ll ans = 0;
	for(int i=0;i<n;i++){
		map<char,ll> tmp;
		for(int j=0;j<vs[i].size();j++)tmp[vs[i][j]]++;
		if(used[tmp] == 1)con;
		else used[tmp] = 1; 
		ll cnt = mp[tmp]-1;
		ans+=(cnt+1)*cnt/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 130388
s=raw_input()
t=raw_input()
m={}
ret = "Yes"
for i,c in enumerate(s):
  if c in m and m[c]!=t[i]:ret = "No"
  m[c] = t[i]
if len(set(m[c] for c in m))!=len(m):ret = "No"
print ret

Measured memory_bytes: 3072
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

H,W,K = inpl()
field = [[] for _ in range(H)]
for ii in range(H):
    C = str(input())
    for c in C:
        field[ii].append(c)
ans = 0
kumi = list(itertools.product([0,1],repeat=(H+W)))
for k in kumi:
    fieldf = copy.deepcopy(field)
    for i,o in enumerate(k):
        if o==1:
            if i <= H-1:
                for j in range(W):
                    fieldf[i][j] = '.'
            else:
                for jj in range(H):
                    fieldf[jj][i-H] = '.'
    count = 0
    for l in range(H):
        for ll in range(W):
            if fieldf[l][ll] == '#':
                count += 1
    if K ==count:
        ans+= 1
print(ans)


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

#define mp make_pair
#define pb push_back
#define repm(i, n, m)  for(int i = n; i < m; ++i)
#define Repm(i, n, m)  for(int i = n; i <= m; ++i)
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repn(i, n) repm(i, 1, n)
#define mod 1000000000+7

int main(){
    int n; cin >> n;
    cout << n*n*n << endl;

    return 0;
}


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

int main()
{
  int battery;
  char s, t, b;

  while (cin >> battery)
  {
    double pmatrix[9][9] = {
      {0.5,  0.25, 0,    0.25, 0,    0,    0,    0,    0}, // 0 A
      {0.25, 0.25, 0.25, 0,    0.25, 0,    0,    0,    0}, // 1 B
      {0,    0.25, 0.5,  0,    0,    0.25, 0,    0,    0}, // 2 C
      {0.25, 0,    0,    0.25, 0.25, 0,    0.25, 0,    0}, // 3 D
      {0,    0.25, 0,    0.25, 0,    0.25, 0,    0.25, 0}, // 4 E
      {0,    0,    0.25, 0,    0.25, 0.25, 0,    0,    0.25}, // 5 F
      {0,    0,    0,    0.25, 0,    0,    0.5,  0.25, 0},    // 6 G
      {0,    0,    0,    0,    0.25, 0,    0.25, 0.25, 0.25}, // 7 H
      {0,    0,    0,    0,    0,    0.25, 0,    0.25, 0.5}   // 8 I
    };

    if (battery==0) return 0;
    cin >> s >> t >> b;

    int start = s-'A';
    int broom = t-'A';
    int junk = b-'A';

    for (int i=0;i<9;i++) pmatrix[junk][i]=pmatrix[i][junk]=0;
    switch (junk)
    {
    case 0:
      pmatrix[1][1]=pmatrix[3][3]=0.5;
      break;
    case 1:
      pmatrix[0][0]=pmatrix[2][2]=0.75;
      pmatrix[4][4]=0.25;
      break;
    case 2:
      pmatrix[1][1]=pmatrix[5][5]=0.5;
      break;
    case 3:
      pmatrix[0][0]=pmatrix[6][6]=0.75;
      pmatrix[4][4]=0.25;
      break;
    case 4:
      pmatrix[1][1]=pmatrix[3][3]=pmatrix[5][5]=pmatrix[7][7]=0.5;
      break;
    case 5:
      pmatrix[2][2]=pmatrix[8][8]=0.75;
      pmatrix[4][4]=0.25;
      break;
    case 6:
      pmatrix[3][3]=pmatrix[7][7]=0.5;
      break;
    case 7:
      pmatrix[6][6]=pmatrix[8][8]=0.75;
      pmatrix[4][4]=0.25;
      break;
    case 8:
      pmatrix[5][5]=pmatrix[7][7]=0.5;
      break;
    }

    double P[9][9], Q[9][9];

    for (int i=0;i<9;i++)
      for (int j=0;j<9;j++) P[i][j] = pmatrix[i][j];

    for (int i=1;i<battery;i++)
    {
      for (int i=0;i<9;i++)
      {
        for (int j=0;j<9;j++)
        {
          Q[i][j] = 0.0;
          for (int k=0; k<9;k++)
          {
            Q[i][j] += P[i][k] * pmatrix[k][j];
          }
        }
      }
      for (int i=0;i<9;i++)
        for (int j=0;j<9;j++) P[i][j] = Q[i][j];

    }
    // for (int i=0;i<9;i++)
    // {
    //   for (int j=0;j<9;j++) printf("%4f ", P[i][j]);
    //   cout << endl;
    // }

    printf("%.8f\n", P[start][broom]);
  }
}

Measured memory_bytes: 1192
#include<stdio.h>
int main(void){
  int n,a=0;
  
  scanf("%d",&n);
  
  for(int i = 1; i <= 9; i++) {
    for(int j = 1; j <= 9; j++) {
      if(i*j == n)
        a = 1;
    }
  }
  if(a==1)
    printf("Yes");
  if(a==0)
    printf("No");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//const int mod=1e9+7;
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
void ckmax(int &x,int y){
	if (x<y)
		x=y;
}
void ckmin(int &x,int y){
	if (x>y)
		x=y;
}
const int N=55;
int n,k,s,t;
vi a;
int gao(int x,int s){
	int v=0;
	Fod(i,17,0)
		if (~s>>i&1)
			v=v*2+(x>>i&1);
	return v;
}
int gao2(int x,int t){
	int v=0;
	Fod(i,17,0)
		if (t>>i&1)
			v=v*2+(x>>i&1);
	return v;
}
int cnt1(int x){
	int ans=0;
	while (x)
		ans+=x&1,x>>=1;
	return ans;
}
LL C[N][N];
int main(){
	n=read(),k=read(),s=read(),t=read();
	if ((t&s)!=s)
		return puts("0"),0;
	t=gao(t,s);
	while (n--){
		int x=read();
		if ((x&s)==s){
			x=gao(x,s);
			if ((t&x)==x){
				x=gao2(x,t);
				a.pb(x);
			}
		}
	}
	int d=cnt1(t);
	n=a.size();
//	outarr(a,0,n-1);
	For(i,0,n){
		C[i][0]=1;
		For(j,1,i)
			C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
	LL ans=0;
	For(s,0,(1<<d)-1){
		vi v;
		for (auto i : a)
			v.pb(i&s);
		sort(v.begin(),v.end());
		LL now=0;
		for (int i=0,j;i<(int)v.size();i=j+1){
			for (j=i;j+1<(int)v.size()&&v[j]==v[j+1];j++);
			int len=j-i+1;
			For(t,1,min(len,k))
				now+=C[len][t];
		}
		if (cnt1(s)&1)
			ans-=now;
		else
			ans+=now;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3660
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
flag=[[True]*n for _ in range(n)]
for k in range(n):
  for i in range(n):
    for j in range(n):
      if i==j or j==k or k==i:
        continue
      if a[i][j]>a[i][k]+a[k][j]:
        print(-1)
        exit()
      if a[i][j]==a[i][k]+a[k][j]:
        flag[i][j]=False
        flag[j][i]=False
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    if flag[i][j]:
      ans+=a[i][j]
print(ans)

Measured memory_bytes: 45020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n,k;cin>>n>>k;
    int *arr=new int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    double ans=0;

    double cur=0;
    for(int i=0;i<k;i++)
    {
        double val=(arr[i]+1)/2.0;
        cur+=val;
    }

    ans=cur;

    for(int i=k;i<n;i++)
    {
        cur-=(arr[i-k]+1)/2.0;
        cur+=(arr[i]+1)/2.0;
        ans=max(ans,cur);
    }

    cout<<PSET(ans,8);
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

def solve_e(n, a_list):
    days = 0
    ind_list = [0] * n
    match_count = 0
    queue = list(range(n))
    stack = dict()
    while len(queue) > 0:
        days += 1
        new_queue = []
        for p in queue:
            if ind_list[p] < n - 1:
                q = a_list[p][ind_list[p]] - 1
                k = str(min(p, q)) + "_" + str(max(p, q))
                if k in stack.keys():
                    ind_list[p] += 1
                    ind_list[q] += 1
                    # print(days, p, q)
                    new_queue.append(p)
                    new_queue.append(q)
                    match_count += 1
                else:
                    stack[k] = 1
        queue = new_queue
    if match_count == n * (n - 1) // 2:
        return days - 1
    else:
        return -1


def test():
    N = 1000
    A_list = []
    for i in range(N):
        A_list.append(list(range(1, i + 1)) + list(range(i + 2, N + 1)))
    print(solve_e(N, A_list))


def main():
    N = int(input())
    A_list = []
    for _ in range(N):
        A_list.append(list(map(int, input().split())))
    print(solve_e(N, A_list))


if __name__ == "__main__":
    main()


Measured memory_bytes: 91520
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    int score = 0;
    int lr = 0, rl = 0;
    rep(i, n - 1)
    {
        if (s[i] == s[i + 1]) {
            score++;
        } else {
            if (s[i] == 'L') {
                lr++;
            } else {
                rl++;
            }
        }
    }

    int f = min(k, min(lr, rl));
    k -= f;
    score += 2 * f;

    if (k > 0) {
        int d = max(lr, rl) - min(lr, rl);
        if (d > 0) {
            score++;
        }
    }

    cout << score << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
//#define ivorysi
#define fi first
#define se second
#define MAXN 25005
#define enter putchar('\n')
#define space putchar(' ')
typedef long long int64;
using namespace std;
template <class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
        c = getchar();
        if(c == '-') f = -1;
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template <class T>
void out(T x) {
    if(x < 0) {x = -x;}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int T;
int64 A,B,C,D;
int64 gcd(int64 a,int64 b) {
    return b == 0 ? a : gcd(b,a % b);
}
void Solve() {
    read(A);read(B);read(C);read(D);
    if(A < B) {puts("No");}
    else {
        if(C >= B && D >= B) puts("Yes");
        else if(D < B) puts("No");
        else {
            if(A > C) {
                int64 t = (A - C - 1) / B + 1;
                if(t > A / B) {
                    puts("No");return;
                }
                A -= B * t;
            }
            int64 g = gcd(D % B,B);
            if((C + 1 - A - 1) / g + 1 == (B - A - 1) / g + 1) puts("Yes");
            else puts("No");
        }
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(T);
    while(T--) {
        Solve();
    }
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll X, Y, a, b;
  cin >> X >> Y;
  if(Y%2==1)cout << "No";
  else {
  a = 2*X - Y/2;
  b = Y/2 - X;
  if(a < 0 || b < 0) cout << "No";
  else cout << "Yes";
  }
}

Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
int n,m,x,y,xx[100],yy[100],i,j,judge=0,e,z;
 
scanf("%d %d %d %d",&n,&m,&x,&y);
 
for(i=0;i<n;i++){
  scanf("%d ",&xx[i]);
}
for(i=0;i<m;i++){
  scanf("%d",&yy[i]);
}
 
//xxについて
for(i=0;i<n-1;i++){
  for(j=i+1;j<n;j++){
    if(xx[i]<xx[j]){
      e=xx[i];
      xx[i]=xx[j];
      xx[j]=e;
    }
  }
}
 
//yyについて
for(i=0;i<m-1;i++){
  for(j=i+1;j<m;j++){
    if(yy[i]>yy[j]){
      e=yy[i];
      yy[i]=yy[j];
      yy[j]=e;
    }
  }
}
 
for(z=0;z<=y;z++){
  if(x<z && z<=y && xx[0]<z && yy[0]>=z){
    judge=1;
    puts("No War");
    break;
  }
}
 
if(judge==0){
  puts("War");
}
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
#include<unordered_map>
using namespace std ;

#define MAXN 307
#define MOD 1000000007

int n , q ;
vector < pair < int , int > > v[ MAXN ] ;

long long dp[ MAXN ][ MAXN ][ MAXN ] ;
long long ans = 0 ;

bool check ( int x , int y , int z , int id ) {
    int sz = v[ id ].size ( ) ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        int cnt = 0 ;
        if ( v[ id ][ i ].first <= x ) { ++ cnt ; }
        if ( v[ id ][ i ].first <= y ) { ++ cnt ; }
        if ( v[ id ][ i ].first <= z ) { ++ cnt ; }
        if ( cnt != v[ id ][ i ].second ) { return false ; }
    }
    if ( x == n || y == n || z == n ) {
        ans = ( ans + dp[ x ][ y ][ z ] ) ;
        if ( ans >= MOD ) { ans -= MOD ; }
    }
    return true ; 
}

void add ( int x , int y , int z , int mx ) {
    dp[ x ][ y ][ mx + 1 ] += dp[ x ][ y ][ z ] ;
    if ( dp[ x ][ y ][ mx + 1 ] >= MOD ) {
        dp[ x ][ y ][ mx + 1 ] -= MOD ;
    }

    dp[ x ][ mx + 1 ][ z ] += dp[ x ][ y ][ z ] ;
    if ( dp[ x ][ mx + 1 ][ z ] >= MOD ) {
        dp[ x ][ mx + 1 ][ z ] -= MOD ;
    }

    dp[ mx + 1 ][ y ][ z ] += dp[ x ][ y ][ z ] ;
    if ( dp[ mx + 1 ][ y ][ z ] >= MOD ) {
        dp[ mx + 1 ][ y ][ z ] -= MOD ;
    }
}

void input ( ) {
    scanf ( "%d%d" , &n , &q ) ;
    for ( int i = 1 ; i <= q ; ++ i ) {
        int x , y , z ;
        scanf ( "%d%d%d" , &x , &y , &z ) ;
        v[ y ].push_back ( { x , z } ) ;
    }
}

void solve ( ) {
    dp[ 0 ][ 0 ][ 0 ] = 1 ;
    for ( int mx = 0 ; mx <= n ; ++ mx ) {
        int x , y , z ;
        x = mx ;
        for ( y = 0 ; y <= mx ; ++ y ) {
            for ( z = 0 ; z <= mx ; ++ z ) {
                if ( dp[ x ][ y ][ z ] == 0 ) { continue ; }
                if ( check ( x , y , z , mx ) == false ) { continue ; }
                add ( x , y , z , mx ) ;
            }
        }
        y = mx ;
        for ( x = 0 ; x <= mx ; ++ x ) {
            for ( z = 0 ; z <= mx ; ++ z ) {
                if ( dp[ x ][ y ][ z ] == 0 ) { continue ; }
                if ( check ( x , y , z , mx ) == false ) { continue ; }
                if ( x + y + z == 0 ) { continue ; }
                add ( x , y , z , mx ) ;
            }
        }
        z = mx ;
        for ( x = 0 ; x <= mx ; ++ x ) {
            for ( y = 0 ; y <= mx ; ++ y ) {
                if ( dp[ x ][ y ][ z ] == 0 ) { continue ; }
                if ( check ( x , y , z , mx ) == false ) { continue ; }
                if ( x + y + z == 0 ) { continue ; }
                add ( x , y , z , mx ) ;
            }
        }
    }
    printf ( "%lld\n" , ans ) ;
}


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


Measured memory_bytes: 223488
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<a){
		cout<<k<<endl;
	}else{
		if(k-a<b){
			cout<<a<<endl;
		}else{
			cout<<a-(k-a-b)<<endl;
		}
	}
}

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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

ll N;

int main(void)
{
    cin >> N;
    vector<ll> A(N + 1);
    vector<ll> Abucket(N + 1);
    REP(i, 1, N + 1) {
        ll a;
        cin >> a;
        Abucket[a]++;
        A[i] = a;
    }

    vector<ll> Acomb(N + 1);
    ll sum = 0;
    for(int i = 1; i <= N; ++i) {
        Acomb[i] = (Abucket[i] * (Abucket[i] - 1)) / 2;
        sum += Acomb[i];
    }

    for(int i = 1; i <= N; ++i) {
        ll tsum = sum - Acomb[A[i]];
        tsum += max((ll)0, (Abucket[A[i]] - 1) * (Abucket[A[i]] - 2) / 2);
        cout << tsum << endl;
    }

    return 0;
}

Measured memory_bytes: 7296
import numpy as np
import collections as col
import math
n, m, d = map(int, input().split())
ans = 0.0

if d == 0:
    ans = (m - 1)/n
else:
    ans = 2.0 * (n - d) * (m - 1) /n/n

# if d == 0:
#     ans = (n - 1)*(m - 1)/n/n
# else:
#     ans = (n - 1)*(m - 1)/n/n/n * 2.0 * (n - d) * (m - 1)

print(ans)


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

int main() {
  int l,r; cin >>l >>r;
  int ans;
  if (r-l+1>=2019) ans = 0;
  else if (l%2019>r%2019) ans = 0;
  else{
    l %= 2019; r %= 2019; // l<r<2019になる
    ans = (l*(l+1))%2019;
    for (int i=l; i<r; i++){
      for (int j=l+1; j<=r; j++){
        ans = min(ans, (i*j)%2019);
      }
    }
  }
  
  cout <<ans;
  cout <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, m, a, b, c, sum = 0, num = 0; cin >> n >> m >> a >> b >> c;
	sum = m / b; num = a / c;
	if (m % b != 0) {
		sum++;
	}
	if (a % c != 0) {
		num++;
	}
	cout << n - max(sum, num) << endl;
}


Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int N,K,C;
string S;
int main(void){
    cin>>N>>K>>C>>S;
    int work[2][K];
    memset(work,0,sizeof work);
    for(int day=0,cnt=0;day<N&&cnt<K;day++)if(S[day]=='o')work[0][cnt++]=day,day+=C;
    for(int day=N-1,cnt=0;day>=0&&cnt<K;day--)if(S[day]=='o')work[1][K-1-cnt++]=day,day-=C;
    for(int i=0;i<K;i++)if(work[0][i]==work[1][i])cout<<work[0][i]+1<<endl;
    return 0;
}

Measured memory_bytes: 3332
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
# define int long long
  
using namespace std;
  
const int N = 1e3 + 7;
const int mod = 1e9 + 7;

int32_t main() {
    speed;
    int n;
    cin >> n;
    vector < int > a;
    for ( int i = 0; i < n; i++ ) {
        int x;
        cin >> x;
        a.push_back( x );
        a.push_back( x );
    } 
    sort( a.rbegin(), a.rend() );
    a.erase( a.begin() );
    int sum = 0;
    for ( int i = 0; i < n - 1; i++ ) {
        sum += a[i];
    }
    cout << sum;
}


Measured memory_bytes: 7412
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int k, i;
	char s[111111];
	cin >> s >> k;
	for (i = 0; s[i] != '\0'; i++) {
		if (s[i] != 'a'&&'z' - s[i] + 1 <= k) {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	}
	i--;
	while(k > 0) {
		if (s[i] == 'z')
			s[i] = 'a';
		else
			s[i]++;
		k--;
	}
	cout << s << endl;
}

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

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

Measured memory_bytes: 256
object Main extends App {
	val Array(h, w) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val a = Array.ofDim[Int](h, w)

	for(i<-0 until h){
		a(i) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	}

	var ans = List[(Int, Int, Int, Int)]()

	for(i<-0 until h){
		for(j<-0 until w){
			if(a(i)(j)%2!=0){
				if(j!=w-1){
					a(i)(j+1)+=1
					ans=(i, j, i, j+1) :: ans
				}
				else if(i!=h-1){
					a(i+1)(j)+=1
					ans=(i, j, i+1, j) :: ans
				}
			}
		}
	}

	println(ans.size)
	for(x <- ans.reverse){
		myP(x._1, x._2, x._3, x._4)
	}

	def myP(x: Int, y: Int, a: Int, b: Int): Unit = {
		println(Array(x+1,y+1,a+1,b+1).mkString(" "))
	}

}


Measured memory_bytes: 84324
public class Main {
	public static void main(String[] args) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int i = 1;
		do {
			int x = sc.nextInt();
			if (x == 0) { break; }
			sb.append("Case ").append(i).append(": ").append(x).append("\n");
			i++;
		} while (true);
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 42020
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int x,y;
cin>>x>>y;
if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))cout<<"Yes";
else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11))cout<<"Yes";
else if(x==2&&y==2)cout<<"Yes";
else cout<<"No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
 int main()
{
  int h , a;
  cin >> h >> a;
  int r = h % a ;
  int ans = ( h - r ) / a;
  if ( r > 0 ) 
  {
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;

typedef long long lli;

string toString(const lli &i) {
  char buff[128];
  sprintf(buff, "%lld", i);
  return string(buff);
}

int main() {
  lli N, K;
  while(cin >> N >> K && (N|K)) {
    string tmp = "";
    lli cnt = 1;
    lli i, t, n;
    for(i = 1, t = 10, n = 1; ; ++i) {
      if(i == t) {
        ++n;
        t *= 10;
      }
      cnt += n;
      if(cnt > N) {
        cnt -= n;
        break;
      }
    }
    for(; cnt < N+K; ++i) {
      string s = toString(i);
      cnt += s.size();
      tmp += s;
    }
    cout << tmp.substr(tmp.size()-(cnt-N), K) << endl;
  }
  return 0;
}

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

int main() {
    int N, L;
    string combi;
    cin >> N >> L;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }

    sort(S.begin(), S.end());
    for (int i = 0; i < N; i++) {
        combi += S.at(i);
    }
    cout << combi << endl;
}


Measured memory_bytes: 256
// ABC159C - Maximum Volume

#include <bits/stdc++.h>
using namespace std;

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

	double answer;

	answer = ((double)L / 3.0) * ((double)L / 3.0) * ((double)L / 3.0);
	printf("%lf\n", answer);

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n, m, match[15], vis[13], ans;
char s[15][15];

bool check() {
	memset(vis, 0, sizeof(vis));
	for(int i=1; i<=m; i++)
		for(int j=1; j<=m; j++) {
			if(vis[i] || vis[j] || i==j) continue;
			bool flag = 1;
			for(int k=1; k<=n; k++) {
				if(s[match[k]][i] != s[k][j]) {
					flag = 0;
					break;
				}
			}
			if(flag) vis[i] = vis[j] = 1;
		}
	int cnt = 0, flag = 0;
	for(int i=1; i<=m; i++)
		if(!vis[i]) {
			cnt++;
			flag = i;
		}
	if((m % 2 == 0 && cnt) || cnt >= 2) return 0;
	if(!cnt) return 1;
	for(int i=1; i<=n; i++)
		if(s[match[i]][flag] != s[i][flag]) return 0;
	return 1;
}

void dfs(int step, bool flag) {
	if(ans) return;
	if(step == ((n+1) >> 1)) {
		if(check()) ans = 1;
		return;
	}
	for(int i=step; i<=n; i++) {
		for(int j=i+1; j<=n; j++)
			if(match[i] == -1 && match[j] == -1) {
				match[i] = j, match[j] = i;
				dfs(step+1, flag);
				match[i] = match[j] = -1;
			}
		if(flag && match[i] == -1) {
			match[i] = i;
			dfs(step+1, 0);
			match[i] = -1;
		}
	}
}

int main()
{
	memset(match, -1, sizeof(match));
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++) scanf("%s", s[i]+1);
	if(n % 2 == 1) dfs(0, 1);
		else dfs(0, 0);
	if(ans) printf("YES\n");
		else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
/**
 *    author        : Saurav Paul 
 *    created       : August 29, 2020 6:00 PM
 *    Problem Name  : A - Don't be late
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc177/tasks/abc177_a
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

using ll = long long int ;

class TC{

    public :
    void solve(){
        ll d , t , s;
        cin >> d>> t >> s;
        t = t * s;
        if(d > t) {
            cout << "No" << endl ;
        }
        else {
            cout << "Yes" << endl ;
        }

    }
};

int main(){
    ios_base::sync_with_stdio(false);

    int testcases = 1;
    for(int i = 1 ; i <= testcases ; i ++){
        TC tc;
        tc.solve() ;
    }

    return 0 ;
}


Measured memory_bytes: 3648
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

N = num()
A = nums()
Ag = [i for i in A if i%2 ==0]
p = True
for i in Ag:
    if i%3 != 0 and i%5 != 0:
        p = False
        print("DENIED")
        break
if p:
    print("APPROVED")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
#define rp
int main()
{
    string s;
    cin>>s;
    int n,d=0,sum=0,i,x;
    vector<long long>v;
    for(i=0;i<s.size();i++)
    {
        x=s[i]-'0';
        v.pb(x);
    }
   for(i=0;i<v.size();i++)
   {
       sum=sum+v[i];
   }
   for(i=0;i<s.size();i++)
   {
       d=d*10+(s[i]-'0');
   }
   if(d%sum)
    cout<<"No"<<endl;
   else
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]

R = [0]*N

S = 0
for n in range(N-1):
  S += (1-2*(n%2))*A[n]

R[N-1] = (A[N-1]-S)/2

for n in range(N-1):
  R[n] = S + (1-2*(n%2)) * R[N-1]
  S = A[n] -S

for n in range(N):
  R[n] = int(R[n]*2)

print(' '.join(map(str, R)))

Measured memory_bytes: 90212
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,ar[100005],dp[100005];
ll findmin(ll i){
	if(i==n){
		return 0;
	}
	if(dp[i]!=-1){
		return dp[i];
	}

	ll a=1e18,b=1e18;
	if(i+1<=n)
		a=findmin(i+1)+abs(ar[i]-ar[i+1]);
	if(i+2<=n)
		b=findmin(i+2)+abs(ar[i]-ar[i+2]);
	return dp[i]=min(a,b);
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,k,l;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	memset(dp,-1,sizeof(dp));
	ll an=findmin(1);
	cout<<an;
	return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int A,B,m,am = INF,bm = INF;
    cin>>A>>B>>m;
    vector<int>a(A),b(B);
    rep(i,0,A){
        cin>>a[i];
        am = min(am,a[i]);
    }
    rep(i,0,B){
        cin>>b[i];
        bm = min(bm,b[i]);
    }
    int ans = am + bm;
    rep(i,0,m){
        int x,y,c;
        cin>>x>>y>>c;
        x--;y--;
        ans = min(ans,a[x]+b[y]-c);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define pb push_back
#define re return
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF=1e9;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef queue <int> qi; 
int main(void){
  long long i,j,n,m,k,a,b,c,h,w,r=0,l,t,g;
  long long mem[64][64]={0};
  char s[64];
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%s",s);
    l=strlen(s);
    t=0;w=0;a=0;
    for(j=0;j<l;j++){
      if(s[j]=='.'){t=1;continue;}
      a*=10;
      a+=(s[j]-'0');
      if(t){w++;}
    }
    for(j=w+1;j<=9;j++){a*=10;}
    g=a;
    h=0;w=0;
    while(g%2==0){g/=2;h++;}
    while(g%5==0){g/=5;w++;}
    //printf("%lld %lld\n",h,w);
    mem[h][w]++;
  }
  for(i=0;i<64;i++){
    for(j=0;j<64;j++){
      for(k=0;k<64;k++){
        for(l=0;l<64;l++){
          if((i+k)<18 || (j+l)<18){continue;}
          if(i==k&&j==l){
            if(mem[i][j]>=2){
              r+=(mem[i][j]*(mem[i][j]-1));
            }
          }
          else{
            r+=(mem[i][j]*mem[k][l]);
          }
        }
      }
    }
  }
  printf("%lld\n",r/2);
  return 0;
}

Measured memory_bytes: 3808
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // get value from StandardIn
    int h = sc.nextInt();
    int w = sc.nextInt();
    int n = sc.nextInt();
    int out = 0;

    if(h>w && n%h!=0){
      out = n/h + 1;
    }else if(h>w && n%h==0){
      out = n/h;
    }else if(h<=w && n%w!=0){
      out = n/w +1;
    }else if(h<=w && n%w==0){
      out = n/w;
    }

    System.out.println(out);
  }
}


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

const int N_MAX=100, M_MAX=100;
char p[N_MAX+1][M_MAX+1];

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




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

typedef long long ll;

const int N = 200005;
const ll inf = 1e17;
int n, a[N];
ll d[N], r[N], e[N], ma;

ll E(int n) {
	return e[n];
}

ll D(int n) {
	if(n == 1) return 0;
	else if(n & 1) return max(D(n - 2) + a[n], E(n - 1));
	else return E(n);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	for(int i = 2; i <= n; i += 2) {
		d[i] = d[i - 2] + a[i - 1];
		r[i] = r[i - 2] + a[i];
	}
	ma = 0;
	for(int i = 2; i <= n; i += 2) {
		ma = max(ma, d[i] - r[i]);
		e[i] = ma + r[i];
	}
	cout << D(n) << endl;
	return 0;
}


Measured memory_bytes: 10664
#include<bits/stdc++.h>
using namespace std;
bool br[2000000];
void siv ()
{
    memset(br,true,2000000);
    int i,j;
    br[0]=false;
    br[1]=false;
    for(i=2; i*i<=2000000; i++)
    {
        if(br[i]==true)
        {
            for(j=i*i; j<=2000000; j+=i)
            {
                br[j]=false;
            }
        }
    }

}

int prime(int n)
{
    int i,j;
    for(i=2; i<=n; i++)
    {
        if(br[i]==true)
        {
            if(n%br[i]==0)
            {
                return i;
            }
        }
    }
}
int main()
{
    int n,i,j,gd;
    while(cin>>n)
    {
        siv();
        vector<int>v;
        map<int, int>mp;
        int x,c=0,z;
        for(i=0; i<n; i++)
        {
            cin>>x;
            v.push_back(x);
        }
        gd=v[0];
        for(i=1;i<n;i++)
        {
            gd=__gcd(gd,v[i]);
        }
        if(gd!=1)
        {
            cout<<"not coprime"<<endl;
        }
        else
        {
            int p;
            int flag=0;
           for(i=0;i<n;i++)
           {
               p=v[i];
               if(br[p]==true)
               {
                   mp[p]++;
                   if(mp[p]>1)
                   {
                       flag=1;
                       break;
                   }
               }
               else
               {
               for(j=2;j<=p;j++)
               {
                   if(br[j]==true)
                   {
                       if(p%j==0)
                       {
                           mp[j]++;
                       }
                       if(mp[j]>1)
                       {
                           flag=1;
                           break;
                       }
                   }
               }
               }

           }
           if(flag==1)
            cout<<"setwise coprime"<<endl;
           else
            cout<<"pairwise coprime"<<endl;
           mp.clear();

        }


    }
}


Measured memory_bytes: 11268