akhauriyash/Code-Regression huggingface dataset:
/*coderanant*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    string a;
    cin>>a;

    int arr1[n];//for #
    int arr2[n];
        arr1[0]=0;
    f1(i,1,n)
    {
        if(a[i-1]=='#')
        {
            arr1[i]=arr1[i-1]+1;
        }
        else
            arr1[i]=arr1[i-1];
        //cout<<arr1[i]<<gp;
    }
    arr2[n-1]=0;
    f2(i,n-2,0)
    {
        if(a[i+1]=='.')
        {
            arr2[i]=arr2[i+1]+1;
        }
        else
            arr2[i]=arr2[i+1];
    }
    int min=99999999999;
    // f1(i,0,n)
    // {
    //     cout<<arr1[i]<<gp<<arr2[i]<<endl;
    // }
    f1(i,0,n)
    {
        if(arr1[i]+arr2[i]<min)
            min=arr1[i]+arr2[i];
    }
    if(min>9999999999)
        cout<<0;
    else
    cout<<min;
    return 0;

}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<int mod>
class Combination {
    std::vector<long long> fact, finv, inv;
    
public:
    Combination(int sz) {
        fact.resize(sz);
        finv.resize(sz);
        inv.resize(sz);
        fact[0] = 1;
        for(int i=1;i<sz;++i) {
            fact[i] = fact[i-1] * i % mod;
        }
        inv[0] = 0;
        inv[1] = 1;
        for(int i=2;i<sz;++i) {
            inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        }
        finv[0] = 1;
        for(int i=1;i<sz;++i) {
            finv[i] = finv[i-1] * inv[i] % mod;
        }
    }

    long long C(long long n, long long k) {
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return (fact[n] * finv[k] % mod) * finv[n-k] % mod;
    }

    long long P(long long n, long long k) {
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fact[n] * finv[n-k] % mod;
    }

    long long H(long long n, long long k) {
        return this->C(n + k - 1, k);
    }

    long long getfact(int i) {
        return fact[i];
    }

    long long getinv(int i) {
        return inv[i];
    }

    long long getfinv(int i) {
        return finv[i];
    }
};

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

  Combination<MOD> comb(100000);

  ll n, k; cin >> n >> k;
  for(int i=1;i<=k;++i) {
    cout << comb.C(n-k+1, i) * comb.C(k-1, i-1) % MOD << endl;
  }

}


Measured memory_bytes: 2560
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

ll dp[100005];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> h(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &h[i]);
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(i=2; i<n; i++) {
        dp[i]=MIN(abs(h[i-2]-h[i])+dp[i-2],abs(h[i-1]-h[i])+dp[i-1]);
    }
    printf("%lld\n", dp[n-1]);
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll x;
    cin>>x;
    ll a,b;
    for(ll i=-1000;i<=1000;i++)
    {
        for(ll j=-1000;j<=1000;j++)
        {
            if(i*i*i*i*i-j*j*j*j*j==x)
            {
                a=i;
                b=j;
                break;
            }
        }
    }
    cout<<a<<" "<<b<<'\n';


}


Measured memory_bytes: 3652
N,M = input().split()
N,M = int(N),int(M)
L,R = [],[]

for i in range(M):
    l,r = input().split()
    l,r = int(l),int(r)
    L.append(l)
    R.append(r)

max_L = max(L)
min_R = min(R)
import numpy as np
L = np.array(L)
R = np.array(R)

print(min_R-max_L+1) if min_R-max_L+1>=1 else print(0)

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

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

        int n = sc.nextInt();
        int[][] a = new int[n][2];
        int[][] b = new int[n][2];

        for(int i = 0; i < n; i++){
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();
        }

        for(int i = 0; i < n; i++){
            b[i][0] = sc.nextInt();
            b[i][1] = sc.nextInt();
        }

        sc.close();
        
        Arrays.sort(a, (s, t) -> Integer.compare(t[1],s[1]));

        Arrays.sort(b, (s, t) -> Integer.compare(s[0],t[0]));

        int result = 0;

        loop:
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if((a[i][0] < b[j][0]) && (a[i][1] < b[j][1])){
                    result++;
                    b[j][0] = -1;
                    b[j][1] = -1;
                    continue loop;
                }
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 29012
from collections import Counter
c = Counter()
for _ in range(3):
	a, b = map(int, input().split())
	c[a] += 1
	c[b] += 1
one, two = 0, 0
for i in range(1, 5):
	if c[i] == 1:
		one += 1
	elif c[i] == 2:
		two += 1
if (one, two) == (2, 2):
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define  ll  long long
#define  sf  scanf
#define  pf  printf
int main()
{
    int t,z,i,n,m;
    sf("%d %d",&n,&m);
    if(m==100)
    {
        m++;
    }
    if(n==0)
    {
        pf("%d\n",m);
    }
    else if(n==1)
    {
        pf("%d\n",(m*100));
    }
    else
    {
        pf("%d\n",(m*10000));
    }
    return 0;
}


Measured memory_bytes: 256
x=range(int(input())-1,-1,-1)
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j+1][1]*P[j][0]-P[j][1]*P[j+1][0]
print(_*0.5)

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

using namespace std;

int main()
{
  int n, y;

  scanf("%d %d", &n, &y);

  bool can = false;

  for (int i = 0; i <= n; i++)
  {
    for (int j = 0; j <= n; j++)
    {
      if (10000 * i + 5000 * j + 1000 * (n - i - j) == y && n - i - j >= 0)
      {
        printf("%d %d %d\n", i, j, n - i - j);

        can = true;
        break;
      }
    }
    if (can)
      break;
  }

  if (can == false)
    printf("-1 -1 -1");
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  int n;
  n=(int)s.length();
  vector<int> array(n,0);
  vector<int> r(n,0);
  vector<int> l(n,0);
  vector<int> ans(n,0);
  for(int i=0;i<n-1;i++){
    if(s[i]=='R'&&s[i+1]=='L'){
      array[i]=1;
      array[i+1]=1;
    }
    if(s[i]=='R') r[i]++;
    if(s[i+1]=='L') l[i+1]++;
  }
  int buf=1;
  int odd=0;
  int even=0;
  for(int i=0;i<n;i++){
    if(array[i]==1) {
      ans[i]++;
      buf=i;
    }
    if(array[i]!=1){
      if(l[i]==1){
	if((i-buf)%2==0) ans[buf]++;
	else ans[buf-1]++;
      }
    }
  }
  for(int i=n-1;i>=0;i--){
    if(array[i]==1){
      buf=i;
    }
    if(array[i]!=1){
      if(r[i]==1){
	if((buf-i)%2==0) ans[buf]++;
	else ans[buf+1]++;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
  return 0;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  cout << (N+1) / 2 << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);


int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  int maxv = 0;
  for(auto p : mp) maxv = max(maxv, p.second);
  for(auto p : mp) {
    if(p.second != maxv) continue;
    cout << p.first << endl;
  }
  return 0;
}

Measured memory_bytes: 25216
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

inline int add(int _a, int _b)
{
	_a += _b;
	if(_a >= MOD)
	{
		_a -= MOD;
	}
	return _a;
}

inline int sub(int _a, int _b)
{
	_a -= _b;
	_a %= MOD;
	while(_a < MOD)
	{
		_a += MOD;
	}
	return _a % MOD;
}

inline int mul(int _a, int _b)
{
	return (long long) _a * _b % MOD;
}

int rows, cols;
ll temp;

int X, Y;

int main()
{

	scanf("%d %d", &rows, &cols);

	for(int i = 0; i < rows; i++)
	{
		scanf("%lld", &temp);
		X = add(X, mul(i, temp));
		X = sub(X, mul(sub(rows, add(i, 1)), temp));
	}

	// cout << X << "\n";

	for(int i = 0; i < cols; i++)
	{
		scanf("%lld", &temp);
		Y = add(Y, mul(i, temp));
		Y = sub(Y, mul(sub(cols, add(i, 1)), temp));
	}

	cout << mul(X, Y);


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  string s,t;
  cin >>  n >> s >> t;
  rep(i,n){
    cout << s[i] << t[i];
  }
  cout  << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define LIM 100005
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define vi vector <int>
#define pb push_back
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
int32_t main()
{
  IOS;
  int t,x,y,k,n,i,j;
  cin>>n;
  t=n%1000;
  if(t==0)
    cout<<0;
  else
    cout<<1000-t;
    return 0;
}


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

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

  int ans = 0;
  for (int a = 1; a < n; a++) {
    for (int b = 1; b < n; b++) {
      if (n <= a * b) {
        break;
      } else {
        ans++;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define sq(a)           (a)*(a)
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define rep(i,a,b)      for(i=a;i<=b;i++)
#define Fo(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(x)          x.begin(),x.end()
#define rall(x)         x.rbegin(),x.rend()
#define sortall(x)      sort(all(x))
#define sortrall(x)     sort(rall(x))
#define clr(x)          memset(x,0,sizeof(x))
#define tr(it, a)       for(auto it=a.begin();it!=a.end();it++)
#define pii             pair<int,int>
#define mk(arr,n,type)  type *arr=new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y)/gcd(x,y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.1415926535897932384626
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
void __print(int32_t x) {cout<<x;}
void __print(int x) {cout<<x;}
void __print(ld x) {cout<<x;}
void __print(double x) {cout<<x;}
void __print(float x) {cout<<x;}
void __print(bool x) {cout<<(x?"true":"false");}
void __print(char x) {cout <<'\''<<x<<'\'';}
void __print(const char *x) {cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f=0;cout<<'{';for(auto &i:x)cout<<(f++?",":""),__print(i);cout<<"}";}void _print(){cout<<"]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif
int power(int base,int exp) {int res=1;base%=mod;while(exp>0){if(exp&1)res=(res*base)%mod;base=(base*base)%mod;exp=exp>>1;}return res;}
int inv(int x) {return power(x,mod-2)%mod;}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




const int N=1e6+6,M=N;
int i,j;

void solve() {
    
    int l,r,d; cin>>l>>r>>d;
    int cnt=0;

    Fo(i,l,r) if(i%d==0) cnt++;
    cout<<cnt;
    
    
    
    
}




int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int n, m;
long a[105];
long sum, res;

int main()
{
	cin >> n;

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

	cin >> m;

	for (int i = 0; i < m; ++i)
	{
		long p, x, tmp;

		cin >> p >> x;

		res = sum;
		res -= a[p - 1];
		res += x;

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// ABC095 B
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

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

    int mm = 100000;
    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;

        if (m < mm) {
            mm = m;
        }

        x -= m;
    }

    cout << n + x / mm << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    cout << n*n*n << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int x,y;
    cin >> x >> y;
    bool flag = false;
    for(int i = 0; i <= x; i++){
        int j = x - i;
        if(i * 2 + j * 4 == y) flag = true; 
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;


set<pair<int,string> > makeTree(string str){

	set<pair<int,string> > trees; 

	if(str.size()==1&&str[0]>='0'&&str[0]<='9'){
		trees.insert(make_pair((int)(str[0]-'0'),str));
		return trees;
	}
	else{
		for(int i = 0; i < str.size(); i++){
			if(str[i]=='*'||str[i]=='+'||str[i]=='-'){
				string str1 = str.substr(0,i);
				string str2 = str.substr(i+1);
				set<pair<int,string> > spis = makeTree(str1);
				set<pair<int,string> > spis2 = makeTree(str2);
				for(set<pair<int,string> >::iterator it = spis.begin(); it!=spis.end(); it++){
					for(set<pair<int,string> >::iterator iit = spis2.begin(); iit!=spis2.end(); iit++){
						if(str[i]=='*'){
							int ret=it->first*iit->first;
							string rets = '(' + it->second + ") * (" + iit->second + ')';
							trees.insert(make_pair(ret,rets));
						}
						else if(str[i]=='+'){
							int ret=it->first+iit->first;
							string rets = '(' + it->second + ") + (" + iit->second + ')';
							trees.insert(make_pair(ret,rets));
						}
						else if(str[i]=='-'){
							int ret=it->first-iit->first;
							string rets = '(' + it->second + ") - (" + iit->second + ')';
							trees.insert(make_pair(ret,rets));
						}
					}
				}
			}
		}
	}
	return trees;
}

int main(){

	int a,b,c,d;
	char op[3];
	op[0]='+';
	op[1]='-';
	op[2]='*';

	while((cin>>a>>b>>c>>d)&&!(a==0&&b==0&&c==0&&d==0)){
		bool f=false;
		vector<int> v;
		v.push_back(a);
		v.push_back(b);
		v.push_back(c);
		v.push_back(d);
		sort(v.begin(),v.end());
		do{
			for(int i = 0; i < 3; i++){
				for(int j = 0; j < 3; j++){
					for(int k = 0; k < 3; k++){
						string str="";
						str+=(char)(v[0]+'0');
						str+=(char)op[i];
						str+=(char)(v[1]+'0');
						str+=(char)op[j];
						str+=(char)(v[2]+'0');
						str+=(char)op[k];
						str+=(char)(v[3]+'0');
						set<pair<int,string> > spbs = makeTree(str);
						for(set<pair<int,string> >::iterator it = spbs.begin(); spbs.end()!=it; it++){
							if(it->first==10){
								cout<<'(' + it->second + ')'<<endl;
								f=true;
								break;
							}
						}
						if(f)
							break;
					}
					if(f)
						break;
				}
				if(f)
					break;
			}
			if(f)
				break;
		}while(next_permutation(v.begin(),v.end()));
		if(!f)
			cout<<0<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
  int a=0;
  int b=0;
  int t=0;
  int ans = 0;


  scanf("%d %d %d",&a, &b, &t);
  for(int i=1; 1;i++){
    if( (i*a) > t ){
      break;
    }
    ans += b;
  }

  printf("%d\n",ans);

  return 0;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    long long sum=0,counter=0;
    for(int i=0;i<n;i++)
    {
        sum+=arr[i];
        if(sum<=k)counter++;
    }
    cout<<counter+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int m = 1e9;

int main() {
  ll s;
  cin >> s;
  int x1 = 0, y1 = 1;
  int x2 = m, y2 = 0;
  int x3 = (s - 1) % m + 1, y3 = (s - 1) / m + 1;
  cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  ll ans=1;
  sort(a.begin(),a.end());
  bool is=true;
  if(n%2==1){
    if(a.at(0)!=0){
      is=false;
    }
    ll p=2;
    for(ll i=1;i<n;i+=2){
      if(a.at(i)!=a.at(1+i) || a.at(i) != p){
        is=false;
      }
      p+=2;
    }
  }else{
    ll p=1;
    for(ll i=0;i<n;i+=2){
      if(a.at(i)!=a.at(i+1) || a.at(i)!=p){
        is=false;
      }
      p+=2;
    }
  }
  if(is){
    if(n%2==1){
      n--;
    }
    n=n/2;
    ll mod=1e9+7;
    for(ll j=0;j<n;j++){
      ans=ans*2;
      ans%=mod;
    }
  }else{
    ans=0;
  }
  cout << ans;
}

Measured memory_bytes: 3912
#include<stdio.h>
int main(){
	int i, j, x, y, total;
	
	scanf("%d %d %d %d", &i, &j, &x, &y);
	
		if(i>j){
			total = j*x;
			total = total + (i-j)*y;
		}
	
		else{
			total = i*x;
		}
	
	
	printf("%d\n", total);
	
return 0;	
}

Measured memory_bytes: 128
import sys


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


MOD = 998244353
n = int(input())
xys = []
ys = []
for line in sys.stdin:
    x, y = map(int, line.split())
    xys.append((x, y))
    ys.append(y)
ys.sort()
y_dict = {y: i + 1 for i, y in enumerate(ys)}
xys = [(x, y_dict[y]) for x, y in xys]
xys.sort()
bit = Bit(n)

p2d = [1]
for i in range(n):
    p2d.append(p2d[-1] * 2 % MOD)

ans = 0
for i, (x, y) in enumerate(xys):
    a = bit.sum(y)
    b = i - a
    c = y - a - 1
    d = (n - i - 1) - c
    bit.add(y, 1)
    # print(i, x, y, a, b, c, d)
    pa, pb, pc, pd = p2d[a], p2d[b], p2d[c], p2d[d]
    tmp = p2d[n - 1]
    tmp += (pa - 1) * (pd - 1) * (pb + pc - 1) % MOD
    tmp += (pb - 1) * (pc - 1) % MOD * pa * pd % MOD
    ans = (ans + tmp) % MOD
print(ans)


Measured memory_bytes: 110932
#include<iostream>
using namespace std;
int len, cnt_0, cnt_1;
string s;
int main() {
    cin>>s;
    len=s.size();
    for (int i = 0; i <len; ++ i)
        if (s[i] == '0')++ cnt_0;
        else if (s[i] == '1')++ cnt_1;
    cout<<2*min(cnt_0,cnt_1)<<endl;;
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
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); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int N;  cin>>N;
  vector<int> v(N);
  ll sum=0;
  rep(i,0,N) cin>>v[i], sum+=v[i];
  sort(all(v));
  if(sum%10 != 0){
  }else{
    int k=1e5;
    rep(i,0,N){
      if(v[i]%10!=0){
        k=v[i];
        break;
      }
    }
    sum -= k;
    chmax(sum, 0LL);
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	int n = fetch<int>();
	auto a = fetch_vec<int>(n);
	ll answ = 0;

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

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

	set<int> setik;
	int ch = 0;

	for(int i = n - 1; i >= 0; --i) {
		setik.insert(a[i] - ch);

		while(!setik.empty()) {
			auto fst = setik.begin();

			if(*fst + ch <= 0) {
				setik.erase(fst);
			} else {
				break;
			}
		}

		answ += len(setik);
		--ch;
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>

using namespace std;


int main(){
  int n, m;

  while(cin >> n >> m, n != 0 && m != 0){
    int a[n];
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    int max = -1;
    for(int i = 0; i < n; i++){
      for(int j = i+1; j < n; j++){
        if(max < a[i] + a[j] && a[i] + a[j] <= m){
          max = a[i] + a[j];
        }
      }
    }
    if(max == -1) cout << "NONE" << endl;
    else          cout << max << endl;


    /*for(int i = 0; i < n; i++){
      cout << a[i] << endl;
    }*/

  }
}



