akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

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

int main(){
    int a,b; cin >> a >>b;
    cout << ((a*b%3 == 0 || (a+b)%3 == 0)? "Possible":"Impossible") << endl; return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[100010],b[100010],c[100010],d[100010],fa[100010];

int find(int x)
{
    if (x!=fa[x]) fa[x]=find(fa[x]);
    return fa[x];
}

void merge(int x,int y) {fa[find(x)]=find(y);}

int main()
{
    int n;scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=1;i<=n;i++) scanf("%d",&b[i]);
    a[n+1]=0;for (int i=1;i<=n;i++) a[n+1]^=a[i];
    b[n+1]=0;for (int i=1;i<=n;i++) b[n+1]^=b[i];
    int l=0;
    for (int i=1;i<=n+1;i++) if (a[i]!=b[i]||i==n+1) {c[++l]=a[i];d[l]=b[i];}
    sort(c+1,c+l+1);sort(d+1,d+l+1);
    for (int i=1;i<=l;i++) if (c[i]!=d[i]) {puts("-1");return 0;}
    int ans=0;
    for (int i=1;i<=n;i++) ans+=(a[i]!=b[i]);
    int m=0;for (int i=1;i<=l;i++) if (i==1||c[i]!=c[i-1]) c[++m]=c[i];
    for (int i=1;i<=m;i++) fa[i]=i;
    for (int i=1;i<=n;i++) if (a[i]!=b[i]) merge(lower_bound(c+1,c+m+1,a[i])-c,lower_bound(c+1,c+m+1,b[i])-c);
    for (int i=1;i<=m;i++) if (fa[i]==i) ans++;
    printf("%d\n",ans-1);
    return 0;
}


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

int main(){
    int N;

    cin >> N;

    if(N%2 == 0){
        cout << N/2*N/2 << endl;
    }else{
        cout << N/2*(N/2 + 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
e = s.count("E")
w = n - e
ans = 10**9
if s[0] == "W":
    cnt = e
else:
    cnt = e-1
num = cnt
for i in range(n-1):
    if s[i] == s[i+1] and s[i] == "E":
        cnt -= 1
    elif s[i] == s[i+1]:
        cnt += 1
    ans = min(ans,cnt,num)
    ans = max(ans,0)
print(max(ans,0))

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

int main()
{
	int arr[100000];
	int n,k;
	cin>>n>>k;
	int a;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a);
		arr[i]=a;
	}
	sort(arr,arr+n);
	int min=1000000000;
	int q=0;
	for(int i=0;i<n-k+1;i++)
	{
		if(arr[i+k-1]-arr[i]<min)
		min=arr[i+k-1]-arr[i];
	}
	cout<<min;
}

Measured memory_bytes: 640
#include <vector>
#include <iostream>
using namespace std;
int main() {
	vector<vector<double> > A(3, vector<double>(4));
	vector<double> P(3);
	for (int i = 0; i < 3; ++i) cin >> P[i];
	for (int i = -1; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> A[j][(i + 4) % 4];
			A[j][(i + 4) % 4] -= P[j];
		}
	}
	for (int i = 0; i < 3; ++i) {
		int ptr = -1;
		for (int j = i; j < 3; ++j) {
			if (A[j][i] != 0) {
				ptr = j;
				break;
			}
		}
		if (ptr != i) swap(A[ptr], A[i]);
		double mult = 1.0 / A[i][i];
		for (int j = 0; j < 4; ++j) {
			A[i][j] *= mult;
		}
		for (int j = 0; j < 3; ++j) {
			if (j == i) continue;
			double submult = A[j][i];
			for (int k = 0; k < 4; ++k) {
				A[j][k] -= submult * A[i][k];
			}
		}
	}
	if (A[0][3] >= 0 && A[1][3] >= 0 && A[2][3] >= 0 && A[0][3] + A[1][3] + A[2][3] >= 1) {
		cout << "MISS" << endl;
	}
	else {
		cout << "HIT" << endl;
	}
	return 0;
}


