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

#define STRING(str) #str

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<string> S(N);
	vector<string> ans(N);
	mf_graph<int> graph(N*M+2);
	int s = N*M;
	int t = N*M+1;
	// s-> even / odd -> t
	for (int i=0;i<N;i++) {
		cin >> S[i];
		ans[i] = S[i];
		for (int j=0;j<M;j++) {
			if ((i+j)%2 == 0) {
				// even
				if (S[i][j] == '.') {
					graph.add_edge(s, i*M+j, 1);
				}
			} else { // (i+j)%2 == 1
				// odd
				if (S[i][j] == '.') {
					graph.add_edge(i*M+j, t, 1);
				}
			}
		}
	}

	// even -> odd
	for (int i=0;i<N;i++) {
		for (int j=0;j<M;j++) {
			if ((i+j)%2 == 0 && (S[i][j] == '.')) {
				// even
				if (i-1>=0 && S[i-1][j] == '.') {
					graph.add_edge(i*M+j, (i-1)*M+j, 1);
				}
				if (j-1>=0 && S[i][j-1] == '.') {
					graph.add_edge(i*M+j, i*M+(j-1), 1);
				}
				if (i+1<N && S[i+1][j] == '.') {
					graph.add_edge(i*M+j, (i+1)*M+j, 1);
				}
				if (j+1<M && S[i][j+1] == '.') {
					graph.add_edge(i*M+j, i*M+(j+1), 1);
				}
			}
		}
	}
	cout << graph.flow(s, t) << endl;

	vector<mf_graph<int>::edge> edges = graph.edges();
	for (auto edge : edges) {
		if ((edge.from != s) && (edge.to != t) && (edge.flow == 1)) {
			int ff = edge.from;
			int tt = edge.to;

			if (tt-ff == M) {
				ans[ff/M][ff%M] = 'v';
				ans[tt/M][tt%M] = '^';
			} else if (ff-tt == M) {
				ans[ff/M][ff%M] = '^';
				ans[tt/M][tt%M] = 'v';
			} else if (ff-tt == 1) {
				ans[ff/M][ff%M] = '<';
				ans[tt/M][tt%M] = '>';
			} else if (tt-ff == 1) {
				ans[ff/M][ff%M] = '>';
				ans[tt/M][tt%M] = '<';
			}
		}
	}

	for (int i=0;i<N;i++) {
		cout << ans[i] << endl;
	}
}

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

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

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> a_sorted = a;
	sort(a_sorted.begin(), a_sorted.end(), greater<int>());

	int maximum_f = a_sorted[0];
	int maximum_s = a_sorted[1];
	
	for (int i = 0; i < n; i++) {
		int ans;
		if (a[i] == maximum_f) ans = maximum_s;
		else ans = maximum_f;
		cout << ans << endl;
	}

	return 0;
}

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

const int MAXN=200100;
bool node1[MAXN],node2[MAXN];
int main() {
	memset(node1,0,sizeof(node1));
	memset(node2,0,sizeof(node2));
	int n,m; cin>>n>>m;
	for (int i=0;i<m;i++) {
		int a,b;
		cin>>a>>b;
		if (a==1)
			node1[b]=1;
		if (b==1)
			node1[a]=1;
		if (a==n)
			node2[b]=1;
		if (b==n)
			node2[a]=1;
	}
	for (int i=2;i<n;i++)
		if (node1[i] && node2[i]) {
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


Measured memory_bytes: 1272
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String args[]) throws Exception{
    	final int L= 20;
    	final int S= 19;
    	final int[] DAY_YEAR     ={ L,S,L,S,L,S,L,S,L,S };
//    	final int[] DAY_LEAP_YEAR={ L,L,L,L,L,L,L,L,L,L };
    	final int DAYS_YEAR= 5*(L+S);
    	final int DAYS_LEAP_YEAR= 10*L;
    	final int NUM_MILL= (999- 999/3)*DAYS_YEAR+ 999/3*DAYS_LEAP_YEAR+ 1;
    	
    	BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
    	int N= Integer.parseInt( br.readLine() );
    	int year,month,day;
    	int num_tot,num_prev_year,num_this_year;
    	for(int i=0;i<N;i++){
    		String[] buf= br.readLine().split(" ");
    		year = Integer.parseInt(buf[0]);
    		month= Integer.parseInt(buf[1]);
    		day  = Integer.parseInt(buf[2]);
    		
    		num_prev_year  =(year-1- (year-1)/3)*DAYS_YEAR+ (year-1)/3*DAYS_LEAP_YEAR;
    		if( year%3==0 ){
    			num_this_year= (month-1)*L+ day;
    		} else{
    			num_this_year= 0;
    			for(int j=0;j<month-1;j++){
    				num_this_year+= DAY_YEAR[j];
    			}
    			num_this_year+= day;
    		}
    		num_tot= num_prev_year + num_this_year;
    		System.out.println(NUM_MILL-num_tot);
    	}
    }
}