Measured memory_bytes: 3100
import java.util.*;

public class Main {
  
  private static final int MOD = 1_000_000_007;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    if (Math.abs(N-M) > 1) {
      System.out.println(0);
      return;
    }
    int min = Math.min(N, M);
    long a = perm(min);
    long aa = (a*a) % MOD;
    long ans;
    if (M == N) {
      ans = (2*aa) % MOD;
    } else {
      ans = (Math.max(N,M)*aa) % MOD;
    }
    System.out.println(ans);
  }
  
  private static long perm(int n) {
    if (n == 1) {
      return 1;
    }
    return (n*perm(n-1)) % MOD;
  }
}

Measured memory_bytes: 29392
#include<stdio.h>
#include<math.h>
#define PI 3.1415926535

int main(){
        double a, b, x;
        scanf("%lf %lf %lf", &a, &b, &x);
        if(x > a*a*b/2.0){
                double rad = atan((b-(2*x/a/a-b)) / a);
                printf("%lf\n", rad/PI * 180);
        }else{
                double rad = atan(b / (2*x/b/a));
                printf("%lf\n", rad/PI * 180);
        }
        return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	int n;
	cin >> n;
	vl a(n + 1);
	for (int i = 0;i <= n;i++)
		cin >> a[i];
	vl l(n + 1);
	if (a[0] > 1) {
		cout << "-1\n";
		return 0;
	}
	l[0] = 1 - a[0];
	for (int i = 1;i <= n;i++) {
		if (l[i - 1] * 2 < a[i]) {
			cout << "-1\n";
			return 0;
		}
		l[i] = l[i - 1] * 2 - a[i];
	}
	vl r(n + 2, 0);
	ll ans = 0;
	for (int i = n;i >= 0;i--) {
		r[i] = min(r[i + 1], l[i]) + a[i];
		ans += r[i];
	}
	cout << ans << '\n';
}


Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
typedef long long ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ll n;
	cin>>n;
	ll i=0;
	while(i*i<=n){
		i++;
	}	
	cout<<(i-1)*(i-1);

   return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <map>

