akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N;
  cin >> N;
  vll A(N);
  ll m = 0;
  rep(i, N) {
    ll a;
    cin >> a;
    A[i] = a;
    m = max(m, a);
  }

  ll b = m;
  ll sa_min = m / 2;
  rep(i, N) {
    if (A[i] == m) {
      continue;
    }
    ll sa = abs(A[i] - m / 2.0);
    if (sa <= sa_min) {
      b = A[i];
      sa_min = abs(A[i] - m / 2.0);
    }
  }
  cout << m << " " << b << endl;

  return 0;
}

Measured memory_bytes: 1024
b_1,b_2,b_3=map(int,input().split())
if (b_1==1):
    if (b_2==0):
        if (b_3==0):
            print("Close")
    else:
        if(b_2==1):
            if (b_3==0):
                print("Open")
elif (b_1==0):
    if (b_2==1):
        if (b_3==0):
            print("Close")
    elif (b_2==0):
        if (b_3==1):
            print("Open")
        elif (b_3==0):
            print("Close")
        else:
            print("Close")
            


Measured memory_bytes: 5596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, m;
int a[100000];
int par[100000];  //親
int rank1[100000]; //木の深さ
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        rank1[i] = 0;
    }
}
//木の根を求める
int find(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}
//併合
void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x==y) return;
    if(rank1[x]<rank1[y]){
        par[x]=y;
    }
    else{
        par[y]=x;
        if(rank1[x]==rank1[y]) rank1[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}
int size(int x) {
        return -par[find(x)];
    }
vector<pair<int, int> > s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    init(n);
    for (int i = 0; i < m; i++)
    {
        int tempx, tempy, tempz; 
        cin >> tempx>>tempy>>tempz;
        s.push_back(make_pair(tempx,tempy));
        unite(tempx-1,tempy-1);
    }
    //sort(par,par+n);
    int ans = 0;
    for(int i=0;i<n;i++){
        //cout<<par[i]<<"\n";
        if(par[i]==i)
        ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 2168
#include "stdio.h"

int main(){
	int a[3];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	for(int i=0;i<3;i++)for(int j=i+1;j<3;j++)if(a[i]>a[j]){
		int temp = a[i]; a[i] = a[j];a[j]=temp;
	}
	printf("%d",a[2] - a[0]);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> W(N),V(N);
    for(int i=0;i<N;i++){
        cin >> W[i] >> V[i];
    }
    vector<vector<ll>> dp(N+10,vector<ll>(M+10));
    for(int i=1;i<=N;i++){
        for(int w=0;w<=M;w++){
            if(w-W[i-1]>=0) {
                dp[i][w]=max(dp[i-1][w],dp[i-1][w-W[i-1]]+V[i-1]);
            }
            else {
                dp[i][w]=dp[i-1][w];
            }

            
        }
    }
    cout << dp[N][M] << endl;
}

Measured memory_bytes: 87296
#include <iostream>
using namespace std;
int main(void){
    int N;
    int i = 0;
    string s;
    cin >> N;
    while(i<N){
        cin >> s;
        if(s == "Y"){
            cout << "Four" << endl;
            break;
        }
        i++;
    }
    if(i == N){
        cout << "Three" << endl;
    }
}

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

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	final long MOD=(long)1e9+7;

	void run() {
		FastScanner sc=new FastScanner();
		int X=sc.nextInt();
		System.out.println(X>=30?"Yes":"No");
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
	
	
	class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        if (!hasNext()) throw new NoSuchElementException();
	        long n = 0;
	        boolean minus = false;
	        int b = readByte();
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        if (b < '0' || '9' < b) {
	            throw new NumberFormatException();
	        }
	        while(true){
	            if ('0' <= b && b <= '9') {
	                n *= 10;
	                n += b - '0';
	            }else if(b == -1 || !isPrintableChar(b)){
	                return minus ? -n : n;
	            }else{
	                throw new NumberFormatException();
	            }
	            b = readByte();
	        }
	    }
	    public int nextInt() {
	    	return (int)nextLong();
	    }
	}
}



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