Measured memory_bytes: 16996
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int prev = 0;
    int cnt = 0;
    rep(i, N) {
        cin >> A[i];
        if (A[i] == prev + 1) {
            cnt++;
            prev = A[i];
        }
    }

    if (cnt == 0) {
        cout << -1 << endl;
    } else {
        cout << N - cnt << endl;
    }
}

Measured memory_bytes: 1024
import itertools
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
a=[]
for i in range(1,N+1):
    a.append(i)
ans=[]
for j in itertools.permutations(a):
    ans.append(list(j))
print(abs(ans.index(P)-ans.index(Q)))

Measured memory_bytes: 10228
// #include "bits/stdc++.h"
#include<iostream>
#include<algorithm>
#include<bitset>
#include<string>
#include<vector>
#include<string.h>
#include<map>
#include<queue>
#include<stack>


using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

using ll = long long;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
int n, m, k;
string s[N];
vector<vector<int>> bfs(int xx, int yy) {
    auto check  = [&] (int x, int y) {
        if(x >= 0 and x < n and y >= 0 and y < m)
            return true;
        return false;
    };
    queue<pair<int, int>> q;
    q.push({xx, yy});
    vector<vector<int>> dist(n, vector<int> (m, 1e9));
    vector<vector<int>> vis(n, vector<int> (m, 0));

    dist[xx][yy] = 0;
    while(!q.empty()) {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        vis[x][y] = 1;
        debug(x, y);
        for(int i = 0; i < 4; i++) {
            for(int j = 1; j <= k; j++) {
                int nx = x + dx[i] * j;
                int ny = y + dy[i] * j;
                if(!check(nx, ny))
                    break;            
                if(s[nx][ny] == '@')    break;
                if(dist[nx][ny] >= dist[x][y] + 1) {
                    if(vis[nx][ny] == 0) {
                        dist[nx][ny] = dist[x][y] + 1;
                        vis[nx][ny] = 1;
                        q.push({nx, ny});
                    }
                }
                else
                    break;
            }
        }
    }
    return dist;

}
signed main() {
    input;
    cin >> n >> m >> k;
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; x2--; y1--; y2--;

    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }
    vector<vector<int>> d = bfs(x1, y1);
    cout << (d[x2][y2] == 1e9 ? -1 : d[x2][y2]);
}




Measured memory_bytes: 47240
#include <iostream>



using namespace std;

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int result = 0,tmp_int;
  for(int i=1;i<=n;i++){
    tmp_int=(i%10)+((i/10)%10)+((i/100)%10)+((i/1000)%10)+((i/10000)%10);
    if(a<=tmp_int&&tmp_int<=b){
      result+=i;
    }
  
  }
  cout<<result<<endl;

  return 0;
}

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

template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
if (!v.empty()) {
    out << '[';
    std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}

int main(){
    int n;
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++){
        ans += i;
    }
    cout << ans << endl;
    return 0;

}

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

/////////////////////////////////////////////////////////

void Main(){
  int N; cin >> N;
  vector<int> H(N);
  rep(i, 0, N) cin >> H[i];
  int res = 0;
  int cur = H[0];
  int cnt = 0;
  rep(i, 1, N){
    if(H[i] <= H[i - 1]) cnt++;
    else{
      if(cnt > res) res = cnt;
      cnt = 0;
    }
  }
  if(cnt > res) res = cnt;
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int A[N];
  int C[M+1] = {};
  for(int i=0;i<N;i++){
    cin >> A[i];
    int B[A[i]];
    for(int j=0;j<A[i];j++){
      cin >> B[j];
      C[B[j]]++;
    }
  }
  int ans = 0;
  for(int i=1;i<=M;i++){
    if(C[i] == N) ans++;
  }
  cout << ans << endl;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    cout << 6 - A - B << endl;
}

Measured memory_bytes: 256
def main():
    #N,K,C=map(int,input().split())
    #A=list(map(int,input().split()))
    S=input()
    S=int(S)
    ans=0
    for i in range(S+1):
        if i%3!=0 and i%5!=0:
            ans+=i
    print(ans)
    