using namespace std;

int main()
{
    long long n, a, mx = 0, smx = 0;
    cin >> n;
    map <long long, int> mp;
    for (int j = 0; j < n; j++) {
        cin >> a;
        mp[a]++;
        if (mp[a] > 1) {
            if (mx < a) {
                smx = mx;
                mp[a] -= 2;
                mx = a;
            }
            else if (smx < a) {
                smx = a;
                mp[a] -= 2;
            }
        }
    }
    cout << smx * mx;
}


Measured memory_bytes: 6528
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
using namespace std;
#define INF 100000
#define MAX 100000
#define MOD 1000000007n
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
//typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int main(){
  char ans[110][110];
  int W,B;
  cin>>W>>B;
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      char c;
      if(i<=50) c='.';
      else c='#';
      ans[i][j]=c;
    }
  }
  W--; B--;
  bool flag=false;
  int count=0;
  for(int i=1;;i+=2){
    for(int j=1;j<=100;j+=2){
      if(count>=B){
        flag=true; break;
      }
      count++;
      ans[i][j]='#';
    }
    if(flag) break;
  }

  flag=false;
  count=0;
  cout<<100<<" "<<100<<endl;
  for(int i=100;;i-=2){
    for(int j=1;j<=100;j+=2){
      if(count>=W){
        flag=true; break;
      }
      count++;
      ans[i][j]='.';
    }
    if(flag) break;
  }
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++) cout<<ans[i][j];
    cout<<endl;
  }

}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i = 1;
  cin >> N;
  while (true){
    if(N >= i*2){
      i *= 2;
    }
    else{
      cout << i;
      return 0;
    }
  }    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <unordered_map>
