akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

struct Edge {
    int to;
    ll s;
};

ll solve() {
    ll N, M, u, v, s;
    cin >> N >> M;
    vector<vector<Edge>> G(N);
    for ( int i = 0; i < M; i++ ) {
        cin >> u >> v >> s;
        u--, v--;
        G[u].push_back(Edge{v,s});
        G[v].push_back(Edge{u,s});
    }

    bool odd = false;
    int v_odd = -1;
    ll a_odd = -1;
    for ( int z = 0; z < 2; z++ ) {
        bool ng = false, cnt = false;
        odd = false;
        vector<int> cs(N,-1);
        vector<ll> as(N);
        function<void(int,int,ll,int)> dfs = [&](int v, int p, ll a, int c) {
            if ( cs[v] != -1 ) {
                if ( as[v] != a ) {
                    if ( cs[v] == c ) {
                        ng = true;
                    } else {
                        if ( z == 0 ) {
                            if ( (as[v] + a) % 2 == 0 ) {
                                v_odd = v;
                                a_odd = (as[v]+a)/2;
                                cnt = true;
                            } else {
                                ng = true;
                            }
                        } else {
                            ng = true;
                        }
                    }
                }
                if ( cs[v] != c ) odd = true;
                return;
            }
            cs[v] = c;
            as[v] = a;
            for ( auto e : G[v] ) {
                if ( e.to == p ) continue;
                dfs(e.to, v, e.s-a, 1-c);
                if ( ng ) return;
            }
        };

        int st = 0;
        ll a0 = 1;
        if ( v_odd != -1 ) {
            st = v_odd;
            a0 = a_odd;
        }
        dfs(st, -1, a0, 0);
        if ( ng ) return 0;
        if ( cnt ) continue;

        const ll INF = 1LL<<60;
        vector<ll> m(2,INF);
        for ( int i = 0; i < N; i++ ) {
            int c = cs[i];
            m[c] = min(m[c], as[i]);
        }
        ll ans = m[0] + m[1] - 1;
        if ( ans < 0 ) ans = 0;
        if ( odd && ans > 0 ) ans = 1;
        return ans;
    }
    return 0;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 19968
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		int count = 0;
		for (int i = 1;; ++i) {
			for (int j = 1; j <= i; ++j) {
				if (i % j == 0) {
					count++;
				}
			}
			if (count == N) {
				System.out.println(i);
				break;
			}
			count = 0;
		}
		sc.close();
	}
}



Measured memory_bytes: 26324
#include <iostream>
#include <math.h>

using namespace std;


int n;

bool isprime(int m){
  double limit = sqrt(m);
  if(m == 1){
    return false;
  }
  for(int i = 2; i <= limit ; i++){
    if(m % i == 0){
      return false;
    }
  }
  return true;
}


