akhauriyash/Code-Regression huggingface dataset:
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 105 
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N;
    ll ans = 0;
    fei(i, 1, N, 1) {
    	cin >> arr[i];
    	if((i % 2) && (arr[i] % 2)) {
    		ans++;
    	} 
    }
    cout << ans << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3608
from functools import reduce

n, a, b = map(int, input().split())
DIV = 10**9 + 7

def nCr(N, R, DIV):
    f = lambda x,y: x*y%DIV
    X = reduce(f, range(N-R+1, N+1))
    Y = reduce(f, range(1, R+1))
    return X*pow(Y, DIV-2,DIV)%DIV

all_combi = pow(2,n,DIV)
combi_a = nCr(n,a,DIV)
combi_b = nCr(n,b,DIV)


output = all_combi-1 - combi_a - combi_b
# if output>(10**9+7):
#     output = output%(10**9+7)
print(output%DIV)


Measured memory_bytes: 3572
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	int sum=a+b+c;
	int max1=max(a,max(b,c));
	for(int i=max1*3;1;i+=3)
	  {
	  	if(sum<=i)
	  	  {
	  	  	if((i-sum)%2==0)
	  	  	  {
	  	  	  	cout<<(i-sum)/2<<'\n';
	  	  	  	break;
	  	  	  }
	  	  }
	  	  
	  }
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t,x,y,m,d;
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>t>>d;
      ll ans=0;
      while(t--){
        cin>>x>>y;
        ans+=(x*x+y*y<=d*d);
      } 
      cout<<ans;
}

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

long long n;
int tot;
deque<int> Queue;

void dfs(long long x) {
	if (x == 1) return;
	if (x & 1) dfs(x - 1), Queue.push_front(++tot);
	else dfs(x >> 1), Queue.push_back(++tot);
}