#include <assert.h>
using namespace std;

#define ran(i, a, b) for ((i) = (a); (i) < (b); (i)++)
#define rep(i, a) ran ((i), 0, (a))
#define rep1(i, a) ran ((i), 1, (a)+1)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;
#define _0 first
#define _1 second
#define _pb(x) push_back(x)
#define _mp(x, y) make_pair(x, y)
#if defined(SHIROKO1_LOCAL) && !defined(NDEBUG)
#define DEBUG(...) fprintf(stderr, "[DEBUG] " __VA_ARGS__)
#else
#define DEBUG(...) ((void)0)
#endif

int main()
{
	int a, b, c;
	int n;
	cin >> a >> b >> c;
	n = 0;
	while (a%2 == 0 && b%2 == 0 && c%2 == 0) {
		int na = b/2 + c/2;
		int nb = a/2 + c/2;
		int nc = a/2 + b/2;
		a = na;
		b = nb;
		c = nc;
		//DEBUG("%i %i %i\n", a, b, c);
		n++;
		if (n > 100000000) {
			puts("-1");
			return 0;
		}
	}
	cout << n << endl;
	return 0;
}


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

int main()
{
    int i;
   string K[3]={"Sunny","Cloudy","Rainy"};
   string S;
   cin>>S;
   for(i=0;i<3;i++)
   {
       if(K[i]==S)
       {
           if(i==2){
            cout<<K[0];
           }
           else{
           cout<<K[i+1];
           }
       }
   }
    return 0;
}


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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;