//int main(int argc, char *argv[]){
int main(){
  cin >> n;
  for(int i = 11; i <= 55555; i+=10){
    if(isprime(i)){
      if(i == 11){
        cout << i;
      }else{
        cout << " " << i;
      }
      n--;
    }
    if(!n){
      break;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    int flag = 0;
    cin >> N;

    for(int i = 1; i < 10; i++)
    {
        if(N % i == 0)
        {
            if((N / i) < 10)
            {
                flag = 1;
                break;
            }
        }
    }

    if(flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef complex<double> P;
typedef complex<double> Vec;
typedef pair<int, int> pii;
typedef pair<int, pii> p;
 
#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
const ll MOD = 1000000007ll;
 
ll n;
ll a[112345], b[112345];
ll cnt[112345];
 
int main() {
	cin >> n;
	REP(i, n) scanf("%lld", a + i);
	
	ll sum = 0;
	REP(i, n) sum += a[i];
	
	ll tmp = (1ll + n) * n / 2;
	if (sum % tmp != 0) puts("NO");
	else {
		ll cnt = sum / tmp;
		
		int ans = 0;
		REP(i, n) {
			ll diff = a[(i + 1) % n] - a[i] - cnt;
			if (diff < 0 && -diff % n == 0) ans += -diff / n;
		}
		puts(ans == cnt ? "YES" : "NO");
		
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N=101;
const LL p=1e9+7;
const LL inf=0x3f3f3f3f;
LL n,h[N];
inline LL pw(LL x,LL y){
	LL ans=1;
	while(y){
		if(y&1)ans=ans*x%p;
		x=x*x%p; y>>=1;
	}
	return ans;
}
#define pii pair<LL,LL>
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
inline pii solve(LL l,LL r,LL H){
	LL mn=inf;
	for(LL i=l; i<=r; ++i)mn=min(mn,h[i]-H);
	bool flag=0; for(LL i=l; i<=r; ++i)if(h[i]>mn+H)flag=1;
	if(!flag)return mp(pw(2,mn-1),(pw(2,r-l+1)-2+p)%p);
	LL ans0=1,ans1=1,x=r-l+1,y=0;
	for(LL i=l,pre=0; i<=r; ++i){
		if(!pre&&h[i]>mn+H)pre=i;
		if(pre&&h[i]==mn+H){
			pii P=solve(pre,i-1,mn+H);
			ans0=2*ans0%p*P.fi%p; ans1=ans1*(P.se+4*P.fi%p)%p;
			++y; x-=i-pre; pre=0;
		}else if(pre&&i==r){
			pii P=solve(pre,r,mn+H);
			ans0=2*ans0%p*P.fi%p; ans1=ans1*(P.se+4*P.fi%p)%p;
			++y; x-=r-pre+1; pre=0;
		}
	}
	ans1=(ans1-ans0+p)%p;
	ans1=ans1*pw(2,x)%p;
	ans1=(ans1+(pw(2,x)%p-2+p)%p*ans0%p)%p;
	ans0=ans0*pw(2,mn-1)%p;
	return mp(ans0,ans1);
}
int main(){
	scanf("%lld",&n);
	for(LL i=1; i<=n; ++i)scanf("%lld",&h[i]);
	pii ans=solve(1,n,0);
	printf("%lld",(2*ans.fi+ans.se)%p);
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

ll result[200005] = {0};
void fact(ll n) {
   if (n >= 0) {
      result[0] = 1;
      for (ll i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
   }
}

void solution(){
  ll a, b, n;
  cin >> a >> b >> n;

  cout << a*min(n, b-1)/b << endl;
}     



Measured memory_bytes: 3164
#include <iostream>

using namespace std;

int main()
{
    char s[3];
    char t[3];
    cin >> s[0];
    cin >> s[1];
    cin >> s[2];
    cin >> t[0];
    cin >> t[1];
    cin >> t[2];

    int c = 0;
    for (size_t i = 0; i < 3; i++)
    {
        if (s[i] == t[i])
        {
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

int main() {
  int n;
  ll c;
  cin >> n >> c;
  mint k = c;
  vl A(n);
  rep(i, n) cin >> A[i];

  mint ans = 0;
  rep(i, n) {
    mint r = 0;
    srep(j, i, n) {
      if (A[i] > A[j]) r+=1;
    }

    mint all = 0;
    rep(j, n) {
      if (A[i] > A[j]) all+=1;
    }
    ans += r * k;
    ans += all*(k - 1) * k / 2;
  }
  print(ans.x);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[200005],minn,maxx;
	cin>>n;
	for (int i=0; i<n; i++)
	    cin>>a[i];
    maxx=a[1]-a[0];
    minn=a[0];
    for (int i=1; i<n; i++){
    	maxx=max(maxx,a[i]-minn);
    	minn=min(minn,a[i]);
	}
	cout<<maxx<<endl;
    return 0;
} 


Measured memory_bytes: 3840
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

cntA = Counter(A)

ans = sum(A)

for i in range(Q):
    B, C = map(int, input().split())

    ans += cntA[B]*(C - B)
    cntA[C] += cntA[B]
    cntA[B] = 0
    
    print(ans)

Measured memory_bytes: 24016
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n = I()
A = LI()
if len(A) == len(set(A)):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 117456
#include <bits/stdc++.h>
#define ll long long
#define se second
#define vl vector<ll>
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(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 SORT(v) sort((v).begin(), (v).end(),compare_by_b)
#define RSORT(v) sort((v).rbegin(), (v).rend())
using namespace std;

vector<pair<string,ll>> pairs;
vector<pair<string,ll>> pairs2;
ll n;
bool compare_by_b(pair<string,ll> a, pair<string,ll> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return b.second < a.second;
    }
}

int main(){
    cin>>n;
    rep(i,0,n){
        string s;ll point;
        cin>>s>>point;
        pairs.pb(mp(s,point));
        pairs2.pb(mp(s,point));
    }
    SORT(pairs);

    for(auto& i: pairs){
        for(ll j=0;j<n;j++){
            if(i.first==pairs2.at(j).first&&i.second==pairs2.at(j).second){
                cout<<j+1<<endl;
            }
        }
    }
};


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
	string s; cin >> s;
	vector<string> word = {"dream", "dreamer", "erase", "eraser"};
	
	while(s.size()){
	    int n = s.size();
	    bool flag = false;
	    
	    rep(i, 4){
	        int w = word[i].size();
	        if(w > n) continue;
	        if(s.substr(n-w, w) == word[i]){
	            s = s.substr(0, n-w);
	            flag = true;
	            break;
	        }
	    }    
	    
	    if(!flag){
	        cout << "NO" << endl;
	        return;
	    }
	    // cout << s << endl;
	}
	cout << "YES" << endl;

	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3800
def main():
    n, k, q = map(int, input().split(' '))
    a_s = [0] * n

    for _ in range(q):
        index = int(input()) - 1
        a_s[index] += 1
    
    for a in a_s:
        if (k-q+a) > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 4680
//#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
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; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x; cin >> x;
  cout << 1-x << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define print printf("==================\n")
#define ll long long
#define pi acos(-1.0)
#define eps 1e-16
#define max3(a,b,c) max(a,max(b,c))
const ll INF = 1 << 30;
#define mod 1000000007
typedef pair<double, double  > payar;
typedef struct
{
    ll  x, y;
} point;
priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending
vector< pair<double,payar  > > vpp;
vector < payar >  vp;
double  ara[3000];
double  dp[3000][3000];
int n, m ;
double cal(int i, int cnt,double pro )
{



    if(n+1==i)
    {
        if( cnt> ( n-cnt) )
        {
            return 1.0;
        }
        else
        {
            return 0.0;
        }
    }
    double &ret = dp[i][cnt];
    if(ret!=-1.0)
    {
       return ret;
    }
    ret = ara[i]* cal(i+1,cnt+1,0) + (1.0-ara[i])*cal(i+1,cnt,0 );///head taken
    return ret;
}
int main()
{


    // int n ;
    for(int i = 0 ; i<3000; i++)
    {
        for(int j = 0 ; j<3000; j++)
        {
            dp[i][j]=-1.0;
        }
    }
    cin>>n;
    for(int i  = 1 ; i<=n ; i++)
    {
        cin>>ara[i];
    }
    cout<<setprecision(15);
    cout<<cal(1,0,1.0);
    return  0 ;
}


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

int main() {
  string S;
  cin >> S;
  int x = 0;
  for (int i = 0; i < 3; i++){
    if (S.at(i) == 'o'){
      x++;
    }
  }
  cout << 700 + (x * 100) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#define in(n, m) for (int i=n; i<m;i++)
#define inj(n, m)for (int j=n; j<m;j++)
#define ink(n, m)for (ll k=n; k<m;k++)
using namespace std;
using ll=long long;
using P =pair<ll, ll>;
const ll INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define N 100000

int main() {
	int n, M;
	cin >> n >> M;
	int H[N],ma[N];

	in(1, n+1) {
		cin >> H[i];
		ma[i] = 0;
	}
	in(0, M) {
		int a, b;
		cin >> a >> b;
		ma[a] = max(ma[a], H[b]);
		ma[b] = max(ma[b], H[a]);
	}

	int ans = 0;
	in(1, n+1 ) {
		ans += H[i] > ma[i];
	}

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


Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e2 + 5;
char mp[MAX_N][MAX_N];
int main() {
    int ans = 0, n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", mp[i]);
    }
    for (int l = 0; l < n; l++) {
        bool flag = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (mp[i][j] != mp[(j + n - l) % n][(i + l) % n]) flag = false;
                if (!flag) break;
            }
            if (!flag) break;
        }
        if (flag) ans += n;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)


int main(void){
	int n1, n2; cin >> n1 >> n2;
	vector<int> a(n1), b(n2);
	rep(i, n1) cin >> a[i];
	rep(i, n2) cin >> b[i];

	int ans = 0;
	for (int i = 0; i < n2; ++i){//b?????£?¶???¨??????top??????????????\????????????????±???????
		int tmp = 0, next = 0;
		bool flag = false;
		for (int j = i; j < n2; ++j){
			for (int k = next; k < n1; ++k){//a????????§?????´????????????????????????????????????
				if(b[j] == a[k]){
					tmp++; next = k + 1;
					ans = max(ans, tmp);
					break;
				}
				if(k == n1 - 1){ flag = true; break; }
			}
			if(flag) break;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define MAXN 105
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int L=0,Q=850,q=0;
int sigma=62;
char alpha[MAXN];
int ask(string &str)
{
    q++; assert(q<=Q);
    cout<<"? "<<str<<endl;
    int x;
    scanf("%d",&x);
    return x;
}
bool is_subsequence(string &str)
{
    return (ask(str)==(L-(int)str.size()));
}
void answer(string &str)
{
    cout<<"! "<<str<<endl;
    exit(0);
}
string get_str(char ch)
{
    string x=string(128,ch);
    int ret=ask(x);
    L+=128-ret;
    return string(128-ret,ch);
}
vector<string> v;
bool cmp(string x,string y)
{
    return x.size()>y.size();
}
string merge(string &s,string &t)
{
    string ret=s;
    int now=0,i=0;
    while(i<(int)t.size())
    {
        if(now==(int)s.size())
        {
            ret=ret+t.substr(i);
            break;
        }
        int num=now+i;
        string tmp=ret.substr(0,num)+t[i]+ret.substr(num);
        if(is_subsequence(tmp)) {ret=tmp; i++;} else now++;
    }
    return ret;
}
int main()
{
    for(int i=0;i<26;i++) alpha[i]='a'+i;
    for(int i=26;i<52;i++) alpha[i]='A'+i-26;
    for(int i=52;i<62;i++) alpha[i]='0'+i-52;
    for(int i=0;i<62;i++) 
    {
        string str=get_str(alpha[i]);
        if(str.size()) v.push_back(str);
    }
    while(v.size()>1)
    {
        sort(v.begin(),v.end(),cmp);
        string s=v.back(); v.pop_back();
        string t=v.back(); v.pop_back();
        v.push_back(merge(s,t));
    }
    assert(v[0].size()==L);
    answer(v[0]);
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define vll vector<ll>
#define nloop(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define fill(i,n) memset(i,n,sizeof i)
#define all(a) a.begin(),a.end()
#define pb(x) push_back(x)
#define sz() size()
#define T(n) while(n--)
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define endl '\n'
#define nfs  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll bin_expo(ll a, ll b, ll m){ll res = 1LL;while (b > 0){if(b % 2 == 1){res = (res * a) % m;}a = (a * a) % m; b = b/ 2;}return res;}

const  int MAXn= 3e5+5;
const  long long INF= 1e18;

int main(){
    int t=1;
    //cin>>t;
    T(t){
      ll n,w;
			cin>>n>>w;
			vector<ll> dp(w+1,0);

			for(int i=0;i<n;i++){
				ll weight,value; cin>>weight>>value;
				for(int temp=w-weight;temp>=0;temp--){
					dp[temp+weight]= max(dp[temp+weight],dp[temp]+value);
				}
			}
			ll ans=0;
			for(int i=1;i<=w;i++){
				ans= max(ans,dp[i]);
			}
			cout<<ans<<endl;
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

  int A,B,T;
  cin >> A >> B >> T;
  cout << T/A * B << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long long int abs(long long int a){
  return a<0?-1*a:a;
}
int main(){
  int a;
  scanf("%d",&a);
  long long int b[a],c=400000000000000;
  long long int d=0LL,e=0LL;
  for(int i=0; i<a; i++){
    scanf("%lld",&b[i]);
    e+=b[i];
  }
  for(int i=0; i<a-1; i++){
    d+=b[i];e-=b[i];
    if(abs(d-e)<c){c=abs(d-e);}
  }
  printf("%lld",c);
  return 0;}


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

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  if((b-a)%2 == 0) cout << (b-a)/2 << endl;
  else cout << min(a-1,n-b)+1+(b-a-1)/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int spf[1000001];
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i <= 1000000; i++)
        spf[i] = i;
    for (int i = 2; i <= 1000000; i += 2)
    {
        spf[i] = 2;
    }
    for (int i = 3; i * i <= 1000000; i += 2)
    {
        if (spf[i] == i)
        {
            for (int j = i * i; j <= 1000000; j += i)
            {
                spf[j] = i;
            }
        }
    }
    map<int, int> cnt;
    for (int i = 0; i < n; i++)
    {
        while (a[i] != 1)
        {
            cnt[spf[a[i]]]++;
            int div=spf[a[i]];
            while (a[i] % div == 0)
                a[i] /= div;
        }
    }
    bool yes = true, no = false;
    for (auto x : cnt)
    {
        if (x.second != 1)
        {
            yes = false;
        }
        if (x.second == n)
        {
            no = true;
        }
    }
    if (yes)
        cout << "pairwise coprime";
    else if (no)
        cout << "not coprime";
    else
        cout << "setwise coprime";
    return 0;
}

Measured memory_bytes: 15072
#include <iostream>
#include <math.h>
using namespace std;
int main(){
  int x;
  cin >> x;
  int h = (int)sqrt(x);
  
  while(true){
    for(int j=2;j<=h+1;j++){
      if(x%j == 0){
        if(x == j){
          cout << x << endl;
          return 0;
        }
        break;
      }
      if(j == h){
        cout << x << endl;
        return 0;
      }
    }
    x++;
  }
  return 0;
}

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

using namespace std;

#define ll 			long long
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cmax(a,b)		a = max (a, b)
#define cmin(a,b)		a = min (a, b)
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

const int MAXN = 2e5 + 5;
const int oo = 0x3f3f3f3f;

int N, a[MAXN];
bool mark[MAXN], vaild[MAXN];

namespace Graph{
	struct edge {
		int y, next, c;
	}e[MAXN << 1];
	int LINK[MAXN], len = 0, deg[MAXN];
	deque<int> q;
	inline void ins(int x, int y, int c) {
		e[++len].next = LINK[x]; LINK[x] = len;
		e[len].y = y; e[len].c = c;
	}
	inline void Ins(int x, int y){
		ins(x, y, 1);
		ins(y, x, 0);
		deg[x]++;
	}
	bool chk(int st){
		q.push_back(st);
		while (!q.empty()) {
			int node = q.front(); q.pop_front();
			if (node != st) {
				Auto (i, node) if (e[i].c == 1) mark[a[e[i].y]] = 1;
				int cur = 0;
				while (mark[cur]) cur++;
				a[node] = cur;
				Auto (i, node) if (e[i].c == 1) mark[a[e[i].y]] = 0;
			} 
			Auto (i, node) if (e[i].c == 0 && vaild[e[i].y] && e[i].y != st) 
				q.push_back(e[i].y);
		}
		int cur = 0;
		Auto (i, st) if (e[i].c == 1) mark[a[e[i].y]] = 1;
		while (mark[cur]) cur++;
		Auto (i, st) if (e[i].c == 1) mark[a[e[i].y]] = 0;
		return cur == a[st];
	}
}using namespace Graph;

namespace solution{
	void Prepare(){
		scanf("%d", &N);
		up (i, 1, N) {
			int x, y = i;
			scanf("%d", &x);
			Ins(x, y);
		}
	}
	void Solve(){
		up (i, 1, N) if (!deg[i])	
			q.push_back(i);
		up (i, 1, N) vaild[i] = 1;
		while (!q.empty()) {
			int node = q.front(); q.pop_front();
			vaild[node] = 0;
			Auto (i, node) if (e[i].c == 1) 
				mark[a[e[i].y]] = 1;
			int cur = 0;
			while (mark[cur]) cur++;
			a[node] = cur;
			Auto (i, node) if (e[i].c == 0) {
				if (!--deg[e[i].y]) q.push_back(e[i].y);
			}
			Auto (i, node) if (e[i].c == 1) 
				mark[a[e[i].y]] = 0;
		}
		up (i, 1, N) if (vaild[i]) {
			int cur = 0;
			Auto (j, i) if (e[j].c == 1 && !vaild[e[j].y])
				mark[a[e[j].y]] = 1;
			while (mark[cur]) cur++;
			a[i] = cur;
			Auto (j, i) if (e[j].c == 1 && !vaild[e[j].y])
				mark[a[e[j].y]] = 0;
			if (chk(i)) break;
			Auto (j, i) if (e[j].c == 1 && !vaild[e[j].y])
				mark[a[e[j].y]] = 1;
			mark[a[i]] = 1; 
			cur = 0;
			while (mark[cur]) cur++;
			mark[a[i]] = 0;
			a[i] = cur;
			Auto (j, i) if (e[j].c == 1 && !vaild[e[j].y]) 
				mark[a[e[j].y]] = 0;
			if (chk(i)) break;
			puts("IMPOSSIBLE");
			return;
		}
		puts("POSSIBLE");
	}
}

int main(){
	using namespace solution;
	Prepare();
	Solve();
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define E(x,y,c) edge{P{(x),(y)},c}
const int INF = 1e9 + 7;

using namespace std;

#define P pair<int,int>
#define MAX_V 100001
struct edge{
    P pi;
    int cost;
};

int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int v,m;
    cin >> v >> m;
    vector<map<int,vector<edge>>> G(v+1);
    REP(i,m){
        int p,q,c;
        cin >> p >> q >> c;
        G[p][c].push_back(E(q,c,0));
        G[q][c].push_back(E(p,c,0));

        G[p][c].push_back(E(p,0,0));
        G[p][0].push_back(E(p,c,1));
        G[q][c].push_back(E(q,0,0));
        G[q][0].push_back(E(q,c,1));
    }

    vector<map<int,int>> d(v+1);

    priority_queue<pair<int,P>,vector<pair<int,P>>,greater<pair<int,P>>> que;
    que.push(make_pair(0,P{1,0}));

    while(!que.empty()){
        pair<int,P> p = que.top(); que.pop();
        int vx=p.second.first,vy=p.second.second;
        //printf("[%d][%d]:%d\n",vx,vy,(int)G[vx][vy].size());
        //if(d[vx] < p.first) continue;
        REP(i,G[vx][vy].size()){
            edge e = G[vx][vy][i];
            int ex=e.pi.first,ey=e.pi.second;
            if(d[ex][ey] == 0 || d[ex][ey] > d[vx][vy] + e.cost){
                d[ex][ey] = d[vx][vy] + e.cost;
                que.push(make_pair(d[ex][ey],e.pi));
            }
        }
    }

    if(d[v][0]) cout << d[v][0] << "\n";
    else cout << "-1\n";
    return 0;
}


Measured memory_bytes: 93744
import math

def main():
    n = int(input())
    r = math.ceil(math.sqrt(n))
    ans = 0

    for i in range(1, r+1)[::-1]:
        if n % i == 0:
            w = i
            h = n / w
            ans = int(w) + int(h) -2
            break

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#include <map>

#define ll long long
#define MAX 25 * 1e13
#define N  200010

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

using namespace std;
int MOD = 1000000007;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int lens = (int) s.size();
  vector<vector<ll>> r(2, vector<ll>(2019));

  REP(j,2019) r[0][j] = 0;
  REP(j,2019) r[1][j] = 0;

  ll num = 0;
  ll M = 2019;
  ll cnt = 0;
  int odd = 0;
  for (int i = 0; i < lens; i++ ) {
    odd = (odd + 1) % 2;
    num = num*10 + s[i] - '0';
    num %= M;
    
//    cout << num  << " " << r[1][num] << " " << r[0][num] <<  endl;
    if( odd % 2 == 0 ){
      if( num == 0 ) {
        cnt++;
      }
      cnt += r[0][num];
      r[0][num]++;
    }
    else {
      if( num == 0 ) {
        cnt++;
      }
      cnt += r[1][num]; 
      r[1][num]++;
    }

    if( odd % 2  == 0) { // 0 -> 1
    REP(j,2019) r[1][j] = 0;
    REP(j,2019) if( r[0][j] > 0 ) {
      ll newr = (ll)j * 10;
      newr %= M;
      r[1][newr] = r[0][j];
    }
    }
    else {
    REP(j,2019) r[0][j] = 0;
    REP(j,2019) if( r[1][j] > 0 ) {
      ll newr = (ll)j * 10;
      newr %= M;
      r[0][newr] = r[1][j];
    }
    
    }
  }
  cout << cnt << endl;


  return 0;

}



Measured memory_bytes: 3324
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = 3005;

ff dp[N][N], p[N];
int n;

void solve() {
   for (int i = 0; i <= n; ++i) for (int j = 0; j <= n; ++j)
      dp[i][j] = 0;

   dp[0][0] = 1;

   for (int i = 1; i <= n; ++i) for (int j = 0; j <= n; ++j)
   {
      dp[i][j] = dp[i-1][j]*(1-p[i]);
      if (j > 0) dp[i][j] += dp[i-1][j-1]*p[i];
   }
   ff total = 0;
   for (int j = (n+1)/2; j <= n; ++j) {
      total += dp[n][j];
   }
   cout << total << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;
   for (int i = 1; i <= n; ++i) cin >> p[i];
   solve();

   return EXIT_SUCCESS;
}


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

int main() {
	int a, b;
	char op;
	cin >> a >> op >> b;
	while (op != '?') {
		if (op == '+'){
			cout << a + b << endl;
		} else if (op == '-'){
			cout << a - b << endl;
		} else if (op == '*'){
			cout << a * b << endl;
		} else if (op == '/'){
			cout << a / b << endl;
		} cin >> a >> op >> b;
	}
	return 0;
}



Measured memory_bytes: 3084
#include <iostream>

using namespace std;

int BMI( double w , double h ){

  double bmi = w / (h * h);

  if( bmi >= 25 )return 1;
  else return 0;

}


int main(void){

  int stu;
  int out[10000];
  double w,h;
  char ten;
  int i = 0;

  while( cin >> stu >> ten >> w >> ten >> h ){

    switch( BMI(w,h) ){
    case 1:
      out[i++] = stu;
      break;
    case 0:
      continue;
    }
  }
  for( int j = 0 ; j < i ; j++ ) cout << out[j] << endl;
  return 0;
}

Measured memory_bytes: 1236
using System;
namespace AtCoder.BeginnersSelections
{
    class Test
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int max = 0;
            int count = 0;
            int j, ans = N;
            for (int i = 1; i <= N; i++)
            {
                j = i;
                count = 0;
                while (j % 2 == 0)
                {
                    count++;
                    j /= 2;
                }
                if (count > max)
                {
                    ans = i;
                    max = count;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

typedef long long ll;


int main() {
	int n; cin >> n;
	ll y; cin >> y;
	for (ll i = 0; i <= n; i++) {
		for (ll j = 0; i + j <= n; j++) {
			ll k = n - i - j;
			if (10000 * i + 5000 * j + 1000 * k == y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
s = input() # 入力が1つ
# map(int, input().split()) # 入力が複数
# [int(i) for i in input().split()] # 配列で数字

t = ''
words = ['dream', 'dreamer', 'erase', 'eraser']

while s:
    for w in words:
        if s[-len(w):] == w:
            s = s[:-len(w)]
            break
    else:
        print('NO')
        break
else:
    print('YES')

Measured memory_bytes: 133860
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DB double
#define SG string
#define LL long long
#define G(A,B) G[A][B]
#define Fp(A,B,C,D) for(A=B;A<=C;A+=D)
#define Fm(A,B,C,D) for(A=B;A>=C;A-=D)
#define Clear(A) memset(A,0,sizeof(A))
using namespace std;
const LL Max=2e5+5;
const LL Mod=1e9+7;
const LL Inf=1e18;
struct Node{
	LL ID,V;
}G[Max];
LL N,A[Max];
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
bool Cmp(Node A,Node B){
	return A.V<B.V;
}
LL Find(LL V){
	LL I,J,K;
	LL Left=1,Right=N;
	while(Left<=Right){
		LL Mid=Left+Right>>1;
		if(G[Mid].V>V){
			Right=Mid-1;
		} else if(G[Mid].V<V){
			Left=Mid+1;
		} else {
			return Mid;
		}
	}
}
int main(){
	LL I,J,K;
	N=Read();
	Fp(I,1,N,1){
		A[I]=G[I].V=Read();G[I].ID=I;
	}sort(G+1,G+1+N,Cmp);
	Fp(I,1,N,1){
		LL P=Find(A[I]);
	//	cout<<"P:???"<<P<<endl;
		if(P>(N>>1)){
			Write(G[(N>>1)].V);puts("");
		} else {
			Write(G[(N>>1)+1].V);puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll a,b,c,n,ans=0;
void Main(){
    cin>>n;
    for(double i=0;i<50000;i++){
        if(floor(i*1.08)==n) ans=round(i);
    }
    if(ans==0) cout<<":("<<endl;
    else cout<<ans<<endl;
}
main(){
    Main();
}

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

int main(){
	int n,d;
	cin>>n>>d;
	double x[n][d];
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++)cin>>x[i][j];
	}
	int ans = 0;
	double tmp=0;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			if(i==j)continue;
			tmp=0;
			for(int k=0;k<d;k++){
				tmp += pow(x[i][k]-x[j][k],2);
			}
			double t = sqrt(tmp);
			if(ceil(t)==floor(t)){
				//cout<<"ij:"<<i<<" "<<j<<" t:"<<t<<endl;
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    int result=1000000;
    //数直線上の位置固定
    for(int i=1;i<=vec.at(n-1);i++){
        int sum=0;
        //各点の体力消費
        for(int j=0;j<n;j++){
            int d=vec.at(j)-i;
            sum+=(d*d);
        }
        result=min(result,sum);
    }
    cout<<result<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public void Germany() {
		Scanner sc = new Scanner(System.in);
		int a,b;
		int d;
		int r;
		double f;
		a = sc.nextInt();
		b = sc.nextInt();
		d = a / b;
		r = a % b;
		f = (double)a / b;
		System.out.printf("%1d %1d %1.5f",d,r,f);
	}
	    public static void main(String[] args) {
	        new Main().Germany();
	    }
	}

Measured memory_bytes: 17328
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader rd = new MyReader();  
        int K, X;
        {int[] a = rd.ii(); K = a[0]; X = a[1];}
        int r = X + Math.min(K-1, 1000000-X);
        int l = X - Math.min(K-1, X+1000000);
        for(int i = l; i <= r; i++)
            print(i+" ");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 22484
a,b = map(int,input().split())
if a == 0 or b == 0 or a*b < 0:
    print('Zero')
elif a > 0:
    print('Positive')
else:
    if (b - a + 1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;
  int n = s.size();
  vector<int> v(n);
  rep(i, 0, n) v[i] = s[i] - '0';

  rep(i, 0, 1 << n - 1) {
    string op = "";
    rep(j, 0, n - 1) {
      if (i >> j & 1)
        op += "+";
      else
        op += "-";
    }

    int ans = v[0];
    rep(j, 0, n - 1) {
      if (op[j] == '+')
        ans += v[j + 1];
      else
        ans -= v[j + 1];
    }
    if (ans == 7) {
      cout << v[0];
      rep(j, 0, n - 1) { cout << op[j] << v[j + 1]; }
      cout << "=7" << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
int main()
{
    int n, deal;
    int four = 0, two = 0, odd = 0;
    scanf("%d", &n);
    while (n--)
    {
        scanf("%d", &deal);
        if (deal % 4 == 0)
            four++;
        else if (deal % 2 == 0)
            two++;
        else
            odd++;
    }
    if (two == 0)
    {
        if (four >= odd - 1)
            printf("Yes");
        else
            printf("No");
    }
    else if (four >= odd)
        printf("Yes");
    else
        printf("No");
}

Measured memory_bytes: 128
n = int(input())
a = [int(s) for s in input().split()]
l_ia = []
for i in range(n):
    # 出席番号i+1の生徒はa[i]番目に登校した
    l_ia.append([a[i], i+1])
l_ia.sort()
# turn = [l_ia[i][1] for i in range(n)]
# print(*turn)
print(*[l_ia[i][1] for i in range(n)])


Measured memory_bytes: 22848
N = int(input())
N2 = 1 << N

S = sorted([int(x) for x in input().split()])

s = []
s.append(S[-1])
S[-1] = -1

flag = True
for i in range(N):
    p = sorted([x for x in s])

    Si = N2 - 1
    while len(p) > 0 and Si >= 0:
        if S[Si] == -1:
            Si -= 1
            continue

        if S[Si] < p[-1]:
            s.append(S[Si])
            del p[-1]
            S[Si] = -1
        
        Si -= 1
    
    if len(p) > 0:
        flag = False

print('Yes' if flag else 'No')

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


int main() {
    char S[3];
    cin >> S;
    if (S[0] == S[1] and S[1] == S[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [1000000000 for _ in range(n)]
dp[0] = 0
for i in range(1, n):
  if i > 1:
    dp[i] = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]))
    dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]))
  else:
    dp[i] = min(dp[i], dp[i-1] + abs(h[i]-h[i-1]))
ans = dp[n-1]
print(ans)

Measured memory_bytes: 13784
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

int main(){
    int N,M;
    while(scanf("%d%d",&N,&M),N||M){
        vi x(N+1,0),y(M+1,0);
        map<int,int>a,b;
        rep(i,N){
            scanf("%d",&x[i+1]);
            x[i+1]+=x[i];
        }
        rep(i,M){
            scanf("%d",&y[i+1]);
            y[i+1]+=y[i];
        }

        rep(i,N){
            rrep(j,i+1,N+1){
                a[x[j]-x[i]]++;
            }
        }
        rep(i,M){
            rrep(j,i+1,M+1){
                b[y[j]-y[i]]++;
            }
        }

        ll ans=0;
        rep(i,1500001){
            if(a.find(i)==a.end()||b.find(i)==b.end())continue;
            ans+=a[i]*b[i];
        }

        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 27696
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int A, B, X, w, ans = 0;
	cin >> A >> B >> X;
	if (A <= B) {
		while (X > 0) {
			ans += A;
			X -= 1000;
		}
	}
	else if (A >= B * 2) {
		while (X > 0) {
			ans += B;
			X -= 500;
		}
	}else{
		while (X > 500) {
			ans += A;
			X -= 1000;
		}
		while (X > 0) {
			ans += B;
			X -= 500;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100005
#define INF 1000000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000005;
const int MOD = 1000000007;
int main(){
    int n;
    cin>>n;
    vector<vector<char>>s(n,vector<char>(n));
    REP(i,n){
        REP(j,n)cin>>s[i][j];
    }
    int ans=0;
    REP(i,n){
        bool f=true;
        REP(j,n){
            int y=(2*n-i+j-1)%n;
            REP(k,n){
                if(s[j][k]!=s[(j-y+k+n)%n][y]){
                    f=false;
                    break;
                }
            }
            if(!f)break;
        }
        if(f)ans+=n;
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 384