using namespace std;

int main(void) {
    string N;
    cin >> N;
    if(N.find_first_of('7') == string::npos) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	string s;
	cin >> s;
	bool ym=true,my=true;
	if(s[0]>='2' || (s[0]=='1' && s[1]>='3') || (s[0]=='0' && s[1]=='0')){
		my=false;
	}
	if(s[2]>='2' || (s[2]=='1' && s[3]>='3') || (s[2]=='0' && s[3]=='0')){
		ym=false;
	}
	if(ym && my){
		printf("AMBIGUOUS\n");
	}else if(ym){
		printf("YYMM\n");
	}else if(my){
		printf("MMYY\n");
	}else{
		printf("NA\n");
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.awt.Point;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        int n;
        int[] S;
        int q;
        int[] T;

        boolean binarySearch(int[] arr, int v) {
            int left = 0;
            int right = arr.length;
            while (left < right) {
                int mid = (left + right) / 2;
                if (arr[mid] == v) {
                    return true;
                } else if (arr[mid] < v) {
                    left = mid + 1;
                } else {
                    right = mid;
                }
            }
            return false;
        }

        // write your code
        void solve(InputReader in, PrintWriter out) {
            n = in.nextInt();
            S = new int[n];
            for (int i = 0; i < n; i++) {
                S[i] = in.nextInt();
            }
            q = in.nextInt();
            T = new int[q];
            for (int i = 0; i < q; i++) {
                T[i] = in.nextInt();
            }

            int ans = 0;
            for (int i = 0; i < q; i++) {
                if (binarySearch(S, T[i])) {
                    ans++;
                }
            }
            out.println(ans);
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}



Measured memory_bytes: 48884
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

N += 1
H = [0] + H

inf = 10 ** 15
DP = [[inf] * N for _ in range(N)]
DP[0][0] = 0
for i in range(1, N):
  DP[i][1] = H[i]
  for j in range(2, i + 1): 
    for k in range(1, i):
      DP[i][j] = min(DP[i][j], DP[k][j - 1] + max(0, H[i] - H[k]))

ans = inf
for i in range(N):
    ans = min(ans, DP[i][N - K - 1])

print(ans)

Measured memory_bytes: 42860
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

ll n, m, q;
ll ans = 0;
vector<int> a(q), b(q), c(q), d(q);
void solve(vector<int> &arr)
{
    if ((int)arr.size() == n)
    {
        ll curr = 0;
        for (int i = 0; i < q; i++)
        {
            curr += arr[b[i] - 1] - arr[a[i] - 1] == c[i] ? d[i] : 0;
        }
        ans = max(ans, curr);
    }
    else
    {
        int s = arr.size() ? *arr.rbegin() : 1;

        for (int i = s; i <= m; i++)
        {
            arr.push_back(i);
            solve(arr);
            arr.pop_back();
        }
    }
}

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

    cin >> n >> m >> q;
    a.assign(q, 0);
    b.assign(q, 0);
    c.assign(q, 0);
    d.assign(q, 0);

    for (int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<int> arr;
    solve(arr);

    cout << ans << endl;
}

Measured memory_bytes: 3664
def xor_operate(a_list):
    result = 0
    for a in a_list:
        result ^= int(a)
    return result



if __name__ == "__main__":
    N = input()
    a_list = input()

    a_list = a_list.split(" ")

    bit_value = xor_operate(a_list)

    i_list = []
    for a in a_list:
        i_list.append(str(bit_value ^ int(a)))
    print(" ".join(i_list))
    


        



Measured memory_bytes: 41704
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int a,b;
  cin >> a >> b;

  a--; b--;

  cout << (b+a-1)/a << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define fi first 
#define se second 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);
#define mem(a,v) memset(a,v,sizeof(a))
const ll INF=1e18;
const int mod=1e9+7;
const int iinf=1e9+10;
const int xd[4]={1,0,-1,0},yd[4]={0,1,0,-1};
int main()
{
    faster
    string s;
    cin>>s;
    if(s[sz(s)-1]=='s')
        s+="es";
    else
        s+='s';
    cout<<s;
}

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

using namespace std;

int main(void){
  int c[3];
  cin >> c[0] >> c[1] >> c[2];
  sort(c,c+3);
  int ans=3;
  if(c[0]==c[1]){
    ans--;
  }
  if(c[1]==c[2]){
    ans--;
  }
  cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string S; cin >> S;
    int l = 0, r = S.length()-1;
    int ans = 0;
    while(l < r){
        if(S[l] != S[r]) ans++;
        l++; r--;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int C = 0;
  
  if (S.size() + 1 == T.size()) {
    for (int i = 0; i < S.size(); i++) {
      if (T.at(i) == S.at(i)) {
      C = C + 1;
      }
    }
    if (C == S.size()) {
      cout << "Yes";
    }
    else {
      cout << "No";
    }
  }
  else {
    cout << "No";
  }

}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

string s;
ll cnt[100010][13];

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

    cin >> s;
    int n=s.length();

    ll now=1;
    cnt[n][0]=1;
    for (int i=n-1;i>=0;i--){
        if (s[i]=='?'){
            for (ll j=0;j<10;j++){
                ll tm=j*now%13;
               
                for (ll k=0;k<13;k++){
                    cnt[i][(k+tm)%13]+=cnt[i+1][k];
                    cnt[i][(k+tm)%13]%=MOD;
                }
            }
        } else{
            ll tm=(ll)(s[i]-'0');
            tm=tm*now%13;
            for (ll k=0;k<13;k++){
                cnt[i][(k+tm)%13]+=cnt[i+1][k];
                cnt[i][(k+tm)%13]%=MOD;
            }
        }

        now=now*10%13;
    }

    cout << cnt[0][5] << el;

    return 0;
}

Measured memory_bytes: 10604
#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
int b[110000];
int c[110000];
int R[110000];
int L[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	long long ret=1;
	for(int i=0;i<a;i++)L[i]=1;
	for(int i=0;i<a;i++)R[i]=mod;
	for(int i=0;i<a;i++){
		if(i==0||b[i]>b[i-1]){
			L[i]=R[i]=b[i];
		}else{
			R[i]=b[i];
		}
	}
	for(int i=a-1;i>=0;i--){
		if(i==a-1||c[i]>c[i+1]){
			L[i]=max(L[i],c[i]);
			R[i]=min(R[i],c[i]);
		}else{
			R[i]=min(R[i],c[i]);
		}
	}
//	for(int i=0;i<a;i++)printf("%d %d\n",L[i],R[i]);
	for(int i=0;i<a;i++){
		if(L[i]>R[i])ret=0;
		else ret=ret*(R[i]-L[i]+1)%mod;
	}printf("%lld\n",ret);
}

Measured memory_bytes: 1792
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;*/
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
typedef long long ll;
typedef pair<ll, ll> Pa;

/*
template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

typedef modint<MOD> m;
m func[400001];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
m comb(m n, m r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}*/

ll dp[101][100000];
int w[100], v[100];
int main() {
	cin >> N >> W;
	rep(i, N) {
		cin >> w[i] >> v[i];
	}
	rep(i, W+1) {
		dp[0][i] = 0;
	}
	ll mv = 0;
	rep(i, N) {
		rep(j, W + 1) {
			dp[i + 1][j] = dp[i][j];
		}
		rep(j, W+1) {
			if(w[i] + j <= W) dp[i+1][w[i] + j] = max(dp[i+1][w[i] + j], dp[i][j] + v[i]);
		}
	}
	rep(i, W + 1) {
		mv = max(mv, dp[N][i]);
	}
	cout << mv;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
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; }

struct Edge {
    int to;
    int cost;
};
vector<Edge> G[100005];
vector<int> color(100005);

void dfs(int v, int c) {
    color[v] = c; // 頂点vをcで塗る
    for(int i = 0; i < (int)G[v].size(); i++){
        Edge e = G[v].at(i);
        if(color[e.to] != 0) continue;
        if(e.cost % 2 == 0) { // 距離が偶数だったら同じ色で塗る
            dfs(e.to, c);
        }
        else {
            dfs(e.to, -1*c);
        }
    }
    return;
}

int main(){
    int N, s, t, w;
    cin >> N;
    rep(i, N-1){
        cin >> s >> t >> w;
        s--; t--;
        Edge edge = {t, w};
        G[s].push_back(edge);
        edge = {s, w};
        G[t].push_back(edge);
    }
    rep(i, N){
        if(color[i] == 0){
            dfs(i, 1);
        }
    }
    rep(i, N){
        if(color[i] == -1) cout << 0 << endl;
        else cout << 1 << endl;
    }
}

Measured memory_bytes: 11016
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>

#define INF 10e6
using namespace std;

// 状態を表すクラスpairの場合、typedefしておくと便利
typedef pair<int, int> P;

// 最短経路を求めてそれ以外の道を黒く塗りつぶせば良い

int h, w;
vector<vector<char>> field;
int gx, gy;
int sx, sy;

vector<vector<int>> d;

// 4方向の移動ベクトル
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int bfs() {
	queue<P> que;
	// スタート地点をキューに入れ、その点の距離を0とする
	que.push(P(sx, sy));
	d[sx][sy] = 0;

	// キューが空になるまでループ
	while (que.size()) {
		// キューの先頭を取り出す
		P p = que.front(); que.pop();
		// 取り出した状態がゴールなら探索をやめる
		if (p.first == gx && p.second == gy) break;
		// 移動4方向をループ
		for (int i = 0; i < 4; i++) {
			// 移動した後の点を(nx, ny)とする
			int nx = p.first + dx[i], ny = p.second + dy[i];

			// 移動が可能かの判定と既に訪れたことがあるかの判定
			if (field[nx][ny] != '#' && d[nx][ny] == INF) {
				// 移動できるならキューに入れ、その点の距離をpからの距離+1で確定する
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[gx][gy];
}

int main() {
	cin >> h >> w;

	field = vector<vector<char>>(h+2, vector<char>(w+2,'#'));
	d = vector<vector<int>>(h + 2, vector<int>(w + 2,INF));

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> field[i][j];
		}
	}

	int cnt = 0;
	sx = 1;
	sy = 1;
	gx = h;
	gy = w;

	cnt = bfs();
	if (cnt == INF) cout << -1 << endl;
	else {
		int res = 0;
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if (field[i][j] == '.')
					res++;
			}
		}
		res -= cnt + 1;
		cout << res << endl;
	}
}

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

using namespace std;

int main(){
    char c;
    string s="aeiou";
    cin >> c;
    bool ans=false;
    for(int i=0;i<=4;i++){
        if(s[i]==c){
            ans=true;
        }
    }
    if(ans){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

fn power_set(n: usize) -> Vec<Vec<usize>> {
    return (1..(1 << n))
        .map(|i| (0..n).filter(|j| i & (1 << j) > 0).collect())
        .collect();
}

#[fastout]
fn main() {
    input! {
        n: usize, m: usize, x: usize,
        mut ca: [(usize, [usize; m]); n]
    }
    let mut ans:isize = -1;

    let power_set = power_set(n);
    let mut ca_power_set = Vec::new();
    for i in 0..power_set.len() {
        let mut sum = 0;
        for j in 0..power_set[i].len() {
            sum += ca[power_set[i][j]].0;
        }
        ca_power_set.push((sum, power_set[i].clone()));
    }
    ca_power_set.sort();

    for i in 0..ca_power_set.len() {
        let mut dp = vec![0; m];
        for j in 0..ca_power_set[i].1.len() {
            for l in 0..m {
                dp[l] += ca[ca_power_set[i].1[j]].1[l];
            }
        }
        if dp.iter().filter(|&&d| d < x).count() == 0 {
            ans = ca_power_set[i].0 as isize;
            break;
        }
    }

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


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

int main(){
	int n ; 
	cin >> n ;
	vector<int> v(n) ; 
	for(int &x : v){
		cin >> x ; 
	}
	sort(v.rbegin(),v.rend());
	int sum = 0 ; 
	for(int i=1;i<n;i++){
		sum += v[i] ; 
	}
	if ( v[0] < sum ){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0 ; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
int main(){
    ll h,w,s,t;cin>>h>>w>>s>>t;
    if(h%2==0||w%2==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(s%2||t%2){
        if(s%2&&t%2){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"Yes"<<endl;
    }
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  int ans = 0;
  vector<int> v(n,0),c(n,0);
  for(auto &i:v) cin >> i;
  for(auto &i:c) cin >> i;
  for(int i=0;i<n;i++){
    if(v[i]-c[i]>=0) ans+=(v[i]-c[i]);
  }
  cout << ans << endl;
}


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

using namespace std;

int sticks[10]={0,2,5,5,4,5,6,3,7,6};

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int a[m],dp[n+3];
    for(int i=0;i<m;i++)
        scanf("%d",a+i);
    sort(a,a+m,greater<int>());
    fill(dp,dp+n+3,-1);
    dp[0]=0;
    for(int i=0;i<m;i++)
    {
        for(int j=sticks[a[i]];j<=n;j++)
        if(dp[j-sticks[a[i]]]!=-1)
        {
            dp[j]=max(dp[j],dp[j-sticks[a[i]]]+1);
        }
    }

    while(n){

        for(int i=0;i<m;i++){
            if(n-sticks[a[i]]>=0&&dp[n]==dp[n-sticks[a[i]]]+1){
                printf("%d",a[i]);
                n-=sticks[a[i]];
                break;
            }
        }

    }

    return 0;
}


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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef stack<int> si;
typedef deque<int> dqi;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define PF push_front
#define PB push_back
#define FST first
#define SEC second
#define sz(obj) ((int)(obj).size())
#define ALL(v) (v).begin(), (v).end()

const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int gcd(int a, int b){ int c; while (a != 0){ c = a; a = b % a; b = c; } return b; }

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

  int n, m;
  cin >> n >> m;
  int box[n];
  bool flg[n];
  int x, y, ans = 0;

  memset(flg, false, sizeof(flg));
  flg[0] = true;
  REP(i, n) box[i] = 1;

  REP(i, m){
    cin >> x >> y;
    box[y - 1]++;
    box[x - 1]--;
    if (flg[x - 1]) flg[y - 1] = true;
    if (box[x - 1] == 0) flg[x - 1] = false;
  }
  REP(i, n){
    if (flg[i] && box[i] != 0) ans++;
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 768
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;


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

    int N, M, Q;
    cin >> N >> M >> Q;
    vector<pair<int, int>> v;
    vector<pair<int, int>> seg(M+Q+1);

    int idx = 0;
    REP(i, M) {
        int l, r;
        cin >> l >> r;
        v.push_back({r, idx});
        seg[idx] = {l, r};
        idx++;
    }
    REP(i, Q) {
        int l, r;
        cin >> l >> r;
        v.push_back({r, idx});
        seg[idx] = {l, r};
        idx++;
    }
    sort(v.begin(), v.end());

    vector<int> n(505);
    vector<int> q(Q);
    REP(i, v.size()) {
        auto kv = v[i];
        if (kv.second < M) {
            auto tseg = seg[kv.second];
            n[tseg.first]++;
        } else {
            auto tseg = seg[kv.second];

            int ans = 0;
            FOR(j, tseg.first, tseg.second) {
                ans += n[j];
            }
            q[kv.second - M] = ans;
        }
    }

    REP(i, q.size()) {
        cout << q[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 15340
#include<stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int a[n], b[n], c[n-1];
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    for(int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }
    for(int i = 0; i < n-1; i++) {
        scanf("%d", &c[i]);
    }

    int manzoku = 0;
    int tmp = -1;

    for(int i = 0; i < n; i++) {
        manzoku += b[a[i] - 1];
        if(tmp + 1 == a[i]) {
            manzoku += c[tmp - 1];
        }
        tmp = a[i];
    }

    printf("%d\n", manzoku);
    return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		player player1[] = new player[8];
		player player2[] = new player[8];
		player player3[] = new player[8];
        for(int i=0; i<8; i++)player1[i] = new player(sc.nextInt() , sc.nextDouble());
        for(int i=0; i<8; i++)player2[i] = new player(sc.nextInt() , sc.nextDouble());
        for(int i=0; i<8; i++)player3[i] = new player(sc.nextInt() , sc.nextDouble());
        
        Arrays.sort(player1);
        System.out.println(player1[0] + "\n" + player1[1]);
        player1[0].record = 50;
        player1[1].record = 50;
         
        Arrays.sort(player2);
        System.out.println(player2[0] + "\n" + player2[1]);
        player2[0].record = 50;
        player2[1].record = 50;
         
        Arrays.sort(player3);
        System.out.println(player3[0] + "\n" + player3[1]);
        player3[0].record = 50;
        player3[1].record = 50;
        
        Arrays.sort(player1);
        Arrays.sort(player2);
        Arrays.sort(player3);
        player player4[]= new player[6];
        player4[0] = new player(player1[0].playerNumber,player1[0].record);
        player4[1] = new player(player1[1].playerNumber,player1[1].record);
        player4[2] = new player(player2[0].playerNumber,player2[0].record);
        player4[3] = new player(player2[1].playerNumber,player2[1].record);
        player4[4] = new player(player3[0].playerNumber,player3[0].record);
        player4[5] = new player(player3[1].playerNumber,player3[1].record);
        Arrays.sort(player4);
        System.out.println(player4[0] + "\n" + player4[1]);
    }
}
	class player implements Comparable<player>{
		int playerNumber;
	    double record;
	    player(int playerNumber, double record){
	        this.playerNumber = playerNumber;
	        this.record = record;
	    }
	    @Override
	    public String toString(){
	        return  playerNumber + " " + record;
	    }
	    @Override
	    public int compareTo(player o) {
	    	return new Double(record).compareTo(o.record);
	    }
}

Measured memory_bytes: 27848
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int n;
void f(char m, string s) {
	if (s.size() == n) {
		cout << s << endl; return;
	}
	for (char c = 'a'; c <= m + 1; c++) {
		string s1 = s + c;
		f(max(m, c) , s1);
	}
}
signed main() {
	cin >> n; f('a', "a");
}

Measured memory_bytes: 1536
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

int N, M;
int uf[1<<20];
int size[1<<20];
long long ans[1<<20];

int root(int i) {
	while (i != uf[i]) {
		i = uf[i];
	}
	return i;
}

bool same_component(int i, int j) {
	if(root(i) == root(j)) return true;
	return false;
}

long long add_component(int i, int j) {
	if(same_component(i, j)) return 0;
	int ri = root(i);
	int rj = root(j);

  long long si = size[ri], sj = size[rj];
  long long ans = -si*sj;

	if(size[ri] <= size[rj]) {
		uf[ri] = rj;
		size[rj] += size[ri];
	} else {
		uf[rj] = ri;
    size[ri] += size[rj];
	}

  return ans;
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  vector<pair<int, int> > edges;
  cin >> N >> M;
  for(int i = 0;i < M;i++) {
    int u, v;
    cin >> u >> v;
    edges.push_back({u, v});
  }

  for(int i = 1;i <= N;i++) {
    uf[i] = i;
    size[i] = 1;
  }

  long long answer = (1LL*N)*(N-1)/2;
  for(int i = M-1;i >= 0;i--) {
    ans[i] = answer;
    answer += add_component(edges[i].first, edges[i].second);
  }

  for(int i = 0;i < M;i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 7156
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int N=305,P=1e9+7;

int n,m,k,a[N][N],cnt[N],p[N],del[N];

bool chk(int mid){
	mem(del,0);
	mem(cnt,0);
	rep(i,1,n){
		p[i]=1;
		++cnt[a[i][p[i]]];
	}
	while(true){
		int cur=0;
		rep(i,1,m)if(!del[i]){
			if(cnt[i]<=mid)continue;
			cur=i;
			del[i]=1;
			break;
		}
		if(!cur)break;
		rep(i,1,n)if(a[i][p[i]]==cur){
			--cnt[a[i][p[i]]];
			for(++p[i];del[a[i][p[i]]];++p[i]);
			if(p[i]>m)return false;	
			++cnt[a[i][p[i]]];
		}
	}
	return true;
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	scanf("%d%d",&n,&m); 
	rep(i,1,n)rep(j,1,m)scanf("%d",a[i]+j);
	int l=0,r=n;
	while(r-l>1){
		int mid=(l+r)>>1;
		if(chk(mid))r=mid;
		else l=mid;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N, D;
  cin >> N >> D;
  cout << (N-1) / (D*2+1) + 1 << rt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s;
    int a,b,c;
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>t>>b>>c;
        if(t=="replace"){
            cin>>t;
            for(int j=b;j<=c;j++) s[j]=t[j-b];
        }
        else if(t=="reverse"){
            string ss=s;
            for(int j=b;j<=c;j++) s[j]=ss[b+c-j];
        }
        else cout<<s.substr(b,c-b+1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3192
def binary_search(arr, num):
  left = 0
  right = len(arr)-1
  while right-left > 0:
    mid = (left+right) // 2
    if arr[mid] > num:
      right = mid
    else:
      left = mid + 1
  if arr[left] > num:
    return left
  else:
    return len(arr)

def main():
  n, m, k = map(int , input().split())
  a_books = list(map(int , input().split()))
  b_books = list(map(int , input().split()))
  a_cum_sum = [0] * (n+1)
  b_cum_sum = [0] * (m+1)

  for i in range(n):
    a_cum_sum[i+1] = a_cum_sum[i] + a_books[i]
  for i in range(m):
    b_cum_sum[i+1] = b_cum_sum[i] + b_books[i]
  ans = 0
  for i in range(n+1):
    if a_cum_sum[i] > k:
      break
    rest = k - a_cum_sum[i]
    index = binary_search(b_cum_sum, rest)
    ans = max(ans, i+index-1)
  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 47364
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int n , d;
    cin >> n >> d;
    double p[n][d];
    for(int i=0; i<n; i++){
        for(int j = 0; j<d; j++){
            cin >> p[i][j];
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            double distance = 0;
            for(int k=0; k<d; k++){
                distance += pow(p[i][k]-p[j][k],2);
            }
            distance = sqrt(distance);
            if(distance == floor(distance)) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

/* 判定式を指定できるめぐる式二分探索 */
/* input: arr:行列、callback:判定方法の関数ポインタ、 userQuery:判定に使用するための引数(省略可)*/
/* output: 条件を満たす要素の最小値(全て満たさなければ要素サイズを返す) */
/* 制約事項: 行列のある要素に対して判定方法callbackを満たすとき、それより大きな要素も判定方法を満たす必要がある。 */
template<class X> int binarySearch_latest(vector<X> &arr, bool (*callback)(X, int), X userQuery = 0) {
    int ng = -1;
    int ok = (int)arr.size();
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if (callback(arr[mid], userQuery)){ ok = mid; } else { ng = mid; }
    }
    return ok;
}

/* 判定方法1 */
/* input: arrValue:行列の要素、user:任意に指定した引数*/
/* 指定した値userがarrValueより小さいとき真を返す */
template<class X> bool judge1(X arrValue, int user){
    return (arrValue > (X)user);
}


int main()
{
    string s,t;
    cin >> s;
    cin >> t;
    vector<vector<int>> alphamap(30);

    rep(i, s.size()){ 
        int a = s[i] - 'a';
        alphamap[a].push_back(i);
    }   

    ll ansloop = 0;
    int cnt = -1;
    rep(i, t.size()){
        //t[i]文字目を調査
        int targalpha = t[i] - 'a';
        if (alphamap[targalpha].size() == 0) {
            cout << "-1" << endl;
            return 0;
        }
        int add = binarySearch_latest(alphamap[targalpha], judge1, cnt);        
        if (add == alphamap[targalpha].size()){
            cnt = alphamap[targalpha][0];
            ansloop++;
        } else {
            cnt = alphamap[targalpha][add];
        }
    }
    ll ans = ((ll)ansloop * (ll)s.size()) + (ll)cnt + 1;
    cout << ans << endl; 
}



Measured memory_bytes: 1216
// GYM problem J ArabellaCPC 2019
				
					#include<bits/stdc++.h>
                    #include <set>
					#include <ext/pb_ds/assoc_container.hpp> 
					#include <ext/pb_ds/tree_policy.hpp> 
					using namespace __gnu_pbds; 
					#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
					using namespace std;
                    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
                    #define pb push_back
                    #define ff first
                    #define ss second
                    #define sz size()
                    #define mp make_pair
                    #define int long long int
                    #define double long double
                    #define bp __builtin_popcountll
                    #define FOR(i,a,b) for(int i=a;i<b;i++)
                    #define ROR(i,a,b) for(int i=a;i>=b;i--)
                    const int M=1e9+7;
                    const int N=1e6+5;
                    const int inf=1e18;
                    string s;
                    int n;
                    int dp[N][2];
                    int solve(int idx,int vaddi)
                    {
                    	if(idx==0)
                    	{
                    		if(vaddi==1)
                    		return 1;
                    		return 0;
                    	}
                    	int &ans=dp[idx][vaddi];
                    	if(ans!=-1)
                    	return ans;
                    	ans=0;
                    	char pp;
                    	if(vaddi==1)
                    	{
                    		pp=s[idx]+1;
                    		if(s[idx]+1>'9')
                    		ans=solve(idx-1,1);
                    		else
                    		ans=min((pp-'0')+solve(idx-1,0),(10 +'0'-pp)+solve(idx-1,1));
                    		
                    	}
						else
						ans=min((s[idx]-'0')+solve(idx-1,0),(10 +'0'-s[idx])+solve(idx-1,1));
                    	return ans;
                    }
                    int32_t main()
                    {
                		FAST
                		cin>>s;
                		s='0'+s;
                		n=s.size();
                		// cout<<s;
                		memset(dp,-1,sizeof(dp));
                		cout<<(solve(n,0)+48);
                    }

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

int main(){
    char a, b;
    cin >> a >> b;
    if(a == 'H') cout << b << endl;
    else{
        if(b == 'H') cout << 'D' << endl;
        else cout << 'H' << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

ll md = (ll)1e9 + 7;

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N, 0);
	vector<ll> sm(N, 0);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	for (int i = N - 2; i >= 0; --i) {
		sm[i] = (sm[i + 1] + A[i + 1]) % md;
	}

	ll ans = 0;
	for (int i = 0; i < N; ++i) {
		ans += (A[i] * sm[i]) % md;
		ans = ans % md;
}

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


Measured memory_bytes: 6348
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		char b = reader.next().charAt(0);
		String ans = "";
		if (b == 'A') {
			ans = "T";
		}
		if (b == 'T') {
			ans = "A";
		}
		if (b == 'C') {
			ans = "G";
		}
		if (b == 'G') {
			ans = "C";
		}
		reader.close();
		System.out.println(ans);
	}
}





Measured memory_bytes: 21076
// Problem : C - Rally
// Contest : AtCoder - AtCoder Beginner Contest 156
// URL : https://atcoder.jp/contests/abc156/tasks/abc156_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

int sqr(int x){return x*x;}

void solve(){
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int best = inf;
    for(int k=1;k<=100;k++){
        int cur = 0;
        for(int i=0;i<n;i++) cur += sqr(a[i]-k);
        best = min(cur,best);
    }
    cout<<best<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3572