akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;

const int MAXN=405;

int n,h;
int in[MAXN],out[MAXN],cnt[MAXN],fa[MAXN];

int Find(int x){return fa[x]==0?x:fa[x]=Find(fa[x]);}

int main(){
	scanf("%d%d",&n,&h);
	for(int i=1;i<=n;i++){
        int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int x=c==0?a:(c+200);
		int y=d==0?(b+200):d;
		in[y]++,out[x]++;
		x=Find(x),y=Find(y);
		if(x!=y) fa[x]=y;
	}
	bool f=1;
	for(int i=1;i<=400;i++)
		if(in[i]!=out[i]){
			if((in[i]<out[i]&&i>200)||(in[i]>out[i]&&i<200)){
				f=0;
				break;
			}
			int x=Find(i);
			cnt[x]++;
		}
	if(f){
		for(int i=1;i<=400;i++)
			if((in[i]||out[i])&&cnt[Find(i)]==0){
				f=0;
				break;
			}
	}
	if(f) puts("YES");
	else puts("NO");
}


Measured memory_bytes: 256
n = int(input())
A = [int(input()) for i in range(n)]
B = sorted(A)
if B[-1] == B[-2]:
    for _ in range(n):
        print(B[-1])
else:
    for a in A:
        if a == B[-1]: print(B[-2])
        else: print(B[-1])


Measured memory_bytes: 14112
#include <stdio.h>
int main(void){
int a,b,c,temp;
scanf("%d %d %d",&a,&b,&c);
if(a>b){
    temp=b;
    b=a;
    a=temp;
}
if(b>c){
    temp=c;
    c=b;
    b=temp;
}
if(a>b){
    temp=b;
    b=a;
    a=temp;
}
printf("%d %d %d\n",a,b,c);
return 0;

}



Measured memory_bytes: 2044
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())

digit = len(str(N))

if digit == 1:
    ans = N
elif digit == 2:
    ans = 9
elif digit == 3:
    ans = N - 99 + 9
elif digit == 4:
    ans = 909
elif digit == 5:
    ans = N - 9999 + 900 + 9
elif digit == 6:
    ans = 90000 + 900 + 9

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