int main(){
	
	FASTIO

	string s, t;
	cin >> s >> t;
	
	int ans = INT_MAX;
	for(int i=0; i<=s.size()-t.size(); i++) {
		int d = 0;
		for(int j=0; j<t.size(); j++) {
			if(t[j] != s[i+j]) d++;
		}
		ans = min(ans, d);
	}
	
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h> 
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb emplace_back 
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii; 
typedef vector<int> vi; 
typedef pair<string, int> Psi; 
typedef pair<ll, ll> Pll;
#define int long long

signed main(){
	string str;
	cin >> str;

	int ans = 0;
	rep(i,1<<(str.size()-1)){
		vi bit(str.size());
		rep(j,str.size()-1){
			if(i>>j&1){
				bit[j] = 1;
			}
		}
		int sum = 0;
		int c = str[0]-'0';
		rep(j,str.size()-1){
			if(bit[j] == 1){
				sum += c;
				c = str[j+1]-'0';
			}
			else{
				c *= 10;
				c += (str[j+1]-'0');
			}
		}
		sum += c;
		ans += sum;
	}

	cout << ans << endl;

	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

void Solve(){
	int n,t[10000];
	cin >> n;
	rep(i,0,n-1) cin >> t[i];

	static int dp[2][2][6000];
	fill_n((int*)dp,2*2*6000,INF);
	dp[0][0][1]=dp[0][1][0]=0;
	rep(i,0,n-1){
		rep(j,0,n/2+100){
			if(j-1>=0) dp[1][0][j]=min(dp[0][0][j-1],dp[0][1][j-1]+t[i]);
			dp[1][1][j]=min(dp[0][1][j],dp[0][0][j]+t[i]);

			dump(j);
			dump(dp[1][0][j]);
			dump(dp[1][1][j]);
		}
		swap(dp[0],dp[1]);
	}

	cout << min(dp[0][0][n/2],dp[0][1][n/2]) << endl;
}

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

Measured memory_bytes: 1328
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n;
  rd(n);
  int tot = 0;
  for (int i = 1; i <= n; i += 2) {
    int k = 2;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0)
        k += 2;
    }
    if (k == 8) {
      tot++;
    }
  }
  writeln(tot);

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 256
n,m,l=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=[list(map(int,input().split())) for i in range(m)]

