akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

vector<lli> divisor(lli x){
    vector<lli> d;
    for(lli i = 1; i*i <= x; i++){
        if(x%i == 0){
            d.push_back(i);
            if(i != x/i) d.push_back(x/i);
        }
    }
    sort(d.begin(), d.end());
    return d;
}

lli n;

int main(void){
    cin >> n;
    auto d = divisor(n);
    lli ans = 0;
    for(auto i : d){
        lli m = i-1;
        if(0 <= n/i && n/i <= m-1){
            ans += m;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C,K;
  cin >> A >> B >> C;
  cin >> K;
  string F;
  F = "No";
  int f = 1;
  for(int i = 0;i < K;i++){
    if (A >= B){
      B *= 2;
    }
    else if(B >= C){
      C *= 2;
    }
  }
  if (A < B){
    if (B < C){
      F = "Yes";
    }
  }
  cout << F << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    // vector<double> l(n, 0);
    double l, ls = 0;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
    }
    /*
    auto len = [&](int i, int j) {
        double X = x[i] - x[j], Y = y[i] - y[j];
        return sqrt(X*X + Y*Y);
    };
     */
    for(int i = 0; i < n; i++){
        l = 0;
        for(int j = 0; j < n; j++){
            double X = x[i] - x[j], Y = y[i] - y[j];
            l += sqrt(X*X + Y*Y);
            // l += len(i, j);
        }
        ls += l;
    }
    printf("%.10lf\n", ls / n);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,(int)v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define Endl cout << endl
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
    ll cnt=0;
    string s;
    cin >> s;
    ll n=(int)s.size();
    vll v(n,0);
    rep(i,n){
        if(s[i]=='R') cnt++;
        if(i==n-1 && s[i]=='R') v[i]=cnt;
        else if(s[i]=='R' && s[i+1]=='L'){
            v[i]+=(cnt+1)/2;
            v[i+1]+=cnt/2;
            cnt=0;
        }
    }
    cnt=0;
    for(ll i=n-1;i>=0;i--){
        if(s[i]=='L') cnt++;
        if(i==0 && s[i]=='L') v[i]=cnt;
        else if(s[i]=='L' && s[i-1]=='R'){
            v[i]+=(cnt+1)/2;
            v[i-1]+=cnt/2;
            cnt=0;
        }
    }
    pvec(v);
    return 0;
}


Measured memory_bytes: 1408
function main(input) {
    const args = input.split(' ');
    const s = parseInt(args[0], 10);
    const w = parseInt(args[1], 10);

    if ( w >= s ) {
        console.log('unsafe');
    } else {
        console.log('safe');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m;
    cin >> m;
     
    cout << 48 - m << endl;
    return 0;
}


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

int main() {
int N,M,X;
  cin >> N >> M >> X;
  vector<int> money(12,0);
  vector<vector<int>> data(12, vector<int>(12)); 
  int moneycount = 0;
  int anscount = 0;
  vector<int> datacount(12,0);
  vector<int> kouho;
  for(int i = 0; i < N; i++){
  	cin >> money[i];
    for(int j = 0; j < M; j++){
    	cin >> data[i][j];
    }
  }
  for(int i1 = 0; i1 < 2; i1++){
  	for(int i2 = 0; i2 < 2; i2++){

    	for(int i3 = 0; i3< 2; i3++){
          
        	for(int i4 = 0; i4 < 2; i4++){
             
            	for(int i5 = 0; i5 < 2; i5++){

                	for(int i6 = 0; i6 < 2; i6++){

                    	for(int i7 = 0; i7 < 2; i7++){

                        	for(int i8 = 0; i8 < 2; i8++){

                            	for(int i9 = 0; i9 < 2; i9++){

                                	for(int i10 = 0; i10 < 2; i10++){

                                    	for(int i11 = 0; i11 < 2; i11++){
                                                                                  
                                        	for(int i12 = 0; i12 < 2; i12++){

                                              anscount = 0;
                                              for(int j = 0; j < M; j++){
                                              	moneycount = i1*money[0]+i2*money[1]+i3*money[2]+i4*money[3]+i5*money[4]+i6*money[5]+i7*money[6]+i8*money[7]+i9*money[8]+i10*money[9]+i11*money[10]+i12*money[11]; 
                                              	datacount[j] = i1*data[0][j]+i2*data[1][j]+i3*data[2][j]+i4*data[3][j]+i5*data[4][j]+i6*data[5][j]+i7*data[6][j]+i8*data[7][j]+i9*data[8][j]+i10*data[9][j]+i11*data[10][j]+i12*data[11][j];
                                              	if(datacount[j] < X){
                                                	anscount++;
                                                }
                                              }
                                              if(anscount == 0){
                                              	kouho.push_back(moneycount);
                                              }
                                            	
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
      }
  }
  if(kouho.size() == 0){
  cout << -1 << endl;
  }
  else {
//  vector<int> B;
//  B = sort(kouho);
    sort(kouho.begin(),kouho.end());
    cout << kouho[0] << endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#define rep(i, n)for(int i=0; i<n; i++)
using ll = long long int;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i];
    rep(i, n) cin >> y[i];
    double ans1=0, ans2=0, ans3=0, ans4=0;
    
    rep(i, n){
        ans1 += fabs(x[i]-y[i]);
    }

    rep(i, n){
        ans2 += fabs(x[i]-y[i]) * fabs(x[i]-y[i]);
    }
    ans2 = sqrt(ans2);

    rep(i, n){
        ans3 += fabs(x[i]-y[i]) * fabs(x[i]-y[i]) * fabs(x[i]-y[i]);
    }
    ans3 = cbrt(ans3);

    rep(i, n){
        ans4 = ans4>fabs(x[i]-y[i]) ? ans4 : fabs(x[i]-y[i]);
    }
    cout << fixed << setprecision(6) << ans1 << endl << ans2 << endl << ans3 << endl << ans4;

    
    return 0;
}


Measured memory_bytes: 3440
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	string s,ans;
	cin >> s;
	ans = s;
	map<char, int>m;
	rep(i, 26)m[char('a' + i)]++;
	if(s.size() == 26){
		char c = ' ';
		for (int i = 25; i > 0;i--) {
			if (s[i-1] < s[i]) {
				ans = s.substr(0, i - 1);
				c = s[i -1];
				break;
			}
		}
		for (auto ss : ans)m[ss]--;
		for (auto mm : m) {
			if (mm.second == 1 && c < mm.first) {
				ans += mm.first;
				break;
			}
		}

	}
	else {
		for (auto ss : s)m[ss]--;
		for (auto mm : m) {
			if (mm.second == 1) {
				ans = s + mm.first;
				break;
			}
		}
	}
	if (s != ans) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 100000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll I,O,T,J,L,S,Z;
int main(){
	cin >> I >> O >> T >> J >> L >> S >> Z;
	ll ans = 0ll;
	ans += I/2ll*4ll;
	ans += O*2ll;
	ans += J/2ll*4ll;
	ans += L/2ll*4ll;
	ll ans2 = 0ll;
	if(I>0ll&&J>0ll&&L>0ll){
		ans2=6ll;
		I--;
		J--;
		L--;
		ans2 += I/2ll*4ll;
		ans2 += O*2ll;
		ans2 += J/2ll*4ll;
		ans2 += L/2ll*4ll;
	}
	cout << max(ans,ans2)/2ll << endl;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
Hs = list(map(int, input().split()))

AB = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    AB[A-1].append(B-1)
    AB[B-1].append(A-1)

counter = 0
for i in range(N):
    for next_node in AB[i]:
        if Hs[i] <= Hs[next_node]:
            break
    else:
        counter += 1

print(counter)


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    int N; cin >> N;
    ll ans = pow(3,N), kisu_p = 1;
    rep(i,N) {
        int A; cin >> A;
        if(A%2==0) kisu_p *= 2;
    }
    cout << ans-kisu_p << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

    int main(){
      int n;
      cin >> n;
      int a[n];
      rep(i,n)cin >> a[i];
      int ans=a[0];
      rep(i,n)ans=__gcd(ans,a[i]);
      cout << ans << endl;
      return 0;}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define ALL(x) (x).begin(),(x).end()

int main () {
  int a, b, n, count;
  vector<vector<int>> as = vector<vector<int>>(3, vector<int>(3, 0));

  REP(i, 3) {
    REP(j, 3) {
      cin >> a;
      as[i][j] = a;
    }
  }

  cin >> n;

  REP(i, n) {
    cin >> b;

    REP(i, 3) {
      REP(j, 3) {
        if(as[i][j] == b) as[i][j] = INT_MAX;
      }
    }
  }

  REP(i, 3) {
    count = 0;

    REP(j, 3) {
      if(as[i][j] == INT_MAX) count++;
    }

    if(count == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  REP(i, 3) {
    count = 0;

    REP(j, 3) {
      if(as[j][i] == INT_MAX) count++;
    }

    if(count == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  count = 0;
  REP(i, 3) {
    if(as[i][i] == INT_MAX) count++;
  }
  if(count == 3) {
    cout << "Yes" << endl;
    return 0;
  }

  count = 0;
  REP(i, 3) {
    if(as[i][2-i] == INT_MAX) count++;
  }
  if(count == 3) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
using namespace std;
int main() {
    while (true) {
        char tmp[210];
        scanf("%s", tmp);
        string cards = tmp;
        if (cards == "-") {
            break;
        }

        int count;
        scanf("%d", &count);
        int sum = 0;
        for (int i = 0; i < count; i++) {
            int tmp;
            scanf("%d", &tmp);
            sum += tmp;
        }
        int shuffle_count = sum % cards.size();
        string left = cards.substr(0, shuffle_count);
        string right = cards.substr(shuffle_count, cards.size());
        printf("%s\n", (right + left).c_str());
    }
}

Measured memory_bytes: 1056
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll dp[22][1<<21]={};
int main(){
	ll MOD=1e+9+7;
	int N;
	scan(N);
	ll kumi=(1<<N);
	int a[22][22];
	dp[0][0]=1;
	rep(i,N){
		rep(j,N){
			scan(a[i][j]);
			if(a[i][j]==1){
				rep(bit,kumi){
					if(((bit>>j)&1)==0){
						dp[i+1][bit|(1<<j)]+=dp[i][bit];
						dp[i+1][bit|(1<<j)]%=MOD;
					}
				}
			}
		}
	}
	prin(dp[N][kumi-1]);
	return 0;
}


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

const long MAXN=300100;
int h,w,m;

int col[MAXN],row[MAXN];

struct thing{
	int x,y;
};	thing tar[MAXN];
bool cmp(thing a,thing b) {		//return a<b;
	if(a.x!=b.x) return a.x<b.x;
	return a.y<b.y;
}

bool exist(thing a) {
	
	int l=1,r=m,mid;
	while(r-l>=3) {
		mid=(l+r)>>1;
		if(cmp(a,tar[mid]))
			r=mid-1;
		else l=mid;
	}
	for(int i=l;i<=r;++i)
		if(a.x==tar[i].x && a.y==tar[i].y)
			return 1;
	return 0;
}

vector<int> co,ro;

int main() {
	cin>>h>>w>>m;register int i;
	for(i=1;i<=m;++i) {
		scanf("%d%d",&tar[i].x,&tar[i].y);
		++row[tar[i].x];++col[tar[i].y];
	}
	
	sort(tar+1,tar+m+1,cmp);
	
	int max_col=0,max_row=0,num_row=0,num_col=0;
	for(i=1;i<=h;++i)
		max_row=max(max_row,row[i]);
	for(i=1;i<=w;++i)
		max_col=max(max_col,col[i]);
	for(i=1;i<=h;++i)
		if(max_row==row[i])
			ro.push_back(i),++num_row;
	for(i=1;i<=w;++i)
		if(max_col==col[i])
			co.push_back(i),++num_col;
	
	bool flag=1;
	for(i=0;i<num_row;++i)
		for(int j=0;j<num_col;++j)
			if(!exist((thing){ro[i],co[j]})) {
				flag=0;
				break;
			}
	
	if(flag==0) cout<<max_row+max_col<<endl;
	else cout<<max_row+max_col-1<<endl;
	return 0;
}

Measured memory_bytes: 12092
n = int(input())
m = []


def memoize(f):
    memo = [[None] * n for _ in range(n)]
    for i in range(n):
        memo[i][i] = 0

    def main(b, e):
        if memo[b][e] is not None:
            return memo[b][e]
        result = memo[b][e] = f(b, e)
        return result

    return main


@memoize
def contract(b, e):
    return min(contract(b, i) + contract(i + 1, e) + m[b] * m[i + 1] * m[e + 1] for i in range(b, e))


r, c = map(int, input().split())
m.append(r)
m.append(c)
nc = n - 1
while nc:
    r, c = map(int, input().split())
    m.append(c)
    nc -= 1

print(contract(0, n - 1))

Measured memory_bytes: 7932
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#define rep(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int N, K;

int main()
{
    int i, j, k;
    vector<bool> dp(100010, false);
    int a[105];
    int MIN = 9999999;
    int n;

    cin >> N >> K;

    rep(i, 0, N - 1)
    {
        cin >> a[i];
    }

    rep(i, 0, K)
    {
        rep(j, 0, N - 1)
        {
            if (i - a[j] >= 0)
            {
                if (dp[i - a[j]] == false)
                {
                    dp[i] = true;
                }
            }
        }
    }

    if (dp[K] == false)
    {
        cout << "Second" << endl;
    }
    else
    {
        cout << "First" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}
template<typename T>
void maxi(T &a, T &b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T &b) {
	a = min(a, b);
}

int main() {
	makei(A);
	makei(B);
	makei(X);
	YN(A <= X && X <= A + B);
}

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

int main () {

  int x;
  std::vector<int> v;

  for(int n = 10000; n!=0; --n) {
    std::cin >> x;

    if(x == 0)
      break;
 
    v.push_back(x);
  }

  for(int n = 0 ; n != v.size(); n++)
    std::cout << "Case " << n + 1 << ": " << v[n] << std::endl;
  return 0;
}



Measured memory_bytes: 3252
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int a[200005];
char s[200005];

int main()
{
    memset(a,0,sizeof(a));
    scanf("%s",s);
    for(int i=0; s[i]!='\0'; )
    {
        int j=0;
        if(s[i]=='R')
        {
            while(s[i]=='R'&&s[i]!='\0')
            {
                j++;
                i++;
            }
            //printf("y=%d\n",j);
            if(j%2==0)
            {
                a[i]=j/2+a[i];
                a[i-1]=j/2+a[i-1];
            }
            else
            {
                a[i]=j/2+a[i];
                a[i-1]=j/2+a[i-1]+1;
            }
        }
        else
        {
            while(s[i]=='L'&&s[i]!='\0')
            {
                j++;
                i++;
            }
            //printf("l=%d\n",j);
            if(j%2==0)
            {
                a[i-j]=j/2+a[i-j];
                a[i-1-j]=j/2+a[i-j-1];
            }
            else
            {
                a[i-j]=j/2+a[i-j]+1;
                a[i-j-1]=j/2+a[i-j-1];
            }
        }
    }
    int i=0;
    for(;s[i+1]!='\0';i++)
    {
        printf("%d ",a[i]);
    }
    printf("%d\n",a[i]);
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<math.h>

typedef long long int ll;

using namespace std;

int main(void){

    ll n;
    ll ans = 0;
    ll tmp = 0;
    ll min = 10000000000000;

    cin >> n;


    if(n == 1){
        cout << ans << endl;
    }else{
        for(ll i = 1;i <= sqrt(n)+1;i++){
            if(n % i == 0){
                ll a = i;
                ll b = n/i;
                if(a == 1) tmp = b - 1;
                else if(b == 1) tmp = a - 1;
                else tmp = a + b - 2;

                if(min > tmp) min = tmp;
            }
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
L=[]
for i in range(N):
	a,b=map(int,input().split())
	L.append([a,b])
L=sorted(L)
for i in range(N):
	if L[i][1]<K:
		K-=L[i][1]
	else:
		print(L[i][0])
		exit()

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

using namespace std;

struct myPair {
	int first;
	int second;
};

int main(void) {
	for (int n = 0; (cin >> n) && n != 0;) {
		vector<myPair> conversion;
		for (int i = 0; i < n; i++) {
			char preLetter = 0, afterLetter = 0;
			cin >> preLetter >> afterLetter;
			myPair tmpPair;
			tmpPair.first = preLetter;
			tmpPair.second = afterLetter;
			conversion.push_back(tmpPair);
		}
		int m = 0;
		cin >> m;
		vector<char> letters;
		for (int i = 0; i < m; i++) {
			char letter = 0;
			cin >> letter;
			letters.push_back(letter);
		}
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < conversion.size(); j++) {
				if (conversion[j].first == letters[i]) {
					letters[i] = conversion[j].second;
					break;
				}
			}
			cout << letters[i];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
typedef long long int ll;
// #define int long long int
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FRE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define debug(x) cout << #x << " is: " << (x) << endl;
#define debugx(x) cout << #x << " is: " << (x) << endl; exit(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define fa(i,a,n) for(ll i=a;i<n;i++)
#define loop(i,a, n) for(ll i = a; i <= n; i++)
#define loopb(i,a, n) for(ll i = a; i >= n; i--)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define setmem(x, k) memset(x, k, sizeof(x))
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define MOD 1000000007
#define INF 1000111000111000111LL
#define endl "\n"
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<vector<ll>> matrix;
ll dx[] = {0, 1, 0, -1};
ll dy[] = {-1, 0, 1, 0};
const ll N = 5e5+5;
// ll a[N], b[N], dp[N], level[N], vis[N], in[N], out[N];
// vl g[N];
ll n, m;

void solve() {
    cin >> n;
    ll x = 0;
    ll res = 0;
    if(n % 2 == 0){
        cout << -1 << endl;
        return;
    }
    while(1){
        res++;
        x = x*10 + 7;
        x %= n;
        if(x % n == 0){
            cout << res << endl;
            break;
        }
        if(res > n){
            cout << -1 << endl;
            break;
        }
    }
}   
 
int32_t main() {
    IOS
    clock_t begin = clock();
    ll T = 1;
    // cin >> T;
    while(T--)
    solve();
    cerr<<"Time elapsed : "<<(clock()-begin)*1000.0/CLOCKS_PER_SEC<<"ms"<<'\n';
    return 0;
}

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

int main(){
  int n,d;
  cin >> n >> d;
  vector<vector<int>>x(n,vector<int>(d));
  int ans=0;
  
  for(int i=0; i<n; i++){
    for(int j=0; j<d; j++){
      cin >> x[i][j];
    }
  }
  
  for(int i=0;i<n; i++){
    for(int j=i+1;j<n; j++){
      int b=0; //ここで平方根の中身を初期化
      for(int k=0;k<d; k++){
        int a=abs(x[i][k]-x[j][k]);
        b+=a*a;
      }
      for(int k=0; k<=b; k++){
        if(k*k==b){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  
   

}

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

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

bool isAllBlack(vector<vector<char>> a, int h, int w) {
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (a[i][j] == '.') {
				return false;
			}
		}
	}
	return true;
}

signed main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h, vector<char>(w));
	int cnt = 0;
	queue<pair<int, int>> que, next_que;
	int sharp = 0, rest = h * w;

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				next_que.push(make_pair(i, j));
				sharp++;
			}
		}
	}

	rest -= sharp;
	
	while (!isAllBlack(a, h, w)) {
		que = next_que;
		while (!next_que.empty()) next_que.pop();
		while (!que.empty()) {
			pair<int, int> u;
			u = que.front();
			que.pop();
			int i = u.first, j = u.second;
			for (int k = 0; k < 4; ++k) {
				if (i + dx[k] >= 0 and i + dx[k] < h and j + dy[k] >= 0 and j + dy[k] < w) {
					if (a[i + dx[k]][j + dy[k]] == '.') {
						a[i + dx[k]][j + dy[k]] = '#';
						rest--;
						next_que.push(make_pair(i + dx[k], j + dy[k]));
					}
				}
			}
		}
		cnt++;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 11388
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define MOD int(1e9+9)
#define PI 3.1415926535898
using namespace std;
ll dp[101][100001];
int n, W, w[101], v[101];
int main(int argc, char const *argv[]) {
    cin >> n >> W;
    int sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    for(int i = 0; i < n; i++)
        for(int j = 0; j <= sum; j++)
            dp[i][j] = 1e9 + 10;
    for(int i = 0; i <= n; i++)dp[i][0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= sum; j++) {
            if(j >= v[i - 1]) {
                dp[i][j] = min(dp[i - 1][j],
                               dp[i - 1][j - v[i - 1]] + w[i - 1]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    ll ans = 0;
    for(ll i = 0; i <= sum; i++) {
        if(dp[n][i] <= W) {
            ans = max(ans, i);
        }
    }
   // cout << dp[1][10] << endl;
    cout << ans << endl;
}




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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define VECCIN(x)            \
	for (auto &youso_ : (x)) \
	cin >> youso_
#define mp make_pair
#define All(a) (a).begin(), (a).end()
template <typename T = long long>
inline T IN()
{
	T x;
	cin >> x;
	return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail)
{
	cin >> head;
	CIN(move(tail)...);
}
#define CINT(...)    \
	int __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define LCIN(...)   \
	ll __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define SCIN(...)       \
	string __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

const ll NMAX = 1e2;
ll fac[NMAX + 1], inv[NMAX + 1], finv[NMAX + 1];

ll N, L, T;
VL X, W, Y, Z;

int main()
{
	cin >> N >> L >> T;
	X.resize(N);
	W.resize(N);
	REP(i, N)
	{
		LCIN(x, w);
		X[i] = x;
		W[i] = w;
	}
	Y.resize(N);

	REP(i, N)
	{
		if (W[i] == 1)
		{
			Y[i] = (X[i] + T) % L;
		}
		else
		{
			Y[i] = ((L - X[i]) + T) % L;
			Y[i] = (L - Y[i]) % L;
		}
	}
	sort(All(Y));
	long long count = 0;
	for (int i = 0; i < N; ++i)
	{
		if (W[i] == 1)
			count -= (T - (L - X[i]) + L) / L;
		else
			count += (T - (X[i] + 1) + L) / L;
	}
	count = (count % N + N) % N;
	Z.resize(N);
	REP(i, N)
	{
		Z[(i + count) % N] = Y[i];
	}
	REP(i, N)
	{
		cout << Z[i] << "\n";
	}
}

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

struct SegmentTree{
    private:
        int n;
        vector<int> node;
    
    public:
        SegmentTree(vector<int> v){
            int sz = v.size();
            n = 1; while(n < sz) n *= 2;
            node.resize(2 * n - 1, INT_MAX);
            for(int i = 0; i < sz; i++) node[i+n-1] = v[i];
            for(int i = n - 2; i >= 0; i--) node[i] = min(node[2*i + 1], node[2*i+2]);
        }

        void update(int x, int val){
            x += n - 1;
            node[x] = val;
            while(x > 0){
                x = (x - 1) / 2;
                node[x] = min(node[2*x + 1], node[2*x + 2]);
            }
        }

        int getmin(int a, int b, int k = 0, int l = 0, int r = -1){
            if(r < 0) r = n;
            if(r <= a || b <= l) return INT_MAX;
            if(a <= l && r <= b) return node[k];

            int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
            int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
            return min(vl, vr);
        }
};

int main(){
    int n, q; cin >> n >> q;
    SegmentTree seg(vector<int>(n, INT_MAX));
    while(q--){
        int com, x, y; cin >> com >> x >> y;
        if(com == 0){
            seg.update(x, y);
        }else{
            cout << seg.getmin(x, y + 1) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4148
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let mut x:f64 = 0.00000;
	for i in 0..n {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		let v:Vec<&str> = buf.split_whitespace().collect();
		if v[1] == "JPY" {
			x += v[0].parse::<f64>().ok().unwrap();
		}else{
			x += 380000.0*v[0].parse::<f64>().ok().unwrap();
		}
	}
	println!("{}", x);
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    string s;
    lli n;
    lli i,j,k;
    cin>>s;
    if((s[2]==s[3])&&(s[4]==s[5])){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int H,W,a,b,k=0;
  while(k != -1){
  scanf("%d %d",&H,&W);
    if(H==0 && W==0){
      break;
    }
    for(b=1;b<=W;b++){
      printf("#");
    }
    printf("\n");
    for(a=2;a<=H-1;a++){
      printf("#");
      for(b=2;b<=W-1;b++){
        printf(".");
      }
      printf("#\n");
    }
    for(b=1;b<=W;b++){
      printf("#");
    }
    printf("\n\n");
  }
  return 0;
}

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

using namespace std;

int main() {

	long long int n, a, b;

	cin >> n >> a >> b;

	vector<long long int> h(n);

	for (long long int i = 0; i < n; i++) {
		cin >> h[i];
	}

	long long int lb = 0;
	long long int rb = 1000000010;

	while (rb - lb > 1) {
		long long int mid = (rb + lb) / 2;
		long long int ans = 0;
		for (int i = 0; i < n; i++) {
			long long int p = h[i];
			p -= b*mid;
			if (p > 0) {
				ans += p / (a-b);
				if (p%(a-b) != 0) {
					ans++;
				}
			}
		}
		if (ans > mid) {
			lb = mid;
		}
		else {
			rb = mid;
		}
		//cout << lb << ' ' << rb << endl;
	}
	cout << rb << endl;
	return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)

string solve(int n, int d)
{
	int m[100];
	vector<int> c[100];
	int index[100];
	int sum[100];
	rep(i, 0, n)
	{
		cin >> m[i];
		sum[i] = 0;
		rep(j, 0, m[i])
		{
			int cc; cin >> cc;
			c[i].push_back(cc);
			sum[i] += cc;
		}
		index[i] = m[i];
	}

	while (1)
	{
		int maxsum = -1;
		int pre_maxsum = -1;
		rep(i, 0, n)
		{
			if (maxsum < sum[i])
			{
				pre_maxsum = maxsum;
				maxsum = sum[i];
			}
		}
		if (maxsum == 0) return "Yes";

		bool ok = false;
		rep(i, 0, n)
		{
			if (index[i] == 0) continue;

			int nextsum = sum[i] - c[i][index[i]-1];

			if (sum[i] == maxsum)
			{
				if (pre_maxsum <= nextsum)
				{
					sum[i] = nextsum;
					index[i]--;
					ok = true;
					break;
				}
				else if ((pre_maxsum - nextsum) <= d)
				{
					sum[i] = nextsum;
					index[i]--;
					ok = true;
					break;
				}
				else
				{
					continue;
				}
			}
			else
			{
				if((maxsum - nextsum) <= d)
				{
					sum[i] = nextsum;
					index[i]--;
					ok = true;
					break;
				}
				else
				{
					continue;
				}
			}
		}

		if (!ok) return "No";
	}
}

int main()
{
	while (1)
	{
		int n, d;
		cin >> n >> d;
		if (n == 0) return 0;

		cout << solve(n, d) << endl;
	}
}

Measured memory_bytes: 3252
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#define DEBUG 1

int N, A, B, C;
std::vector<int> l;

int dfs(int no, int a, int b, int c) {
  if (no == N) {
    if (a == 0 || b == 0 || c == 0) return INT_MAX - 30;
    else return std::abs(a - A) + std::abs(b - B) + std::abs(c - C) - 30;
  }

  int r0 = dfs(no + 1, a, b, c);
  int r1 = dfs(no + 1, a + l[no], b, c) + 10;
  int r2 = dfs(no + 1, a, b + l[no], c) + 10;
  int r3 = dfs(no + 1, a, b, c + l[no]) + 10;

  r0 = std::min(r0, r1);
  r0 = std::min(r0, r2);
  r0 = std::min(r0, r3);

  return r0;
}

int main() {
  std::cin >> N >> A >> B >> C;
  l = std::vector<int>(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> l[i];
  }
  std::cout << dfs(0, 0, 0, 0) << std::endl;
}


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

const int MAXV = 100010;
map<long long, long long> cnt;

int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long long n, sum = 0;
    cin >> n;
    
    for (long long i = 0, a; i < n; i++) {
        cin >> a;
        cnt[a]++;
        sum += a;
    }
    
    int q;
    cin >> q;
    
    while (q--) {
        long long a, b;
        cin >> a >> b;
        sum += cnt[a]*(b - a);
        cout << sum << endl;
        cnt[b] += cnt[a], cnt[a] = 0;
        
    }
    
    return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = x ; i < n ; ++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 SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int n;
vector<int> h;
int memo[100010];

int solve(int i){
    if(i == 0){
        return 0;
    }
    if(i == 1){
        return abs(h[1] - h[0]);
    }
    if(memo[i] >= 0){
        return memo[i];
    }
    return memo[i] = min(solve(i - 1) + abs(h[i] - h[i - 1]), solve(i - 2) + abs(h[i] - h[i - 2]));
}

int main(){
    cin >> n;
    h.resize(n);
    rep(i, n){
        cin >> h[i];
    }
    fill(memo, memo + n, -1);
    int ans = solve(n - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,n;
while(cin>>l>>n){
  map<int ,string>m;
    for(i=1;i<=l;i++){
        char s[10000];
        cin>>s;
        m.insert({i,s});
    }
    for(i=0;i<=l+1;i++){
        if(i==0) for(j=0;j<=n+1;j++) cout<<"#";
        else if(i==l+1) for(j=0;j<=n+1;j++) cout<<"#";
        else{
            cout<<"#"<<m[i]<<"#";
        } cout<<endl;
    }

} return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MAX = 2000000;
const ll MOD = 1000000007;
ll n;

int main() {
    cin >> n;
    ll side1[400000];
    ll side2[400000];
    ll count = 0;
    for(ll i=0;i<400000;i++){
        side1[i] = 0;
        side2[i] = 0;
    }
    for(ll i=0;i<n;i++){
        ll atemp = 0;
        cin >> atemp;
        if(atemp<=200000){
            side1[i+atemp]++;
        }
        if(i-atemp>=0){
            side2[i-atemp]++;
        }
    }
    for(ll i=0;i<400000;i++){
        count += side1[i]*side2[i];
    }
    cout << count << endl;
    return 0;
}

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

int main () {

  int a,b; cin >> a >>b;
  
  if (a>b){
    for (int i=0; i<a; i++) {
      cout << b ;
    }
  }
  else 
    for (int i=0; i<b; i++) {
      cout << a ;
    }
}

Measured memory_bytes: 256
// A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pq priority_queue<int> 
#define pqs priority_queue<int,vector<int>, greater<int>>
#define setbits(x) __builtin_popcountll(x)  // no of ones in setbit
#define zrobits(x) __builtin_ctzll(x)       //101000 here 3..no of 0 aftrer 1sr right one 
#define mod 1000000007
#define inf 1e18
#define ps(x,y)  fixed<<setprecision(y)<<x  // ans upto 5 decimal place 
#define mk(ar,n,type) type *arr=new type[n];
#define w(x) int x;cin>>x;while(x--)
int dp[1000000]; 



int  fn(int arr[],int i , int n)
{
	if(i==n)
	{
		return 0 ; 
	}

	if(i==n-1)
	{
		return abs(arr[i]-arr[n]) ; 

	}
	if(dp[i] !=-1)
	{
		return dp[i] ; 
	}

	int x=  abs(arr[i]-arr[i+1])+fn(arr, i+1, n) ; 
	int y=  abs(arr[i]-arr[i+2])+fn(arr, i+2, n); 

	return dp[i]= min(x, y) ; 
	
}



int32_t main()
{
	int n ; 
	cin>>n ; 
	int arr[n+10] ; 
	memset(dp, -1, sizeof(dp)) ; 

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

	cout<<fn(arr,1 , n) ; 

}

Measured memory_bytes: 16640
A,B=map(int,input().split())
Aans=0
for i in range(10000):
  if int(i*0.08)==A:
    Aans=i
    break
    
Bans=0
for i in range(10000):
  if int(i*0.1)==B:
    Bans=i
    break

if Aans > Bans:
  if (int(Aans*0.1))==B:
    print(Aans)
  else:
    print("-1")
elif Aans < Bans:
  if (int(Bans*0.08))==A:
    print(Bans)
  else:
    print("-1")
else:
  print(Aans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define source 200
#define sink 201
#define pii pair<long long, long long>
using namespace std;
 
const long long INF = 2e16;
 
int N;
long long A[205];
vector<int> adj[205];
long long cap[205][205];
int par[205];
 
void edge(int u, int v, long long c) {
  adj[u].push_back(v);
  adj[v].push_back(u);
//  cout << u << " -> " << v << " " << c << "\n";
  cap[u][v] = c;
}
 
long long BFS() {
  memset(par, -1, sizeof(par));
  queue<pii> q;
  q.emplace(source, INF);
  while(!q.empty()) {
    int u = q.front().first;
    long long flow = q.front().second;
//    cout << u << " " << flow << "\n";
    q.pop();
 
    for(int v : adj[u]) {
      if(par[v] == -1 && cap[u][v] > 0) {
        par[v] = u;
        long long new_flow = min(flow, cap[u][v]);
        if(v == sink) return new_flow;
        q.emplace(v, new_flow);
      }
    }
  }
//  cout << "NO\n" << "\n";
  return 0;
}
 
long long macflow() {
  long long flow = 0, new_flow;
  while(1) {
    new_flow = BFS();
    if(new_flow == 0) break;
    flow += new_flow;
    int u = sink;
    while(u != source) {
      cap[par[u]][u] -= new_flow;
      cap[u][par[u]] += new_flow;
      u = par[u];
    }
  }
//  cout << flow << "\n";
  return flow;
}
 
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  long long sum = 0;
  for(int i = 1; i <= N; i++) {
    cin >> A[i];
    if(A[i] < 0) {
      edge(source, i, -A[i]);
    }else {
      edge(i, sink, A[i]);
      sum += A[i];
    }
    for(int j = i * 2; j <= N; j += i) {
      edge(i, j, INF);
    }
  }
  long long ans = macflow();
//  cout << ans << "\n";
  cout << sum - ans << "\n";
  cin >> N;
}

Measured memory_bytes: 3812
N = int(input())
a = ["null"]*N
for i in range(N):
  a[i] = input()
  
ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
  if a[i] == 'AC':
    ac += 1
  elif a[i] == 'WA':
    wa += 1
  elif a[i] == 'TLE':
    tle += 1
  else:
    re += 1

print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)

Measured memory_bytes: 16176
#include<bits/stdc++.h>
using namespace std;
#define     siii(a,b,c)       scanf("%d%d%d",&a,&b,&c)
#define     si(a)             scanf("%d",&a)
#define     sii(a,b)          scanf("%d%d",&a,&b)
#define     sl(a)             scanf("%lld",&a);
#define     sll(a,b)          scanf("%lld%lld",&a,&b);
#define     slll(a,b,c)       scanf("%lld%lld%lld",&a,&b,&c);
#define     sd(a)             scanf("%lf",&a);
#define     sdd(a,b)          scanf("%lf%lf",&a,&b);
#define     pb(a)             push_back(a)
#define     deb(a)            printf("### %d ###\n",a)
#define     mp                make_pair
#define     pf                printf
#define     fl(a, b, c)       for(int a= b ;a<c;a++)
#define     mx                100000 //10^5
#define     fread             freopen("input.txt","r",stdin)
#define     CLR(a,b)          memset(a,b,szof(a))
#define     ll                long long
#define     D(x)              cout<<#x" = "<<x<<endl;
#define     sz                10000
#define     bl                printf("\n")
#define     spc               printf(" ")


int main()
{
    string ans ="";
    string s;
    cin>>s;
    int w;
    si(w);
    int n = w;
    int ln = s.length();
    fl(i,0,ln){
        if(n == w){
            ans+=s[i];
        }
        n--;
        if(!n){
            n = w;
        }


    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, s, i, a[105];
int main() {
	cin>>n;
	for(i=0; i<n; i++) cin>>a[i];
	sort(a, a+n, greater<int>());
	for(i=0; i<n; i++) i%2 ? s-=a[i] : s+=a[i];
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
N,M=map(int,input().split())

def get_par(x):
  if x == par_list[x]:
    return x
  else:
    par_list[x] = get_par(par_list[x])
    return par_list[x]
def merge(x,y):
  par_x = get_par(x)
  par_y = get_par(y)
  if par_x != par_y:
    par_list[par_y] = par_x
    siz_list[par_x]+= siz_list[par_y]
def is_same(x,y):
  return get_par(x) == get_par(y)

par_list = list(range(N+1))
siz_list = [1]*(N+1)

for _ in range(M):
  a,b=map(int,input().split())
  merge(a,b)
  
for i in range(1,N+1):
  par_list[i]=get_par(i)
  siz_list[i]=siz_list[par_list[i]]
  
set_comp=set()
for i in range(1,N+1):
  set_comp.add(par_list[i])
  
print(len(set_comp)-1)

Measured memory_bytes: 18828
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations, combinations_with_replacement
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


n,k = MI()
d = []
a = []
for _ in range(k):
	tmp = II()
	d.append(tmp)
	tmp = LI()
	for i in (tmp):
		a.append(i)
p = n -len(list(set(a)))
print(p)



















Measured memory_bytes: 68340
N,A,B=map(int,input().split(' '))
if abs(B-A)%2==0:
    print(abs(B-A)//2)
else:
     l = min(A-1,B-1)+1+(abs(A-B)-1)//2
     r = min(N-A,N-B)+1+(abs(A-B)-1)//2
     print(min(l,r))

Measured memory_bytes: 3060
program prob
    implicit none
    character(12) :: s
    integer :: i, n, cnt
    logical :: ans
    read(*,*) s
    ans = .true.
    if(s(1:1) /= 'A')then
        ans = .false.
    end if
    n = len_trim(s)
    do i = 2, n
        if(ichar(s(i:i)) - ichar('a') >= 26 .or. ichar(s(i:i)) - ichar('a') < 0)then
            if(s(i:i) /= 'C')then
                ans = .false.
            end if
        end if
    end do
    cnt = 0
    do i = 3, n-1
        if(s(i:i) == 'C')then
            cnt = cnt + 1
        end if
    end do
    if(cnt /= 1)then
        ans = .false.
    end if
    if(ans)then
        write(*,'(a)') 'AC'
    else
        write(*,'(a)') 'WA'
    end if

    stop
contains
end program prob

Measured memory_bytes: 2920
import * as fs from 'fs';

namespace AtCoder.abc101 {
    class Program {
        constructor(private readonly args: string[]) {
        }

        main(this: Program): void {
            const n: number = parseInt(this.args[0], 10);
            const s: number = n.toString().split('').reduce((acc: number, cuu: string) => {
                return acc + parseInt(cuu, 10);
            }, 0);

            n % s === 0 ? console.log('Yes') : console.log('No');
        }
    }

    const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const prg = new Program(args);
    prg.main();
}

Measured memory_bytes: 7372
import numpy as np
np
d = int(input())
c = [None] + list(map(int, input().split()))
s = [None] + [[None] + list(map(int, input().split())) for _ in range(d)]
t = [None] + [int(input()) for _ in range(d)]
last = np.zeros(27, dtype="i8")

satisfaction = 0
for i in range(1, d + 1):
    last += 1
    last[t[i]] = 0
    satisfaction += s[i][t[i]]
    for j in range(1, 27):
        satisfaction -= c[j] * (last[j])
    print(satisfaction)

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

int main(void)
{
    int n, i;
    cin >> n;
    long long sum, a[200010];
    sum = 0;
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (i = 0; i < n - 1; i++)
    {

        if (a[i] > a[i + 1])
        {
            sum = sum + a[i] - a[i + 1];
            a[i + 1] = a[i];
        }
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n, m;
  cin >> n >> m;
  vector<vector<bool>> p(n, vector<bool>(n, false));
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    p[a][b] = true;
    p[b][a] = true;
  }

  vector<int> g(n);
  for (int i = 0; i < n; ++i) {
    g[i] = i;
  }

  int ans = 0;
  do {
    if (g[0] != 0) break;
    bool ok = true;
    for (int i = 1; i < n; ++i) {
      if (p[g[i - 1]][g[i]] == false) ok = false;
    }
    if (ok == true) ++ans;
  } while (next_permutation(g.begin(), g.end()));

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	v := 0
	for a&1 == 0 && b&1 == 0 && c&1 == 0 {
		v++
		a, b, c = (b+c)/2, (a+c)/2, (a+b)/2
		if a == b && b == c {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(v)
}


Measured memory_bytes: 1768