ll gcd(ll a,ll b){
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
int ok(V<ll> &d, ll t) {
    for(int i=0; i<d.size(); i++) {
        if((t-d[i]/2) % d[i]) return 0;
    }
    return 1;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    ll t = 1;
    ll ma = 0;
    V<ll> a(n); for(int i=0; i<n; i++) {
        cin >> a[i];
        t = (t * a[i]) / gcd(t, a[i]);
        ma = max(ma, a[i]);
    }
    ll s = ma/2;
    while(!ok(a, s)) {
        s+=ma; if(s > m) break;
    }
    if(s > m) cout << 0 << endl;
    else {
        cout << 1 + (m-s) / t << endl;
    }
    
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int ok=0,x=0;
  map<Int, Int> m;
  for(Int i=0;i<n;i++){
    if(m[a[i]]++==0) ok++;
    if(m[a[i]]==0) ok--;
    if(m[a[n-(i+1)]]--==0) ok++;
    if(m[a[n-(i+1)]]==0) ok--;
    
    if(!ok){
      if(x) cout<<" ";
      x=1;
      cout<<i+1;
    }
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 6784
/* 

	CODE TEMPLATE APRATIM

*/

#include <bits/stdc++.h>
#pragma optimize("O3")
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define veci vector<ll>
#define it map<string, vv>::iterator
#define MOD 1000000007
#define N (ll)3e+5
#define test int T;cin>>T;while(T--)
#define nl "\n"
#define FULL(iii) iii.begin(),iii.end()
#define setbit(_) __builtin_popcount(_)
#define INF 9223372036854775807 
#define TOUPR(str) transform(str.begin(), str.end(),str.begin(), ::toupper)
#define TOLWR(str) transform(str.begin(), str.end(),str.begin(), ::tolower)
#define pb push_back
#define len(s) s.length()
#define pb push_back
#define eb emplace_back
#define S second
#define F first
#define len(s) s.length()
#define coutp cout<<setprecision(15)
#define pow(a,b) (ll)(pow(a,b)+0.5)
#define bin(x) stoull(x,0,2)
#define lld long double
#define yy cout<<"Yes"<<nl;
#define nn cout<<"No"<<nl;
class Graph
{
	private:
	map<ll,veci>m;
	public:
	void edges(ll source, ll destination)
	{
		m[source].pb(destination);
		m[destination].pb(source);
	}
	vector<ll> BFS(ll s)
	{
		queue<ll> q;
		map<ll,ll>vis;
		veci x;
		vis[s]=1;
		q.push(s);
		while(!q.empty())
		{
			s=q.front();x.pb(s);
			q.pop();
			for(auto node:m[s])
			{
				if(!vis[node])
				vis[node]=1,q.push(node);
			}
		}
		return x;
		
	}
	
};
ll powi(ll a,ll b)
{
	if(b==0) return (ll)1;
	if(b==1) return a;
	else if(b%2) return a*powi(a,b-1);
	else return powi(a*a,b/2);
}
ll b(vector<ll>a,ll n)
{
	ll l=0,r=n-1;
	while(l<=r)
	{
		int m = r-(r-l)/2;
		if(a[m]==0)
			l = m+1;
		else{
			if(a[m-1]==0 || m==0) return m;
			else r = m-1;
		}
	}
	return -1;
}
int main() {	
	fio;
	
	//test
	ll a,b,c,d;
	ll m,n,o,p;
	cin>>a>>b>>c>>d;
	m=min(a,b)*max(c,d);
	n=min(a,b)*min(c,d);
	o=max(a,b)*max(c,d);
	p=max(a,b)*min(c,d);
	cout<<max({m,n,o,p});
	
	
}
	
/*

4
1 2 4 7

7
1 2 4 8 10 12 6


7
1 2 3 4 5 6 8

*/




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

int main() {
  int a,b,c,d,e;
  cin >> a>>b>>c>>d>>e;
  int a_,b_,c_,d_,e_;
  
  vector<int> vec1={a,b,c,d,e};
  vector<int> vec2={a_,b_,c_,d_,e_};
  
  int temp =0;
  int ch;
  
  for(int i=0;i<5;i++){
  vec2.at(i)=(vec1.at(i)-1)/10*10+10;
    if(temp<vec2.at(i)-vec1.at(i)){
      temp =vec2.at(i)-vec1.at(i);
      ch =i;
    }
    
  }
  
  int sum=0;
  for(int i=0;i<5;i++){
   sum += vec2.at(i); 
  }
  sum-= vec2.at(ch)-vec1.at(ch);
  
  cout << sum <<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;
int main(void){
    // Your code here!
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    int distance = abs(A - B);//距離の絶対値
    int RelativeSpeed = abs(V - W);//相対速度
    if(V > W && (distance <= RelativeSpeed * T)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    //cout << A << V << B << W << T;
}


Measured memory_bytes: 3592
import math

N,K = map(int, input().split())

rate = 0
for i in range(1,N+1):
    if i >= K:
        rate += (1/N)
    else:
        count = math.log2((K/i))
        if int(count) == count:
            count = int(count)
        else:
            count = int(count) + 1
        rate += (1/N) * ((1/2)**count)

print(rate)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<ll>> z(26);
    for (int i = 0; i < n; i++) {
        int p = i + 1;
        z.at(s.at(i) - 'a').insert(p);
    }
    for (int i = 0; i < 26; i++) {
        z.at(i).insert(10000000);
    }
    for (int i = 0; i < q; i++) {
        ll a, b;
        cin >> a >> b;
        if (a == 1) {
            char c;
            cin >> c;
            for (int j = 0; j < 26; j++) {
                z.at(j).erase(b);
            }
            z.at(c - 'a').insert(b);
        }
        else {
            int ct;
            cin >> ct;
            int ans = 0;
            for (int j = 0; j < 26; j++) {
                ll p = *z.at(j).lower_bound(b);
                if (ct >= p) {
                    ans++;
                }
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 24196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);
		int k = Integer.parseInt(str[2]);

		String matrix[][] = new String[h][w];

		for (int i = 0; i < h; i++) {
			str = br.readLine().split("");
			for (int j = 0; j < w; j++) {
				matrix[i][j] = str[j];
			}
		}

		int ans = 0;
		for (int bit = 0; bit < (1 << h + w); bit++) {
			String m[][] = new String[h][w];

			for (int o = 0; o < h; o++) {
				for (int p = 0; p < w; p++) {
					m[o][p] = matrix[o][p];
				}
			}

			for (int i = 0; i < h + w; i++) {
				if ((bit & (1 << i)) != 0) {
					if (i < h) {
						Arrays.fill(m[i], ".");
					} else {
						for (int l = 0; l < h; l++) {
							m[l][i - h] = ".";
						}
					}
				}
			}

			int count = 0;
			for (int o = 0; o < h; o++) {
				for (int p = 0; p < w; p++) {
					if (m[o][p].equals("#")) {
						count++;
					}
				}
			}

			if (count == k) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;

int const maxn = 2005;
int n, k, ans;
int dp[maxn][maxn];
int pref_min[maxn][maxn];
int sz[maxn];
vector < int > g[maxn];

void dfs(int v, int p) {
    sz[v] = 1;
    int child = 0;
    for (auto u : g[v]) {
        if (u == p) continue;
        dfs(u, v);
        child++;
        sz[v] += sz[u];
    }
    dp[v][0] = sz[v];
    if (child == 0) {
        dp[v][1] = 0;
    }
    for (int h = 1; h <= k + 1; ++h) {
        int cur = min(h - 1, k + 1 - h), sum = 0;
        for (auto u : g[v]) {
            if (u == p) continue;
            sum += pref_min[u][cur];
        }
        for (auto u : g[v]) {
            if (u == p) continue;
            dp[v][h] = min(dp[v][h], sum - pref_min[u][cur] + dp[u][h - 1]);
        }
        ans = min(ans, dp[v][h] + n - sz[v]);
    }
    pref_min[v][0] = dp[v][0];
    for (int i = 1; i <= k + 1; ++i) pref_min[v][i] = min(pref_min[v][i - 1], dp[v][i]);
}

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    int u, v;
    for (int i = 1; i < n; ++i) {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 1; i <= n; ++i) for (int j = 0; j <= k + 1; ++j) dp[i][j] = n + 1, pref_min[i][j] = n + 1;
    ans = n;
    dfs(1, 0);
    //cout << dp[2][2] << endl;
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 31872
#include<stdio.h>
#include<math.h>
#include<stdlib.h>


void KochCurve(double x1, double y1, double x2, double y2, int dim);
main(){
  int n;
  double M =100.0, m = 0.0;

 scanf("%d", &n);

 KochCurve(0, 0, 100, 0, n);

 printf("%f %f\n", M, m);
 return 0;
}


void KochCurve(double x1, double y1, double x2, double y2, int dim)
{
  double x3, y3, x4, y4, x5, y5;
  double y;

double s = sin(M_PI/3); 
double c = cos(M_PI/3);


if( dim <= 0 ){
  //printf( x1, y1, x2, y2 );

  if(y1 < 0){y = -y1;
    printf("%f %f\n", x1, y);
  }
  else printf("%f %f\n", x1, y1);
return;
}
x3 = ( 2*x1 + x2 ) / 3;
y3 = ( 2*y1 + y2 ) / 3;
x5 = ( x1 + 2*x2 ) / 3;
y5 = ( y1 + 2*y2 ) / 3;
x4 = x3 + (x5-x3)*c + (y5-y3)*s;
y4 = y3 - (x5-x3)*s + (y5-y3)*c;
KochCurve( x1, y1, x3, y3, dim-1 );
KochCurve( x3, y3, x4, y4, dim-1 );
KochCurve( x4, y4, x5, y5, dim-1 );
KochCurve( x5, y5, x2, y2, dim-1 );
}

Measured memory_bytes: 636
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

ll dp[100001][101][2];
string a;
ll d;
ll call(int pos,int sum,int fa)
{
	if(pos==a.length())
	{
		if(sum==0)
		return 1;
		else
		return 0;
	}
	
	ll &x=dp[pos][sum][fa];
	if(x!=-1)
	return x;
	x=0;
	
	int lm=9;
if(fa==0)
lm=a[pos]-'0';
	
	for(int i=0;i<=lm;i++)
	{
		int nf=fa;
		if(fa==0&&a[pos]-'0'>i) nf=1;
		x=madd(x,call(pos+1,(sum+i)%d,nf));
	}
	return x;
}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{
	mems(dp,-1);
cin>>a>>d;
cout<<msub(call(0,0,0),1);

}return 0;}

Measured memory_bytes: 158848
#include<bits/stdc++.h>
using namespace std;
char mp[55][55];
int main()
{
    int n,m,flag=0;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>mp[i];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(mp[i][j]=='#')
            {
                if(mp[i][j+1]=='.'&&mp[i][j-1]=='.'&&mp[i+1][j]=='.'&&mp[i-1][j]=='.')
                flag=1;
            }
        }
    }
    if(flag==0)
        printf("Yes");
    else
        printf("No");
    return 0;
}


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

int main(void)
{
  int n,k;
  string s;
  cin>>n>>k>>s;
  if(s[k-1]=='A')
    s[k-1]='a';
  if(s[k-1]=='B')
    s[k-1]='b';
  if(s[k-1]=='C')
    s[k-1]='c';
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 
using namespace std;

vector<pii> adj[100001];
int color[100001];
bool vis[100001];

void dfs(int s, int v){
	vis[s] = 1;
	int tmp = 1;
	for(auto x: adj[s]){
		if(vis[x.f] == 0){
			if(tmp<v){
				dfs(x.f,tmp);
				color[x.s] = tmp;
			}
			else{
				dfs(x.f,tmp+1);
				color[x.s] = tmp+1;
			}
			tmp++;
		}
	}
}

void solve(){
	int n; cin>>n;
	int mm  = INT_MIN;
	for(int i=0; i<n-1; i++){
		int x,y; cin>>x>>y;
		adj[x].pb({y,i});
		adj[y].pb({x,i});
		mm = max(mm,(int)adj[x].size());
		mm = max(mm,(int)adj[y].size());
	}
	int r;
	for(int i=0; i<n; i++){
		if(adj[i+1].size() == 1){
			r = i+1;
			break;
		}
	}
	cout<<mm<<"\n";
	dfs(r,1e6);
	for(int i=0; i<n-1;i++){
		cout<<color[i]<<"\n";
	}


}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	
	int t =1; 
	//cin>>t;

	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}

Measured memory_bytes: 12520
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

vector<int> x, y;

double dist(int i, int j) {
    double res = 0;
    return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
}

int main() {
    int n; cin >> n;
    x.resize(n), y.resize(n);
    REP(i, n) {
        cin >> x[i] >> y[i];
    }
    double ans = 0;
    int cnt = 0;
    REP(i, n - 1) {
        FOR(j, i + 1, n) {
            ans += dist(i, j);
            cnt++;
        }
    }
    printf("%.10f",  (n-1) * ans / cnt);
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
int a[200001], v[200001];
int main() {
	int N, C = 0;
	scanf("%d", &N);
	rep(i, 1, N + 1)scanf("%d", &a[i]);
	vector<int> ans;
	for (int i = N; i >= 1; i--) {
		for(int i2 = i; i2 <= N; i2 += i){
			v[i] += v[i2];
		}
		//printf("i:%d v:%d\n", i, v[i]);
		v[i] = v[i] % 2 != a[i];
	}
	rep(i, 1, N + 1) {
		if (v[i]) {
			C++;
			ans.push_back(i);
		}
	}
	printf("%d\n", C);
	rep(i, 0, ans.size())printf(i == ans.size() - 1 ? "%d\n" : "%d ", ans[i]);
	return 0;
}


Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        string c = cin.next();
        if(c =="a" || c == "i"|| c == "u"|| c == "e"|| c == "o")
        {
            Console.WriteLine("vowel");
        }else
        {
            Console.WriteLine("consonant");
        }

    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

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

ll h[100000];
ll dp[100200];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, K;
	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> h[i];
	}

	fill((ll*)begin(dp), (ll*)end(dp), 1LL << 50);
	dp[0] = 0;
	for(int i = 0; i < N; i++){
		for(int j = 1; j <= K; j++){
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
n = int(input())
data = list(map(int, input().split()))
data.sort()
data.reverse()

while data[-1] == 0:
  data.insert(0,0)
  data.pop(-1)
 
ans = 1

for d in data:
  ans = ans * int(d)
  if ans > 10**18 or ans == 0:
    break
 
if ans > 10**18:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 21584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  string S,T; cin>>S>>T;
  int i=0;
  while (S[i]){
    if (S[i] == T[i])
      i++;
    else break;
  }
  if(i == S.size())
    cout << "Yes" << endl;
  else
    cout << "No"<< endl;
  
}


Measured memory_bytes: 3512
#include <iostream>

using namespace std;

int main() {
	int a,b,c,k;cin>>a>>b>>c>>k;;
	if(k<=a){
		cout<<k<<endl;
	}else if(k<=a+b){
		cout<<a<<endl;
	}else{
		cout<<a-(k-a-b)<<endl;
	}
	return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

  public static int[] powerCard = new int[]{2,3,4,5,6,7,8,9,10,11,12,13,1};

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String s = scan.nextLine();
    String[] card = s.split(" ");

    int i = Integer.parseInt(card[0]);
    int j = Integer.parseInt(card[1]);
if ((i < 14 && j < 14) && (i > 0 && j > 0)) {
    for (int k = 0; k < powerCard.length; k++){
      if (powerCard[k] == i){
        i = k;
        break;
      }
    }
    for (int k = 0; k < powerCard.length; k++){
      if (powerCard[k] == j){
        j = k;
        break;
      }
    }


    if (i > j){
      System.out.println("Alice");
    }
    else if (i < j){
      System.out.println("Bob");
    }
    else{
      System.out.println("Draw");
    }
}else{
System.out.println("Draw");
}
  }
}


Measured memory_bytes: 21972
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        while(true) {
            C -=B;
            if(C <= 0){
                System.out.println("Yes");
                return;
            }
            A -=D;
            if(A <= 0){
                System.out.println("No");
                return;
            }
        }



    }
}

Measured memory_bytes: 35764
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string strIn = Console.ReadLine();

            string str0 = strIn.Substring(0, 2);
            string str1 = strIn.Substring(2, 2);

            int int0 = int.Parse(str0);
            int int1 = int.Parse(str1);

            if ( int0 == 0)
            {
                if (int1 > 12 || int1 == 0)
                {
                    Console.WriteLine("NA");
                }
                else
                {
                    Console.WriteLine("YYMM");
                }
            }
            else if ( int1 == 0)
            {
                if (int0 > 12 || int0 == 0)
                {
                    Console.WriteLine("NA");
                }
                else
                {
                    Console.WriteLine("MMYY");
                }
            }
            else if (int0 <= 12 && int1 <= 12)
            {
                Console.WriteLine("AMBIGUOUS");
            }
            else if (int0 <= 12)
            {
                Console.WriteLine("MMYY");
            }
            else if (int1 <= 12)
            {
                Console.WriteLine("YYMM");
            }
            else
            {
                Console.WriteLine("NA");
            }
        }
    }
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

int main (void)
{
	//INPUT
	llint N,K;
	cin >> N >> K;
	string A;
	rep(i,0,N) {
		cin >> A;
	}
	
	//SOLVE
	llint ans=0;
	llint kaisuu=0;
	llint i;
	llint state=0;
	
	for(i=0;i<N-1;i++) {
		if (A[i]==A[i+1]) {
			ans++;
			
			
		} else {
			if (kaisuu>=K) {
				//NOTHING
				
			} else{
				if (state==0) {
					state=1;
					
					
				} else {
					state=0;
					ans+=2;
					kaisuu++;
				}
				
			}
			
		}
	}
	
	if (state==1) {
		if (kaisuu<K) {
			ans++;
		}
	}
	
	//OUTPUT
	cout << ans << endl;
	
}


Measured memory_bytes: 512
package main

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

func comb(n, r int) int {
	if r == 0 {
		return 1
	}
	return comb(n, r-1) * (n - r + 1) / r
}

func main() {
	n := readInt()
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		s := sortArray(readBytes())
		sort.Sort(s)
		m[string(s)]++
	}

	ans := 0
	for _, v := range m {
		if v < 2 {
			continue
		}
		ans += comb(v, 2)
	}
	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []byte

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i] < s[j] }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 9728
#include<stdio.h>