int main() {
	scanf("%lld", &n);
	dfs(n + 1);
	printf("%d\n", tot << 1);
	for (int i = 0; i < tot; ++i) printf("%d ", Queue[i]);
	for (int i = 1; i <= tot; ++i) printf("%d ", i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
  int N = inputValue();
  int K = inputValue();
  int h[100000];
  int ans = 0;
  REP(i, N){
    int val = inputValue();
    if(val >= K){
      ans++;
    }
  }
  cout << ans << endl;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,c; cin>>n>>c;
  vvll d(35, vll(35));
  rep(i,c) rep(j,c) cin>>d[i][j];
  vvll C(505, vll(505));
  rep(i,n) rep(j,n) cin>>C[i][j], C[i][j]--;
  
  vvll cost(3, vll(c)); // 色kiでマスを塗るとき、各(i+j)%3で掛かる総和
  rep(ki,c){
    rep(i,n){
      rep(j,n){
        ll now=C[i][j];
        cost[(i+j)%3][ki]+=d[now][ki];
      }
    }
  }
  
  ll ans=LINF;
  rep(i,c){
    rep(j,c){
      rep(k,c){
        if(i==j || j==k || k==i) continue;
        chmin(ans,cost[0][i]+cost[1][j]+cost[2][k]);
      }
    }
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 2304
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

const int MAXN = 2000 + 10;
int N, K;
vector<int> adj[MAXN];
int tot, ans;

inline void Dfs(int x, int fa, int dep) {
	--tot;
	if(dep == 0) return;
	for(auto y: adj[x])
		if(y != fa)
			Dfs(y, x, dep - 1);
}

int main() {
	register int i; int x, y;
	scanf("%d%d", &N, &K); ans = N;
	for(i = 1; i < N; ++i)
		scanf("%d%d", &x, &y),
		adj[x].emplace_back(y),
		adj[y].emplace_back(x);
	if(K % 2 == 0)
		for(i = 1; i <= N; ++i)
			tot = N, Dfs(i, 0, K / 2), ans = min(ans, tot);
	else
		for(i = 1; i <= N; ++i)
			for(auto y: adj[i])
				tot = N, Dfs(y, i, K / 2), Dfs(i, y, K / 2), ans = min(ans, tot);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
const ll M = 1e9+7;
const ll inf = 1e18+5;
using namespace std;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll bs(ll arr[], ll l, ll r, ll x){
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}

void solve(){
	ll t,ac=0,wa=0,re=0,tle=0;
	cin>>t;
	while(t--){
		string s;
		cin>>s;
		if(s=="AC") ac++;
		if(s=="WA") wa++;
		if(s=="RE") re++;
		if(s=="TLE") tle++;
	}
	cout<<"AC x "<<ac<<"\n"<<"WA x "<<wa<<"\n"<<"TLE x "<<tle<<"\n"<<"RE x "<<re<<"\n";
	
 }
int main(){
	fast();
	solve();
	return 0;
}



Measured memory_bytes: 3656
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
#define PI 3.14159265359


void solve(double a, double b, double x){
    x/=a;
    double ans;
    if(x > 0.5*a*b){
        double t = 2*(a*b-x) /a;
        if(t < a)
            ans = atan(t/a)*180./PI;
        else{
            ans = 90.-atan(a/t)*180./PI;
        }
    }
    else{
        double t = 2*x/b;
        if(t > b) 
            ans = atan(b/t)*180./PI;
        else{
            ans = 90. - atan(t/b)*180./PI;
        }
    }
    cout << setprecision(13) << (ans) << endl;
}

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    solve(a, b, x);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,N,M,input,target,idx;
    scanf( "%d" , &N );
    int k[ N + 1 ];
    int d[2020] = {};
    
    for( i = 1 ; i <= N; i++ ){
        scanf( "%d" , &input );
        k[i] = input;
        d[input] = 1;
    }

    scanf( "%d" , &M );
    for( i = 1 ; i <= M; i++ ){
        scanf( "%d" , &input );
        idx = k[input];
        if( d[idx + 1] == 1 || idx + 1 > 2019 ){
            continue;   
        }
        
        d[idx] = 0;//printf("%d" , d[idx] );
        d[idx+1] = 1;//printf("%d" , d[idx+1] );
        k[input]++;
    }
    
    for( i = 0 ; i < 2020 ; i++ ){
        if( d[i] == 1 ){
            printf( "%d\n" , i );
        }
    }
    
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

bool is_p(string s, int l, int r){
    string sub = s.substr(l, r-l+1);
    int n = sub.size();

    rep(i, n){
        if(sub[i] != sub[n-i-1]) return false;
    }

    return true;
}

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

    string s;
    cin >> s;
    int n = s.size();

    if(is_p(s, 0, n-1) && is_p(s, 0, (n-1)/2-1) && is_p(s, (n+3)/2-1, n-1)) puts("Yes");
    else puts("No");


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void){
	int a[10];
	string n;
	
	while(cin>>n){
		for(int i = 0; i < 10 ; i ++ )a[i]=n[i]-'0';
		for(int i = 9; 0 < i; i --)
			for(int j = 0 ; j <= i ; j ++)
				a[j] =(a[j] + a[j+1])%10;
		cout<<a[0]<<endl;
	}
}

Measured memory_bytes: 1180
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    double noudo = 0;
    int ans_w = 0, ans_s = 0;
    int x, y, i, k;
    for (x = 1; 100*x <= f; x++) {
        for (i = 0; i <= x/a; i++) {
            if ((x - a*i) % b == 0) {
                for (y = 0; y <= f - 100*x; y++) {
                    for (k = 0; k <= y/c; k++) {
                        if ((y - c * k) % d == 0 && y <= e * x) {
                            double z = (double)y / (double)(x + y);
                            if (noudo < z) {
                                ans_w = 100*x;
                                ans_s = y;
                                noudo = z;
                            }
                        }
                    }
                }
            }
        }
    }
    if (!(ans_w == 0 && ans_s == 0))
        cout << ans_w + ans_s << " " << ans_s << endl;
    else
        cout << 100*a << " " << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
	val ans = mutableListOf<String>()

	for (i in 1 .. Int.MAX_VALUE) {
		val x = readLine()!!.toInt()
		if (x == 0) break

		ans.add("Case $i: $x")
	}

	println(ans.joinToString("\n"))
}


Measured memory_bytes: 36380
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
 
void main() {
	auto data = readln().split();
	auto S = data[0].to!string();
	auto first = S;
	auto num = 0;
	foreach (c; S) { if (c == '1') num++; }
	
	writeln(2*min( num, S.length-num ));
}

Measured memory_bytes: 508
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
signed main() {
	double W, H, w, h, x, y; cin >> W >> H >> w >> h >> x >> y;
	x = (max(-W / 2, x - w / 2) + min(W / 2, x + w / 2)) / 2;
	y = (max(-H / 2, y - h / 2) + min(H / 2, y + h / 2)) / 2;
	printf("%.10f\n", y / x);
}


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

template <class T>
inline void swap0(T &a,T &b){
	T t;
	t=a;a=b;b=t;
}

int main(){
	
	int N,cnt=0;
	cin >> N;
	vector<int> A(N);
	
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	
	for(int i=0;i<N;i++){
		if(i==N-1&&i+1==A[i]){
			swap0(A[i-1],A[i]);
			cnt++;
		}else if(i+1==A[i]){
			swap0(A[i],A[i+1]);
			cnt++;i++;
		}
	}
	
	cout<<cnt<<endl;
}

Measured memory_bytes: 640
// D - Lucky PIN
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	string s;
	cin >> n >> s;

	vector<vector<int> > a(n, vector<int>(10));
	for (int i = n - 2; i >= 0; i--) {
		a[i] = a[i + 1];
		a[i][s[i + 1] - '0']++;
	}
	vector<int> c(10), r(1000);
	for (int i = 0; i < n; i++) {
		int d = s[i] - '0';
		for (int j = 0; j < 10; j++) {
			if (c[j] == 0) continue;
			for (int k = 0; k < 10; k++)
				if (a[i][k] > 0)
					r[j * 100 + d * 10 + k] = 1;
		}
		c[d]++;
	}
	int ans = accumulate(r.begin(), r.end(), 0);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 2432
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int a,b,c;
	scanf("%d %d %d", &a,&b,&c);
	int temp;
	if (a > b) {
		temp = b;
		b = a;
		a = temp;
	}
	if (a > c) {
		temp = c;
		c = a;
		a = temp;
	}
	if (b > c) {
		temp = c;
		c = b;
		b = temp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 2700
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
#include <utility>
using namespace std;
typedef long long longlong;

int main(void) {

	long long a, b, c, i, j, x, y, z;
	cin >> a >> b >> c;

	for (i = 0; i < 1000000; i++) {
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
			cout << i << endl;
			return 0;
		}
		x = (b / 2) + (c / 2);
		y = (a / 2) + (c / 2);
		z = (a / 2) + (b / 2);
		a = x; b = y; c = z;
	}
	cout << -1 << 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;
typedef float fl;
typedef long long ll;

static const int N = 100;

int main(){
    int n, p[N + 1], m[N + 1][N + 1];
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> p[i - 1] >> p[i];

    for(int i = 1; i <= n; i++) m[i][i] = 0;
    for(int l = 2; l <= n; l++){
        for(int i = 1; i <= n - l + 1; i++){
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for(int k = i; k <= j - 1; k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1]*p[k]*p[j]);
            }
        }
    }
    cout << m[1][n] << endl;
    return 0;
}


Measured memory_bytes: 3128
N = int(input())
nums = list(input().split())
odd = []
even = []
for idx, num in enumerate(nums):
  if idx%2 == 0:
    even.append(num)
  else:
    odd.append(num)
if N%2 == 0:
  print(' '.join(odd[::-1]+even))
else:
  print(' '.join(even[::-1]+odd))


Measured memory_bytes: 27068
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1<<17;

int n,dat[2*MAX_N-1];

void init(int n_){
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=INT_MAX;
}

void update(int k,int a){
  k+=n-1;
  dat[k]=a;
  while(k>0){
    k=(k-1)/2;
    dat[k]=min(dat[k*2+1],dat[k*2+2]);
  }
}

int query(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return INT_MAX;
  if(a<=l&&r<=b)return dat[k];
  else{
    int v1=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(v1,vr);
  }
}

int main(){

  int q;
  cin>>n>>q;

  init(n);

  for(int i=0,com,x,y;i<q;i++){
    cin>>com>>x>>y;
    if(com==0)update(x,y);
    if(com==1)cout<<query(x,y+1,0,0,n)<<endl;
  }

  return 0;
}

Measured memory_bytes: 4080
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	nl := strings.Split(nextLine(), " ")
	n, _ := strconv.Atoi(nl[0])
	var s []string
	for i := 0; i < n; i++ {
		s = append(s, nextLine())
	}
	sort.Sort(sort.StringSlice(s))

	ret := ""
	for _, s := range s {
		ret += s
	}

	fmt.Println(ret)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        siz.assign(sz_, 1LL);  // assign: 再代入
        par.resize(sz_);  // resize: 再確保
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    int fr[n]={};
    UnionFind tree(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        tree.merge(a,b);
        fr[a]++;
        fr[b]++;
    }
    rep(i,k){
        int c,d;
        cin >> c >> d;
        c--;
        d--;
        if(tree.issame(c,d)){
            fr[c]++;
            fr[d]++;
        }
    }
    rep(i,n){
        cout << tree.size(i)-fr[i]-1 << ' ';
    }


    
}