main()


Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,A,B,C;
int ans = 0;
int L[10];
int dfs(int k, int a, int b, int c){
    if(k == N){
        if(min(a,min(b,c))){
            return abs(a-A)+abs(b-B)+abs(c-C);
        } else {
            return MAX;
        }
    }
    int ans = MAX;
    ans = min(ans, dfs(k+1,a,b,c));
    ans = min(ans, dfs(k+1, a+L[k], b, c) + (a>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b+L[k], c) + (b>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b, c+L[k]) + (c>0 ? 10:0));
    return ans;
}
int main(){
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++) cin >> L[i];
    int res = dfs(0,0,0,0);
    cout << res << endl;
}



Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
// int dx[]={0,1,0,-1,1,1,-1,-1};
// int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int dx[]={-1,-1,0,0,1,1};
int dy[]={-1,0,-1,1,0,1};//RDLU
int main(){
	string s;
	cin>>s;
	int a;
	cin>>a;
	for(int i=0;i<s.size();i+=a)cout<<s[i];
	cout<<endl;
}
	








Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U> bool chmax(T &a, U b) { if (a <= b) {a = b; return 1;} return 0; }
template <class T, class U>  bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T>  ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; }

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
    ll x=0,y=0,z=0,n,m,ans=0,sum=0,k,w,Max=-1,Min=1e9+1;
    bool ok = true;
    string s,t;
    cin >> n >> m;
    VI h(n);
    rep(i,n) cin >>h[i];
    VI a(m),b(m),c(n);

    rep(i,m) { cin >> a[i] >> b[i];  }
    rep(i,m){
        if(h[a[i]-1] > h[b[i]-1] ){
            c[b[i]-1]++;
        }
        else if(h[a[i]-1] < h[b[i]-1]){
            c[a[i]-1]++;
        }
        else{
            c[b[i]-1]++;
            c[a[i]-1]++;
        }
    }
    rep(i,n){
        if(c[i]==0)
            ans++;
    }


    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string N;
  cin>>N;
  if(N[0]=='9'||N[1]=='9')puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=3010,p=1e9+7;