#define N 100

int bubbleSort(int *,int);

int main()
{
  int a[N],n,i,cnt;

  scanf("%d",&n);

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

  cnt = bubbleSort(a,n);

  for(i = 0; i < n; i++)
  {
    if(i > 0)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  
  return 0;
}

int bubbleSort(int *A, int n)
{
  int flag,j,temp,cnt=0;

  flag = 1;
  j = 0;

  while(flag == 1){
    flag = 0;
    for(j = n-1; j > 0; j--)
    {
      if(A[j] < A[j-1])
      {
	temp = A[j];
	A[j] = A[j-1];
	A[j-1] = temp;
	flag = 1;
	cnt++;
      }
    }
  }
  
    return cnt;
}



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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

class UnionFind {
public:
  UnionFind(int n) {
    r.resize(n, 0);
    s.resize(n, 1);
    p.resize(n);
    for (int i = 0; i < n; ++i) {
      p[i] = i;
    }
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) {
      return ;
    }

    s[a] = (s[b] = s[a] + s[b]);
    if (r[a] > r[b]) {
      p[b] = a;
    } else {
      p[a] = b;
      if(r[a] == r[b]) r[b]++;
    }
    return ;
  }
  int find(int a) {
    return (a == p[a]) ? a : p[a] = find(p[a]);
  }
  bool same(int a, int b) {
    return find(a) == find(b);
  }
  size_t size(int n) {
    return s[find(n)];
  }
private:
  vector<int> r, p, s;
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, m;
  while (cin >> n >> m) {
    vector<pair<int, int>> v(m);
    cin >> v;
    reverse(v.begin(), v.end());

    UnionFind uf(n + 1);

    vector<lli> u;
    lli x = (n - 1) * n / 2;
    each (e, v) {
      u.push_back(x);
      if (uf.same(e.first, e.second)) {
        continue;
      }
      
      x += (uf.size(e.first) - 1LL) * uf.size(e.first) / 2;
      x += (uf.size(e.second) - 1LL) * uf.size(e.second) / 2;

      uf.unite(e.first, e.second);

      x -= (uf.size(e.first) - 1LL) * uf.size(e.first) / 2;
    }
    reverse(u.begin(), u.end());
    each (i, u) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 4212
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define SIZE 26     
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int N = 1e5 + 5;

ll fact[N],ifact[N],a[N];
 
ll power(ll x,ll y){
    ll res=1;
    x=x%mod;
    while(y>0){
        if(y & 1) res=(res*x)%mod;
        y=y>>1;
        x=(x*x)%mod;
    }
    return res%mod;
}
 
ll modInv(ll n){
    return power(n,mod-2);
}
 
ll mul(ll a,ll b){
    return (a*b)%mod;
}

ll C(ll n,ll r){
    if(r>n or r<0 or n<0) return 0; 
    return mul(fact[n],mul(ifact[r],ifact[n-r]));
}

signed main(){
    fastio;
    ll i,n,k,ans=0;
    fact[0]=1;
    ifact[0]=1;
    for(i=1;i<N;++i){
        fact[i]=mul(fact[i-1],i);
        ifact[i]=mul(ifact[i-1],modInv(i));
    }
    cin>>n>>k;
    for(i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<n;++i){
        ans+=mul(a[i],C(i,k-1)-C(n-i-1,k-1));
        ans%=mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2560
// You may see me struggle,but you will never see me quit!
#include <bits/stdc++.h>
 using namespace std;
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define pb                      push_back
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define asort(c)                sort(all(c)) 
#define lbpos(x,v)              (int)(lower_bound(all(v),x)-v.begin())//=v.size()==>No LB 
#define ubpos(x,v)              (int)(upper_bound(all(v),x)-v.begin())//=v.size()==>No UB
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  long double                 ld;
#define debug(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(double)(time_p)/CLOCKS_PER_SEC<<"\n";
}


int32_t main()
{
  FIO;

 
  int n,k,sum=0,mx=-mod;
  cin>>n;
  int a[n+1];
  rep(i,1,n)
  {
    cin>>a[i];
    sum+=a[i];
    mx=max(mx,a[i]);
  }
  cout<<sum-mx/2;
 // timer();
  return 0;
}  

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int n = sc.nextInt();
        var a = new long[n];
        var b = new long[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
        }
        Array.Sort(b, a);

        long now = b[n - 1];
        bool flag = false;

        for (int i = n - 1; 0 <= i; i--)
        {
            if (b[i] < now) now = b[i];
            if (0 <= now - a[i]) now -= a[i];
            else
            {
                flag = true;
                break;
            }
        }

        if (flag) Console.WriteLine("No");
        else Console.WriteLine("Yes");
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 18356
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
#define MAXN 200000
#define INF 2000000000
#define LL long long
struct node
{
    int val,cnt;
}a[MAXN+5];
int n,ans;
map<int,int> Dic;
bool cmp(node s1,node s2)
{
    return s1.cnt<s2.cnt;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i].val);
        Dic[a[i].val]++;
    }
    for(int i=1;i<=n;i++)
    {
        LL p=1,cnt=0;
        bool F=0;
        while(p<=INF)p*=2;
        while(!F&&p>1)
        {
            p/=2;
            if(p-a[i].val>=0)
            {
                if((p-a[i].val)==a[i].val)
                {if(Dic[a[i].val]>1)cnt++;}
                else
                {if(Dic[p-a[i].val]>=1)cnt++;}
            }
        }
        a[i].cnt=cnt;
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)
    {
        LL p=1;bool F=0;
        if(Dic[a[i].val]==0)continue;
        while(p<=INF)p*=2;
        while(!F&&p>1)
        {
            p/=2;
            if(p-a[i].val>=0)
            {
                if(p-a[i].val==a[i].val)
                {if(Dic[a[i].val]>1)ans++,Dic[a[i].val]-=2,F=1;}
                else
                {if(Dic[p-a[i].val]>=1)ans++,Dic[a[i].val]--,Dic[p-a[i].val]--,F=1;}
            }
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 34432
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<29)
int N,M,L;
int Wa[111][111];
int P[111],K[111];
struct edge{
  int to,c,rev;
  edge(int to,int c,int rev) : to(to),c(c),rev(rev) {}
};
vector<edge> G[333];
bool used[333];
int dfs(int v,int t,int f){
  if( v == t ) return f;
  used[v] = true;
  for(int i=0;i<(int)G[v].size();i++){
    edge &e = G[v][i];
    if( !used[e.to] && e.c > 0 ){
      int d = dfs(e.to, t , min(f,e.c) );
      if( d > 0 ){
	e.c -= d;
	G[e.to][e.rev].c += d;
	return d;
      }
    } 
  }
  return 0;
}

int max_flow(){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(2*N,2*N+1,INF);
    if( f == 0 ) return flow;
    flow += f;
  }
}

int main(){
  while( cin >> N >> M >> L ){
    fill(Wa[0],Wa[N],INF);
    for(int i=0;i<M;i++){
      int a,b,d;
      cin >> a >> b >> d;
      --a; --b;
      Wa[a][b] = d;
      Wa[b][a] = d;
    }
    for(int i=0;i<N;i++){
      Wa[i][i] = 0;
      cin >> P[i];
    }
    for(int i=0;i<N;i++){
      cin >> K[i];
    }
  
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
	for(int k=0;k<N;k++)
	  Wa[j][k] = min(Wa[j][k],Wa[j][i]+Wa[i][k]);

  
    for(int i=0;i<2*N+2;i++) G[i].clear();
    for(int i=0;i<N;i++){
     
      G[i+N].push_back( edge(2*N+1,K[i],G[2*N+1].size() ) );
      G[2*N+1].push_back( edge(i+N,0,G[i+N].size()-1) );

      G[2*N].push_back( edge(i,P[i],G[i].size()) );
      G[i].push_back( edge(2*N,0,G[2*N].size() -1) );
  
      for(int j=0;j<N;j++){
	if( Wa[i][j] < L ){
	  int nj = j+N;
	  G[i].push_back( edge(nj,INF,G[nj].size()) );
	  G[nj].push_back( edge(i,0,G[i].size() - 1) );
	}
      }
    }

    cout << max_flow() << endl;
  }
}

Measured memory_bytes: 1572
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int k[150];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int r; cin >> r;
    if (r < 1200)
        cout << "ABC" << endl;
    else if (r < 2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
     int n, m;
     scanf("%d %d",&n,&m);
     bool ar[n+1];
     int ar1[n+1];
     string s;
     int p;
     memset(ar,false,sizeof(ar));
     memset(ar1,0,sizeof(ar1));

     int crt=0;
     int pen=0;
     for(int i=1;i<=m;i++)
     {
         scanf("%d",&p);
         getchar();
         cin >> s;

         if(s=="AC")
         {
             if(ar[p]==false)
             {
             crt++;
             ar[p]=true;
             pen=pen+ar1[p];
             }
         }
         else if(s=="WA")
         {
             if(ar[p]==false)
             {
                 ar1[p]++;
             }
         }
     }
     printf("%d %d",crt,pen);
     return 0;

}


Measured memory_bytes: 768
#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>;
static const ll INF = 1000000000000000000;
static const ll MOD = 1000000007;

int main(){
	int n, m;
	cin >> n >> m;
	map<int, int> mp;
	rep(i, m){
		int a, b;
		cin >> a >> b;
		mp[a]++;
		mp[b]++;
	}
	
	for(auto itr : mp){
		if(itr.second % 2 == 1){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}



Measured memory_bytes: 4352
def restore(sec, x):
  return int(sec.replace("X", str(x)))

while True:
  try:
    s = input()
    p_ind = s.index("+")
    e_ind = s.index("=")
    sec1 = s[:p_ind]
    sec2 = s[p_ind + 1:e_ind]
    sec3 = s[e_ind + 1:]

    for x in range(10):
      if not (not x and
        ((sec1[0] == "X" and len(sec1) > 1) or
         (sec2[0] == "X" and len(sec2) > 1) or
         (sec3[0] == "X" and len(sec3) > 1))):
        if restore(sec1, x) + restore(sec2, x) == restore(sec3, x):
          print(x)
          break
    else:
      print("NA")

  except EOFError:
    break



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

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

	ll ans = INT_MAX;
	for(int i = -100;i<=100;i++)
	{
		ll now = 0;
		for(int j = 0;j<n;j++)
		{
			now += (a[j]-i)*(a[j]-i);
		}
		ans = min(ans,now);
	}
	cout<<ans<<endl;
}

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

int main() {
	char s[12], t[13];
	int f = 0,n;
	scanf("%s", s);
	scanf("%s", t);
	n = strlen(s);
	for (int i = 0; i < n; i++) {
		if (s[i] == t[i]) {}
		else {
			f = 1;
		}
	}
	if (strlen(s) + 1 == strlen(t)) {}
	else {
		f = 1;
	}
		if (f == 0) {
			printf("Yes");
		}
		else {
			printf("No");
		}
}

Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
#define Maxn 100005
int n,a[Maxn],cnt,minnum = 1000000000;
long long ans;

int main(){
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		if (abs(a[i]) < abs(minnum))
			minnum = a[i];
		if (a[i] < 0)
			cnt++;
		ans += abs(a[i]);
	}
	if (cnt % 2 && minnum != 0)
		ans = ans - 2 * abs(minnum);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640