akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin>>S;
    int n=S.length();
    int ans=0;
    rep(i,0,n){
        int cnt=0;
        rep(j,i,n){
            if(S[j]=='A'||S[j]=='T'||S[j]=='G'||S[j]=='C'){
                cnt++;
            }
            else{
                ans=max(ans,cnt);
                break;
            }
            if(j==n-1) ans=max(ans,cnt);
        }
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
using namespace std;

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


int main() {

	int n, h[100001];
    long long dp[100001];
	cin >> n;
	for (int i=0; i < n; i++) {
		cin >> h[i];
		dp[i] = 10000000000;
	}

	
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1)chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
#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()
typedef long long ll;
typedef pair<int,int> P;
const int max_n = 100000;
const int max_m = 100000;


class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
    vector<int> Rank;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N);
        Rank = vector<int> (N,1);
        for(int i = 0;i < N;i++){
            Parent[i] = i;
        }
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] == A) return A;
		return Parent[A] = root(Parent[A]);
	}

	//AとBをくっ付ける
	void connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			return ;
		}

		if (Rank[A] < Rank[B]) Parent[A] = B;
		
		else{
            Parent[B] = A;
            if(Rank[A] == Rank[B]) Rank[A]++;
        }
		return;
	}
    bool find(int A,int B){
        return root(A) == root(B);
    }
};

int N,M;
vector<int> p(max_n,0);

int main(){
    cin >> N >> M;
    UnionFind number(N);
    REP(i,N){
        cin >> p[i];
        p[i]--;
    }
    REP(i,M){
        int x,y;
        cin >> x >> y;
        x--, y--;
        number.connect(x,y);
    }

    int ans = 0;
    REP(i,N){
        if(number.root(i) == number.root(p[i])){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1536
import sys
 
input_lines = sys.stdin.readlines()
 
 
lines = map(lambda x: x[:-1], input_lines)
 
lines = map(lambda x: x.split(" "), lines)
 
n = int(lines[0][0])
 
lines.pop(0)
 
for l in lines:
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, l)
     
    X1 = x2 - x1
    X2 = x4 - x3
    Y1 = y2 - y1
    Y2 = y4 - y3
    if abs(X1*Y2 - X2*Y1) < 1e-10:
        print "YES"
    else:
        print "NO"

Measured memory_bytes: 6448
//
//  main.cpp
//  1_6
//
//  Created by Keita on 2020/06/19.
//  Copyright © 2020 Keita. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;

void doProblemA(){
    int x1, x2, x3, x4, x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    cout << 15 - x1 - x2 - x3 - x4 - x5 << endl;
}

void doProblemB(){
    int X, Y;
    cin >> X >> Y;
    if((X > 0) && (Y > 0) && 2 <= (Y / X) && (Y / X) <= 4){
        cout << "Yes" << endl;
    }
    else if(Y == 0 && X > 0){
        cout << "No" << endl;
    }
    else if(X == 0 && Y > 0){
        cout << "No" << endl;
    }
    else if(X == 0 && Y == 0)
        cout << "Yes" << endl;
    else{
        cout << "No" << endl;
    }
}

void doProblemBDash(){
    float X, Y;
    float answer;
    cin >> X >> Y;
    answer = (Y / X);
    if(fmod(Y, 2) == 0 && 2.0 <= answer && answer <= 4.0){
        cout << "Yes" << endl;
    }
    else if(Y == 0 && X > 0){
        cout << "No" << endl;
    }
    else if(X == 0 && Y > 0){
        cout << "No" << endl;
    }
    else if(X == 0 && Y == 0)
        cout << "Yes" << endl;
    else{
        cout <<  "No" << endl;
    }

}

int main(int argc, const char * argv[]) {
    // insert code here...
    doProblemBDash();
    return 0;
}


Measured memory_bytes: 3844
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int D = in.nextInt();
            int N = in.nextInt();
            System.out.println((N == 100 ? 101 : N) * (D == 0 ? 1 : D == 1 ? 100 : 10000));
        }
    }
}


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

