akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main() {

    int a, b;
    cin >> a >> b;
    int ans = a + b;
    if (ans < a - b) {
        ans = a - b;
    }
    if (ans < a) {
        ans = a;
    }
    if (ans < a * b) {
        ans = a * b;
    }

    cout << ans;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000000000000
#define mod 1000000007
#define endl '\n'
#define omarshagar                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;


int main()
{
    omarshagar
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    ll res=0;
    bool can=1;
    while(can)
    {
        for(int i=0;i<n;i++)
        {
            if(arr[i]%2==0)
            {
                arr[i]/=2;
            } else{
                can=0;
                break;
            }
        }
        if(can)
        res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
17D8101031C 杉山　祥吾 ID:keisei334 C++
*/

#include <iostream>

using namespace std;

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

  for(int k=0;k<n;k++){
    cout<<a[k];
    if(k!=n-1){
      cout<<" ";
    }
  }
  cout<<"\n";

  for(int i=1;i<n;i++){
    int v=a[i];
    int j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    for(int k=0;k<n;k++){
      cout<<a[k];
      if(k!=n-1){
	cout<<" ";
      }
    }
    cout<<"\n";
  }

  return 0;
}

/*実行結果
6
5 2 4 6 1 3
5 2 4 6 1 3
2 5 4 6 1 3 
2 4 5 6 1 3 
2 4 5 6 1 3 
1 2 4 5 6 3 
1 2 3 4 5 6 

3
1 2 3
1 2 3
1 2 3 
1 2 3 
*/


Measured memory_bytes: 3104
K = int(input())

def dfs(A, li):
    if len(A)==10:
        return
    
    for i in right(A):
        A.append(i)
        A_int = int(''.join(map(str, A)))
        li.append(A_int)
        dfs(A, li)
        A.pop()
    return
        
def right(A):
    if A==[]:
        return [x for x in range(1, 10)]
    
    ret = A[-1]
    if ret==9:
        return [8, 9]
    elif ret==0:
        return [0, 1]
    else:
        return [ret-1, ret, ret+1]

li = []    
dfs([], li)
li.sort()
# print(len(li))
print(li[K-1])

Measured memory_bytes: 11240
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[4];
	for(int i=1;i<=3;i++){
		cin>>a[i];
	}
	sort(a+1,a+3+1);
	int ans=a[1]+a[2];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
# ABC145c


def main():
    import sys
    import itertools
    import math
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    # map(int,input().split())
    n = int(input())
    town = [tuple(map(int, input().split())) for _ in range(n)]
    ans = 0

    def kyori(pos1, pos2):
        return math.sqrt((pos1[0] - pos2[0]) ** 2 + (pos1[1] - pos2[1]) ** 2)

    def permutations_count(n, r):
        return math.factorial(n) // math.factorial(n - r)

    for i in itertools.permutations(town, n):
        # print(i)
        t = 0
        for j in range(1, n):
            t += kyori(i[j - 1], i[j])
        # print(t)
        ans += t
    print(ans/math.factorial(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165
int main(){
  int A, B, H, M;
  long double At, Bt, rad;
  cin >> A >> B >> H >> M;
  //At = 30*H+(long double)M/(long double)2;//360*H/12 + 360/12*M/60
  //Bt = 6*M;//360*M/60
  //rad = (At-Bt)*PI/180;
  rad = (30*H+(long double)M/(long double)2-6*M)*PI/(long double)180;
  cout << setprecision(20) << sqrtl(A*A+B*B-2*A*B*cosl((30*H+(long double)M/(long double)2-6*M)*PI/(long double)180));
}

Measured memory_bytes: 4180
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  vector<int> line(n);
  foreach(i,line)i=in();
  int q = in();
  rep(_,q){
    vector<int> next = line;
    int b = in();
    int m = in();
    int e = in();
    rep(i,e-b){
      int x = b + i;
      int y = b + (i + (e - m)) % (e-b);
      next[y] = line[x];
    }
    line = next;
  }
  foreach(i,line){
    output(i);
  }
  outendl();
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

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

    while(true){
        bool flag = true;
        for(int i = 2; i < x; i++){
            if(x % i == 0)flag = false;
        }
        if(flag){
            cout << x << endl;
            return 0;
        }
        x++;
    }
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int a;
    cin>>a;
    cout<<(3*a*a);

    return 0;
}


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

int calc(string s){
	int c = 0;
	deque<int> v;
	for(int i = 0 ; i < s.size() ; i++) v.push_back(s[i]-'0');
	while( v.size() != 1 ){
		int s = v[0] + v[1];
		v.pop_front();
		v.pop_front();
		if( s < 10 ) v.push_front(s);
		else v.push_front(s%10),v.push_front(s/10);
		c++;
	}
	return c;
}
int main(){
	string s;
	int n;
	cin >> n;
	while(n--){
		cin >> s;
		cout << (calc(s) % 2 ? "Fabre wins.":"Audrey wins.") << endl;
	}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc;
string s,h;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>s>>h;
	for(i=0; i<s.size(); i++){
		if(s[i]!=h[i]) e++;
	}
	cout<<e;
	return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;


int main(){
  ll n,a,b,c,d,e;
  cin >>n>>a>>b>>c>>d>>e;
  ll mi=1e15;
  mi=min(mi,a);
  mi=min(mi,b);
  mi=min(mi,c);
  mi=min(mi,d);
  mi=min(mi,e);
  ll ans=4;
  ans=ans+((n+mi-1ll)/mi);
  cout<<ans;
}

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

int main(){
  int x, y, z, co = 0, next;
  cin >> x >> y >> z;
  while (x > 0){
    x -= z;
    next = x - y;
    if (next < z){
      break;
    }else{
      x = next;
      co += 1;
    }
  }
  cout << co << endl;
  return 0;
}

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

const int SIZE = 1 << 20;
const int NUM_SIZE = 200000;
int n, segment_tree[SIZE];
vector<vector<int> > vertex;
int numbers[NUM_SIZE];
int numbers_child[NUM_SIZE];

void init(int _n) {
	n = 1;
	while (n < _n)
		n *= 2;
}

int sum(int index) {

	index += n - 1;
	int sum = segment_tree[index];
	while (index > 0) {
		index = (index - 1) / 2;
		sum += segment_tree[index];
	}

	return sum;
}

void update(int index, int weight, int a, int b, int left = 0, int right = n) {

	if (right <= a || b <= left)
		return;
	else if (a <= left && right <= b) {
		segment_tree[index] += weight;
	}
	else {
		int mid = (left + right) / 2;
		update(index * 2 + 1, weight, a, b, left, mid);
		update(index * 2 + 2, weight, a, b, mid, right);
	}

}

void dfs(int index) {

	static int id = 0;

	numbers[index] = id;
	id++;

	for (int i = 0; i < vertex[index].size(); ++i)
		dfs(vertex[index][i]);

	numbers_child[index] = id;

}

void print(int k) {

	for (int i = 0; i < k; ++i) {
		cout << i << " ";
	}
	cout << endl;

	for (int i = 0; i < k; ++i) {
		cout << numbers[i] << " ";
	}

	cout << endl;

	for (int i = 0; i < k; ++i) {
		cout << numbers_child[i] << " ";
	}
	cout << endl;
}

void print_tree() {

	for (int i = 0; i < 2 * n - 1; ++i)
		cout << segment_tree[i] << " ";
	cout << endl;

}

int main() {

	int vertex_size;
	cin >> vertex_size;

	vertex.resize(vertex_size);

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

		int input_v;
		cin >> input_v;

		for (int j = 0; j < input_v; ++j) {
			int v;
			cin >> v;
			vertex[i].push_back(v);
		}
	}

	init(vertex_size);
	dfs(0);
	// print(vertex_size);
	int q;

	cin >> q;

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

		int command;
		int v, w;

		cin >> command;

		if (command == 0) {
			cin >> v >> w;
		//	cout << "v = " << v << ", w = " << w << endl;
			update(0, w, numbers[v], numbers_child[v]);
		//	print_tree();
		//	cout << endl;
		}
		else {
			cin >> v;
			cout << sum(numbers[v]) << endl;
		}

	}

	return 0;

}


Measured memory_bytes: 13124
#include <iostream>
using namespace std;
#define MAX 10000

int A[MAX];
int n,m,key;

int linearSerch();

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  cin>>m;
  int count=0;
  for(int i=0;i<m;i++){
    cin>>key;
    count+=linearSerch();
  }

  cout<<count<<endl;
  return 0;
}

int linearSerch(){
  for(int i=0;i<n;i++){
    if(A[i]==key){
      return 1;
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push_back
#define ITR ::iterator


#define MOD 1000000009LL
#define EPS 1e-8


int n, x, m;
int l[10], r[10], s[10];
vint c, ans;
int anss = -1;


void dfs(int k){
	if(k == n){
		bool ok = true;
		for(int i = 0; i < m; ++i){
			int t = s[i];
			for(int j = l[i] - 1; j < r[i]; ++j){
				t -= c[j];
			}
			if(t){
				ok = false;
				break;
			}
		}
		
		if(ok){
			int u = accumulate(ALL(c), 0);
			if(u > anss){
				anss = u;
				ans = c;
			}
		}
	}
	else{
		for(int i = 0; i <= x; ++i){
			c[k] = i;
			dfs(k + 1);
		}
	}
}

int main(){
	cin >> n >> x >> m;
	for(int i = 0; i < m; ++i){
		cin >> l[i] >> r[i] >> s[i];
	}
	c.resize(n);
	
	ans.push_back(-1);
	dfs(0);

	for(int i = 0; i < ans.size(); ++i){
		printf("%d%c", ans[i], i + 1 == ans.size() ? '\n' : ' ');
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

vector<ll> A;

signed main() {
    ll N, K;
    cin >> N >> K;
    A.resize(N, 0);
    REP(i, N) cin >> A[i];

    ll cnt = 0;
    ll i = 0;
    while (true) {
        if (i >= N - 1) break;
        i += (K - 1);
        cnt++;
    }

    cout << cnt << LF;
    return 0;
}


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

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

#define ll long long
#define vl vector<ll>
#define vll vector<vl>

const int INF = 1e9;

ll mod=1000000007;

int edge[210][210];

int col[210];

bool muri=false;

int n;



int main() {
	vector<int> qq;
	for(int i=1; i<=9; i++)for(int j=1; j<=9; j++)
	{
		qq.push_back(i*j);
	}
	int n;
	cin >> n;
	int muri=1;
	rep(i, qq.size()) if(qq[i]==n) muri=0;
	if(muri) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
const double EPS=1e-9;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
int main(){
    int n;cin>>n;ll ans=0;
    ll a[100010];
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]){
            sum+=a[i];
        }else{
            ans+=sum/2;
          sum=0;
        }
    }
    ans+=sum/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
 

using namespace std;

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

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

int main()
{
   ll a, b;
   cin >> a >> b;

   cout << lcm(a, b) << endl;
   return 0;
}
 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll N,X,T; cin>>N>>X>>T;
  
  ll ans = 0;
  ans = (N / X) * T;
  if (N%X)
    ans += T;
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 15;
int N, M, p[maxn], mt[maxn]; char s[maxn][maxn], tmp[maxn];
bool f = false, used[maxn], ok[maxn];
struct data { char a, b; }t1[maxn], t2[maxn];
const int cmp(const data &A, const data &B)
{ return (A.a<B.a) || (A.a==B.a&&A.b<B.b); }

bool Check(int a, int b)
{
	for(int i = 1; i <= N; ++i)
		if(s[p[i]][a] != s[p[N-i+1]][b])
			return false;
	return true;
}

bool pal(int n)
{
	for(int i = 1; i <= (N>>1); ++i)
		if(s[p[i]][n] != s[p[N-i+1]][n])
			return false;
	return true;
}

bool check()
{
	int mid = 0;
	memset(ok, 0, sizeof(ok));
	for(int i = 1; i <= M; ++i)
	{
		if(ok[i]) continue;
		for(int j = i+1; j <= M; ++j)
			if(!ok[j] && Check(i, j)) { ok[i] = ok[j] = true; break; }
		if(!ok[i])
		{
			if(M & 1)
			{
				if(!mid && pal(i)) mid = i;
				else return false;
			}
			else return false;
		}
	}
	return true;
}

void dfs(int dep)
{
	if(f) return;
	if(dep > (N>>1))
	{
		if(N & 1) for(int i = 1; i <= N; ++i) if(!used[i]) p[dep] = i;
		if(check()) f = true; return;
	}
	for(int i = 1; i <= N; ++i)
	{
		if(used[i]) continue;
		p[dep] = i, p[N-dep+1] = mt[i];
		used[i] = used[mt[i]] = true;
		dfs(dep+1);
		used[i] = used[mt[i]] = false;
	}
}

bool OK(int a, int b)
{
	for(int i = 1; i <= M; ++i)
	{
		t1[i].a = s[a][i], t1[i].b = s[b][i];
		t2[i].b = s[a][i], t2[i].a = s[b][i];
	}
	sort(t1+1, t1+M+1, cmp);
	sort(t2+1, t2+M+1, cmp);
	for(int i = 1; i <= M; ++i)
		if(t1[i].a!=t2[i].a || t2[i].b!=t2[i].b)
			return false;
	return true;
}

void prework()
{
	for(int i = 1; i <= N; ++i)
		if(!mt[i]) for(int j = 1; j <= N; ++j)
				if(i!=j && !mt[j] && OK(i, j)) { mt[i] = j, mt[j] = i; break; }
}

void Init()
{
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= N; ++i)
		scanf("%s", s[i]+1);
}

void Solve()
{
	prework(), dfs(1);
	if(f) printf("YES\n");
	else printf("NO\n");
}

int main()
{
	Init(), Solve();
}

Measured memory_bytes: 256
#include <stdio.h>

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repeat(i, j, n) for(int i = (j); i < (n); i++)
#define all(v) begin(v), end(v)

using namespace std;
int main() {
  while(1){
    int n,k,s;
    cin>>n>>k>>s;
    if(n==0)
      return 0;
    int ans=0;
    for(int state=0;state<(1<<n);state++){
      int count=0,sum=0;
      for(int i=0;i<n;i++)
        if(state&(1<<i)){
            count++;
            sum+=i+1;
        }
      if(count==k && sum==s)
        ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
int main() {
	
	int a, b, c, x, sum, ans;
	ans = 0;
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				sum = 500 * i + 100 * j + 50 * k;
				if (sum == x) {
					ans++;
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
キュー　queue<int> q;
   q.push(7);　//７が入る
   cout << q.front() << endl;  // 先頭の値を出力
   q.pop();  // 先頭の値を削除
   q.empty();
*/
//座標　corrdinateト深さヲ保持スルタメノ構造体
struct Coor{
  ll y;
  ll x;
  ll depth;
};
 ll N,M;  
 ll sy,sx,gy,gx;
 ll y,x,depth;//キューから取り出した座標
vector<string> vec;
queue<Coor> q;
vector<ll> y_vec={0,0,-1,+1};//technique
vector<ll> x_vec={-1,+1,0,0};

int BFS(){
  while(!q.empty()){
    Coor now=q.front();q.pop();//キューの先頭を取り出す
    y=now.y,x=now.x,depth=now.depth;
    
    //停止条件
    if(y==gy&&x==gx){return depth;}
    
    //上下左右４方向を探索、進むことができればキューに格納
    for(int i=0;i<4;i++){
      Coor next={y+y_vec[i],x+x_vec[i],depth+1};
      if(0<=next.y&&next.y<=N-1&&0<=next.x&&next.x<=M-1&&vec[next.y][next.x]=='.'){
        vec[next.y][next.x]='x';//同じ場所を探索しないようにする
        q.push(next);
      }
    }
  }
  return 0;
}
                   
  


int main(void){
cout<<fixed<<setprecision(14);
//cin.tie(0); ios::sync_with_stdio(false);

string S;cin>>S;
  vsort(S);
 // cout<<S<<endl;
bool app[26];
  for(int i=0;i<26;i++){
    app[i]=false;
  }
  for(int i=0;i<S.size();i++){
    app[S[i]-'a']=true;
  }
  for(int i=0;i<26;i++){
    if(!app[i]){cout<<(char)(i+'a')<<endl;
               return 0;
              }
  }
                    
    
 
  cout<<"None"<<endl;
  
  
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
string s;
int n,ans;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>s;
	ans=1;
	for (int i=1;i<s.size();++i)
		if (s[i]!=s[i-1]) ++ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

bool first_win[100001];
void solve(long long N, long long K, std::vector<long long> a) {
  first_win[0] = false;
  FOR(i, 1, K + 1) {
    bool win = false;
    REP(j, N) {
      if (i - a[j] >= 0 && !first_win[i - a[j]]) {
        win = true;
      }
    }
    first_win[i] = win;
  }
  std::cout << (first_win[K] ? "First" : "Second") << std::endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, K, std::move(a));
  return 0;
}


Measured memory_bytes: 384
import itertools
import numpy as np
import sys
input = sys.stdin.buffer.readline

def main():
    N,M,R = map(int,input().split())
    r = list(map(int,input().split()))
    INF = float('INF')
    root = [[INF for _ in range(N)] for _ in range(N)]
    for i in range(N):
        root[i][i] = 0
    for i in range(M):
        A,B,C = map(int,input().split())
        root[A-1][B-1] = C
        root[B-1][A-1] = C
    
    for i in range(N):
        for j in range(N):
            for k in range(N):
                if root[j][k] > root[j][i]+root[i][k]:
                    root[j][k] = root[j][i]+root[i][k]
                
    ans = INF
    for i in itertools.permutations(r):
        L = 0
        for j in range(R-1):
            L += root[i[j]-1][i[j+1]-1]
        ans = min(ans,L)
                
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 13512
L0 = 2
L1 = 1
L = L1 + L0

N = int(input())

for i in range(N - 2):
  
  L0 = L1
  L1 = L
  L = L1 + L0

if N == 1:
  print(L1)
elif N == 2:
  print(L1 + L0)
else:
  print(L)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long a[100001],n,k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	long long f[100001];
	memset(f, 0x7F, sizeof(f));
	f[1]=0;
	for(int i=2;i<=n;i++)
		for(int j=1;j<=k&&j<i;j++)
			f[i]=min(f[i-j]+abs(a[i]-a[i-j]),f[i]);
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
N = int(input())
tmp = []
ans = []

for i in range(N):
	a, b = input().split()
	tmp.append(list((i + 1, a, int(b))))
	
ans = sorted(tmp, key = lambda x:(x[1], -x[2]))

for i in range(N):
	print(ans[i][0])

Measured memory_bytes: 3060
// Last Change: 04/25/2019 18:40:48.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  string S;
  cin >> S;

  ll ans = 100000;
  for (int i = 0; i < S.size() - 2; ++i) {
    string sub = S.substr(i, 3);
    int num = stoi(sub);
    ans = min(ans, (ll)abs(num - 753));
  }

  cout << ans << endl;

  // NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
import heapq
N = int(input())
robo = list(list(map(int,input().split()))for _ in range(N))
robo.sort(key=lambda x:x[0])
queue = []
for x,l in robo:
    heapq.heappush(queue,[x+l,x-l])
ans = 0
left = -float('inf')
while queue:
    q = heapq.heappop(queue)
    if q[1] >= left:
        left = q[0]
        ans += 1
print(ans)



Measured memory_bytes: 41740
s = input()
n = len(s)
ans = 0
for bit in range(1 << n-1):
    t = ""
    for i in range(n-1):
        if bit & (1<<i):
            t += "+"
        t += s[i+1]
    t = s[0] + t

    ans += sum(map(int,t.split("+")))
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

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

  vector<llong> v;
  for(llong i = 1; i * i <= n; ++i){
    if(n % i == 0){
      v.pb(i);
    }
  }

  llong ans = n - 1;
  REPI(itr, v){
    if(*itr == 1){
      ans = n - 1;
    }else
      ans = min(ans, *itr + n / *itr - 2);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    private static long n;

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 18:18-

            int r = sc.nextInt();
            int D = sc.nextInt();
            long x = sc.nextInt();

            for (int i = 0; i < 10; i++) {
                x = x * r - D;
                out.println(x);
            }
        }
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

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

	if(x==7||x==5||x==3){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iterator>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd long long
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
using namespace std;
char a[300005];
ll is_pow_2(ll n){
   ll x=n&(n-1);
   return x>0;	
}
int main(){
   
   ll t;
   cin>>t;
   cout<<1-t<<endl;
   
}
    
   
   

  
   
 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll> a,b;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a.push_back(x);
	}
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		b.push_back(x);
	}
	ll A=0,B=0;
	while( next_permutation(a.begin(), a.end()) ){
		A++;
	}
	while( next_permutation(b.begin(), b.end()) ){
		B++;
	}
	cout << abs(A-B);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
#include <climits>
#include <cstdio>
#include <list>
#include <iomanip>
using namespace std;

#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define si second
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define AS 200001
#define mod 1000000007
double  dp[3001][3001];
double solve(vector<double>&ar, int i, int x) {
	if (x == 0)
		return 1;
	if (i == 0)
		return 0;
	if (dp[i][x] > -0.9)
		return dp[i][x];
	return dp[i][x] = ar[i] * solve(ar, i - 1, x - 1) + (1 - ar[i]) * solve(ar,i - 1, x);
}
int main() {
	fastIO
	int n;
	cin >> n;
	vector<double>ar;
	ar.resize(n + 1);
	memset(dp, -1, sizeof dp);
	F1(ar, n);
	cout << fixed << setprecision(10) << solve(ar, n, (n + 1) / 2);
}

Measured memory_bytes: 70912
#include <iostream>

using namespace std;

int main(){
	
	string X;
	size_t i, ant, tam;
	int tot = 1;


	cin >> X;
	ant = 0;
	tam = 1;
	for (i = 1; i < X.size(); ){
		//cout << "ANT == " << X[ant] << " ATUAL == " << X[i] << " TAM == " << tam << endl;
		if(X[i] == X[ant]){
			if(i+1 == X.size()){
				if(tam > 1){
					tot++;
				}
				i++;
			}else if(tam > 1){
				ant = i;
				tam = 1;
				i++;
				tot++;
			}else{
				ant = i;
				tam = 2;
				i += 2;
				tot++;
			}
		}else{
			ant = i;
			tot++;
			i++;
			tam = 1;
		}
	}

	cout << tot;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)

int main(){
	ll N,M; cin>>N>>M;
	cout<<(N-1)*(M-1);
}

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>
#include <unordered_set>
#include <unordered_map>

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) do{rep(__i,(x).size()) pri(x,__i);}while(0)
#define pran(x,n) do{rep(__i,n) pri(x,__i);}while(0)
#define pral(x) do{cerr << (#x) << " =";rep(__i,(x).size()) cerr<<" "<<(x[__i]);cerr<<endl;}while(0)
#define prar(x,b,e) do{repr(__i,b,e) pri(x,__i);}while(0)

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

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

ll MOD = 1000000007;

function<void(int,int)> tensi_no_3p=[&](int v,int d){
};

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

int main() {
	int N = in();
	vint A(N);
	int s = 0;
	rep(i, N) {
		A[i] = in();
		CHMAX(s, A[i]);
	}
	int t = 0;
	rep(i, N) {
		if (min(t, s - t) < min(A[i], s - A[i])) {
			t = A[i];
		}
	}
	cout << s << " "  << t << endl;
	return 0;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
  best := 0
  out := ""
  for _, c := range s{
    if c == 'A' || c == 'C' || c == 'G' || c == 'T' {
      out += string(c)
    } else {
      if len(out) > best {
        best = len(out)
        out = ""
      }
    }
  }
      if len(out) > best {
        best = len(out)
        out = ""
      }
	fmt.Println(best)
}


Measured memory_bytes: 512
def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
N, M, R = map(int,input().split())
r = list(map(int,input().split()))
d = [[float("inf")]*N for i in range(N)]
edge = [[] for i in range(N)]
for i in range(M):
    x, y, z = map(int,input().split())
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(N):
    d[i][i] = 0

warshall_floyd(d)
ans = float('inf')

import itertools
for i in itertools.permutations(r):
    tmp = 0
    for k in range(1,R):
        tmp += d[i[k-1]-1][i[k]-1]
    ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 75260
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, t, s;
double a[1001];

int main(){
	cin >> n >> t >>s;
	
	for(int i = 0; i < n ;i++){
		cin >> a[i];
		a[i] = t - a[i] * 0.006;
	}
	
	pair<double, int> m = make_pair(1000000.0, 0);
	for(int i = 0; i < n; i++){
		if(m.first > abs(a[i] - s)){
			m.first = abs(a[i]-s);
			m.second = i;
		}
	}
	
	cout << m.second+1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
N,Q=list(map(int,input().split()))
edge = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = list(map(int,input().split()))
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

node = [0]*N
for _ in range(Q):
    p,x = list(map(int,input().split()))
    node[p-1] += x

from collections import deque
q = deque()
q.append(0)
visited = [False]*N
visited[0] = True
while len(q) > 0:
    index = q.pop()
    
    for e in edge[index]:
        if visited[e]:
            continue
        node[e] += node[index]
        visited[e] = True
        q.append(e)
print(*node)



Measured memory_bytes: 64680
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 1; (i) <= (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int h, w; cin >> h >> w;
	vector<string> v(h + 2);
	rep(i, h)
	{
		string s; cin >> s;
		s = '#' + s + '#';
		v[i] = s;
	}
	string buf ="";
	rep(i, w + 2)buf += '#';
	v[0] = v[h + 1] = buf;
	int res = 0;
	int INF = 1e5;
	int d[] = { 0,1,0,-1 };
	rep(sx, h)rep(sy, w)rep(gx, h)rep(gy, w)
	{
		if (v[sx][sy] == '#' || v[gx][gy] == '#')continue;
		vector<vector<int>> g(h + 2, vector<int>(w + 2, INF));
		g[sx][sy] = 0;
		queue<pair<int, int>> q;
		q.push(make_pair(sx, sy));
		while (!q.empty())
		{
			int x, y;
			tie(x, y) = q.front();
			q.pop();
			for(int i = 0; i < 4; ++i)
			{
				int nx = x + d[i];
				int ny = y + d[i ^ 1];
				if (v[nx][ny] == '.'&&g[nx][ny] == INF)
				{
					g[nx][ny] = g[x][y] + 1;
					q.push(make_pair(nx, ny));
				}
			}
		}
		chmax(res, g[gx][gy]);
	}
	cout << res << endl;
}

Measured memory_bytes: 3652
H,W=map(int,input().split())
grid=[None]*H
for i in range(H):
  grid[i]=list(map(int,input().split()))
  
ans=[]
for i in range(H):
  for j in range(W):
    if grid[i][j]%2==1:
      if j+1<W:
        grid[i][j]-=1
        grid[i][j+1]+=1
        ans.append([i+1,j+1,i+1,j+1+1])
      elif i+1<H:
        grid[i][j]-=1
        grid[i+1][j]+=1
        ans.append([i+1,j+1,i+1+1,j+1])
      else:
        continue        

print(len(ans))
for p in ans:
  print(*p)

Measured memory_bytes: 30372
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

struct node
{
	int distance;
	bool accessed;
	node(int d, bool a) : distance(d), accessed(a) {}
};

void bfs(vector<node> &nodes, vector<vector<bool>> &conn_mat)
{ //index = n-1
	nodes[0].accessed = true;
	nodes[0].distance = 0;
	queue<int> bfs_queue;
	bfs_queue.push(0);
	int dis = 0;
	while (!bfs_queue.empty())
	{
		int index = bfs_queue.front();
		int i = 0;
		bfs_queue.pop();
		for (auto connected : conn_mat[index])
		{
			if (connected && (!nodes[i].accessed))
			{
				bfs_queue.push(i);
				nodes[i].accessed = true;
				nodes[i].distance = nodes[index].distance + 1;
			}
			i++;
		}
	}
}

int main()
{

	int n_node, index, n_cn, cn;
	cin >> n_node;
	vector<node> nodes(n_node, node(-1, false));
	vector<bool> vertex(n_node, false);
	vector<vector<bool>> conn_mat(n_node, vertex);
	while (n_node--)
	{
		cin >> index >> n_cn;
		while (n_cn--)
		{
			cin >> cn;
			conn_mat[index - 1][cn - 1] = true;
		}
	}
	bfs(nodes, conn_mat);
	int i = 0;
	for (node nd : nodes)
	{
		i++;
		cout << i << ' ' << nd.distance << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
using namespace std;
typedef long long ll;
/*
int mojisuu(string s) {
	int cnt = 1;
	bool flag = true;
	for (int i = 1; i < s.size(); ++i) {
		for (int j = 0; j < i; ++j) {
			flag = true;
			if (s[i] == s[j]) {
				flag = false;
			}
		}
		if (flag) {
			cnt++;
		}
	}
	return cnt;
}
*/
int doumoji(string s1, string s2) {
	int cnt = 0;
	string s3 = "";
	bool flag;
	for (int i = 0; i < s1.size(); ++i) {
		for (int j = 0; j < s2.size(); ++j) {
			if (s1[i] == s2[j]) {
				flag = true;
				for (int k = 0; k < s3.size(); ++k) {
					if (s3[k] == s1[i]) {
						flag = false;
					}
				}
				if (flag) {
					s3 += s1[i];
					cnt++;
				}
			}
		}
	}
	return cnt;
}
int main() {
	int n;
	string s;
	//char a[110];
	//bool flag = true;
	cin >> n >> s;
	//cin >> n;
	/*string s1 = s.substr(0, 2);
	string s2 = s.substr(2, n - 2);
	cout << doumoji(s1,s2) << endl;*/
	int res = 0;
	for (int i = 1; i < n; ++i) {
		string s1 = s.substr(0, i);
		string s2 = s.substr(i);
		res = max(res,doumoji(s1, s2));
	}
	/*for (int i = 0; i < n; ++i) {
	cin >> a[i];
	if (a[i] == 'Y') {
	flag = false;
	}
	}
	if (flag) {
	cout << "Three" << endl;
	}
	else {
	cout << "Four" << endl;
	}
	*/

	//int res = max({ a + b,a - b,a * b });
	cout << res << endl;
	return 0;

}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    K, X = LI()
    start = X-K+1
    end = X+K-1
    li = [str(x) for x in list(range(start, end+1)) if -1000000 <= x <= 1000000]
    print(' '.join(li))

main()

Measured memory_bytes: 3064
use proconio::*;

fn run() {
    input! {
        n: usize,
        d: [(u32, u32); n],
    }
    let elem = d.windows(3).any(|d| d.iter().all(|d| d.0 == d.1));
    let ans = if elem { "Yes" } else { "No" };
    println!("{}", ans);
}

fn main() {
    run();
}


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

int main (){
   string s ;
   cin >> s;
   if(s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
        return 0;}
    cout << "No" << endl;
    return 0;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int M1, D1, M2, D2;
  std::cin >> M1 >> D1 >> M2 >> D2;

  if(M1 != M2) {
    std::cout << "1" << '\n';
  } else {
    std::cout << "0" << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string S,T;cin>>S>>T;
    sort(S.begin(),S.end());
    sort(T.begin(),T.end());
    reverse(T.begin(),T.end());
    int N=min(S.size(),T.size());
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(S[i]<T[j]){
                cout<<"Yes"<<endl;
                return 0;
            }
            if(S[i]==T[j]){
                break;
            }
            else{
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    if(S.size()<T.size()){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
 
using namespace std;
 
int main() {
  int n, x, cnt;
 
  while(cin >> n >> x && n || x) {
    cnt=0;
    for(int i=1; i <= n-2; i++) {
      for(int j=i+1; j <= n-1; j++) {
        for(int k=j+1; k <= n; k++) {
          if(i+j+k == x) cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}


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


int main()
{
int N;
cin>>N;
vector<int>X(N);
for(int i=0;i<N;i++)
{cin>>X[i];}
vector<int>answers(100);
for(int i=0;i<100;i++)
{answers[i]=0;
for(int j=0;j<N;j++)
{answers[i]+=(i+1-X[j])*(i+1-X[j]);}
}
sort(answers.begin(),answers.end());
cout<<answers[0]<<endl;



}



Measured memory_bytes: 256
//077A
#include <iostream>
using namespace std;
int main(void){
    string s1 = " ";
    string s2 = " ";
    cin >> s1 >> s2;
    if (s1[0]==s2[2] and s1[1] == s2[1] and s1[2]==s2[0]){
        cout << "YES";
    }else{
        cout << "NO";
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int n, k;
	cin >> n >> k;

	vector<int> b(n, 0);

	rep(i, k){
		int d;
		cin >> d;

		rep(i, d){
			int a;
			cin >> a;
			a--;
			b[a]++;
		}
	}

	int ans = 0;
	rep(i, n) if(b[i] == 0) ans++;

	cout << ans << endl;
}


Measured memory_bytes: 3660