Measured memory_bytes: 3268
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    int n, d;
    cin >> n >> d;
    long long D = d * 1LL * d;

    int res = 0;
    for (int i = 0; i < n; ++i) {
        long long x, y;
        cin >> x >> y;
        if (x * x + y * y <= D) {
            ++res;
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

main(){
  int data[20],i,n,p,ans,temp=1;

  data[0]=1;
  for(i=1;;i++){
    temp*=4;
    data[i]=temp;
    if(temp>=1500000){
      data[i]=-1;
      break;
    }
  }
  while(1){
    scanf("%d", &n);
    if(n==-1) break;
    if(n==0){
      printf("0\n");
      continue;
    }

    for(i=0;;i++){
      if(data[i]==-1) break;
      if(n<data[i]){
	p=i;
	break;
      }
    }

    for(i=p-1;i>=0;i--){
      ans=n/data[i];
      n = n-data[i]*ans;
      printf("%d", ans);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int c;
void abc(int sum, int n, int s, int d)
{
	int i;
	if (n){
		for (i = d; i <= 9; i++){
			abc(sum + i, n - 1, s, i + 1);
		}
	}
	else if (sum == s){
		c++;
	}
}

int main(void)
{
	int n, s;
	
	while (scanf("%d %d", &n, &s), n + s != 0){
		c = 0;
		abc(0, n, s, 0);
		printf("%d\n", c);
	}
	
	return 0;
}

Measured memory_bytes: 596
N, M = map(int, input().split())
MOD = 10**9+7

oks = [True] * (N+1)
for _ in range(M):
    a = int(input())
    oks[a] = False

dp = [0] * (N+1)
dp[0] = 1
for now in range(N):
    for next in range(now+1, min(N, now+2)+1):
        if oks[next]:
            dp[next] += dp[now]
            dp[next] %= MOD
            
print(dp[N])

Measured memory_bytes: 13636
#include <iostream>
#include <algorithm>
#include <cstdio>
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
using namespace std;

int main() {
	while(true){
		int h, w;
		cin >> h >> w;
		if(h == 0 && w == 0)break;
		REP(i, h){
			REP(j, w){
				if((i+j) % 2 == 0) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


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

const long long mod = 1e9 + 7;
const long long maxn = 1e6 + 10;

long long n;
long long ans;
long long lca;
long long a[maxn];
long long alpha[maxn];

void in();
void solve();
void upd_lca(long long);
long long pwr(long long, long long);
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
    for(long long i = 0; i < n; i++)
        cin >> a[i];
}

void solve(){
    lca = 1;
    for(long long i = 0; i < n; i++)
        upd_lca(a[i]);
    for(long long i = 0; i < n; i++){
        ans += lca * pwr(a[i], -1) % mod;
        ans %= mod;
    }
}

void upd_lca(long long x){
    for(long long i = 2; i * i <= x; i++){
        long long tmp = 0;
        while(x % i == 0){
            tmp++;
            x /= i;
        }
        if(tmp > alpha[i]){
            lca = lca * pwr(i, tmp - alpha[i]) % mod;
            alpha[i] = tmp;
        }
    }
    if(x != 1){
        if(1 > alpha[x]){
            lca = lca * pwr(x, 1 - alpha[x]) % mod;
            alpha[x] = 1;
        }
    }
}

long long pwr(long long a, long long b){
    if(b < 0)
        return pwr(a, b + mod - 1);
    if(b == 0)
        return 1;
    long long c = pwr(a, b / 2);
    if(b % 2)
        return c * c % mod * a % mod;
    return c * c % mod;
}

void out(){
    cout << ans;
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

#define rep(i,s,n)for(int i = s;i<n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define repe_r(i,s,n)for(int i = n;i>=s;i--)

int main() {
	ll l, r; cin >> l >> r;
	if (r - l >= 2019) {
		cout << 0 << endl;
		return 0;
	}

	else {
		ll t = 1e13;
		rep(i, l, r) {
			repe(j, i + 1, r) {
				//ll p = (i*j) % 2019;
				//t = min(t, p % 2019);
				t = min((ll)(i % 2019)*(ll)(j % 2019) % 2019, t);
			}
		}
		cout << t << endl;
		return 0;
	}

	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long

#define INF 999999999

using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
// input
int n;

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

    cout << int(pow(floor(sqrt(n)),2)) << "\n";
    
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, N;
int A[int(1e3+5)], B[int(1e3+5)];
int DP[int(1e3+5)][int(1e4+5)];

int main(){
  cin >> H >> N;
  for (int i = 1; i <= N; i++){
    cin >> A[i] >> B[i];
  }

  fill((int*)DP, (int*)(DP + N + 1), 1e9);
  DP[0][H] = 0;

  for (int i = 1; i <= N; i++){
    for (int j = H; j >= 0; j--){
      DP[i][j] = DP[i-1][j];
    }
    for (int j = H; j >= 0; j--){
      int next = max(j - A[i], 0);
      DP[i][next] = min(DP[i][next], DP[i-1][j] + B[i]); 
    }

    for (int j = H; j >= 0; j--){
      int next = max(j - A[i], 0);
      DP[i][next] = min(DP[i][next], DP[i][j] + B[i]);
    }
  }
  cout << DP[N][0] << endl;

  return 0;
}


Measured memory_bytes: 42680
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
const int vmax=100001;
vector<PA> g[vmax];
int dist1[vmax]={},dist2[vmax]={};

void dfs(int s,int t,int k){
    dist1[s]=k;
    for(auto &i:g[s]){
	    if(i.FI==t) continue;
	    dfs(i.FI,s,k+i.SE);
    }
}
void dfs2(int s,int t,int k){
    dist2[s]=k;
    for(auto &i:g[s]){
	    if(i.FI==t) continue;
	    dfs2(i.FI,s,k+i.SE);
    }
}

int main(){
    int n; cin>>n;
    FOR(i,0,n-1){
        int a,b; cin>>a>>b;
        a--; b--;
        g[a].PB(PA(b,1));
        g[b].PB(PA(a,1));
    }
    dfs(0,-1,0);
    dfs2(n-1,-1,0);
    int fene=0,snuke=0;
    FOR(i,0,n){
        if(dist1[i]<=dist2[i]) fene++;
        else snuke++;
    }
    cout<<(fene>snuke?"Fennec":"Snuke")<<endl;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    VI a(n); REP(i,n) cin >> a[i];
    int count = 1; bool ok = 0;
    int now = 0;
    while(count<n+1){
        if(a[now]==2) ok = 1;
        now = a[now] - 1;
        if(ok) break;
        count++;
    }
    if(ok) out(count);
    else out(-1);

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);

	int n ;
    string s;
    cin >> n >> s;
    int ans = 1 ;
    if(s.size() == 0)
        cout << 0 << endl;
    char c = s[0];
    for(int i = 0 ; i < s.size() ; ++i){
        if(c == s[i]){
            continue;
        }
        else{
            ans++;
            c = s[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
IDENTIFICATION DIVISION.
PROGRAM-ID. 166A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S          PIC X(3).
*>
PROCEDURE DIVISION.
  ACCEPT S.
*>
  IF (S = 'ABC')
    DISPLAY 'ARC'
  ELSE
    DISPLAY 'ABC'
  END-IF.
*>
  STOP RUN.


Measured memory_bytes: 3660
#include<stdio.h>
#include<math.h>
#define pi acos(-1)
int main()
{
	int a,b;
	char op;
	int sum=0;
	scanf("%d %c %d",&a,&op,&b);
	while(op!='?')
	{
		if(op=='+')
         sum=a+b;
	    else if(op=='-')
	     sum=a-b;
	     else if(op=='*')
	     sum=a*b;
	     else if(op=='/') 
	     sum=a/b;
	     printf("%d",sum);
	     printf("\n");
	     scanf("%d %c %d",&a,&op,&b);
	}
return 0;
} 


Measured memory_bytes: 2708
using System;
using System.Text;
using System.Linq;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        System.Diagnostics.Debug.WriteLine("-----TextFile1");
        System.Diagnostics.Debug.WriteLine(process("../TextFile1.txt"));
        System.Diagnostics.Debug.WriteLine("-----TextFile2");
        System.Diagnostics.Debug.WriteLine(process("../TextFile2.txt"));
        System.Diagnostics.Debug.WriteLine("-----TextFile3");
        System.Diagnostics.Debug.WriteLine(process("../TextFile3.txt"));
#endif

#if !DEBUG
        String ret = process(new System.IO.StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static string process(string filePath) {
        using (var input = new System.IO.StreamReader(filePath)) {
            if(input.EndOfStream) return "NO PROC";
            return process(input);
        }
    }

    static string process(System.IO.TextReader input) {
        var s     = input.ReadLine();
        var spl   = s.Split(' ');
        int a     = int.Parse(spl[0]);
        int b     = int.Parse(spl[1]);
        int c     = int.Parse(spl[2]);

        return Math.Max( (c - (a - b)), 0).ToString();
    }

    
    static int[] ToIntArray(string strs, int n) {
        int[] ret = new int[n];
        var spl =strs.Split(' ');
        for (int i = 0; i < n; i++) ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int dst(int i, int j) {
    return abs(j - i);
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <pii> a(n);
    forn (i, 0, n) {
        cin >> a[i].fs;
        a[i].sc = i;
    }
    sort(rall(a));
    vector <long long> dp(n + 1, -1e18);
    dp[0] = 0;
    forn (i, 0, n) {
        vector <long long> new_dp(n + 1, -1e18);
        forn (j, 0, i + 1) {
            int l = j, r = n - (i - j) - 1;
            chkmax(new_dp[j], 1LL * a[i].fs * dst(a[i].sc, r) + dp[j]);
            chkmax(new_dp[j + 1], 1LL * a[i].fs * dst(a[i].sc, l) + dp[j]);
        }
        swap(dp, new_dp);
        //cout << dp << "\n";
    }
    cout << *max_element(all(dp));
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

int n, a[N], m;
string s, t;

int32_t main(){_
   
   cin >> n >> m;


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

   vector<int> good(n+1, true);
   for (int i = 0; i < m; ++i)
   {
      int x, y;
      cin >> x >> y;
      good[x] &= a[x] > a[y];
      good[y] &= a[y] > a[x];
   }

   int ans = accumulate(good.begin()+1, good.end(), 0LL);

   tr(good);
   cout<<ans;

   return 0;
}

Measured memory_bytes: 4768
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    double a[n],sum=0;
    int counter=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    double boader=sum/(4*m);
    for(int i=0;i<n;i++){
        if(double(a[i])>=boader) counter++;
    }
    if(counter>=m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3692
function main(input){
  var line1 = input[0].split(' ');
  var n = parseInt(line1[0]);
    console.log((n-2)*180);
}


function parse(line){
  var ret = [];
  var arr = line.split(' ');
  for (var i = 0; i < arr.length; i++) {
    ret.push(parseInt(arr[i]));
  }
  return ret;
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


Measured memory_bytes: 21192
N=int(input())
L=[]
for i in range(N):
    x,y=map(int,input().split())
    L.append([x,y])
    
cnt=0
S=0
for i in range(N-1):
    for j in range(i+1,N):
        cnt+=1
        S+=((L[i][0]-L[j][0])**2+(L[i][1]-L[j][1])**2)**0.5
AVE=S/cnt
print(AVE*(N-1))
        

Measured memory_bytes: 38384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();

            int len = s.length();
            int l = 1, r = s.length();
            while (l < r) {
                int mid = r - (r - l) / 2;
                boolean flag = true;
                if (2 * mid - len > 1) {
                    for (int i = len - mid + 1; i < mid; ++i) {
                        if (s.charAt(i) != s.charAt(len - mid)) {
                            flag = false;
                            break;
                        }
                    }
                }

                if (flag) {
                    l = mid;
                } else {
                    r = mid - 1;
                }
            }

            out.println(l);
        }

    }
}



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

int s=1000000001;
int l=0;

int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        s=min(s,a);
        l=max(l,a);
    }
    cout<<l-s<<endl;
    return 0;
}

Measured memory_bytes: 256
from functools import reduce

# 入力
N = int(input())
S = input()

# 閉じられていない '(' の個数だけ S の末尾に ')' を、
# 閉じられていない ')' の個数だけ S の先頭に '(' を付与した文字列が解である
a, b = reduce(
    lambda acc, s: (
        (
            acc[0] + 1 if s == '(' else max(0, acc[0] - 1),
            acc[1] + 1 if s == ')' and acc[0] == 0 else acc[1]
        )
    ),
    S,
    (0, 0)
)
ans = b * '(' + S + a * ')'

# 出力
print(ans)


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

string a;
int main() {
    cin >> a;
    int len = a.size();
    for(int i = 0; i < len; ++i) {
        if(a[i] == 'C') {
            for(int j = i + 1; j < len; ++j)
                if(a[j] == 'F') {
                    puts("Yes");
                    return 0;
                }
            }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#d greedy might work well
n = int(input())
a = [int(i) for i in input().split()]

#make the pairs of place index and its value
a_num = [(v,num+1) for num,v in enumerate(a)]

ans = [0] * (n**2)
for i,v in enumerate(a):
    ans[v-1] = i+1

a_num.sort()

judge = True

ind = 0
for v,num in a_num:
    # we do not use the value v in this loop
    cnt = 0
    while not (cnt==num-1):
        if ans[ind]==0: #not yet written
            ans[ind]=num
            cnt += 1
        elif ans[ind]==num: #impossible to make an array
            judge = False
            break
        ind += 1

        
a_num.reverse()
ind = n*n-1
for v,num in a_num:
    # we do not use the value v in this loop
    cnt = 0
    while not (cnt==n-num):
        if ans[ind]==0: #not yet written
            ans[ind]=num
            cnt += 1
        elif ans[ind]==num: #impossible to make an array
            judge = False
            break
        ind -= 1

if judge==True:
    print("Yes")
    print(*ans)
else:
    print("No")

Measured memory_bytes: 10928
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	n,m = map(int,input().split())
	if(abs(n-m)>1):
		print(0)
	elif(abs(n-m)==1):
		print(math.factorial(n)*math.factorial(m)%(10**9+7))
	else:
		print(2*math.factorial(n)*math.factorial(m)%(10**9+7))

main()

Measured memory_bytes: 85592
using System;

namespace ABC086
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if ((a * b) % 2 == 0) { Console.WriteLine("Even"); }
            else { Console.WriteLine("Odd"); }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
using namespace std;

int main() {
  ll N, K;
  cin >> N >> K;
  if(N % K == 0) cout << 0 << endl;
  else cout << min(abs(((N / K) + 1) * K - N), abs(((N / K) + 1) * K - N - K)) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
    int n,m;
    cin >>n >>m;

    bool res = true;
    vector<int> num(n, -1);
    for(int i = 0; i < m; i++){
        int s,c;
        cin >>s >>c;
        if(num[s-1] != -1 && num[s-1] != c){
            res = false;
        }else{
            num[s-1] = c;
        }
        if(n != 1 && s == 1 && c == 0){
            res = false;
        }
    }

    if(res){
        for(int i = 0; i < n; i++){
            if(num[i] == -1){
                if(i > 0 || n == 1){
                    printf("0");
                }else{
                    printf("1");
                }
            }else{
                printf("%d", num[i]);
            }
        }
        printf("\n");
    }else{
        printf("-1\n");
    }

    return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scanf("%d", &k)
	fmt.Scanf("%d%d", &a, &b)

	if a%k == 0 || b%k == 0 {
		fmt.Println("OK")
		return
	}

	n1 := a / k
	n2 := b / k
	if n2-n1 >= 1 {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}
}


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

using namespace std;
using ll = long long;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	int n, k;
	cin >> n >> k;

	if (!k) {
		cout << "0\n";
		return 0;
	}

	map<int, int> cnt;
	cnt[1] = 1;

	ll ans = 0;

	vector<ll> p(n + 1, 0);

	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		p[i + 1] = (p[i] + x) % k;

		if (i >= k - 1) {
			cnt[p[i - k + 1] - i + k]--;
		}

		ans += cnt[k + p[i + 1] - i] + cnt[p[i + 1] - i];

		cnt[p[i + 1] - i]++;
	}

	cout << ans;
}

Measured memory_bytes: 23476
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner stdIn = new Scanner(System.in);
		int H, W; 		
		
		do {
			H = stdIn.nextInt();
			W = stdIn.nextInt();
			
			if( W == 0 && H == 0)break;
			
			for(int i = 1; i <= H; i++) {
				for(int j = 1; j <= W; j++) {
					if( i % 2 == 0) {
						if( j % 2 == 0) {
							if(j == W) {
								System.out.println("#");
							}else {
								System.out.print("#");
							}
						}else {
							if(j == W) {
								System.out.println(".");
							}else {
								System.out.print(".");
							}
						}
					}else {
						if( j % 2 == 0) {
							if(j == W) {
								System.out.println(".");
							}else {
								System.out.print(".");
							}
						}else {
							if(j == W) {
								System.out.println("#");
							}else {
								System.out.print("#");
							}
						}
					}
				}
		
			}
			
			System.out.print("\n");
			
		}while(true);			
	}
}


Measured memory_bytes: 38016
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int X, A;
	cin >> X >> A;
	if (X < A) {
		cout << 0;
	}
	else {
		cout << 10;
	}

	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int N, M;
    cin >> N >> M;
    cout << N * M << endl;
    return (0);
}



Measured memory_bytes: 3120
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int M = sc.nextInt();
		final int D = sc.nextInt();

		int cnt = 0;

		for(int m=4;m<=M;m++) {
			for(int d=22;d<=D;d++) {
				final int d1 = d%10;
				if(d1 <= 1) {
					continue;
				}
				final int d2 = d/10;
				if(d1*d2==m) {
					cnt++;
				}
			}
		}
		out.println(cnt);

	}
}


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

using namespace std;

int main() {
    #define int long long
    int n, x; cin >> n >> x;
    vector<int> v(n);
    for(int i = 0 ; i < n ; i++) cin >> v[i];
    sort(v.begin(), v.end());
    int cnt = 0;
    for(int i = 0 ; i < n ; i++) if(x-v[i] >= 0) { x -= v[i]; v[i] = 0; }
    v[n-1] += x;
    for(int i = 0 ; i < n ; i++) if(v[i] == 0) cnt++;
    cout << cnt << '\n';
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;

public class Main {
    public static void main(String[] args)throws Exception {
        StringBuilder sb=new StringBuilder();
        FastReader in=new FastReader(System.in);
        int i,j;
        int n=in.nextInt();
        HashSet<String> set=new HashSet<>();
        for(i=0;i<n;i++)
            set.add(in.next());
        System.out.println(set.size());
    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}





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

int main(){
    long int a[200000],n,cha;
    
    cin>>n;
    for(long int i=0;i<n;i++){
        //scanf("%ld",&s[i]);
        cin>>a[i];
    }
    
    long int back = 0;
    for(long int j=1;j<n;j++){
        back += a[j];
    }
    
    long int front = a[0];
    
    cha = abs(back - front);
    
    for(long int k=1;k<n-1;k++){
        front += a[k];
        back -= a[k];
        if(labs(front - back)<cha){
            cha = labs(front -back);
        }
    }
    cout<<cha<<endl;
    //printf("%ld\n",cha);
}


Measured memory_bytes: 1920
n,q = map(int, raw_input().split())
que = [map(str, raw_input().split()) for i in range(n)]
mxt = sum([int(y) for x,y in que])
t = 0
i = 0
while t < mxt:
	i %= n
	if int(que[i][1]) <= q:
		t += int(que[i][1])
		print que[i][0],t
		que.pop(i)
		n -= 1
	else:
		t += q
		que[i][1] = int(que[i][1]) - q
		i += 1

Measured memory_bytes: 14000
#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;

typedef complex<double> point; // 2D point only
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldob;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ii_i;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<iii> viii;

#define re real()
#define im imag()
#define fi first
#define se second

// OST
template <typename T>
using ordered_set = __gnu_pbds::tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// from: https://codeforces.com/blog/entry/62393
// struct custom_hash {
// 	static uint64_t splitmix64(uint64_t x) {
// 		// http://xorshift.di.unimi.it/splitmix64.c
// 		x += 0x9e3779b97f4a7c15;
// 		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
// 		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
// 		return x ^ (x >> 31);
// 	}

// 	size_t operator()(uint64_t x) const {
// 		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
// 		return splitmix64(x + FIXED_RANDOM);
// 	}
// };

const int INF = ~(1<<31);
const ll LINF = (1LL << 60);
const long double EPS = 1e-9;
const long double PI = acos(-1);

const int N = 1005;
const int NN = 1001;
const int MOD = 998244353;
const int IMAX = 1e9+7;
const ll LMAX = 1e15+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main () {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	// cout.precision(10); cout << fixed;

	int K; cin >> K; K--;
	queue<ll> q;
	for (int i = 1; i < 10; ++i)
		q.push(i);

	while (K--) {
		if (q.front()%10 != 0)
			q.push(q.front()*10+q.front()%10-1);
		q.push(q.front()*10+q.front()%10);
		if (q.front()%10 != 9)
			q.push(q.front()*10+q.front()%10+1);
		q.pop();
	}

	cout << q.front() << endl;

	return 0;
}

Measured memory_bytes: 4768
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    int h[N];
    for (int i = 0; i < N; i++) cin >> h[i];

    int dp[N];
    fill(dp, dp + N, INF);
    dp[0] = 0;

    for (int i = 0; i < N - 1; i++) {
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        if (i+2 <= N - 1) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>){
	//Hello_World()
	//X_Cubic()
	//Rectangle()
	//Watch()
	//Small_Large_or_Equal()
	//Range()
	//Sorting_Three_Numbers()
	Circle_in_the_Rectangle()
}

fun Circle_in_the_Rectangle(){
	val a = readLine()!!.split(" ").map(String::toInt)
	val w = a[0]
	val h = a[1]
	val x = a[2]
	val y = a[3]
	val r = a[4]

	when {
		x-r<0 || y-r<0 || w<x+r || h<y+r ->{
			println("No")
		}else ->{
			println("Yes")
		}
	}
}


Measured memory_bytes: 32068
#include <iostream>
using namespace std;
int A[20];
int N;
int solve(int count, int M)
{
    if(M == 0)
        return 1;
    if(count > N)
        return 0;
    else
    {
        int res = solve(count + 1, M - A[count]) || solve(count + 1, M);
        return res;
    }
}

int main()
{
    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> A[i];
    int q;
    cin >> q;
    int M;
    for(int i = 0; i < q; i++)
    {
        cin >> M;
        if(solve(0, M))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
using namespace std;
int main() {
  int K,X;
  cin>>K>>X;
  
    for(int n=K-1;n>=0;n--){
      cout<<X-n<<" ";
    }
    for(int i=1;i<K;i++){
    cout<<X+i<<" "; 
    }

return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  int ans = 0;
  if (N >= 2) {
    ans += N*(N-1)/2;
  }
  if (M >= 2) {
    ans += M*(M-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
    //static List<string> str = new List<string>();
	static void Main(string[] args)
	{
		// 入力フェーズ
		string[] input = Console.ReadLine().Split(' ');
		int A = int.Parse(input[0]);
		int B = int.Parse(input[1]);

    int K2 = A+B;
		if(K2%2 == 0)
			Console.WriteLine("" + (K2/2));
		else
		  Console.WriteLine("IMPOSSIBLE");

    }

}


Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    
    for (int i = sx; i < tx; i++) {
        cout << "R";
    }

    for (int i = sy; i < ty; i++) {
        cout << "U";
    }

    for (int i = tx; i > sx; i--) {
        cout << "L";
    }

    for (int i = ty; i > sy; i--) {
        cout << "D";
    }

    cout << "D";
    for (int i = sx; i < tx + 1; i++) {
        cout << "R";
    }

    for (int i = sy; i < ty + 1; i++) {
        cout << "U";
    }

    cout << "LU";
    for (int i = tx; i > sx - 1; i--) {
        cout << "L";
    }

    for (int i = ty; i > sy - 1; i--) {
        cout << "D";
    }
    cout << "R" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans=0;
map<int,int>mp;
int n,q;
int main(){
	cin>>n;
	while(n--){
		int x;cin>>x;mp[x]++,ans+=x;
	}
	cin>>q;
	while(q--){
		int a,b;cin>>a>>b;
		ans+=1ll*(b-a)*mp[a];
		mp[b]+=mp[a],mp[a]=0;
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 7980
#include<cstdio>
int N,ans;
int main(){
	scanf("%d",&N);
	for(int h=0,a;N--;){
		scanf("%d",&a);
		if(a>1<<h)while(1<<h<a)h++,ans++;
		else while(1<<h>a)h--;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
    char b[7][7];
    char a[7][7];
    int n,m,k;
    void copy_matrix(){
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++)
                b[i][j]=a[i][j];
        }
        return;
    }
    void color(int i,int j){
        for(int x=0;x<n;x++){
            if(i&(1<<x)){
                for(int y=0;y<m;y++)
                    b[x][y]='$';
            }
        }
        for(int x=0;x<m;x++){
            if(j&(1<<x)){
                for(int y=0;y<n;y++)
                    b[y][x]='$';
            }
        }
        return;
    }
 
    bool check(){
        int total=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(b[i][j]=='#')
                    total++;
            }
        }
        if(total==k)
            return true;
        else
            return false;
    }
 
    void solve(){
        cin>>n>>m>>k;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++)
                cin>>a[i][j];
        }
        int total=0;
        for(int i=0;i<(1<<n);i++){
            for(int j=0;j<(1<<m);j++){
                copy_matrix();
                color(i,j);
                if(check())
                    total++;
            }
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3620
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxx=1e5+6;

class point {
public:
	double x,y;
	point(double x=0,double y=0):x(x),y(y){}

	bool operator < (const point &u)const{
		if(x!=u.x) return x<u.x;
		return y<u.y;
	}   
};
point a[maxx],b[maxx];

inline double dis(point a,point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); }
inline bool cmp(point a,point b){return a.y<b.y;}
double solve(int left,int right){
	if(left+1==right) return dis(a[left],a[right]);
	double xl,xr,xm;
	int mid=(left+right)>>1;
	xl=solve(left,mid);
	xr=solve(mid,right);
	xm=min(xl,xr);
	int k=1;
	for(int i=left;i<=right;i++){
		if(fabs(a[mid].x-a[i].x)<=xm) b[k++]=a[i];
	}
	sort(b+1,b+k,cmp);
	for(int i=1;i<k;i++){
		for(int j=i+1;j<k && (b[j].y-b[i].y<xm);j++){
			xm=min(xm,dis(b[i],b[j]));
		}
	}
	return xm;
}

int main() {
	int n;
	double x,y;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lf%lf",&x,&y);
		a[i]=point(x,y);
	}
	sort(a+1,a+1+n);
	double ans=solve(1,n);
	printf("%.6f\n",ans);
	return 0;
}


Measured memory_bytes: 6344
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()

p = list(map(int, input().split()))
l = []
for i in range(-100,102):
  l.append(i)

L = []
for i in l:
  if i not in p:
    L.append(i)

l = []
for i in L:
  l.append([i, abs(x-i)])
a = min(l, key = lambda t: t[1])
print(list(a)[0])


Measured memory_bytes: 9200
// 基本テンプレート
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    vector<int> A(N);

    double sum = 0.0;
    for(int i=0; i<N; i++) cin >> A[i], sum += A[i];
    sum /= N;

    double mi = INF;
    int ans = 0;
    for(int i=0; i<N; i++) {
        double dist = abs(sum - A[i]);
        if(mi > dist) {

            ans = i;
            mi = dist;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n,d,a,i;
	cin>>d>>n;
	a=1;
	for(i=0;i<d;i++){
		a=a*100;
	}
	if(n==100&&d==0) n=a*n+1;
	else if(n==100&&d==1) n=a*n+100;
	else if(n==100&&d==2) n=a*n+10000;
	else n=a*n;
	
	cout<<n<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
/**  '' "\n" ^ -  =**/

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    cin>>str;
    if(str[0]=='S')
    {
        printf("Cloudy\n");
    }
    if(str[0]=='C')
    {
        cout<<"Rainy\n";
    }
    if(str[0]=='R')
    {
        cout<<"Sunny\n";
    }
}


Measured memory_bytes: 256
base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

allPatterns :: Integer -> Integer
allPatterns n = power 2 n - 1

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]

main = do
   [n,a,b] <- map (read :: String -> Integer) . words <$> getLine
   putStrLn $ show $ minus (allPatterns n) $ plus (binom n a) (binom n b)



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

#define endl '\n'

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(0);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

int main() { BUFF
  string s; cin >> s;
  ll ans = stol(s);
  for(int i=1; i<pow(2, s.size()-1); i++) {
    int last = 0;
    for(int j=1; j<pow(2, s.size()-1); j*=2) {
      if(!(i & j)) continue;
      int a = log2(j) + 1;
      ans += stol(s.substr(last, a-last));
      last = a;
    }
    ans += stol(s.substr(last, s.size()));
  }
  cout << ans << endl;
  return 0;
}


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


Measured memory_bytes: 3112