int main() {
	int t, n;

	cin >> t;
	while (t--) {
		int mup = 0, mdown = 0, height[101] = { 0 };
		cin >> n;
		for (int i = 0; i < n; ++i) {
			cin >> height[i];
		}
		for (int i = 1; i < n; ++i) {
			int diff = height[i] - height[i - 1];
			if (diff > 0 && diff > mup) mup = diff;
			if (diff < 0 && -diff > mdown) mdown = -diff;
		}
		cout << mup << " " << mdown << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

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

	auto N=in(),W=in();
	vvll V(4);

	ll w=in(),v=in();
	V[0].push_back(v);
	REP(i,N-1){
		ll x=in();
		V[x-w].push_back(in());
	}
	REP(i,4) sort(ALL(V[i]),greater<ll>());

	ll maxV=0;
	for(ll a=0,ea=V[0].size(),sa=0;a<=ea;a++){
		for(ll b=0,eb=V[1].size(),sb=0;b<=eb;b++){
			for(ll c=0,ec=V[2].size(),sc=0;c<=ec;c++){
				for(ll d=0,ed=V[3].size(),sd=0;d<=ed;d++){
					if((a*w+b*(w+1ll)+c*(w+2ll)+d*(w+3ll))<=W){
						maxV = max(maxV,sa+sb+sc+sd);
					}
					if(d<ed) sd+=V[3][d];
				}
				if(c<ec) sc+=V[2][c];
			}
			if(b<eb) sb+=V[1][b];
		}
		if(a<ea) sa+=V[0][a];
	}

	out(maxV);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll w, a, b;
  cin >> w >> a >> b;
  if (a + w < b) cout << b - a - w << endl;
  else if (b + w < a) cout << a - b - w << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define int long long
inline LL read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	LL k=0,kk=1;if (c=='-')c=getchar(),kk=-1;
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(LL x){if (x<0)x=-x,putchar('-');if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(LL x){write(x);puts("");}
int a,b,c,k;
signed main(){
	a=read();b=read();c=read();k=read();
	if (k&1)writeln(b-a);else writeln(a-b);
}


Measured memory_bytes: 256
x,y = map(int, input().split())
point = 0
if x == 1 and y == 1:
    point = 400000
    
if x == 1:
    point += 300000
elif x == 2:
    point += 200000
elif x == 3:
    point += 100000
else:
    pass

if y == 1:
    point += 300000
elif y == 2:
    point += 200000
elif y == 3:
    point += 100000
else:
    pass

print(point)



Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  cout << (s == "AAA" || s == "BBB" ? "No\n" : "Yes\n");
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


#define MAX_V 100000
vector<int> G[MAX_V];
bool used[MAX_V];
int ord[MAX_V],lowlink[MAX_V];
int k=0;


void dfs(int v,int p){	//make ord and lowlink
	used[v] = true;
	ord[v]=lowlink[v]=k;
	k++;
	
	rep(i,G[v].size()){
		int to = G[v][i];
		if(!used[to]){
			dfs(to,v);
			lowlink[v] = min(lowlink[v],lowlink[to]);
		}
		else if(used[to]&&to!=p){	//use back edge
			lowlink[v] = min(lowlink[v],ord[to]);
		}
	}
}

vector<pii> enumerateBridge(int e,vector<pii> edges){	//????????????
	vector<pii> ret;
	
	rep(i,e){
		int a = edges[i].first, b = edges[i].second;
		if(ord[a]>ord[b])swap(a,b);
		if(ord[a]<lowlink[b])ret.pb(pii(edges[i].first,edges[i].second));
	}
	return ret;
}


int main(){
	int v,e;
	cin>>v>>e;
	vector<pii> edges;
	rep(i,e){
		int s,t;
		cin>>s>>t;
		if(s>t)swap(s,t);
		edges.pb(pii(s,t));
		G[s].pb(t);
		G[t].pb(s);
	}
	
	dfs(0,-1);
	
	vector<pii> ans = enumerateBridge(e,edges);
	
	sort(all(ans));
	rep(i,ans.size())cout<<ans[i].first<<" "<<ans[i].second<<endl;
}

Measured memory_bytes: 7512
N,M = map(int, input().split())
A = []
for i in range(N):
    I = list(map(int, input().split()))
    A.append(I)

b = []
for i in range(M):
    bi = []
    I = int(input())
    bi.append(I)
    b.append(bi)

for i in range(N):
    result = 0
    for j in range(M):
        result += A[i][j] * b[j][0]
    print(result)

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

int main(){
  int n, k, ans = 0; cin >> n >> k;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  for(int l = 0; l <= k; l++){
    for(int r = 0; r <= k - l; r++){
      if(l + r > n) break;
      int d = k - l - r, now = 0;
      vector<int> s;
      for(int i = 0; i < l; i++){
        s.push_back(v[i]);
        now += v[i];
      }
      for(int i = 0; i < r; i++){
        s.push_back(v[n - 1 - i]);
        now += v[n - 1 - i];
      }
      sort(s.begin(), s.end());
      for(int i = 0; i < d; i++){
        if(i >= s.size()) break;
        if(s[i] > 0) break;
        now -= s[i];
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3564
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		BigInteger result = new BigInteger(Integer.toString(N));
		result = result.multiply(new BigInteger(Integer.toString(N - 1)));
		result = result.divide(new BigInteger("2"));
		
		System.out.println(result.toString());
		
	}
	
	private static int kaijo(int x) {
		int result = 1;
		for(int i = 1; i <= x; ++i) result *= 2;
		return result;
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 23252
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;

int n[100003]={};
int main(){

	int N;
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>n[i];
	
	int x=0,y=0;
	while(x<N&&y<N){
		
		if(n[x]<=n[N-1]){x++;y=x+1;}
		else if(n[x]>n[N-1]&&n[y]>n[N-1])y++;
		else if(n[x]>n[N-1]&&n[y]<=n[N-1]){
			int t=n[y];n[y]=n[x];n[x]=t;
			x++;y++;
			
		}
	}

	//	cout<<n[N-1];
//	int t=n[N-1];n[N-1]=n[x-1];n[x-1]=t;
			
	for(int i=0;i<N;i++)
	{
		if(i>0)cout<<" ";
		if(i!=x-1)cout<<n[i];
		if(i==x-1)cout<<"["<<n[i]<<"]";
	}
	cout<<endl;

	return 0;
	}

Measured memory_bytes: 1548
#include<stdio.h>

int min(int a, int b){
        return a<b? a:b;
}

int main(void){
        char* rank[] = {"NA", "E", "D", "C", "B", "A", "AA", "AAA"};
        double a, b;
        while(scanf("%lf %lf", &a, &b) == 2){
                int ra = (a<70) + (a<55) + (a<50) + (a<43) + (a<40) + (a<37.5) + (a<35.5);
                int rb = (b<148) + (b<116) + (b<105) + (b<89) + (b<83) + (b<77) + (b<71);
                printf("%s\n", rank[min(ra, rb)]);
        }
        return 0;
}


Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl


int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  int j = 1;
  int ans = 0;
  rep(i, N){
    if(j == a[i]) j++;
    else ans++;
  }
  if(ans == N) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 1024
# AOJ 0045: Sum and Average
# Python3 2018.6.12 bal4u

sum = 0
n = 0
k = 0
while True:
    try:
        a, b = list(map(int, input().split(',')))
        sum += a*b
        n += b
        k += 1
    except EOFError:
        break
        
print(sum)
if n % k > (k-1)//2:
	print(n//k + 1)
else:
	print(n//k)


Measured memory_bytes: 5596
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int ans=0;
  int count[100001]={};
  for(i=0;i<n;i++){
    if(a[i]<100001){
      count[a[i]]++;
    }
    else{
      ans++;
    }
  }
  for(i=1;i<100001;i++){
    if(count[i]<i){
      ans+=count[i];
    }
    else{
      ans+=count[i]-i;
    }
  }

  printf("%d",ans);

  return 0;

}

Measured memory_bytes: 896
H,W=map(int,input().split())
N=int(input())
a=tuple(map(int,input().split()))
l=[]
for i in range(N):
    l+=[i+1]*a[i]
for i in range(H//2):
    for j in range(W):
        print(l[2*i*W+j],end=" ")
    print()
    for j in range(W):
        print(l[2*(i+1)*W-j-1],end=" ")
    print()
if H%2:
    for i in l[(H-1)*W:]:
        print(i,end=" ")

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

const int MOD = 1e9+7;

int main() {
    ll N, B = 60;
    cin >> N;
    vl A(N), cnts(B);
    rep(i,N) {
        cin >> A[i];
        rep(j,B) {
            cnts[j] += (A[i]>>j) & 1;
        }
    }
    ll ans = 0;
    rep(i,N) {
        ll base = 1;
        rep(j,B) {
            if ((A[i] >> j) & 1) {
                ans += (N - cnts[j]) * base;
                ans %= MOD;
            }
            (base <<= 1) %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5560
N, K = map(int,input().split())
p = list(map(int,input().split()))
p = list(map(lambda x:(x+1)/2,p))
from itertools import accumulate
A =  [0] + list(accumulate(p))
M = 0
index = 0
for x in range(N - K +  1):
    M = max(M,A[x + K] - A[x])
print(M)


Measured memory_bytes: 80776
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>

int main() {
	long long int n, m, a = 0;
	std::cin >> n >> m;
	if (n <= m / 2) {
		a += n;
	}
	else if (n >= m / 2) {
		a += m / 2; std::cout << a << std::endl; return 0;
	}
	std::cout << a + (m - n * 2) / 4 << std::endl;
	return 0;
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
map<string, int> cnt;
ll ret = 0;

void input() {
  IN(N);
  string s;
  REP(i, N) {
    IN(s);
    sort(s.begin(), s.end());
    if (cnt.find(s)==cnt.end()) {
      cnt[s] = 1;
    } else {
      cnt[s] += 1;
    }
  }
}

void solve() {
  ll n;
  EACH(cnt.begin(), cnt.end()) {
    n = itr->second;
    ret += n*(n-1)/2;
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 11136
#include <iostream>

using namespace std;

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

	if (a == b & b == c) {
		cout << 1 << endl;
	}
	else if (a == b | a == c | b == c) {
		cout << 2 << endl;
	}
	else {
		cout << 3 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
    int a,b;
    cin>>a>>b;
    if(a<b){
    for (int i=0;i<b;i++){
        cout<<a;
        }
        }
        else {
        for(int i=0;i<a;i++){
            cout<<b;
        }
        }
}










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

int a[51];

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

    int n;
    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>a[i];

    int sol=0;

    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++){
            sol += a[i]*a[j];
        }
    cout<<sol;
}



Measured memory_bytes: 256
P = 10**9 + 7
X, Y = map(int, input().split())

def factorial(n):
    res = 1
    for i in range(2, n+1):
        res *= i
        res %= P
    return res

if (2*X-Y)%3 == 0 and (-X+2*Y)%3 == 0 and 2*X-Y >= 0 and -X+2*Y >= 0:
    a = (-X+2*Y)//3
    b = (2*X-Y)//3
    print((factorial(a+b)*pow(factorial(a), P-2, P)*pow(factorial(b), P-2, P))%P)
else:
    print(0)

Measured memory_bytes: 3064
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int w[] = new int[N]; 
		for(int i=0;i<N;i++){
			w[i] = sc.nextInt();
		}
		int ans = 100000000;
		for(int i=0;i<N;i++){
			int sum1 = 0;
			int sum2 = 0;
			for(int j=0;j<i;j++){
				sum1 += w[j];
			}
			for(int k=i;k<N;k++){
				sum2 += w[k];
			}
			ans = Math.min(ans, (int)Math.abs(sum1-sum2));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
from collections import defaultdict
from itertools import product

H, W = map(int, input().split())
c = [[int(x) for x in input().split()] for _ in range(10)]
A = defaultdict(int)
for _ in range(H):
    for x in input().split():
        x = int(x)
        if x != -1 and x != 1:
            A[x] += 1

for k, i, j in product(range(10), range(10), range(10)):
    c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for k, v in A.items():
    ans += c[k][1] * v
print(ans)

Measured memory_bytes: 3316
<?php
fscanf(STDIN, "%d %d", $n,$m);

if($n==1 && $m==1)
{
	echo("1");
}
elseif($n==1)
{
	echo($m-2);
}
elseif($m==1)
{
	echo($n-2);
}
else
{
	echo(($n-2)*($m-2));
}

Measured memory_bytes: 3576
from collections import Counter
n, m = map(int, input().split())
group = [None for _ in range(n)]
connected = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    connected[a].append(b)
    connected[b].append(a)
# print(connected)
for i in range(n):
    if group[i] is not None: continue
    newly_visited = [i]
    group[i] = i
    while len(newly_visited) > 0:
        new = newly_visited.pop()
        for j in connected[new]:
            if group[j] is not None: continue
            group[j] = i
            newly_visited.append(j)
# print(Counter(group))
print(len(Counter(group)) - 1)


Measured memory_bytes: 91368
#include <stdio.h>
#include <stdlib.h>
long long min(long long a, long long b){
	return a > b ? b: a;
}

int main(){
	long long int pre[200005], mindif;
	int n, read;
	scanf("%d%lld", &n, &pre[0]);
	for(int i = 1; i < n; ++i){
		scanf("%d", &read);
		pre[i] = pre[i-1] + read;
	}
	mindif = abs(pre[n-1] -pre[0] - pre[0]);//uma dif qualquer
	for(int i = 0; i < n-1; ++i){
		long long ma = pre[i], rog = pre[n-1] - pre[i];
		mindif = min(mindif, llabs(ma - rog));
	}
	printf("%lld\n", mindif);
	return 0;
}


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

n,w = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(n)]

dp = [[0] * (w+1) for _ in range(n+1)]

for i in range(n):
    for j in range(w):
        dp[i+1][j] = max(dp[i][j], dp[i+1][j])
        if j + wv[i][0] <= w:
            dp[i+1][j+wv[i][0]] = max(dp[i][j+wv[i][0]], dp[i][j] + wv[i][1])

print(dp[-1][-1])


Measured memory_bytes: 121836
#include <stdio.h>

int main(void)
{
        for (;;) {
                double a,b,p,c,d,q;
                if (scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &p, &c, &d, &q) == EOF)
                        return 0;
                double x = ((p*d-b*q) / (a*d-b*c));
                double y = ((a*q-p*c) / (a*d-b*c));
                printf("%.3f %.3f\n", x == -0 ? 0 : x, y == -0 ? 0 : y);
        }
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  string s,t; cin>>s>>t;
  ll ans{};
  for(int i=0; i<s.size(); i++){
    ans += s.at(i)!=t.at(i);
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3916
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int N,s1,s2=0;
  int i,t;
  int W[100];
  int total[10];
  int u =0;
  int keep;

  scanf("%d\n",&N);

  for(i=0;i<N;i++)
    {
      scanf("%d ",&W[i]);
    }

  for(t=0;t<N;t++)
    {
      s1 = s1 + W[t];
    }
  

  for(;;){ 
      s1 = s1 - W[u];
      s2 = s2 + W[u];
//printf("%d %d",s1,s2);
    if(s1>s2)
      total[u] = s1-s2;
    else
      total[u] = s2-s1;
    
    //printf("%d\n",total[u]);
    if(u==N-1)
      break;
    u++;
  }
  
  for(u=0;u<N;u++){
    if(total[0]>total[u])
      {   total[0] = total[u];}
  }
  printf("%d",total[0]);

}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    string s; cin >> s;
    rep(i,s.size()-1){
        if(s[i] == s[i+1]){cout << "Bad" << endl; return 0;}
    }
    cout << "Good" << endl; return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	bool arr[110];
	memset(arr,0,sizeof(arr));
	int ans=0;
	int n;
	cin>>n;
	for(int x=0;x<n;x++){
		int a;
		cin>>a;
		if(!arr[a]){
			ans++;
			arr[a]=true;
		}
	}
	cout<<ans<<endl;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1777777777ll
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li a, b;
    cin >> a >> b;
    li res = 0;
    li now = 1;
    while (now < b) {
        res++;
        now += a - 1;
    }
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
#define int long long

void solve() {
	int n, k, q; cin >> n >> k >> q;
    vector<int> a(n, k - q);
    rep(i, q) {
        int x; cin >> x; x--;
        a[x] ++;
    }
    int ans = 0;
    rep(i, n) {
        if(a[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    int ans=a[0];
    for(int i=1; i<n; i++)
        ans=a[i]^ans;
    for(int i=0; i<n; i++)
        cout<<(a[i]^ans)<<" ";
}


Measured memory_bytes: 4416
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.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;
}

// based on editorial.pdf (or video)
int main(void) {
    vector<int> cs(9);
    for (int i = 0; i < 9; i++) {
        cin >> cs[i];
    }

    vector<int> cand_as(3);
    vector<int> cand_bs(3);
    cand_as[0] = 0;
    cand_bs[0] = cs[0] - cand_as[0];
    cand_bs[1] = cs[1] - cand_as[0];
    cand_bs[2] = cs[2] - cand_as[0];
    cand_as[1] = cs[3] - cand_bs[0];
    cand_as[2] = cs[6] - cand_bs[0];

    bool ok = true;
    for (int i = 0; i < 9; i++) {
        if (cs[i] != cand_as[i / 3] + cand_bs[i % 3]) {
            ok = false;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
N, Q = map(int, input().split())
S = input()

ans = [0]*N
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        ans[i+1] += (ans[i]+1)
    else:
        ans[i+1] = ans[i] 

for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])

Measured memory_bytes: 6132
N=int(input())
l=list(map(int,input().split()))
a=1
if N%2==0:
    if len(l)!=len(set(l))*2:
        a=0
else:
    if l.count(0) == 1:
        l.remove(0)
        if len(l) != 2*len(set(l)):
            a = 0
    else:
        a=0
if a:
      print((2**(N//2))%(10**9+7))
else:
      print(0)
  

Measured memory_bytes: 14008
#!/usr/bin/env python
n = int(input())
ans = 0 

is_primes = [True for _ in range(n+1)]
is_primes[0] = is_primes[1] = False
minFactor = [-1 for _ in range(n+1)]

for i in range(2, n+1):
    if not is_primes[i]: continue
    minFactor[i] = i 
    for j in range(i*i, n+1, i): 
        is_primes[j] = False
        minFactor[j] = i 


def fast_factorization(n):
    data = {}
    while n > 1:
        if minFactor[n] not in data:
            data[minFactor[n]] = 1 
        else:
            data[minFactor[n]] += 1
        n //= minFactor[n]
    return data


def count_divisors(n):
    ret = 1 
    for v in fast_factorization(n).values():
        ret *= (v+1)
    return ret 

for i in range(1, n): 
    ans += count_divisors(i)

print(ans)


Measured memory_bytes: 27172
from itertools import permutations

N = int(input())
P = int(''.join(input().split()))
Q = int(''.join(input().split()))

perms = []
for order in permutations(list(map(lambda x:x + 1, range(N)))):
    order = map(str, list(order))
    perms.append(int(''.join(order)))

def binary_search(x):
    left_index = 0
    right_index = len(perms)
    while right_index - left_index > 1:
        mid_index = (left_index + right_index) // 2
        if perms[mid_index] <= x:
            left_index = mid_index
        else:
            right_index = mid_index
    return left_index + 1 #インデックスTo番目は＋１する必要がある
            
print(abs(binary_search(P) - binary_search(Q)))

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i, m) { cin >> b[i]; }
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n) {
    rep(j, m) {
      cin >> a[i][j];
    }
  }
  
  int ans = 0;
  rep(i, n) {
    if (inner_product(a[i].begin(), a[i].end(), b.begin(), c) > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a, b;
  char eq;

  while(1) {
    scanf("%d %c %d", &a, &eq, &b);
    if(eq == '?'){ break; }
    switch(eq){
      case '+':
        printf("%d\n", a + b);
        break;
      case '-':
        printf("%d\n", a - b);
        break;
      case '*':
        printf("%d\n", a * b);
        break;
      case '/':
        printf("%d\n", a / b);
        break;
    }
  }
  return 0;
}



Measured memory_bytes: 2124
#include <iostream>
#include <string.h>

using namespace std;
const int N = 9;
void solve()
{
	int n;
	cin >> n;
	while(n--)
	{
		char Field[N][N];
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				cin >> Field[i][j];
			}
		}
		bool Flag[N][N];
		memset(Flag, 1, sizeof(Flag));
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				if(Flag[i][j])
				{
					for(int a = 0; a < N; ++a)
					{
						if(i != a && Field[a][j] == Field[i][j])
						{
							Flag[i][j] = Flag[a][j] = false;
						}
					}
					for(int a = 0; a < N; ++a)
					{
						if(j != a && Field[i][a] == Field[i][j])
						{
							Flag[i][j] = Flag[i][a] = false;
						}
					}
					int x = j / 3;
					x *= 3;
					int y = i / 3;
					y *= 3;
					for(int a = x; a < x + 3; ++a)
					{
						for(int b = y; b < y + 3; ++b)
						{
							if(a != j && b != i && Field[b][a] == Field[i][j])
							{
								Flag[b][a] = Flag[i][j] = false;
							}
						}
					}
				}
			}
		}
		for(int i = 0; i < N; ++i)
		{
			for(int j = 0; j < N; ++j)
			{
				if(Flag[i][j] == false)
				{
					cout << '*';
				}
				else
				{
					cout << ' ';
				}
				cout << Field[i][j];
			}
			cout << endl;
		}
		if(n != 0)
			cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void)
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	while (1)
	{
		c = c - b;

		if (c <= 0)
		{
			printf("Yes");
			return 0;
		}


		a = a - d;

		if (a <= 0)
		{
			printf("No");
			return 0;
		}

	}

	return 0;
}

Measured memory_bytes: 1708
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,a[3030];
ll f[3030][3030];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	n=read();
	rep(i,1,n) a[i]=read();
	rep(i,1,n) f[i][i]=a[i];
	rep(len,2,n)
	{
		for (int i=1;i+len-1<=n;i++)
		{
			int j=i+len-1;
			f[i][j]=max(a[i]-f[i+1][j],a[j]-f[i][j-1]);
		}
	}
	printf("%lld",f[1][n]);
	return 0;
}


Measured memory_bytes: 71936
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

typedef pair<ll,ll>ii; 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n;
    while(sf("%d",&n)==1)
    {
        int cnt=0;
        set<int>st;
        for(int i=0;i<n;i++)
        {
            int x;
            sf("%d",&x);
            if(x>=3200)cnt++;
            else if(x>=1 && x<=399)st.insert(0);
            else if(x>=400 && x<=799)st.insert(1);
            else if(x>=800 && x<=1199)st.insert(2);
            else if(x>=1200 && x<=1599)st.insert(3);
            else if(x>=1600 && x<=1999)st.insert(4);
            else if(x>=2000 && x<=2399)st.insert(5);
            else if(x>=2400 && x<=2799)st.insert(6);
            else if(x>=2800 && x<=3199)st.insert(7);
        }
        if(st.size()==0)pf("%d %d\n",1,cnt);
        else pf("%d %d\n",st.size(),st.size()+cnt);
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define szof(x) int32_t((x).size())
#define str(x) to_string(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
 
const int MOD = 1e9 + 7;
const int MOD998 = 998244353;
const int INF = 1e9;
const ll LLINF = 1e18;
 
mt19937_64 rng((uint) chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
T rnd(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rng);
}
 
void run() {
	int h, w;
	cin >> h >> w;
	vector<vector<bool>> used(h, vector<bool>(w));
	vector<vector<int>> a(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c; cin >> c;
			a[i][j] = c == '#';
		}
	}
	vector<int> cnt(2);
	function<void(int, int)> dfs = [&](int x, int y) {
		if (used[x][y]) {
			return;
		}
		used[x][y] = 1;
		cnt[a[x][y]]++;
		for (auto p : vector<pair<int, int>>{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}) {
			int nx = x + p.first, ny = y + p.second;
			if (0 <= nx && nx < h && 0 <= ny && ny < w && a[x][y] != a[nx][ny]) {
				dfs(nx, ny);
			}
		}
	};
	ll ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!used[i][j]) {
				cnt[0] = cnt[1] = 0;
				dfs(i, j);
				ans += 1LL * cnt[0] * cnt[1];
			}
		}
	}
	cout << ans << "\n";
}
 
int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout.precision(10); cout << fixed;
	int tests = 1;
	// cin >> tests;
	while (tests--) {
		run();
	}
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
	return 0;
}

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

using namespace std;

int main()
{
    long long n;
    std::cin >> n;

    long long sum = 0;
    for(long long i = 1; i <= n; i++ )
    {
        if(!(i % 3 == 0 || i % 5 == 0))
            sum += i;
    }

    std::cout << sum;

    return EXIT_SUCCESS;
} 

Measured memory_bytes: 3196
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut h: [i64; n],
    }

    for i in 1..n {
        if h[i] > h[i - 1] {
            h[i] -= 1;
        }
    }

    let ans = if h.windows(2).all(|x| x[1] >= x[0]) {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 3732
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
// vector : vector <int> vector;
// array : int array[size];
// set : set<int>set;
// map : map<init , int> map;
using namespace std;
#define ll long long

int main()
{
    ll n;
    cin >> n;
    string res = "";
    while (n > 0)
    {
        --n;
        int r = n % 26;
        res += (char)97 + r;
        n /= 26;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  if(N == 1){
    cout << M << endl;
  }
  else{ 
    int answer = 1;
    for(int i=2; i<M/2+3; i++){
      if(M % i != 0) continue;
      double tmp = M / i;
      if(ceil(tmp) == floor(tmp) && tmp >= N){
        answer = i;
      }else{
        break;
      }
    }
    cout << answer << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x;
#define outb(x) cout << x << ' ';
#define outn(x) cout << x << '\n';

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()

#define forn(i, s, e) for (int i = s; i < e; i++)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	inl(n);inl(k);
	ll fc = 1LL*(n/k), sc = 0;
	if (k % 2 == 0) sc = n / (k/2) - fc;
	//outb(fc); outn(sc);
	ll ret = fc*fc*fc + sc*sc*sc;
	outn(ret);
	
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
if n%2==1:
    dp=[[0 for j in range(3)] for i in range(n//2)]
    dp[0][0]=a[0]
    dp[0][1]=a[1]
    dp[0][2]=a[2]
    for i in range(n//2-1):
        dp[i+1][0]=(dp[i][0]+a[2*(i+1)])
        dp[i+1][1]=max(dp[i][0],dp[i][1])+a[2*(i+1)+1]
        dp[i+1][2]=max(dp[i])+a[2*(i+1)+2]
    print(max(dp[-1]))
if n%2==0:
    dp=[[0 for j in range(2)] for i in range(n//2)]
    dp[0][0]=a[0]
    dp[0][1]=a[1]
    for i in range(n//2-1):
        dp[i+1][0]=(dp[i][0]+a[2*(i+1)])
        dp[i+1][1]=max(dp[i][0],dp[i][1])+a[2*(i+1)+1]
        #dp[i+1][2]=max(dp[i])+a[2*(i+2)+2]
    print(max(dp[-1]))   


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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
constexpr int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
  friend ostream &operator<<(ostream &os, const mint &a) { return (os << a.x); }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int k;
  cin >> k;
  queue<ll> q;
  for (int i = 1; i < 10; ++i) q.push(i);

  ll x = 0;
  int c = 0;
  while (c < k) {
    x = q.front();
    q.pop();
    ++c;
    // printf("%d %d\n", c, x);
    if (x % 10 != 0) { q.push(10 * x + x % 10 - 1); }
    q.push(10 * x + x % 10);
    if (x % 10 != 9) { q.push(10 * x + x % 10 + 1); }
  }
  // while (!q.empty()) {
  //   cout << q.front() << endl;
  //   q.pop();
  // }
  cout << x << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;

int n[3],five=0,seven=0;

int main(){
	cin>>n[0]>>n[1]>>n[2];
	for(int i=0;i<3;i++){
		if(n[i]==5) five++;
		else if(n[i]==7) seven++;
		else break;
	}
	if(five==2&&seven==1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll x[200001] = {};
ll y[200001] = {};
int main() {
	ll n; cin >> n;
	repe(i, 1, n) {
		cin >> x[i];
		y[i] = x[i];
	}
	sort(x, x + n + 1);
	ll a = x[n / 2];
	ll b = x[n / 2 + 1];

	repe(i, 1, n) {
		if (y[i] <= a)cout << b << endl;
		else cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <stdlib.h>

int com(const void *a,const void *b){
	return *(int*)a - *(int*)b;	
}

int main(){
	int n,i,data[200]={0},c=0;
	
	scanf("%d",&n);
	for(i=0;i<(2*n);i+=2){
		scanf("%d",&data[i]);
		scanf("%d",&data[i+1]);
	}
	
	qsort(data,2*n,sizeof(int),com);
	
	for(i=0;i<(2*n);i+=2){
		if(data[i]<=data[i+1]){
			c+=data[i];
		}else{
			c+=data[i+1];	
		}
	}
	
	printf("%d\n",c);
	
return 0;
}

Measured memory_bytes: 128