akhauriyash/Code-Regression huggingface dataset:
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.util.function.DoubleToLongFunction;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int odd = 0;
		for(int i = 0; i < N; i++){
			if(sc.nextInt() % 2 == 1) odd++;
		}
		if(odd % 2 == 0) System.out.println("YES");
        else System.out.println("NO");
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    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: 22024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] sp = s.split("");
        boolean ans = true;
        if(sp.length % 2 == 0) {
            for(int i=0; i<sp.length-1; i+=2) {
                if(sp[i].equals("h") && sp[i+1].equals("i")) {
                    continue;
                }else {
                    ans = false;
                    break;
                }
            }
        }else {
            ans = false;
        }
        
        if(ans) System.out.println("Yes");
        else System.out.println("No");
    }
}


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

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

int main() {
    int H, W; cin >> H >> W;
    vector<string> grids(H);
    for (int i = 0; i < H; i++) cin >> grids[i];
    vector<vector<int>> memo(H, vector<int>(W));
    memo[0][0] = (int)(grids[0][0] == '#');
    for (int j = 1; j < W; j++) {
        memo[0][j] = memo[0][j-1];
        if (grids[0][j] == '#' && grids[0][j-1] == '.') memo[0][j]++;
    }
    for (int i = 1; i < H; i++) {
        memo[i][0] = memo[i-1][0];
        if (grids[i][0] == '#' && grids[i-1][0] == '.') memo[i][0]++;
    }
    for (int i = 1; i < H; i++) {
        for (int j = 1; j < W; j++) {
            int t1 = memo[i][j-1];
            if (grids[i][j] == '#' && grids[i][j-1] == '.') t1++;
            int t2 = memo[i-1][j];
            if (grids[i][j] == '#' && grids[i-1][j] =='.') t2++;
            memo[i][j] = min(t1, t2);
        }
    }
    cout << memo[H-1][W-1] << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct BipartiteMatching {
	int n;
	vector<vector<int>> g;
	vector<int> match;
	vector<int> used;
	BipartiteMatching(int n) : n(n), g(n), match(n), used(n) {}
	void addEdge(int u, int v) {
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}
	int maximumMatching() {
		int cnt = 0;
		rep(i, 0, n)match[i] = -1;
		for (int v = 0; v < n; v++) {
			if (match[v] == -1) {
				rep(i, 0, n)used[i] = false;
				if (augment(v))cnt++;
			}
		}
		return cnt;
	}
	bool augment(int v) {
		used[v] = true;
		for (int u : g[v]) {
			int w = match[u];
			if (w == -1 || (!used[w] && augment(w))) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int N, M, L; cin >> N >> M >> L&&N;) {
		vector<vector<int>> g(N, vector<int>(N, INF));
		rep(i, 0, M) {
			int u, v, d; cin >> u >> v >> d;
			g[u][v] = g[v][u] = d;
		}
		rep(i, 0, N)
			g[i][i] = 0;
		rep(k, 0, N)rep(i, 0, N)rep(j, 0, N) {
			if (g[i][k] != INF&&g[k][j] != INF)
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
		}

		vector<int> p(L), t(L); rep(i, 0, L) {
			cin >> p[i] >> t[i];
		}
		BipartiteMatching bm(L + L);
		int source = L + L, sink = source + 1;
		rep(i, 0, L) {
			rep(j, 0, L) {
				if (i == j)continue;
				if (g[p[i]][p[j]] <= t[j] - t[i]) {
					bm.addEdge(i, L + j);
				}
			}
		}
		auto ans = L - bm.maximumMatching();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 8296
#include <iostream>
#include <cmath>
using namespace std;
int main (void) {
    int N;
    int K;
    int ans = 1;

    cin >> N >> K;

    for (int i = 0; i < N; i++) ans = min(ans * 2, ans + K);

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

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

bool IsRightTriangle(const int a, const int b, const int c)
{
	vector<int> SideLength(3);
	SideLength[0] = a;
	SideLength[1] = b;
	SideLength[2] = c;
	sort(SideLength.begin(), SideLength.end(), greater<int>());
	if(SideLength[0] * SideLength[0] == SideLength[1] * SideLength[1] + SideLength[2] * SideLength[2]){
		return true;
	}else{
		return false;
	}
}

int main()
{
	int N;
	cin >> N;
	for(int i = 0; i < N; i++){
		int a, b, c;
		cin >> a >> b >> c;
		if(IsRightTriangle(a, b, c)){
			cout << "YES" << endl;
		}else{
			cout << "NO"  << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3028
#include <iostream>
#include <string>

using namespace std;
int H, W;
string a[1005];

long long int dp[1005][1005];
long long int MOD = 1000000007;

int main(void) {

	cin >> H >> W;

	string tmp = "";
	for (int i = 0; i <= W; i++) { tmp += "#"; }
	a[0] = tmp; a[H + 1] = tmp;

	for (int i = 1; i <= H; i++) {
		cin >> tmp;
		a[i] = "#" + tmp + "#";
	}

	dp[1][1] = 1;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (i == 1 && j == 1) { continue; }
			if (a[i][j] == '#') { dp[i][j] = 0; }
			else { dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= MOD;
			}
		}
	}

	cout << dp[H][W] << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 10112
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100010];
int f[100010];
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	f[2] = abs(a[2]-a[1]);
	for(int i = 3; i <= n; i++)
		f[i] = min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
	cout << f[n];
	return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
res = []
for a, b in AB:
    if a == 1:
        res.append(b)
    if b == N:
        res.append(a)
print('IMPOSSIBLE' if len(res) == len(set(res)) else 'POSSIBLE')


Measured memory_bytes: 56312
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;
const long long INF=100000000000000;
struct eage{int s;long long cost;};
typedef pair<long long,int> P;
long long C[100005];
int main(){

	int N,Q,a,b,d,K,x,y;
	cin>>N;
	for(int i=1;i<=N;++i)C[i]=INF;
	vector<eage> v[100005];
	for(int i=0;i<N-1;++i){
		cin>>a>>b>>d;
		v[a].push_back(eage{b,d});
		v[b].push_back(eage{a,d});
	}
	priority_queue<P,vector<P>,greater<P> > que;
	cin>>Q>>K;
	que.push(P(0,K));
	while(!que.empty()){
		P p=que.top();que.pop();
		long long c1=p.first;
		int s1=p.second;
		if(C[s1]<=c1)continue;
		C[s1]=c1;
		for(int i=0;i<v[s1].size();++i){
			que.push(P(c1+v[s1][i].cost,v[s1][i].s));
		}
	}
	for(int i=0;i<Q;++i){
		cin>>x>>y;
		cout<<C[x]+C[y]<<endl;
	}
	return 0;
}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
// #include <boost/lexical_cast.hpp>
using namespace std;

#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define vpii vector<pair<ll,ll>>
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1000000000+7;
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
ll factor(ll n){
    vll ans;
	if(n==2)ans.pb(2);
	else
    {for(ll i=2;i*i<=n;i++){if(n%i==0 && n%i!=i){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}ans.pb(n);}
    return ans.sz+1;
}
ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i; 
    return res; } 
  
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r)); } 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 

ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol(const vector<int>& v1, 
               const vector<int>& v2){ 
 return v1[0] < v2[0]; } 

 ll degit(ll n)
 {
 	ll t=0;
 	while(n>0)
 	{
 		t++;
 		n/=10; 	}
 		return t;
 }

vll s()
{
	ll N=10000000;
	vll cnt(N,0);
	for(ll i=1;i<=N;i++)
		for(ll j=i;j<=N;j+=i)
			cnt[j]++;
	return cnt;
}

void solve()
{	
	ll r,d,x;
	cin>>r>>d>>x;
	for(ll i=0;i<10;i++)
	{
		x=r*x-d;
		cout<<x<<endl;;
	}
	return;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


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

int main() {
  vector<int> num(3);
  for (int i = 0; i < 3; i++) cin >> num.at(i);
  sort(num.begin(), num.end());
  for (int i = 0; i < 3; i++) {
    if (i == 2) cout << num.at(i) << endl;
    else cout << num.at(i) << " ";
  }
}


Measured memory_bytes: 3136
#include<stdio.h>

int main(){
    int n;
    int a[200000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    
    int no1;
    int no2;

    for(int i=0;i<n;i++){
        if(a[i]>no1){
            no2=no1;
            no1=a[i];
        }else if(a[i]>no2){
            no2=a[i];
        }
    }

    for(int i=0;i<n;i++){
        if(a[i]!=no1){
            printf("%d\n",no1);
        }else{
            printf("%d\n",no2);
        }
    }
return 0;
}

Measured memory_bytes: 2304
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

char s[10][1001];
int main(void){
	int h=nextpint();
	int w=nextpint();
	int k=nextpint();
	for(int i=0; i<h; i++){
		scanf("%s", s[i]);
	}
	int ans=INT_MAX;
	for(int t=0; t<(1<<(h-1)); t++){
		int now=0;
		char v[10]={1};
		for(int i=0; i<h-1; i++){
			if((t&(1<<i))!=0){ now++; v[i+1]=1;}
		}
		int g[10][2];
		memset(g, 0, sizeof(g));
		int ff=1;
		for(int i=0; i<w; i++){
			int f=0;
			for(int j=0; j<h; j++){
				g[j][1]=s[j][i]-'0';
				if(v[j]==0) g[j][1]+=g[j-1][1];
				g[j][0]+=g[j][1];
				if(g[j][0]>k){
					f=1;
					break;
				}
			}
			if(f==1){
				now++;
				for(int j=0; j<h; j++){
					if(f==0) now++;
					g[j][1]=s[j][i]-'0';
					if(v[j]==0) g[j][1]+=g[j-1][1];
					g[j][0]=g[j][1];
					if(g[j][0]>k){
						ff=0;
						break;
					}
				}
			}
			/*if(t==0){
				for(int j=0; j<h; j++)
					printf("%d ", g[j][0]);
				putchar(10);
			}*/
		}
		//printf("%d %d\n", t, now);
		if(ff!=0 && now<ans) ans=now;
	}
	printf("%d\n", ans);
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long n, a, b, ans = 0;
    cin >> n;
    vector<int> ps(n);
    vector<int> qs(n);
    for (int i = 0; i < n; i++) {
        cin >> ps[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> qs[i];
    }
    if (ps == qs){
        cout << 0 << endl;
        return 0;
    }
    if (ps > qs) {
        swap(ps, qs);
    }
    while (next_permutation(ps.begin(), ps.end())) {
        ans++;
        if (ps == qs) {
            break;
        }
    }
    cout << abs(ans) << endl;
}

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

#define INF 1e18
#define MAX (1e9+5)

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

  mint ans = mint(10).pow(n);
  ans -= mint(9).pow(n)*2;
  ans += mint(8).pow(n);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  // string ;
  // vl A;
  cin >> N;
  cout << N * N * N << endl;

  return 0;
}


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

int n;

void CountingSort(int A[], int B[], int k) {
    int C[k+1];
    for(int i = 0; i < k+1; i++) {
        C[i] = 0;
    }
    for(int j = 1; j < n+1; j++) {
        C[A[j]]++;
    }
    for(int i = 1; i < k+1; i++) {
        C[i] = C[i] + C[i-1];
    }
    for(int j = 1; j < n+1; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
}

int main() {
    int A[2000001], B[2000001];
    cin >> n;
    for(int i = 1; i < n+1; i++) {
        cin >> A[i];
    }
    CountingSort(A, B, 10000);
    for(int i = 1; i < n+1; i++) {
        if(i > 1) cout << " ";
        cout << B[i];
    }
    cout << endl;
    return 0;
}


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

int main() {
	int a,b,c,i,j,k,x,ans=0;
	cin >> a >> b >> c >> x;
	for(i=0; i<=a; i++){
		for(j=0; j<=b; j++){
			if((x-500*i-100*j)/50<=c && (x-500*i-100*j)/50>=0){
				ans++;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>

std::unordered_map<int, int> getPiecesLocation(const int& num_pieces,
											   std::unordered_map<int, int>& piece_ids,
											   const int& num_iteration,
											   std::vector<int> keys_to_move) {
	int total_array_size = 2019;

	if (num_pieces <1 || num_iteration < 1) {
		std::cout <<"exceed min"<< std::endl;
		return piece_ids;
	}
	if ( 100 < num_pieces || 100 < num_iteration) {
		std::cout<< "exceed max"<< std::endl;
		return piece_ids;
	}

	for (const auto piece_id : piece_ids) {
		if (piece_id.second < 1 || piece_id.first < 1 ) {
			std::cout << "exceed min" << std::endl;
			return piece_ids;
		}
		else if (piece_id.second > total_array_size || piece_id.first > num_pieces) {
			std::cout << "exceed max" << std::endl;
			return piece_ids;
		}
	}

	for (int k = 0; k < num_pieces; k++) {
		for (int j = 0; j < num_pieces; j++) {
			if (j != k && piece_ids.at(j + 1) == piece_ids.at(k + 1) ) {
				std::cout << "there are any same number in array" << std::endl;
				return piece_ids;
			}
		}
	}
		for (int k = 0; k < num_iteration ; k++) {
		auto option_to_update = true;
		for (int j = 0; j < num_pieces; j++) {
			if (j+1 != keys_to_move[k] && piece_ids.at(j + 1) == piece_ids.at(keys_to_move[k]) + 1) {
				option_to_update = false;
			}
		}
		if (piece_ids.at(keys_to_move[k]) != 2019 && option_to_update) {
			piece_ids.at(keys_to_move[k]) += 1;
		}
	}
	
	return piece_ids;
}


int main() {

	int i_num_pieces, i_num_iteration;
	std::cin >> i_num_pieces;
	std::unordered_map<int, int> i_pieces_id(i_num_pieces);
	for (int i = 0; i < i_num_pieces; i++) {
		int value;
		std::cin >> value;
		i_pieces_id.emplace(i + 1, value);
	}
	std::cin >> i_num_iteration;
	std::vector<int> keys_to_move(i_num_iteration);
	for (int i = 0; i < i_num_iteration; i++) {
		std::cin >> keys_to_move[i];
	}

	auto results = getPiecesLocation(i_num_pieces, i_pieces_id, i_num_iteration, keys_to_move);
	for (int i = 0; i < i_num_pieces; i++) {
		std::cout << results.at(i+1) << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3184
n = int(input())
w = list(input() for i in range(n))
set_w = list(set(w))
ans = 'Yes'
if len(set_w) != n:
    ans = 'No'
else:
    tmp = w[0][-1]
    for i in range(1,n):
        # print('tmp{}:{}'.format(i,tmp))
        if tmp != w[i][0]:
            ans = 'No'
        else:
            tmp = w[i][-1]
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;
int A[MAX_N + 2];

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

  cin >> N;
  A[0] = 0;
  REP(i, N) cin >> A[i + 1];
  A[N + 1] = 0;

  ll all = 0;
  for (int i = 1; i <= N; i++) {
    all += abs(A[i] - A[i - 1]);
  }
  all += abs(A[N] - A[0]);

  // 拡張点を除いたときの合計金額
  for (int i = 1; i <= N; i++) {
    ll d = all - (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1])) +
           abs(A[i - 1] - A[i + 1]);
    cout << d << SLN(i, N + 1);
  }

  return 0;
}


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


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

    int N;
    string S;
    cin >> N >> S;
    int ans=0;
    rep(i,N-1){
        string b,a;
        int count=0;
        a=S.substr(0,i+1);
        b=S.substr(i+1);
        int x[26]={};
        int y[26]={};
        rep(j,a.size()){
            x[a[j]-'a']++;
        }
        rep(j,b.size()){
            y[b[j]-'a']++;
        }
        rep(j,26){
            if(x[j]>0 && y[j]>0) count++;
        }
        ans=max(ans,count);
        
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    X = int(readline())

    def enum_primes(n):
        flag_num = (n + 1) // 2
        prime_flag = [True] * flag_num

        for num in range(3, int(n ** 0.5) + 1, 2):
            idx = (num - 1) // 2 - 1
            if prime_flag[idx]:
                for j in range(idx + num, flag_num, num):
                    prime_flag[j] = False

        primes = [2]
        temp = [(i + 1) * 2 + 1 for i in range(flag_num) if prime_flag[i]]
        primes.extend(temp)

        return primes

    primes = enum_primes(10 ** 6)

    for prime in primes:
        if prime >= X:
            return print(prime)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75816
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
   int n;
   cin>>n;
   vii v;
   lp(i,n){
       int x,y;
       cin>>x>>y;
    v.pb({x,y});
   }
   bool ok =0;
   for(int i=0;i<n-2;i++){
       if(v[i].fr==v[i].sc&&v[i+1].first==v[i+1].second&&v[i+2].first==v[i+2].second){
           puts("Yes");
           return;
       }
   }
   puts("No");
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>

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

int main() {
    int n; cin >> n;
    vi A(n), B(n), C(n - 1);
    for (auto &a : A) {
        cin >> a;
    }
    for (auto &b : B) {
        cin >> b;
    }
    for (auto &c : C) {
        cin >> c;
    }
    int res = 0, prev = -1;
    for (auto num : A) {
        int idx = num - 1;
        res += B[idx];
        if (idx > 0 && idx == prev + 1) {
            res += C[idx - 1];
        }
        
        prev = idx;
    }
    
    cout << res << endl;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <string>
#include <numeric>

typedef long long ll;
using namespace std;

int main(){
  ll n,x,tmp,r;
  cin >> n>>x;
  ll a[n+1],b[n];
  for(int i=0;i<n;i++){
  	cin >> a[i];
  }
  a[n]=x;
  sort(a,a+(n+1));
  for(int i=0;i<n;i++){
  	b[i]=a[i+1]-a[i];
  }
  for(int i=0;i<n-1;i++){
  	if(b[i]<b[i+1]){
  		tmp=b[i];
  		b[i]=b[i+1];
  		b[i+1]=tmp;
  	}
  	r=b[i]%b[i+1];
  	while(r!=0){
  		b[i]=b[i+1];
  		b[i+1]=r;
  		r=b[i]%b[i+1];
  	}
  }
  cout << b[n-1]<< endl;
  return 0; 
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;
#define PI 3.14159265358979323846

using namespace std;
int MOD = 1000000007;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin  >> n;
  vector<int> a(n);
  int sum = 0;
  REP(i,n){
    cin >> a[i];
    sum ^= a[i];
  }
  REP(i,n) {
    int v = sum ^ a[i];
    cout << v << " ";
  }
  cout << endl;


  return 0;
}



Measured memory_bytes: 3984
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int N = Integer.parseInt(str);
        String[] s = new String[N];
        for (int i=0;i<N;i++){
            s[i] = br.readLine();
        }
        int ans = 0;
        int cnt_AB = 0;
        int cnt_A = 0;
        int cnt_B = 0;
        for (String ss:s){
            for (int i=1;i<ss.length();i++){
                if (String.valueOf(ss.charAt(i-1)).equals("A") && String.valueOf(ss.charAt(i)).equals("B")){
                    ans++;
                }
            }
            if (String.valueOf(ss.charAt(0)).equals("B") && String.valueOf(ss.charAt(ss.length()-1)).equals("A")){
                cnt_AB++;
            } else if (String.valueOf(ss.charAt(0)).equals("B")){
                cnt_B++;
            } else if (String.valueOf(ss.charAt(ss.length()-1)).equals("A")){
                cnt_A++;
            }
        }
        if (cnt_A==0 && cnt_B==0){
            if (cnt_AB!=0){
                ans += cnt_AB-1;
            }
        } else {
            ans += cnt_AB+Math.min(cnt_A,cnt_B);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 28656
class Prime():
    def __init__(self, n):
        self.p = [] # self.p[i] = i番目の素数 < n
        self.d = [0] * n # self.d[i] = iを割り切る最小の素数

        # エラトステネスの篩
        for i in range(2, n):
            if self.d[i] == 0:
                self.p.append(i)
                for j in range(i, n, i):
                    if self.d[j] == 0:
                        self.d[j] = i

        self.ind = [-1] * n # self.ind[i] = self.p.index[i]
        for i in range(len(self.p)):
            self.ind[self.p[i]] = i

    def prime_factorization_index(self, x): # xの素因数のlistをreturn(重複なし)
        l = [self.ind[self.d[x]]]
        x //= self.d[x]
        while x != 1:
            if l[-1] != self.ind[self.d[x]]:
                l.append(self.ind[self.d[x]])
            x //= self.d[x]
        return l

    def num_prime(self): # n未満の素数の個数をreturn
        return len(self.p)

def main():

    from math import gcd
 
    n = int(input())
    a = list(map(int, input().split()))

    # 'not coprime'かどうか判定
    g = a[0]
    for i in range(1, n):
        g = gcd(g, a[i])
        if g == 1:
            break
    else:
        print('not coprime')
        exit()

    # 'setwise coprime'かどうか判定
    p = Prime(10**6 + 1)

    tf = [False] * p.num_prime()

    for i in a:
        if i == 1:
            continue

        l = p.prime_factorization_index(i)
        for j in l:
            if tf[j]:
                print('setwise coprime')
                exit()
            else:
                tf[j] = True

    print('pairwise coprime')

main()


Measured memory_bytes: 126916
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main() {
   ll a,b,q;cin>>a>>b>>q;
   vector<ll>s(a),t(b),x(q);
   rep(i,a)cin>>s[i];
   rep(i,b)cin>>t[i];
   rep(i,q)cin>>x[i];
   vector<ll>ans(q);
   rep(i,q){
       ans[i]=1e11;
       auto sh=lower_bound(s.begin(),s.end(),x[i]);
       auto te=lower_bound(t.begin(),t.end(),x[i]);
       ll ft,bt,fs,bs;
       bool flag[4];
       rep(j,4)flag[j]=1;
       if(sh==s.begin()){flag[0]=0;fs=-1e12;}
       if(te==t.begin()){flag[1]=0;ft=-1e12;}
       if(sh==s.end()){flag[2]=0;bs=1e12;}
       if(te==t.end()){flag[3]=0;bt=1e12;}
       if(flag[2])bs=*sh;
       if(flag[3])bt=*te;
       if(flag[0]){sh--;fs=*sh;}
       if(flag[1]){te--;ft=*te;}
       ans[i]=min(ans[i],max(bs,bt)-x[i]);
       ans[i]=min(ans[i],x[i]-min(fs,ft));
       ans[i]=min(ans[i],min(x[i]-fs,bt-x[i])+bt-fs);
       ans[i]=min(ans[i],min(bs-x[i],x[i]-ft)+bs-ft);
       
   }
rep(i,q)cout<<ans[i]<<endl;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

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

    ll L = (ll)sqrt(N);
    map<ll,ll> M;
    for (ll i = 1; i<=L; i++) {
        for (ll j = i; j <= L; j++) {
            for (ll k = j; k<=L; k++) {
                int c;
                if (i == j && j == k) {
                    c=1;
                } else if ((i == j && j != k) || (j == k && j != i)) {
                    c=3;
                } else {
                    c=6;
                }
 
                M[i*i + j*j + k*k + i*j + j*k + k*i] += c;
            }
        }
    }

    for (ll i = 1; i <= N; i++) {
        cout << M[i] << endl;
    }

}


Measured memory_bytes: 5932
import numpy as np
N, M = map(int, input().split())
A = np.array([int(input().replace("#", "1").replace(".", "0"), base=2) for _ in range(N)], dtype=np.int64)
B = "".join(str(int(input().replace("#", "1").replace(".", "0"), base=2)) for _ in range(M))
mask = (1 << M) - 1
for _ in range(N - M + 1):
    if B in "".join(str(a) for a in A & mask):
        print("Yes")
        break
    A >>= 1
else:
    print("No")

Measured memory_bytes: 12492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}


int main() {
    int n, m; cin >> n >> m;
    vector<int> P(m), Y(m);
    for (int i = 0; i < m; ++i) {
        cin >> P[i] >> Y[i]; --P[i];
    }
    
    vector<vector<int> > vals(n);
    for (int i = 0; i < m; ++i){
        vals[P[i]].push_back(Y[i]);
    }
    
    for (int v = 0; v < n; ++v) {
        sort(vals[v].begin(), vals[v].end());
    }

    for (int i = 0; i < m; ++i) {
        int v = P[i];
        printf("%06d", v + 1);
        int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", id + 1);
    }
}


Measured memory_bytes: 9496
#include<bits/stdc++.h>
#define MOD 1000000007
#define fi(i,a,b) for(ll i = a; i < b; i++)
#define fd(i,a,b) for(ll i = a; i >= b; i--)
#define cfi(container,it) for(auto it = container.begin(); it != container.end(); it++)
#define cfd(container,it) for(auto it = container.rbegin(); it != container.rend(); it++)
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pbx(num) ll temp; cin>>temp; num.pb(temp) 

using namespace std;
typedef long long ll;

struct modll {
	ll num;
	operator ll() {return num;}
};
modll operator *(modll x, modll y) {return {(x.num * y.num) % MOD} ;}
modll operator +(modll x, modll y) {return {(x.num + y.num + MOD) % MOD} ;}

int n;
const int nax = 1e5 + 5;
// first for white and second for black
vector<pair<ll,ll>> dp(nax, {1, 1});
vi adj[nax];
vector<bool> vis(nax);

void add_self(ll &a, ll b) {
	a += b;
	if(a > MOD)
		a -= MOD;
}

void mul_self(ll &a, ll b) {
	a *= b;
	a %= MOD;
	if(a < 0)
		a += MOD;
}


void dfs(int i) {

	vis[i] = true;

	cfi(adj[i], it) {
		if(!vis[*it]) {
			dfs(*it);
			ll temp = 0;
			add_self(temp, dp[*it].first);
			add_self(temp, dp[*it].second);
			mul_self(dp[i].first, temp);
			mul_self(dp[i].second, dp[*it].first);
			// flag = true;
		}
	}

	// if(!flag) {
	// 	dp[i].first = dp[i].second = 1;
	// }

}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin>>n;
	fi(i, 0, n - 1) {
		int x, y;
		cin>>x>>y;
		x--;y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}

	ll ans = 0;

	// because its a tree and everything is connected 
	dfs(0);
	add_self(ans, dp[0].first);
	add_self(ans, dp[0].second);

	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 11520
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define let const auto
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'

int N, K;

int main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   cin >> N >> K;
   long cnt = 0L;

   for (int i=K+1; i <= N; ++i) {
      cnt += (i-K) * (N/i);
      if (N % i >= K) {
         cnt += N % i - K +1;
         if (K == 0)--cnt;
      }
   }
   outl(cnt);
}




Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>
#include<stack>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;

//--------------
///#define DEBUG
//--------------

#ifdef DEBUG
	#define debugprint(x) cout<<x<<" "
	#define debugendl cout<<endl
	#define debug(x) x
#else
	#define debugprint(x)
	#define debugendl
	#define debug(x)
#endif

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	zahyo operator*(int t){
		zahyo temp;
		temp.x=this->x*t;
		temp.y=this->y*t;
		return temp;
	}
	zahyo operator%(int t){
		zahyo temp(this->x%t,this->y%t);
		return temp;
	}
	zahyo operator/(int t){
		zahyo temp(this->x/t,this->y/t);
		return temp;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};
int mae[200000]={};
int ato[200000]={};
int main(){
	int n;
	long long int mod=1000000007LL;
	cin>>n;
	long long int ans=0;
	long long int allsum=0;
	for(int i=0;i<n;i++){
		long long int t;
		cin>>t;
		ans=(ans-t*t)%mod;
		while(ans<0){ans+=mod;}
		allsum=(allsum+t)%mod;
	}
	int nijyo=(allsum*allsum)%mod;
	nijyo=(nijyo+ans)%mod;
	if(nijyo%2==0){cout<<nijyo/2<<endl;}
	else{cout<<(nijyo+mod)/2<<endl;}

	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
int selectionsort(int a[],int n)
{
    int i,j,t,sw=0,minj;
    for(i=0;i<n-1;i++){
        minj=i;
        for(j=i;j<n;j++){
            if(a[j]<a[minj])minj=j;
        }
        t=a[i];
        a[i]=a[minj];
        a[minj]=t;
        if(i!=minj)sw++;
    }
    return sw;
}
int main(){
    int a[100],n,i,sw;
    scanf("%d",&n);
    for(int j=0;j<n;j++)
        scanf("%d",&a[j]);
    sw=selectionsort(a, n);
    for(i=0;i<n;i++){
        if(i>0)printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
    printf("%d\n",sw);
    return 0;
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define rep(I, N) for (int I = 1; I <= (N); ++I)
#define repp(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORR(I, A, B) for (int I = (A); I >= (B); I--)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
const int N = 1000 + 5;
const double eps = 1e-7;
const int mod = 1e9 + 7;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
LL gcd(LL a,LL b){return b>0?gcd(b,a%b):a;}
LL ksm(LL a,LL b){LL ans = 1;while(b){if(b&1) ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans % mod;}
int a[N][N];
int n,d;
map<int, int> mp;
int solve(int x,int y)
{
    int ans = 0;
    for (int i = 1; i <= d;i++)
    {
        ans += (a[x][i] - a[y][i]) * (a[x][i] - a[y][i]);
    }
    if(mp[ans])
        return 1;
    else
        return 0;
}
int main() {
    //int n,d;
    for (int i = 0; i <= 1000;i++)
        mp[i * i] = 1;
    cin >> n >> d;
    rep(i,n)
    {
        rep(j,d)
        {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    rep(i,n){
        for (int j = i + 1; j <= n;j++)
        {
            if(solve(i,j))
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

void solve()
{
    long long int n, d;
    cin >> n >> d;
    long long int x, y, ans = 0;
    for (long long int i = 0; i < n; i++)
    {
        cin >> x >> y;
        if (x * x + y * y <= d * d)
            ans++;
    }
    cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;

int N, C;
int D[40][40];
int c[510][510];
int mc[3][40];


void makeMC(){
	rep(i, 0, N)
		rep(j, 0, N) mc[(i+j)%3][c[i][j]]++;
}


int solve(){
	int ans = INF;
	rep(i, 0, C){
		rep(j, 0, C){
			if(i == j) continue;
			rep(k, 0, C){
				if(j == k || k == i) continue;
				int sum = 0;
				rep(l, 0, C) sum += mc[0][l]*D[l][i];
				rep(l, 0, C) sum += mc[1][l]*D[l][j];
				rep(l, 0, C) sum += mc[2][l]*D[l][k];
				ans = min(ans, sum);
			}
		}
	}
	return ans;
}


signed main(){
	cin>> N >> C;
	rep(i, 0, C)
		rep(j, 0, C) cin >> D[i][j];
	rep(i, 0, N)
		rep(j, 0, N) cin >> c[i][j], c[i][j]--;

	makeMC();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  int N, M;
  cin >> N >> M;
  int a, b;
  map<int, int> m;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    if(!m.count(a)) m[a] = 1;
    else m.at(a)++;
    if(!m.count(b)) m[b] = 1;
    else m.at(b) ++;
  }
  bool flag = true;
  for(auto i = m.begin(); i != m.end(); i++){
    int x = i -> second;
    if(x % 2 != 0) flag = false;
  }
  cout << (flag? "YES": "NO") << endl;
}

Measured memory_bytes: 4352
n,k = list(map(int, input().split()))
ret = 0
sum_max = sum(range(n, n-(k-1), -1))
sum_min = sum(range(0,(k-1)))
for i in range(k, n+2):
    sum_max += n-(i-1)
    sum_min += i-1
    ret += ( sum_max - (sum_min-1) )
    if (10**9+7) <= ret:
        ret = ret % (10**9+7)
print(ret)

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

int main() {
  int N;
  cin >> N;
  
  int Answer=1;
  
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  for (int i=0; i<N-1; i++){
    if(vec.at(i)!=vec.at(i+1)){
      Answer++;
    }
  }
  
  cout << Answer << endl;
}


Measured memory_bytes: 3604