c=[[0 for i in range(l)] for j in range(n)]

for i in range(n):
    lst=[0 for _ in range(l)]
    for j in range(l):
        sm=0
        for k in range(m):
            sm+=a[i][k]*b[k][j]
        lst[j]=str(sm)
    print(" ".join(lst))


Measured memory_bytes: 6540
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;



int main(){
    string s;
    cin >> s;
    if(s.size() % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < s.size() / 2; i += 2){
        if(s[i] != 'h' || s[i+1] != 'i'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool isPrime(int x)
{
    if(x==1)
        return false;
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
int main(int argc, const char * argv[])
{
    int x;
    cin>>x;
    while(!isPrime(x))
        x++;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli gcd(lli a,lli b){
    if(!b) return a;
    return gcd(b,a%b);
}

lli x,y;

int main(){
    cin >> x >> y;
    cout << gcd(x,y) << endl;
}

Measured memory_bytes: 3108
w = {}
l = {}
for _ in range(int(input())):
    u, c, d = input().split() 
    if c == "lock":
        if u not in l:l[u] = set([d])
        else:l[u].add(d)
    else:
        if d not in w:w[d] = set([u])
        else:w[d].add(u)
f = 0
for k in l:
    a = [k]
    while True:
        b = set()
        for i in a:
            if i in l:b |= l[i]
        b = list(b)
        a = set()
        for i in b:
            if i in w:a |= w[i]
        a = list(a)
        if k in a:
            print(1)
            f = 1
            break
        elif a == []:break
    if f:break
else:print(0)


Measured memory_bytes: 5712
#include<bits/stdc++.h>
using namespace std;
main(){
  while(1){
    int noon,afternoon,max=0,maxn=-1;
    for(int i=0;i<5;i++){
      cin>>noon>>afternoon;
      if(noon==afternoon&&afternoon==0){
	return 0;
      }
      if(max<noon+afternoon){
	max=noon+afternoon;
	maxn=i;
      }
    }
    char a='A'+maxn;
    cout<<a<<" "<<max<<endl;
  }
}

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

int main()
{
  int n;
  int k;
  cin >> n >> k;
  int h[1000000];
  int count = 0;
  for(int i = 0; i < n; i++ )
  {
    cin >> h[i];
    if( h[i] >= k )
      count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
 
const int N = 1e5 + 5;
 
int n, m, k;
int x11, y11, x2, y2;
int dx[4]={-1, +1, 0, 0};
int dy[4]={0, 0, +1, -1};
vector<vector<char> > a;
vector<vector<int> > vis, ways, dist;
 
void bfs(int x, int y)
{
	queue<pair<int, int> > q;
	q.push({x, y});
	vis[x][y] = 1;
	dist[x][y] = 0;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		for(int dir=0;dir<4;dir++)
		{
			for(int len = 1; len <= k; len++)
			{
				int nx=x+dx[dir] * len;
				int ny=y+dy[dir] * len;
				if(nx<1 || ny<1 || nx>n || ny>m)
					break;
				if(vis[nx][ny] && dist[x][y] + 1 > dist[nx][ny])
					break;
				if(a[nx][ny] == '@')
					break;
				if(vis[nx][ny])
					continue;
				dist[nx][ny]=dist[x][y]+1;
				vis[nx][ny]=1;
				q.push({nx, ny});
			}
		}
	}
}
 
int32_t main()
{
	IOS;
	cin >> n >> m >> k;
	cin >> x11 >> y11 >> x2 >> y2;
	a = vector<vector<char> > (n + 1, vector<char> (m + 1));
	vis = ways = dist = vector<vector<int> > (n + 1, vector<int> (m + 1, 0));
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> a[i][j];
	bfs(x11, y11);
	if(!vis[x2][y2])
		cout << -1;
	else
		cout << dist[x2][y2];
	return 0;
}


Measured memory_bytes: 32524
#include <iostream>
#include <vector>
#include<iomanip>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int N;
vector<int> d;
map<int, int>m;

int main(int argc, const char * argv[]) {
    cin >> N;
    int i,k;
    for (i = 0; i < N; i++) {
        cin >> k;
        if (!m[k]) {
            m[k] = true;
            d.push_back(k);
        }
    }
    cout << d.size() << endl;
    return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  ll A;
  double B;
  cin>>A>>B;
  ll pa =A*((ll)(B*(double)100));
  cout<<(A*((ll)(B*(double)100+0.001)))/100LL <<endl;
  
  
  
}


Measured memory_bytes: 3756
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  if(x==2&&y==2){
    cout<<"Yes"<<endl;
  }else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
    cout<<"Yes"<<endl;
  }else 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"<<endl;
  }else cout<<"No"<<endl;
      
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
//#define int long long
#define double long double
#define vec vector
#define vi vector<int>
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first, l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
// Init variables here
void input() {
	
}

void solve() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	s[k-1] = tolower(s[k-1]);
	cout << s << endl;
}

//#undef int
int main() {
//#define int long long
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

  //int t; cin >> t;
  //while (t--) 
  {
    input();
    solve();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int S=sc.nextInt();
		int h=S/3600;
		int m=(S-3600*h)/60;
		int s=S%60;

		System.out.println(h+":"+m+":"+s);

	}

}



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

int main(){
    long long int x, y;
    cin >> x >> y;
    if (x >= 0){
        if (y >= x){
            cout << y - x;
        }
        else if (y >= -x){
            long long int s1 = min ( 1+ x+ y, 2+ x - y);

            cout << s1;

        }
        else {
           long long int s1 = 1 - (x+y);
            cout << s1;
        }
    }
    else {
        if (y >= -x){
            cout << 1 + y +x;
        }
        else if (y >= x){
            cout << min (y - x, 1-y - x);
        }
        else {
            cout << 2 + x - y;
        }



    }











    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{  int n;
 cin >> n;
   int a[n];


   long long sum=0;

   int small,big;

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

       cin >> a[i];
   }
   big=a[0];
   small=a[0];
   for (int i=0; i<n; ++i)
   {
       sum+=a[i];
      if(a[i]<small){
        small=a[i];
       }
       if(a[i]>big){
        big=a[i];
       }
   }



   cout <<small << " "<< big << " "<< sum << endl;
   return 0;


}



Measured memory_bytes: 3140