Measured memory_bytes: 2816
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			int k = sc.nextInt();
		
			PriorityQueue<Integer> pq = new PriorityQueue<>();
			
			for(int i = 0 ; i < n ; i++ ) {
				int p = sc.nextInt();
				pq.add(p);
			}
			
			int sum = 0;
			for(int i = 0 ; i < k ; i++ ) {
				sum += pq.remove();
			}
			
			System.out.println(sum);
			
		}
	}

}

Measured memory_bytes: 38692
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (int i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    int L[N];
    REP(i, N) cin >> L[i];

    sort(L, L+N);

    int ret = 0;
    FOR(a, 1, N-1) FOR(b, a+1, N)
    {
        REP(c, a)
        {
            if (L[a]<L[b]+L[c] && L[b]<L[c]+L[a] && L[c]<L[a]+L[b]) ++ret;
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

S = input()
T = input()

len_S = len(S)
S_Converted = S
for i in range (len(S)):
    tmp_S = S_Converted[i]
    tmp_T = T[i]
    if tmp_S == tmp_T:
        continue
    S_Converted = list(S_Converted) 
    list_indexT = [j for j, tmp_SC in enumerate(S_Converted) if tmp_SC == tmp_T]
    if (not list_indexT == []) and (list_indexT[0] < i):
        print('No')
        sys.exit()
    S_Converted = ''.join(S_Converted)
    S_Converted = S_Converted.replace(tmp_S, tmp_T)
    S_Converted = list(S_Converted) 
    for li in list_indexT:
        if li == i:
            continue
        else:
            S_Converted[li] = tmp_S
    #print(''.join(S_Converted))
    
S_Converted = ''.join(S_Converted)

if S_Converted == T:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 10112
#include<iostream>
#include<cstdio>

using namespace std;

int gcd(int m,int n)
{
  return n? gcd(n, m%n) : m;
}

int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long e=c/gcd(c,d);
    e*=d;
    long long ans=(b-a+1)-(b/c+b/d-b/e)+((a-1)/c+(a-1)/d-(a-1)/e);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long int
#define pb push_back
#define RONALDO            \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);
#define endl "\n"
#define pii pair<ll, ll>
#define ff first
#define ss second
#define mod 1000000007
#define vi vector<ll>
#define mi map<ll, ll>
#define Max(x, y, z) max(x, max(y, z))
#define Min(x, y, z) min(x, min(y, z))
//LOVE U MESSI && CRistiano !!

//INSPIRATIONAL MICHAEL PHELPS && USAIN BOLT !!

int main()
{
  RONALDO;
  // ll t;
  // cin >> t;
  // while (t--)
  // {
  ll a,b,c,d,x,y;
  cin >> a>>b>>c>>d;
  vi v, v1;
  v.pb(a);
  v.pb(b);
  v1.pb(c);
  v1.pb(d);
  ll ans = -1e18;
  for(auto g:v)
  {
    for(auto h:v1)
      ans = max(ans, g * h);
  }
  cout << ans;
  }

Measured memory_bytes: 3676
## coding: UTF-8
s = int(input())

d = 1000000007
def multi_mod(a, x): #元の数aにxをかけて、10^9+7で割る。
    return (a * x) % d

n = 1
for i in range(1, s+1):
    n = multi_mod(n, i)
    #print(n)
print(n)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   ll n, k,s;
   cin>>n>>k>>s;
   ll a[n];
   for(int i=0;i<k;i++)
   {
       a[i] = s;
   }
   ll temp =1000000000;
   if( s == temp)
       temp =999999999;



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

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

int gcd(int x, int y){
	if(x < y) swap(x, y);
	while(y != 0){
		int z = y;
		y = x % y;
		x = z;
	}
	return x;
}

int main(){
	int N; cin >> N;
	int A[N];
	for(int i=0; i<N; i++){
		cin >> A[i];
	}
	int le[N], ri[N];
	le[0] = A[0], ri[N-1] = A[N-1];
	for(int i=1; i<N; i++){
		le[i] = gcd(le[i-1], A[i]);
	}
	for(int i=N-2; i>=0; i--){
		ri[i] = gcd(ri[i+1], A[i]);
	}
	int ans = -1;
	for(int i=0; i<N-2; i++){
		if(gcd(le[i], ri[i+2]) > ans){
			ans = gcd(le[i], ri[i+2]);
		}
	}
	if(ans < ri[1]) ans = ri[1];
	if(ans < le[N-2]) ans = le[N-2];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>//atoi 文字列の数字をint型の数値にする

int top,S[1000];

int push(int x){
  S[++top]=x;
  //notS[top++] sがゼロの時に処理してしまうから

}
int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];
  while(scanf("%s",s)!=EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a+b);
    } else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a = pop();
      b = pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
return 0;
}



Measured memory_bytes: 2144
import java.util.Scanner;

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

        int n = Integer.parseInt(sc.next());
        for (int i = 0; i < n; i++) {
            double[] input = new double[8];
            for (int j = 0; j < 8; j++) input[j] = Double.parseDouble(sc.next());

            double v1x = input[2] - input[0];
            double v1y = input[3] - input[1];
            double v2x = input[6] - input[4];
            double v2y = input[7] - input[5];

            System.out.println((Math.abs((v1x * v2y) - (v1y * v2x)) < 1e-10)? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 26988
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;


int main(void) {

    int N, M; cin>>N>>M;
    vector<int> ans(N+3,-1);
	int www = 0;
	if(M == 0){
		if(N == 1) cout<<0<<endl;
		else if(N == 2) cout<<10<<endl;
		else if(N == 3) cout<<100<<endl;
		return 0;
	}


    vector<int> s(M);
    vector<int> c(M);
    for (int i = 0; i < M; ++i) {
        int S,C; cin>>S>>C;
        s[i]=S; c[i]=C;
        //左からs桁目
        if(ans[S-1]==-1 || ans[S-1]==C){
            ans[S-1] = C;
        }else{
        	www = 1;
        }
    }
	if(www == 1){
		cout<<"-1"<<endl;
		return 0;
	}

    for (int i = (N==1)?0:pow(10,N-1); i <= pow(10,N)-1; ++i) {
        string S = to_string(i);
        bool ok = false;
        for (int j = 0; j < M; ++j) {
            if(S[s[j]-1]-'0'==c[j]) {
                ok = true;
            }else{
                ok = false;
                break;
            }
        }
        if(ok){
            cout<<i<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890123456789LL
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N,M;
	cin >> N >> M;
	vector< vector<int> > G(N);
	for(int i =0; i < M; i++) {
		int a,b;
		cin >> a >> b;
		G[--a].push_back(--b);
		G[b].push_back(a);
	}
	queue<int> q;
	vector<int> C(N,-1);
	cat maxM =0;
	for(int i =0; i < N; i++) if(C[i] == -1) {
		bool is_bip =true;
		C[i] =0;
		cat n =0, n1 =0, n2 =0;
		q.push(i);
		while(!q.empty()) {
			if(C[q.front()] == 0) n1++;
			else n2++;
			n++;
			ALL_THE(G[q.front()],it) {
				if(C[*it] == C[q.front()]) is_bip =false;
				if(C[*it] != -1) continue;
				C[*it] =1-C[q.front()];
				q.push(*it);
			}
			q.pop();
		}
		if(!is_bip) maxM +=n*(n-1)/2;
		else maxM +=n1*n2;
	}
	cout << maxM-M << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 6272
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        count+=1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a;
    char b;
    for(int i=0;i<1200;i++){
        scanf("%c",&b);
        if(islower(b)){
            cout<<(char)toupper(b);
        }
        else if( isupper(b)){
            cout<<(char)tolower(b);
        }
        else if(b==' '){
            cout<<" ";
        }
        else if(b=='\n'){
            break;
        }
        else{
            cout<<b;
        }
        
    }
    cout<<endl;
}


Measured memory_bytes: 3168
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>
// #include "utiltime.hpp"

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(double x) { ll m = (ll)sqrt(x); return m + (m * m <= (ll)(x) ? 0 : -1); }
ll ceilsqrt(double x) { ll m = (ll)sqrt(x); return m + ((ll)x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }

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

int main() {
	int n; cin >> n;
	vll a(n); Loop(i, n) cin >> a[i];
	int ans = 0;
	Loop1(i, n - 1) {
		if (a[i] == a[i - 1]) {
			a[i] = -1;
			ans++;
		}
	}
	cout << ans << endl;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  string s ;
  cin >> s ;
  string ans = "Yes";
  
  rep(i,s.size()){
    if(i %2 == 0){
      if(s.at(i) != 'h')
        ans = "No";
    }
  else {
    if(s.at(i) !='i')
       ans = "No";
  }
  }
if(s.size() % 2 == 1)
  ans = "No";
  
  
  cout <<ans ;
      


}


Measured memory_bytes: 256
#include <stdio.h>

#define mod 1000000007;

long long nikou(int n, int r);

long long c[2001][2001];
int done[2001][2001]={};

int main(void){
  int i, j;
  int n,k;
  long long b_wake;
  long long r_wake;
  long long ans;

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

  for(i=1; i<=k; i++){
    ans=0;
    b_wake=0;
    r_wake=0;
    if(i==1){
      ans=(n-k+1)%mod;
    }else{
      if(k-i<0){
        ans=0;
      }else{
        //bの分け方 k-1Ci-1
        b_wake=nikou(k-1,i-1)%mod;
        //rの分け方
        for(j=i-1; j<=i+1; j++){
          //j=i-1 赤が両端にない
          //j=i 赤が右端のみまたは左端のみにある
          //j=i+1 赤が両端にある
          if(n-k<j) break;
          if(j==i){
            r_wake+=2*nikou(n-k-1,j-1)%mod
          }else{
            r_wake+=nikou(n-k-1,j-1)%mod;
          }
        }
        ans=(b_wake*r_wake)%mod;
      }
    }
    printf("%lld\n", ans);
  }

  return 0;
}

long long nikou(int n, int r){
  //n=>rであることが前提
  // printf("nikou(%d,%d)\n", n,r);
  if(done[n][r]==1) return c[n][r];

  if(r==0){
    done[n][r]=1;
    return c[n][r]=1;
  }
  if(r==n){
    done[n][r]=1;
    return c[n][r]=1;
  }

  c[n][r]=(nikou(n-1,r)+nikou(n-1,r-1))%mod;
  done[n][r]=1;
  return c[n][r];
}


Measured memory_bytes: 46336
// Mon Aug 24 16:24:09 IST 2020        
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int ii = (int)a ; ii < (int)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const double pi = 3.141592653589793238;
const int INF = 2e9+7; 
// const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
void print(vector <int>v){
    for(int t : v){
        cout << t << ' ';
    }
    cout << '\n';
}
vector <int> res,h;
vector <vector <int>> g;
vector <bool> vis;
void dfs(int node, int parent){
    vis[node] = true;
    res.push_back(h[node]);
    for(auto child : g[node])
        if(child != parent)
        { 
            dfs(child, node);
        }
}
int tests(){  
    int n,m;
    cin >> n >> m;
    h = vector <int> (n);
    vis = vector <bool> (n,false);
    g.clear();
    g = vector <vector<int>> (n);
    forn(i,0,n)
        cin >> h[i];
    int u,v;
    forn(_,0,m){
        cin >> u >> v;
        u -=1, v -=1;
        g[u].push_back(h[v]);
        g[v].push_back(h[u]);
    } 
    int ans = 0;
    forn(i,0,n)
        sort(g[i].rbegin(), g[i].rend());
    forn(i,0,n)
        if(g[i].empty())
            ans++;
        else
            ans += (h[i] > g[i][0]);
    cout <<ans << '\n';
    return 0;
}    
int main(){
    I__O ;      
    int cases = 1 ;  
    // cin >> cases ;
    while(cases--)
        tests(); 
    return 0 ; 
}
 


Measured memory_bytes: 8680
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,l[100];
	cin>>n>>x;
	for(int i=0;i<n;i++)
	cin>>l[i];
	int d[100];
	d[0]=0;
	for(int i=1;i<=n;i++)
	d[i]=d[i-1]+l[i-1];
	for(int i=0;i<=n;i++)
	{
		if(d[i]>x)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<n+1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    output(48 - N);
    
    return 0;
}


Measured memory_bytes: 892
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    if n == 3:
        print(max(a))
        return
    dp = [[-inf] * 3 for i in range(n + 1)]
    dp[0] = [0, 0, 0]
    dp[1][0] = a[0]
    dp[2][1] = a[1]
    for i in range(3, n+1):
        dp[i][0] = dp[i - 2][0] + a[i-1]
        dp[i][1] = max(dp[i - 2][1], dp[i - 3][0]) + a[i-1]
        dp[i][2] = max(dp[i - 2][2], dp[i - 3][1], dp[i - 4][0]) + a[i-1]
    if n & 1:
        print(max(dp[-3][0], dp[-1][1], dp[-1][2]))
    else:
        print(max(dp[-1][1], dp[-2][0]))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 139672
N, K = map(int, input().split())
p = list(map(int, input().split()))

l = 0
r = K

maxl = l
maxr = r

s = sum(p[l:r])
maxs = s

for i in range(N-K):
    s -= p[i]
    s += p[i+K]
    if s > maxs:
        maxl = i+1
        maxr = i+K+1
        maxs = s

res = 0
for i in range(maxl, maxr):
    res += p[i]/2+0.5

print(res)

Measured memory_bytes: 25604
#include <stdio.h>
#define N 300
void hyouzi(int,int);

int main()
{
  int x,y,i;
  int mat1[N],mat2[N];
  int count;

  count=0;

  while(1)
  {
    scanf("%d %d",&x,&y);
    if(x==0 && y==0) break;
    mat1[count]=x;
    mat2[count]=y;
    count++;
  }

  for(i=0;i<count;i++)
  {
    hyouzi(mat1[i],mat2[i]);
  }

  return 0;
}

void hyouzi(int x,int y)
{
  int i,j;

  for(i=0;i<x;i++)
  {
    if(i%2==0)
    {
      for(j=0;j<y;j++)
      {
        if(j%2==0) printf("#");
        else printf(".");
      }
    }
    else
    {
      for(j=0;j<y;j++)
      {
        if(j%2==0) printf(".");
        else printf("#");
      }
    }
    printf("\n");
  }
  printf("\n");
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7,N=2e5+20;
ll n,k,dp[2500];
int qpow(ll x,int k){
	ll ans=1;
	while(k){
		if(k&1) ans*=x;
		k>>=1,x*=x;
		ans%=mod,x%=mod;
	}
	return ans;
}
int v[3000],cnt;
void init(){
	for(ll i=1;i*i<=n;i++)if(n%i==0){
		v[++cnt]=i;
		if(i*i!=n) v[++cnt]=n/i;
	}
	sort(v+1,v+cnt+1);
}
int main()
{
	cin>>n>>k;
	init();
	ll ans=0;
	for(int x=1;x<=cnt;x++){
		dp[x]=qpow(k,(v[x]+1)/2);
		for(int y=1;y<x;y++){
			if(v[x]%v[y]==0)
				dp[x]=(dp[x]-dp[y]+mod)%mod;	
		}	
		if(v[x]%2)
			ans=(ans+(dp[x]*v[x])%mod)%mod;
		else
			ans=(ans+(dp[x]*v[x]/2)%mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin

n, m = (int(i) for i in input().split())

l = [int(x) for x in stdin.readline().rstrip().split()]
l.pop(0)
for i in range(n-1):
    l2 = [int(x) for x in stdin.readline().rstrip().split()]
    l2.pop(0)
    l = list(set(l)&set(l2))

print(len(l))



Measured memory_bytes: 3060
// review
#include <iostream>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int MAXN= 1e5+10;

string s;
ll dp[MAXN][4];

void solve() {
  dp[s.size()][3] = 1;
  for (int i=s.size();i>=0;i--) {
    for (int j=3;j>=0;j--) {
      if (i == s.size()) {
        dp[i][j] = j == 3 ? 1 : 0;
      } else {
        dp[i][j] = dp[i+1][j] * (s[i] == '?' ? 3 : 1);
        if (j < 3 && (s[i] == '?' || s[i] == "ABC"[j])) {
          dp[i][j] += dp[i+1][j+1];
        }
        dp[i][j] %= MOD;
      }
    }
  }

  cout << dp[0][0] << endl;
}

int main() {
  cin >> s;
  solve();
}


Measured memory_bytes: 3584
N = int(input())
A = [int(i) for i in input().split()]
print(*A)
for i in range(1,N):
    v = A[i]
    j=i-1
    while(j>=0 and A[j] > v):
        A[j+1] = A[j]
        j-=1
    A[j+1]=v
    print(*A)

Measured memory_bytes: 5976
#include <stdio.h>
#include <string.h>

int main()
{
  char str[21];
  int i, len;
  
  scanf("%s",str);
  
  len = strlen(str);

  for(i = len-1; i >= 0; i--){
    putchar(str[i]);
  }
  printf("\n");
  
  return 0;
}
  

Measured memory_bytes: 1756
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))

mi=min(sum(a1[1:]),sum(a2[:-1]))

for i in range(2,n):
    tmp=sum(a1[i:])+sum(a2[:i-1])
    mi=min(tmp,mi)
print(sum(a1)+sum(a2)-mi)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<long int> b(n);
  for(int i=0;i<n-1;i++){cin>>b.at(i);}
  int A=b.at(0);
  b.at(n-1)=100001;
  for(int i=1;i<n;i++){
    A+=min(b.at(i-1),b.at(i));
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
#include<iostream>

int gcd(int x,int y);
int lcm(int x,int y);

int main()
{
	int a,b;
	while(1){
		std::cin>>a>>b;
		if(std::cin.eof())break;
		std::cout<<gcd(a,b)<<' '<<lcm(a,b)<<std::endl;
	}
}

int gcd(int x,int y)
{
	int z;
	while(y!=0)
	{
		z=x%y;
		x=y;
		y=z;
	}
	return x;
}

int lcm(int x,int y)
{
	int g=gcd(x,y);
	return x/g*y;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main () {
	int w = ri();
	int h = ri();
	int n = ri();
	std::pair<int, int> a[n];
	for (int i = 0; i < n; i++) a[i].first = ri(), a[i].second = ri();
	std::sort(a, a + n);
	int res = 1000000000;
	int max = 0;
	for (int i = n - 1; i >= 0; i--) {
		res = std::min(res, max + a[i].first);
		max = std::max(max, a[i].second);
	}
	int res1 = 0;
	for (int i = 0; i < n; i++) res1 = std::max(res1, a[i].second);
	std::cout << std::min(res, res1) << std::endl;
	return 0;
}



Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    LL L; cin >> L;
    VL a(N); REP(i,N) cin >> a[i];
    VL wa(N-1);
    REP(i,N-1){
        wa[i] = a[i]+a[i+1];
    }
    LL wamax = *max_element(wa.begin(),wa.end());
    if(wamax < L){
        cout << "Impossible" << endl;
        return 0;
    }
    else{
        cout << "Possible" << endl;
        int last = max_element(wa.begin(),wa.end()) - wa.begin();
        last++;
        dump(last)

        for(int i = 1; i < last; i++){
            cout << i << endl;
        }
        for(int i = N-1; i > last; i--){
            cout << i << endl;
        }
        cout << last << endl;

    }


}

Measured memory_bytes: 2432
#include<iostream>
using namespace std;
int a[210];
int main() {
	a[1] = 300000;
	a[2] = 200000;
	a[3] = 100000;
	int x, y;
	cin >> x >> y;
	if (x == 1 && y == 1) {
		cout << a[x] + a[y] + 400000;
	}
	else
		cout << a[x] + a[y];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n,l;cin >> n >> l;
	vector<string> v;
	
	REP(i,n)
	{
		string str;cin >> str;v.PB(str);
	}
	
	sort(ALL(v));
	
	REP(i,n)
	{
		cout << v[i];
	}cout << endl;
	
	return 0;
}


Measured memory_bytes: 256
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str1,str2;
    cin>>n>>m;
    if(n==1||m==1){
        sum=m*n-2;
        if(sum<0) sum=1;
        cout<<sum<<endl;
        return 0;
    }
    sum=(n-2)*(m-2);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n,m; cin>>n>>m;
  vector<pair<int,int>> a(n); rep(i,n) cin>>a[i].first>>a[i].second;
  //priority_queue<pair<int,int>> pq;
  //vector<pair<int,int>> b;
  //rep(i,n) pq.push(a[i]);
  ll ans=0;
  //myごみコード
  /*rep(i,m){
    while(!pq.empty()){
      b.push_back(pq.top());
      int x=pq.top().first;
      pq.pop();
      if(pq.top().second<=i+1){
        b.pop_back();
        ans+=x;
        break;
      }
    }
    for(auto x:b){
      pq.push(x);
    }
    b.clear();
  }*/
  sort(a.begin(),a.end());
  priority_queue<ll> b;
  ll t=0;
  rep(i,m){
    while(t<n&&a[t].first<=i+1){
      b.push(a[t].second);
      t++;
    }
    if(!b.empty()){
      ans+=b.top();
      b.pop();
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5016