void inc(int &x,int y){x+=y;if (x>=p) x-=p;}
int n,m,dp[N][N][2];
//dp[i][j][S]表示做了i次操作,剩下j个红球,红球是否恰好用完过的方案数
int main()
{
	scanf("%d%d",&m,&n);
	for (int i=1;i<=m;i++) dp[0][i][0]=1;
	dp[0][0][1]=1;
	for (int i=0;i<n;i++)
	for (int j=0;j<=m;j++)
	for (int k=0;k<2;k++){
		int v=dp[i][j][k];
		if (j){
			inc(dp[i+1][j][k|(j==1)],v);//RB
			inc(dp[i+1][j-1][k|(j==1)],v);//RR
		}
		if (j<m){
			inc(dp[i+1][j][k],v);//BR
			inc(dp[i+1][j+1][k],v);//BB
		}
	}
	int ans=0;
	for (int i=0;i<=m;i++) inc(ans,dp[n][i][1]);
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> v(100,0);
    for (int i = 0; i < N; i++) {
        int j; cin >> j;
        v.at(j - 1) = j;
    }

    int ans = 0;
    for (int i = 0;i < 100; i++) {
        if (v.at(i) != 0) ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll A, B, K;
    cin >> A >> B >> K;


    cout << max(0LL, A - K) << " " << max(0LL, B - max(0LL, K - A)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 107;
const int MOD = 1000000007;

void solve() {
    int n, w;
    cin >> n >> w;
    long weight[MAX], value[MAX];
    for (int i = 1; i <= n; i++) {
        cin >> weight[i] >> value[i];
    }
    long dp[n + 7][w + 7];
    for (int i = 0; i <= w; i++) {
        dp[0][i] = 0;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= w; j++) {
            if (weight[i] <= j) {
                dp[i][j] = max(dp[i - 1][j], value[i] + dp[i - 1][j - weight[i]]);
            }
            else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[n][w];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("in.in", "r", stdin); freopen("out.out", "w", stdout);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {cout << "Case #" << i << ": "; solve();}
    solve();
}

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

int main(){

  int a = 0,b = 0,c = 0,i =0,n = 0,m = 0;

  cin >> a >> b >> c;

  if(a > b){
    i = b;
    b = a;
    a = i;
  } if(b > c){
    n = c;
    c = b; 
    b = n;
  } if(a > b){
    m = b;
    b = a;
    a = m;
  }

  cout << a << " " << b << " " << c << "\n";

  return 0;

}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;
int main(void)
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, 0, 3) if (s[i] == t[i]) ans++;
    cout << ans << endl;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int h, w;
  cin >> h >> w;
  string s = "snuke";
  rep (i, h) {
    rep (j, w) {
      string t;
      cin >> t;
      if (s == t) {
        cout << char('A' + j) << i + 1 << endl;
      }
    }
  }
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i=0;i<n1;i++) L[i] = A[left + i];
	for(int i=0;i<n2;i++) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	int i=0,j=0;
	for(int k=left;k<right;k++){
		cnt++;
		if(L[i] <= R[j]){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[], int n, int left, int right){
	if(left+1<right){
		int mid = (left + right) / 2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(){
	int A[MAX],n,i;
	cnt = 0;
	cin >> n;
	for(i=0;i<n;i++) cin >> A[i];

	mergeSort(A,n,0,n);

	for(i=0;i<n;i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

using Graph = vector<vector<int>>;


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

	int N, K;
	cin >> N >> K;
	int cnt = (N-1)*(N-2)/2;
	if(K > cnt){
		cout << -1 << endl;
		return 0;
	}
	cnt = (N-1) + cnt-K;
	int num = 0;
	cout << cnt << endl;
	for(int i=2;i<=N;i++){
		cout << 1 << " " << i << endl;
		num++;
	}
	int dx = 1;
	while(true){
		if(num == cnt) return 0;
		for(int i=2;i+dx<=N;i++){
			if(num == cnt) return 0;
			cout << i << " " << i+dx << endl;
			num++;
		}
		dx++;
	}
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    REP(i, N) cin >> H[i];

    int num = 0, ans = 0;
    REP(i, N){
        if(i < N-1 and H[i] >= H[i+1]) ++num;
        else{
            ans = max(ans, num);
            num = 0;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,e,count;
    cin>>a>>b>>c;
    count=0;
    for(int j=1;j<=c;j++){
        cin>>d>>e;
        if(a>d&&a<e){
            count=1;
        }else if(b>d&&b<e){
            count=1;
        }else if(a==d&&b==e){
            count=1;
        }else if(a<d&&b>e){
            count=1;
        }
    }
    cout<<count<<endl;
}



Measured memory_bytes: 3116
from numpy import*;B,I=searchsorted,lambda:int32(input().split());input();a,b=I(),I();c=0
for k in range(29):l=2**k;h=2*l;y=sort(hstack((b%h-h,b%h)));c+=sum(B(y,h-a%h)-B(y,l-a%h))%2*l
print(c)

Measured memory_bytes: 37912
N,K=map(int,input().split())
arr=[int(input()) for i in range(N)]
arr=sorted(arr)
min_dis=arr[K-1]-arr[0]
for i in range(1,len(arr)-K+1):
  temp=arr[i+K-1]-arr[i]
  min_dis=min(min_dis,temp)
print(min_dis)
  
  



Measured memory_bytes: 8280
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	static void Main()
	{
		var M = 1000000007;
		var s3s = new List<string>();
		Make3s(s3s, "");
		var id = Enumerable.Range(0, 64).ToDictionary(i => s3s[i]);
		var bl = new HashSet<string> { "AGC", "GAC", "ACG", "AGGC", "ATGC", "AGTC" };

		var n = int.Parse(Console.ReadLine());

		var dp = new long[n + 1, 64];
		dp[0, 63] = 1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 64; j++)
			{
				var s2 = s3s[j].Substring(1);
				foreach (var c in "ACGT")
				{
					var s3 = s2 + c;
					var s4 = s3s[j] + c;
					if (bl.Contains(s3) || bl.Contains(s4)) continue;
					dp[i + 1, id[s3]] += dp[i, j];
					dp[i + 1, id[s3]] %= M;
				}

			}
		Console.WriteLine(Enumerable.Range(0, 64).Sum(i => dp[n, i]) % M);
	}

	static void Make3s(List<string> l, string s)
	{
		if (s.Length == 3) l.Add(s);
		else foreach (var c in "ACGT") Make3s(l, s + c);
	}
}


Measured memory_bytes: 17628
n, k = map(int, input().split())

A = [0] * n

for i in range(k):
    d = input()
    A_okashi = map(int, input().split())

    for j in A_okashi:
        if A[j-1] == 0:
            A[j-1] = 1

print (A.count(0))

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int A, B, C;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> A >> B >> C;
    if(A==B && B!= C) cout <<"Yes\n";
    else if(A==C && C!= B) cout <<"Yes\n";
    else if(B==C && A!= B) cout <<"Yes\n";
    else cout <<"No\n";
    return 0;
}

Measured memory_bytes: 256
PROGRAM-ID.                      ABC_105_C.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N       PIC S9(11).
    01 str     PIC X(128).
    01 ans     PIC X(128).
    01 R       PIC 9(1).
    01 p       PIC 9(3).
    01 len     PIC 9(3).
    01 i       PIC 9(3).

PROCEDURE                        DIVISION.
    ACCEPT N.

    MOVE 1 TO p.

    PERFORM UNTIL N = ZERO
        IF FUNCTION MOD(N, 2) = 1
            SUBTRACT 1 FROM N
            STRING
                '1'
                INTO str POINTER p
            END-STRING
        ELSE
            STRING
                ZERO
                INTO str POINTER p
            END-STRING
        END-IF
        DIVIDE -2 INTO N
    END-PERFORM.

    COMPUTE len = FUNCTION STORED-CHAR-LENGTH(str).

    MOVE 1 TO p.

    PERFORM VARYING i FROM len BY -1 UNTIL i <= ZERO
        STRING
            str(i:1)
            INTO ans POINTER p
        END-STRING
    END-PERFORM

    IF ZERO = len
        DISPLAY ZERO
    ELSE
        DISPLAY ans(1:len)
    STOP RUN.


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, X, Y, Z, a[MAXN], b[MAXN], c[MAXN], num[MAXN];
long long ans, rn;
set<pair<int, int> > s, t[3];
void makeFindT() {
	while (t[0].size() < Y) {
		auto p = *t[1].begin();
		p.first = -p.first, rn = rn - c[p.second] + b[p.second];
		t[0].insert(p);
		t[1].erase(t[1].begin());
	}
}
void makeFindS() {
	auto fr = *s.begin();
	s.erase(s.begin());
	rn = 1ll * rn - fr.first;
	return;
}
int main() {
	ios_base::sync_with_stdio (false);
	cin.tie(0);
	cout.tie(0);
	cin >> X >> Y >> Z;
	n = X + Y + Z;
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i] >> c[i];
	iota(num, num + n, 0);
	sort(num, num + n, [] (int x, int y) { return (a[x] - b[x] > a[y] - b[y]); });
	for (int i = 0; i < X; i++) {
		s.insert({a[num[i]] - c[num[i]], num[i]});
		rn += a[num[i]];
	}
	for (int i = X; i < n; i++) {
		t[1].insert({-1 * (b[num[i]] - c[num[i]]), num[i]});
		rn += c[num[i]];
	}
	makeFindT();
	ans = max(ans, rn);
	for (int i = X; i < n - Y; i++) {
		pair<int, int> fr = {a[num[i]] - c[num[i]], num[i]}, sd = {b[num[i]] - c[num[i]], num[i]};
		s.insert(fr);
		rn += a[fr.second];
		makeFindS();
		auto p = *t[0].begin();
		if (sd >= p) {
			t[0].erase(sd);
			rn -= b[sd.second];
		}
		else {
			sd.first = -sd.first;
			t[1].erase(sd);
			rn -= c[sd.second];
		}
		makeFindT();
		ans = max(ans, rn);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)

int main(){
  string S;
  int K, N;
  cin >> N >> K >> S;

  S.at(K - 1) = tolower(S.at(K - 1));
  cout << S << endl;
}

Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;
#define int long long
signed main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	int n, a, b;
	cin >> n >> a >> b;
	if (a > b) return 0 * printf("0");
	if (n == 1 && a != b) return 0 * printf("0");
	int maxx = b * (n - 1) + a;
	int minn = a * (n - 1) + b;
	cout << max(0LL, maxx - minn + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll a, c;
		ld b;
		cin >> a >> b;
		b += 1e-6;
		c = b * 100;
		a = a * c / 100;
		cout << a << "\n";
	}
	return 0;
}

Measured memory_bytes: 3708
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        int n2 = sc.nextInt();
        if (n1 < n2) {
            System.out.println("a < b");
        } else if (n1 > n2) {
            System.out.println("a > b");
        } else if (n1 == n2) {
            System.out.println("a == b");
        } else {
        }
    }
}


Measured memory_bytes: 26112
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  deque<int64_t> p(A), q(B), r(C);
  for (auto& e : p)cin >> e;
  for (auto& e : q)cin >> e;
  for (auto& e : r)cin >> e;
  sort(rbegin(p), rend(p));
  sort(rbegin(q), rend(q));
  sort(rbegin(r), rend(r));
  int64_t ans = 0;
  for (int i = 0, a = X, b = Y, c = C; i < X + Y; ++i) {
    auto t = max({ tie(p,a),tie(q,b),tie(r,c) }, [](auto& a, auto& b) {
      return get<1>(a) * get<1>(b) ? get<0>(a).front() < get<0>(b).front() : get<1>(a) == 0;
      });
    auto& que = get<0>(t);
    auto& index = get<1>(t);
    ans += que.front();
    que.pop_front();
    --index;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int a[3];
	cinf(a,3);
	sort(a,a+3);
	cout << a[0]+a[1] << endl;	
}

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

const int MOD=1e9+7;
int add(int x,int y){return(x+=y)<MOD?x:x-MOD;}
int sub(int x,int y){return(x-=y)>=00?x:x+MOD;}
int mul(int x,int y){return(ll)x*y%MOD;}

ll k;
int n;
int a[50][50];
int b[50][50];

void mul(int a[50][50],int b[50][50]){
  int c[50][50]={};
  for(int i=0;i<50;++i)
  for(int j=0;j<50;++j)
  for(int k=0;k<50;++k)
  c[i][j]=add(c[i][j],mul(a[i][k],b[k][j]));
  memcpy(a,c,sizeof c);
}

int main(){
  scanf("%d%lld",&n,&k);
  for(int i=0;i<n;++i){
    b[i][i]=1;
    for(int j=0;j<n;++j){
      scanf("%d",&a[i][j]);
    }
  }
  while(k){
    if(k&1)mul(b,a);
    mul(a,a);
    k/=2;
  }
  int sol=0;
  for(int i=0;i<n;++i)
    for(int j=0;j<n;++j)
      sol=add(sol,b[i][j]);
  printf("%d\n",sol);
}


Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int main() {
    int N, Q;
    cin >> N;

    set<int> S;
    for (int i = 0; i < N; ++i) {
        int n;
        cin >> n;
        S.insert(n);
    }

    cin >> Q;

    int ans = 0;
    for (int i = 0; i < Q; ++i) {
        int n;
        cin >> n;
        if (S.find(n) != S.end()) ++ans;
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define N 100001
ll n,ki=0;

int main(){
	cin>>n;
	FOR(i,0,n){
		ll a;
		cin>>a;
		if(a%2){
			ki++;
		}
	}
	if(ki%2){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int a;
    int current = 1;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        if (a == current)
        {
            current++;
        }
    }
    if (current == 1)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << N - (current - 1) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>
#include <climits>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll

using namespace std;
using Graph = vector<vector<int> >;

int Input[300100];
int LS[300100];
int RS[300100];

signed main() {
  int N; cin >> N;

  for (int i = 0; i < N*3; i++) {
    cin >> Input[i];
  }

  priority_queue<int, vector<int>, greater<int> > Left;
  priority_queue<int, vector<int>, less<int> > Right;

  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += Input[i];
    Left.push(Input[i]);
  }

  LS[N] = sum;

  for (int i = N; i < 2*N; i++) {
    if (Input[i] > Left.top()) {
      sum -= Left.top();
      Left.pop();
      Left.push(Input[i]);
      sum += Input[i];
    }
    LS[i+1] = sum;
  }

  int ssum = 0;
  for (int i = 3*N -1; i >= 2*N; i--) {
    ssum += Input[i];
    Right.push(Input[i]);
  }

  RS[2*N] = ssum;

  for (int i = 2*N -1; i >= N; i--) {
    if (Input[i] < Right.top()) {
      ssum -= Right.top();
      Right.pop();
      Right.push(Input[i]);
      ssum += Input[i];
    }
    RS[i] = ssum;
  }

  int ans = LLONG_MIN;
  for (int i = N; i <= 2 * N; i++) {
    ans = max(ans, LS[i] - RS[i]);
    
  }

  cout << ans << endl;
}


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

int main(){
    set<int> dia;
    int n, d;

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> d;
        dia.insert(d);
    }

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

Measured memory_bytes: 256
cube = gets.chomp.split("").map(&:to_i)
cnt0 = 0
cnt1 = 0
cube.each do |col|
  if col == 0
    cnt0 += 1
  else col == 1
    cnt1 += 1
  end
end
if cnt0 < cnt1
  puts cnt0 * 2
else
  puts cnt1 * 2
end

Measured memory_bytes: 7676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(), (c).end());
const long long MOD = 10e9 + 7;
typedef long long ll;

int main(){
	string s;
	cin >> s;
	int N = s.size();
	vector<char> S(N);
	rep(i, N)S.at(i) = s.at(i);
	int ans = 0;
	int cnt = 0;
	for(int i = 0; i < N; i++){
		if(S.at(i) == 'A')cnt++;
		else if(S.at(i) == 'T')cnt++;
		else if(S.at(i) == 'G')cnt++;
		else if(S.at(i) == 'C')cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
		if(i == N - 1){
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	cout << ans << endl;
}

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

void call(int n); 
int main(){

int n;
cin >> n;
call(n);


return 0;
}


void call(int n){
  int i;

  for(i=1;i<=n;i++){
  	int x=i;
  	if(x%3==0){
		cout << " " << i;
  	}else if(x%10==3){
		cout << " " << i;
  	}else{
  		while(x!=0){
  			x /= 10;
  			if(x%10==3){
  					cout << " " << i;
  					break;
  			}
  		}
  	}
  }
  cout << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
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;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n; ;
    vb kind(4,false);
    rep(i,0,n){
       char s;
       cin>>s;
        if(s=='P'){
            kind[0]=true;
        }
        else if(s=='W'){
            kind[1]=true;
        }
        else if(s=='G'){
            kind[2]=true;
        }
        else
        {
            kind[3]=true;
        }

    }
    int cnt=0;
    rep(i,0,4)if(kind[i])cnt++;
    if(cnt==3)cout<<"Three"<<endl;
    else cout<<"Four"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if((i<=h-b && j<=w-a)||(i>h-b && j>w-a)) printf("1");
			else printf("0");
		}
		puts("");
	}
}


Measured memory_bytes: 1280
n=int(input())
s=input()
a=0
x=""
y=""
for i in range(n):
    if s[i]=="(":
        a+=1
    else:
        a-=1
if a>0:
    s=s+")"*a
elif a<0:
    s="("*abs(a)+s
#print(s)
t=0

while t==0:
    b=0
    for i in range(len(s)):
        if s[i]=="(":
            b+=1
        else:
            b-=1
        if b<0:
            s="("+s+")"
            #print(s)
            break
    if b==0:
        break
print(s)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

h, w, a, b = map(int, input().split())
if a > w // 2 or b > h // 2:
    print("No")
    exit()
ans = [[0] * w for _ in range(h)]
for i in range(0, b):
    for j in range(0, a):
        ans[i][j] = 1
for i in range(b, h):
    for j in range(a, w):
        ans[i][j] = 1
for line in ans:
    print("".join([str(item) for item in line]))

Measured memory_bytes: 12020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication66
{
    class Program
    {
        static void Main()
        {
           long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            List<long[]> b = new List<long[]>();
            for(int c=0; c < a[0]; c++)
            {
                long[] d = Console.ReadLine().Split().Select(long.Parse).ToArray();
                b.Add(d);
            }
            for(int e = 0; e < a[2]; e++)
            {
                int f = int.Parse(Console.ReadLine());
                if (b[f - 1][1] == 1)
                {
                    bool g = true;
                    if (f != b.Count)
                    {
                        for(int h = f; h < b.Count; h++)
                        {
                            if (b[h][1] == 2)
                            {
                                g = false;                              
                                {
                                  if ((b[h][0] + b[h - 1][0]) / 2 < b[f - 1][0] + a[1]) { Console.WriteLine((b[h][0]+b[h-1][0])/2); break; }
                                  else { Console.WriteLine(b[f - 1][0] + a[1]); break; }
                                 }
                                
                            }
                        }
                    }
                    if (g) { Console.WriteLine(b[f - 1][0] + a[1]); }
                }
                else
                {
                    bool g = true;
                    if (f != 0)
                    {
                        for (int h = f -2; h >-1; h--)
                        {
                            if (b[h][1] == 1)
                            {
                                g = false;
                                
                                
                                    if (((b[h][0] + b[h + 1][0]) / 2) <(b[f - 1][0] - a[1])) { Console.WriteLine(b[f - 1][0] - a[1]); break; }
                                    else {  Console.WriteLine((b[h][0] + b[h + 1][0]) / 2); break; }
                                
                            }
                        }
                    }
                    if (g) Console.WriteLine(b[f - 1][0] - a[1]);
                }
            }
        }
    }
}

Measured memory_bytes: 18272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>
#define sz(x) (int)((x).size())
#define make_unique(v) v.erase(unique(all(v)),v.end())
#define int long long

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

const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 200 + 11;

int n,m,D,dp[N][2],dp1[N][2];

string K;

int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);

    cin >> K >> D;

    dp[0][0] = 1;

    for(int i = sz(K) - 1; i >= 0; i--){
        int x = K[i] - '0';

        //dp[rest][0] - all the good posibilities by now
        //dp[rest][1] - all the bad posibilities by now
       

        for(int sum = 0; sum < D; sum++){
            for(int dig = 0; dig <= 9; dig++){
                if(x == dig){
                    dp1[(sum + dig)%D][0] += (dp[sum][0])%mod;
                    dp1[(sum + dig)%D][0] %= mod;

                    dp1[(sum + dig)%D][1] += (dp[sum][1])%mod;
                    dp1[(sum + dig)%D][1] %= mod;
                }else{
                    dp1[(sum + dig)%D][(dig > x ? 1 : 0)] += (dp[sum][1] + dp[sum][0])%mod;
                    dp1[(sum + dig)%D][(dig > x ? 1 : 0)] %= mod;
                }
            }
        }

        for(int k = 0; k < D; k++){
            for(int b = 0; b <= 1; b++){
                dp[k][b] = dp1[k][b];
                dp1[k][b] = 0;
            }
        }
    }

    int ans = dp[0][0] - 1;
    ans %= mod;
    ans += mod;
    ans %= mod;
    rc(ans);
return 0;
}

Measured memory_bytes: 256
cnt=1
mochi=[]
import sys
X=int(input())
for i in sys.stdin.readlines():
  mochi.append(int(i.rstrip()))
mochi=sorted(mochi,reverse=True)

cnter=mochi[0]
for j in mochi:
  if cnter!=j:
    cnt+=1
    cnter=j
print(cnt)

Measured memory_bytes: 3060
using System;

class Program
	{
		public static void Main(string[] args)
		{
			string data=Console.ReadLine();
			string[] arg=data.Split();
			// WW???HH???xx???yy???rr 
			int W =int.Parse( arg[0]);
			int H = int.Parse( arg[1]);
			int x=int.Parse( arg[2]);
			int y =int.Parse( arg[3]);
			int r=int.Parse( arg[4]);
			//x :r~W-r
			//y :r~H-r
			if(((r<=x)&&(x<=(W-r)))&&((r<=y)&&(y<=(H-r))))
			Console.WriteLine("Yes");
			else Console.WriteLine("No");
		}
}

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

int n;
#define NO {printf("No");return 0;}
string str,str2;
map<string,int>mp;
int main(){
    scanf("%d",&n);
    cin>>str;mp[str]=1;
    for(int i=1;i<n;i++){
        cin>>str2;
        if(str[str.length()-1]!=str2[0])NO
        if(mp[str2])NO
        mp[str2]=1;str=str2;
    }printf("Yes");
    return 0;
}

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

int main() {
 int n,a;
 int ans = 1e9;
 cin >> n;
 for(int i=0;i<n;i++){
   cin >> a;
   int cnt = 0;
   while(a%2 == 0){
     cnt++;
     a /= 2;
   }
   if(ans > cnt){
     ans = cnt;
   }
 }
 cout << ans << endl;
}

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



/*int main() {
    
    int n; cin >> n;
    string s = "";
    while(n != 0){
        if(n%(-2) != 0){
            n--;
            s += '1';
        }else s += '0';
        n /= -2;
    }
    if( s.size() == 0 ){
        cout << "0" << endl;
        return 0;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    cout<<s[1];
    
    return 0;
}*/





int main(){


    int n;
    cin>>n;
    int ans[10000];
    int i=0;
    if(n==0){
        cout<<0;
        return 0;
    }
    
while(n!=1){
        if(n%2==0){
            n=n/(-2);
           
            ans[i]=0;
            
           // cout<<n<<ans[i]<<endl;
            i++;
            
        }else{
            n=(n-1)/(-2);
       
            ans[i]=1;
          //  cout<<n<<ans[i]<<endl;
            i++;
                      }
    ans[i]=1;
        }
    while(i>=0){
        cout<<ans[i];
        i--;
        
    }

return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int K;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();

        System.out.println(solve());
    }

    static long solve() {
        int[] knt = new int[K];
        for (int i = 1; i <= N ; i++) {
            knt[i % K]++;
        }

        long ret = 0;
        for (int a = 0; a < K; a++) {
            int bc = (2*K - a) % K;
            if( bc*2 % K == 0 ) {
                ret += (long)knt[a] * knt[bc] * knt[bc];
            }
        }
        return ret;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 22484