akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <utility>
#include <functional>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

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

	while (n) {
		vector<int> price(n);
		rep(i, 0, n) cin >> price[i];

		SORT(price);
		REV(price);
		int ans = -1;
		rep(i, 0, n - 1) {
			rep(j, i + 1, n) {
				int sum = price[i] + price[j];
				if (sum <= m) ans = max(ans, sum);
			}
		}
		if (ans == -1) cout << "NONE" << endl;
		else cout << ans << endl;

		cin >> n >> m;
	}

	return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, cnt = 0, m = 0;
    string s;
    cin >> n >> s;
    for(int i = 1; i <= n; i++){
        string left = s.substr(0,i), right = s.substr(i, n-i);

        sort(left.begin(), left.end());
        left.erase(unique(left.begin(), left.end()), left.end());
        sort(right.begin(), right.end());
        right.erase(unique(right.begin(), right.end()), right.end());

        for(int j = 0; j < left.length(); j++){
            if(right.find(left[j]) != string::npos){
                cnt++;
            }
        }
        m = max(m, cnt);
        cnt = 0;
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 200000 + 10;
char s[N];
int main() {
	scanf("%s",s);
	int n=strlen(s);
	if(n%2) return !printf("No\n");
	for(int i=0;i<n;i+=2){
		if(!(s[i]=='h'&&s[i+1]=='i')) return !printf("No\n");
	}
	return !printf("Yes\n");
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

const ll INF = 1LL << 40;

void solve(int n) {
    vector<ll> L(n);
    vector<vector<int> > S(n), E(n);
    int M;
    for (int i = 0; i < n; ++i) {
        cin >> M >> L[i];
        int s, e;
        for (int j = 0; j < M; ++j) {
            cin >> s >> e;
            s -= 6, e -= 6;
            S[i].push_back(s);
            E[i].push_back(e);
        }
    }
    vector<vector<ll> > dp(n + 1, vector<ll>(1 << 16, -INF));
    for (int i = 0; i <= n; ++i) dp[i][0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int mask = 0; mask < 1 << 16; ++mask) {
            dp[i][mask] = dp[i - 1][mask];
            bool is_ok = true;
            for (int j = 0; j < S[i - 1].size(); ++j) {
                for (int k = S[i - 1][j]; k < E[i - 1][j]; ++k) {
                    if (((mask >> k) & 1) == 0) {
                        is_ok = false;
                        break;
                    }
                }
                if (!is_ok) break;
            }
            if (!is_ok) continue;
            int prev_mask = mask;
            for (int j = 0; j < S[i - 1].size(); ++j) {
                for (int k = S[i - 1][j]; k < E[i - 1][j]; ++k) {
                    prev_mask ^= 1 << k;
                }
            }
            dp[i][mask] = max(dp[i][mask], dp[i - 1][prev_mask] + L[i - 1]);
        }
    }
    ll ans = -INF;
    for (int mask = 0; mask < 1 << 16; ++mask) {
        ans = max(ans, dp[n][mask]);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    while (true) {
        cin >> N;
        if (N == 0) break;
        solve(N);
    }
    return 0;
}


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

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;


int main(){
	int n,k;
	cin>>n>>k;

	ll ans=pow(n/k,3);
	if(k%2==0){
		ans+=pow((n+k/2)/k,3);
	}

	cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int INF = 1001001009;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        // to: 隣接リスト
        List<Integer>[] to = new List[n];
        for (int i = 0; i < n; i++) {
            to[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < m; i++) {
            int s = sc.nextInt() - 1;
            int t = sc.nextInt() - 1;
            to[s].add(t);
            to[t].add(s); 
        }
        
        
        // visited: 当該点を既に通ったか否か 
        boolean[] visited = new boolean[n];
        visited[0] = true;
        
        // last: 各点の最終値
        int[] num = new int[n];
        Arrays.fill(num, INF);
        // 頂点0から順に、親から子へ初期値を配り最終値を求める
        Queue<int[]> que = new ArrayDeque<int[]>();
        que.add(new int[]{0, -1});
        while (!que.isEmpty()) {
            int[] cur = que.poll();
            int p = cur[0];
            int par = cur[1];
            
            for (Integer q : to[p]) {
                if (!visited[q]) {
                    que.add(new int[]{q, p});
                    visited[q] = true;
                    num[q] = p;
                }
            }
        }
        
        for (int i = 1; i < n; i++) {
            if (num[i] == INF) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
        for (int i = 1; i < n; i++) {
            System.out.println(num[i]+1);
        }
    }
}

Measured memory_bytes: 83700
s = input()
n = len(s)


def dfs(now, total, i):
    if i == n:
        return total + now
    else:
        res = 0
        res += dfs(now * 10 + int(s[i]), total, i + 1)
        res += dfs(int(s[i]), total + now, i + 1)
        return res


print(dfs(int(s[0]), 0, 1))


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

using namespace std;

const int mod = 1e9 + 7;
const int INF = 1e6;

long long add(long long a, long long b) {
    long long res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

long long sub(long long a, long long b) {
    long long res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

long long mul(long long a, long long b) {
    return (((a % mod) * (b % mod)) % mod);
}

long long potolok(long long a, long long b){   // округление вверх для целых
    return (a + b - 1) / b;
}


long long gcd(long long x, long long y){
    if(y == 0){
        return x;
    }
    if(x > y){
         return gcd(y, x % y);
    }
    else{
         return gcd(x, y % x);
    }
}

bool cmpr(int x, int y){            // сортировка по абсолютной величине
    if(abs(x) < abs(y)) return true;
    else{
        return false;
    }
}

bool comp(pair<int, int> x, pair<int, int> y){  // сортировка по первой компоненте
    if(x.first < y.first)return true;
    else if(x.first == y.first){
        if(x.second < y.second)return true;
        else return false;
    }
    else{
        return false;
    }
}

int cnt(string &s, string &p, int m, int n){
    if((m == 0 && n == 0) || n == 0){
        return 1;
    }
    if(m == 0){
        return 0;
    }
    if(s[m - 1] == p[n - 1]){
        return cnt(s, p, m - 1, n - 1) + cnt(s, p, m - 1, n);
    }
    else{
        return cnt(s, p, m - 1, n);
    }
}

int main(){
    int n;
    cin >> n;
    int j = 0;
    for(int i = 0;i < n;i++){
        int x, y;
        cin >> x >> y;
        if(x == y){
            j++;
            if(j == 3){
                cout << "Yes" <<endl;
                return 0;
            }
        }
        else{
            j = 0;
        }
    }
    cout << "No" <<endl;
 }


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

typedef long long ll;

#define F for(int i = 0; i < N; i++)

int main() {

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll A = max(a * c, a * d);
    ll B = max(b * c, b * d);

    cout << max(A, B) << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string S, M;
	cin >> S >> M;
	int N = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == M[i]) {
			N + 0;
		}
		else {
			N++;
		}
	}
	cout << N << endl;
}

Measured memory_bytes: 3908
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

int main()
{
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  return 0;
}

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

using int64 = long long;

int64 Solve(const vector<int>& a) {
  const int n = a.size();
  int64 ret = 0;
  int i = 0, j = 0;
  int bits = 0;
  while (i < n) {
    while (j < n && (bits & a[j]) == 0) {
      bits ^= a[j];
      ++j;
      cerr << i << " " << j << "\n";
      ret += j - i;
    }
    bits ^= a[i];
    ++i;
  }
  return ret;
}

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

  cout << Solve(a) << "\n";

  return 0;
}


Measured memory_bytes: 1024
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(1,n-1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1]>p[i] and p[i] > p[i+1]):
        ans += 1
    else:
        ans += 0
print(ans)


Measured memory_bytes: 3060
//
//  practise.h
//  c++practise
//
//  Created by Ubnit04 on 2015/06/10.
//
//

#include <iostream>
#include <math.h>

using namespace std;

//float getSquare(float x1, float y1, float x2, float y2, float x3, float y3)
//{
//    float xAB, yAB;
//    float xBC, yBC;
//
//    xAB = x2 - x1;
//    yAB = y2 - y1;
//
//    xBC = x3 - x2;
//    yBC = y3 - y2;
//    
//    return fabs((xAB * yBC - yAB * xBC) / 2.0f); //square of tri-angle
//    
//}
//
//void isIn()
//{
//    float x1, y1;
//    float x2, y2;
//    float x3, y3;
//    float xp, yp;
//    
//    float sABC, sABP, sACP, sBCP;
//    
//    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp)
//    {
//        sABC = getSquare(x1, y1, x2, y2, x3, y3);
//        sABP = getSquare(x1, y1, x2, y2, xp, yp);
//        sBCP = getSquare(x2, y2, x3, y3, xp, yp);
//        sACP = getSquare(x1, y1, x3, y3, xp, yp);
//        
//        if((sABC > 0) && (sBCP > 0) && (sACP > 0))
//        {
//            if (sABC == sABP + sACP + sBCP) //if p is including triangle this should be worked
//            {
//                cout<<"YES"<<endl;
//            }
//            else if (sABC < sABP + sACP + sBCP)
//            {
//                cout<<"NO"<<endl;
//            }
//        }
//    }
//    
//    return;
//}

void isIn()
{
    float x1, y1;
    float x2, y2;
    float x3, y3;
    float xp, yp;
    
    float a, b, c;
    
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp)
    {
        a = (x3 - x2)*(yp - y2) - (y3 - y2)*(xp - x2);
        b = (x1 - x3)*(yp - y3) - (y1 - y3)*(xp - x3);
        c = (x2 - x1)*(yp - y1) - (y2 - y1)*(xp - x1);
        
        if((a >= 0 && b  >= 0 && c >= 0) || (a <= 0 && b <= 0 && c <= 0))
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
}

int main()
{
    isIn();
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll n; cin >> n;
  string p,q;
  rep(i,n){
    string c; cin >> c;
    p.append(c);
  }
  rep(i,n){
    string c; cin >> c;
    q.append(c);
  }
  vector<ll> v(n);
  rep(i,n){
    v[i]=i+1;
  }
  ll cnt=0;
  ll pn,qn;
  do{
    cnt++;
    string s;
    for(auto e:v){
      s.append(to_string(e));
    }
    if(s==p)pn=cnt;
    if(s==q)qn=cnt;    
  }while(next_permutation(v.begin(), v.end()));
  cout << abs(pn-qn);
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,x,a,ans=0,s=0;
int32_t main(){
CODE_START;
cin>>n;
cin>>x;
ans=1;
for(ll i=0;i<n;i++)
{
    cin>>a;
    s=s+a;
    if(s<=x){
        ans++;
    }
}
cout<<ans;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(A*B)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
#include <set>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 1<<17, TOL = 400;
const ll INF = 2e14;

ll __dp[2][2*TOL];
ll *dp[2];
P p[2*MAX];
int x[MAX], y[MAX], z[MAX];
ll dod[MAX];
int A, B, C;
int n;
int treb[MAX];

int main()
{
  REP(i, 2)
    dp[i] = &__dp[i][TOL];

  int sw=0;
  scanf("%d%d%d", &A, &B, &C);
  if (A < B) {
    swap(A, B);
    sw = 1;
  }
  n = A + B + C;

  ll poc = 0;
  REP(i, n) {
    scanf("%d%d%d", &x[i], &y[i], &z[i]);
    if (sw) swap(x[i], y[i]);
    x[i] -= z[i];
    y[i] -= z[i];
    poc += z[i];
    p[i] = P(x[i], y[i]);
  }
  
  int gor = A + B;
  double koef = (double) A / gor;
  
  REP(i, gor+1)
    treb[i] = (int) (koef * i);
  
  sort(p, p + n, greater<P>());
  //  random_shuffle(p, p + gor);

  set <P> NutraY; //val, poz
  set <P> VaniY; //val, poz
  set <P> NutraX;
  set <P> VaniX;

  ll tmpsum = 0;  
  REP(i, A) {
    NutraX.insert({p[i].Y-p[i].X, i});
    tmpsum += p[i].X;
  }

  FOR(i, A, n)
    VaniX.insert({p[i].X, i});    

  FOR(i, A, n)
    VaniY.insert({p[i].Y, i});    

  REP(i, B) {
    auto it = --VaniY.end();
    tmpsum += it->X;
    NutraY.insert(*it);
    VaniY.erase(it);
  }      

  // REP(i, n)
  //   printf("PPP %d    %d %d\n", i, p[i].X, p[i].Y);

  ll rje = tmpsum;
  //  TRACE(rje);
  for (; !VaniX.empty(); ) {
    auto tmp = --VaniX.end();
    
    auto gdje = NutraY.find({p[tmp->Y].Y, tmp->Y});
    if (gdje != NutraY.end()) {
      NutraY.erase(gdje);
      tmpsum -= gdje->X;
      //      TRACE(gdje->X _ gdje->Y);
    }

//    TRACE(tmp->X _ tmp->Y);
    tmpsum += tmp->X;
    NutraX.insert({p[tmp->Y].Y - p[tmp->Y].X, tmp->Y});
    VaniX.erase(tmp);   

    assert(!NutraX.empty());
    auto izb = --NutraX.end();
    //    TRACE(izb->X _ izb->Y);
    tmpsum += izb->X;

    NutraY.insert({p[izb->Y].Y, izb->Y});
    NutraX.erase(izb);

    for (; (int) NutraY.size() > B; ) {
      auto it = NutraY.begin();
      VaniY.insert(*it);
      tmpsum -= it->X;
      NutraY.erase(it);
    }

    for (; (int) NutraY.size() < B; ) {
      assert(VaniY.size());
      auto it = --VaniY.end();
      if (NutraY.find(*it) != NutraY.end() || NutraX.find({p[it->Y].Y-p[it->Y].X, it->Y}) != NutraX.end()) {
	VaniY.erase(it);
	continue;
      }	

      //      TRACE(it->X _ it->Y);
      tmpsum += it->X;
      NutraY.insert(*it);
      VaniY.erase(it);
    }

    //    TRACE(NutraY.size() _ B);

    //    TRACE("aaa" _ tmpsum);
    
    if (tmpsum + poc == 114) exit(0);
    rje = max(rje, tmpsum);
  }
  
  printf("%lld\n", rje + poc);  

  return 0;
}


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

int main() {
	int n;
	cin >> n;
	
	for (int i=1; i<=n; i=i+1) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
	 	} else {
			while (x % 10 != 3 && x > 0) {
				x = x / 10;
			}
			if (x % 10 == 3)
				cout << " " << i;
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3096
def countYakusu(N):
    count = 1
    for i in range(2, N + 1):
        count += [0,1][N % i == 0]
    return count

def NumOfYaku(num):
    ret_count = 0
    for j in range(1, num + 1, 2):
        if countYakusu(j) == 8:
            ret_count += 1
    return ret_count


if __name__ == '__main__':
    N = int(input())
    print(NumOfYaku(N))

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

vector<int> color;
vector<vector<int>> edge;

bool dfs(int node, int c){
    if(color[node] == 0){
        color[node] = -1 * c;
        for(int n_node : edge[node]){
            if(!dfs(n_node, color[node])){
                return false;
            }
        }
        return true;
    }else{
        if(color[node] == c){
            return false;
        }else{
            return true;
        }
    }
}

int main(){
    while(1){
        int N, M;
        cin >> N >> M;
        if(N == 0){
            break;
        }
        edge.assign(N, vector<int>(0));
        int u, v;
        for(int i = 0;i < M; ++i){
            cin >> u >> v;
            edge[u - 1].push_back(v - 1);
            edge[v - 1].push_back(u - 1);
        }
        color.assign(N, 0);
        vector<int> ans;
        if(!dfs(0, 1)){
            cout << 0 << endl;
        }else{
            vector<int> iro(2);
            iro[0] = count(color.begin(), color.end(), 1);
            iro[1] = N - iro[0];
            for(int n : iro){
                if(n % 2 == 0){
                    ans.push_back(n / 2);
                }
            }
            if((int)ans.size() == 0){
                cout << 0 << endl;
            }else if((int)ans.size() == 1){
                cout << 1 << endl;
                cout << ans[0] << endl;
            }else{
                if(ans[0] == ans[1]){
                    cout << 1 << endl;
                    cout << ans[0] << endl;
                }else{
                    cout << 2 << endl;
                    sort(ans.begin(), ans.end());
                    cout << ans[0] << endl << ans[1] << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

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; }

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

const double PI = acos(-1.0);
/*
int N,Q;
vector<ll> a,x;
ll solve(ll K){
    ll r = 0;
    ll sum = 0;
    ll res = 0;
    for(ll l = 0; l < N; l++){
        while(r < N && sum + a[r] <= K){
            sum += a[r];
            r++;
        }
        res += r - l;
        if(l == r)r++;
        else sum -= a[l];
    }
    return res;
}
*/
int main() {
    int N,Q;
    cin>>N>>Q;
    vector<ll> a(N),x(Q);
    rep(i,N)cin>>a[i];
    rep(i,Q)cin>>x[i];
    auto solve = [&](ll K){
        ll r = 0;
        ll sum = 0;
        ll res = 0;
        for(ll l = 0; l < N; l++){
            while(r < N && sum + a[r] <= K){
                sum += a[r];
                r++;
            }
            res += r - l;
            if(l == r)r++;
            else sum -= a[l];
        }
        return res;
    };
    rep(i,Q){
        cout<<solve(x[i])<<endl;;
    }
}


Measured memory_bytes: 3552
# -*- coding: utf-8 -*-
"""
Created on Sat Apr  4 21:00:18 2020

@author: Kanaru Sato
"""

x,y,z = list(map(int, input().split()))

tmp = x
x = y
y = tmp
tmp = x
x = z
z = tmp

lis = [x,y,z]

print(" ".join(map(str,lis)))

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

int main() {
    int n, ans = 0;
    cin >> n;
    char s[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf(" %c", &s[i][j]);
        }
    }
    for (int k = 0; k < n; k++) {
        bool isGood = true;
        // 処理
        for (int i = 1; i < n; i++) {
            for (int j = i; j < n; j++) {
                if (s[i-1][j] != s[j][i-1]) isGood = false;
            }
        }
        if (isGood) ans += n;
        // swap
        for (int i = 0; i < n; i++) {
            for (int j = 1; j < n; j++) {
                swap(s[i][j-1], s[i][j]);
            }
        }
    }
    if (n == 1) ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		for (int i=0;i<S.length()-1;i++) {
			if ("AC".equals(S.substring(i, i+2))) {
				System.out.println("Yes");
				return ;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int h[N];
int dp[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    memset(dp,127,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
}


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

int main(){
    ll n;
    cin>>n;
    ll sum=0;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
        sum+=a[i];
    }
    ll t;
    if(sum>=0){
        t=round(double(sum)/n);
    }else{
        //cout<<-1*int(double(sum)/n*10)%10<<endl;
        if(-1*int(double(sum)/n*10)%10>=5){
            t=(sum+sum-1)/n;
        }else{
            t=sum/n;
        }
        
    }
    //cout<<t<<endl;
    ll ans=0;
    for(ll i=0;i<n;++i){
        ans+=(t-a[i])*(t-a[i]);
    }
    cout<<ans;
}

Measured memory_bytes: 3572
l = sorted(list(map(int,input().split())))
z = l[0]
y = l[1]
x = l[2]
# x > y > z

ans = 0

if (y-z) % 2 == 0:
    ans += (y-z)//2
    ans += (x-y)
else:
    x += 1
    z += 1
    ans += 1
    ans += (y-z)//2
    ans += (x-y)
print(ans)

Measured memory_bytes: 61816
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long int ll;

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> len(n, 1);
	vector<ll> s(n, 0);
	vector<ll> p(n);
	vector<ll> c(n);
	for (int i = 0; i < n; i++)
		cin >> p[i], p[i] -= 1;
	for (int i = 0; i < n; i++)
		cin >> c[i];
	for (int i = 0; i < n; i++){
		ll cur = p[i];
		while (cur != i){
			len[i] += 1;
			s[i] += c[cur];
			cur = p[cur];
		}
		s[i] += c[i];
	}
	ll ans = -5e13;
	for (int i = 0; i < n; i++){
		bool done = false;
		ll t = k / len[i] - 1;
		if (t < 0) t = 0;
		ll tmp = 0, su = 0, ma = 0;
		if (s[i] >= 0) tmp += t * s[i], done = true;
		int start = i;
		for (int j = 0; j < k - t * len[i]; j++){
			start = p[start];
			su += c[start];
			if (!done || su > ma) done = true, ma = su;
		}
		tmp += ma;
		ans = max(ans, tmp);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3740
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

const ll MOD = (1e9+7);

#define MAX_NUM 1000000
bool era[MAX_NUM+1]={false};

void makeERA(){
    for(int i=2;i<MAX_NUM;i++){
        if(era[i]==true){
            int x=MAX_NUM/i;
            for(int j=2;j<=x;j++){
                era[i*j]=false;
            }
        }
    }
    era[2]=true;
}

int main(){
    for(int i=0;i<MAX_NUM;i++)era[i]=true;
    era[0]=false;era[1]=false;
    makeERA();
    
    int n;
    cin>>n;
    vector<int> q(n);
    rep(i,n)cin>>q[i];
    
    
    static ll dp[100001][2];
    rep(i,100001)rep(j,2)dp[i][j] = 0;
    if(era[q[0]]){
        dp[0][0] = 1;
        dp[1][1] = 1;
    }
    
    
    for(int i=1;i<n;i++){
        rep(j,2){
            rep(l,2){
                if( era[q[i-j]] == false )dp[i][j] = 0;
                else{
                    if(i-1-j-l>=0 && q[i-j]>q[i-1-j-l]){
//                        cout<<i<<" "<<j<<" = "<<i-1-j<<" "<<l<<endl;
                        (dp[i][j] += dp[i-1-j][l])%=MOD;
                    }
                }
            }
        }
    }
    
    cout<<(dp[n-1][0] + dp[n-1][1])%MOD<<endl;
}



Measured memory_bytes: 5744
#include<iostream>
#include<vector>
#define MAX 200000
#define NIL 0
using namespace std;

int main(){
    int n;
    cin >> n;
    int T[MAX];
    for(int i = 1;i < n;i++){
        T[i] = NIL;
    }
    for(int id = 1;id < n;id++){
        int num;
        cin >> num;
        T[num - 1]++;
    }

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

    return 0;
}

Measured memory_bytes: 4368
#include<iostream>
#include<stdio.h>
#include<string>
#include<cstring>
using namespace std;
int main(){
    string i,j;
    cin >> i >> j;
    i = i+i;
    if(i.find(j) != -1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    } 
}


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

using namespace std;
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i = j; i < k; i += step)
#define loop(i, j, k) for (int i = j; i < k; i++)
#define rloop1(i, j, k, step) for (int i = j; i >= k; i -= step)
#define rloop(i, j, k) for (int i = j; i >= k; i--)
#define rep(i, k) for (int i = (0); i < (k); i++)
#define rrep(i, k) for (int i = k - 1; i >= 0; i--)
#define forall(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define lin "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(0)
#define PI 2 * acos(0.0)
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// bool sortinrev(const pair<int, int> &a,
//                const pair<int, int> &b)
// {
//     return (a.first > b.first);
// }
// bool spOrder(const pair<int, int> &a,
//              const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first > b.first;
//  }
void solve() {
    int ans = 0;
    for (int i = 0; i < 5; ++i) {
        int x;
        cin >> x;
        if (!x) {
            ans = i + 1;
        }
    }
    cout << ans << lin;
}

int main() {
    auto start = clock();
    fast_io;
    // freopen("test.txt", "r", stdin);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    auto stop = clock();
//    cerr << "time taken:" << double(stop - start) / double(CLOCKS_PER_SEC) << " s" << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m,q;
  cin >> n >> m >> q;
  int a[q],b[q],c[q],d[q];
  rep(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  int w[n];
  int ans=0;
  rep(i,n)w[i]=1;
  while(w[0]!=m){
    int u=n-1;
    while(w[u]==m){
      u--;
    }
    w[u]++;
    rep(j,n-1-u)w[n-1-j]=w[u];
    int y=0;
    rep(i,q){
      if(w[b[i]-1]-w[a[i]-1]==c[i])y+=d[i];
    }
    ans=max(y,ans);
  }
  if(m==1){
    int y=0;
    rep(i,q){
      if(w[b[i]-1]-w[a[i]-1]==c[i])y+=d[i];
    }
    ans=max(y,ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<bool> f(40001); 
    for(int mask = 0; mask < (1LL << n); mask++){
        int sum = 0;
        rep(i, 0, n){
            if(mask & (1LL << i)) sum += a[i];
        }
        f[sum] = true;
    }
    int q;
    cin >> q;
    rep(i, 0, q){
        int m;
        cin >> m;
        if(f[m]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int x;
  cin>>x;
  x/=200;
  x*=-1;
  x=10+x;
  cout<<x<<endl;
}

Measured memory_bytes: 3632
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}

#define X first
#define Y second
typedef pair<int, int> P;

inline int square(int x) {
	return x * x;	
}

inline int area(const P& a, const P& b) {
	return square(abs(a.X - b.X)) + square(abs(a.Y - b.Y));
}

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

	for(int n; cin >> n, n;) {
		vector<vector<bool> > exists(5001, vector<bool>(5001, false));
		vector<P> points(n);
		for(int i = 0; i < n; ++i) {
			cin >> points[i];
			exists[points[i].Y][points[i].X] = true;
		}

		int ans = 0;
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < n; ++j) {
				int dx = points[i].X - points[j].X;
				int dy = points[i].Y - points[j].Y;

				if(points[i].Y + dx < 0 || points[i].Y + dx > 5000
				   || points[i].X - dy < 0 || points[i].X - dy > 5000
				   || points[j].Y + dx < 0 || points[j].Y + dx > 5000
				   || points[j].X - dy < 0 || points[j].X - dy > 5000)
					continue;

				if(exists[points[i].Y + dx][points[i].X - dy]
				   && exists[points[j].Y + dx][points[j].X - dy])
					chmax(ans, area(points[i], points[j]));
			}
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

using namespace std;
long long a[64];
const long long mod=1e9+7;
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        long long b;
        cin>>b;
        for(int j=0; j<60; j++)
        {
            if(b%2)
                a[j]++;
            b>>=1;
        }
    }
    long long ans=0;
    for(int i=0; i<61; i++)
    {
        ans=(ans+((a[i]*(n-a[i])%mod)*((1LL<<i)%mod)))%mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

using sll = signed long long;
using ui =  long int;
class disjoint_set {
	std::vector<int> p;

	auto link(int x, int y) {

		//x = find(x);
		//y = find(y);

		if(x==y)
			return false;

		
		if ( size(x) < size(y) )
			std::swap(x, y);
		
		
		p[x] += p[y];
		p[y] = x;
		return true;
	}

public:
	disjoint_set()
		:p{}{}

	disjoint_set(int size_) :
		p{}
	{
		p.resize(size_, int{-1});
	}

	auto find(int x)
		->decltype(p)::value_type {
		
		return p[x] < 0 ? 
			x : p[x] = find(p[x]);
	}


	auto same(int x, int y) {
		return
			find(x) == find(y);
	}

	auto unite(int x, int y) {
		this->link(find(x), find(y));
	}

	auto size(int x)
		->decltype(p)::value_type{
		return -p[ this->find(x) ];
	}

};

int main() {


	int n, m;
	std::cin >> n >> m;

	std::vector< std::pair<int, int> > vp;

	disjoint_set ds{ n };
	vp.resize(m);


	for (int i{}; i < m; ++i) {
		int a, b;
		std::cin >> a >> b;

		vp[i] = std::make_pair(a-1, b-1);
	}



	auto it = std::rbegin(vp);
	auto end_ = std::rend(vp);

	auto ansi = sll{ n } *(n - 1) / 2;

	std::vector<sll> ans{};
	ans.resize(m, 0);
	ans[m - 1] = ansi;


	for (int i{m-1}; i > 0; --i) {
		
		auto a = it->first;
		auto b = it->second;

		ans[i-1] = ans[i];
//		std::cout << " ab " << a+1 << " " << b+1 << "\n";
		if (!ds.same(a, b)) {
			auto x = ds.size(a);
			auto y = ds.size(b);

			ans[i-1] -= x * y;
			ds.unite(a, b);
//			std::cout <<" xy "<< x << " " << y << "\n";
			if (ans[i-1] < 0 )
				ans[i-1] = 0;
		}
		++it;
	}


	for (auto&e : ans)
		std::cout << e << "\n";
	

	return 0;
}

Measured memory_bytes: 3328
from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))


def main():
    num, min_num, max_num = map(int, input().split())
    data = list(map(int, input().split()))
    data.sort(reverse=True)

    last_ind = 0
    for i in range(num):
        if data[0] == data[i]:
            last_ind = i
        else:
            break

    sum_now = sum(data[:min_num])
    avg = sum_now / min_num
    now_ind = min_num
    ans_count = 0

    while 1:
        if now_ind >= num:
            break
        if data[now_ind] < avg:
            break
        sum_now += data[now_ind]
        now_ind += 1
        avg = sum_now / now_ind

    in_count = 0
    for i in range(now_ind):
        if data[now_ind - 1] == data[i]:
            in_count += 1

    out_count = 0
    for i in range(now_ind, num):
        if data[now_ind - 1] == data[i]:
            out_count += 1

    # print(in_count, out_count)

    if now_ind - 1 <= last_ind:
        toori = 0
        for i in range(min_num, min(now_ind + 1, max_num + 1)):
            toori += combinations_count(last_ind + 1, i)
    else:
        toori = combinations_count(in_count + out_count, in_count)

    # print(in_count, out_count, last_ind, now_ind)

    print(avg)
    print(toori)





if __name__ == '__main__':
    main()

Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){

    intf s,w;
    cin >>s >>w;
    if(s>w){
        cout << "safe" <<endl;
    }else{
        cout << "unsafe" <<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int vx = x2-x1,vy = y2-y1;
    int perx = -vy,pery = vx;
    cout << x2+perx << " " << y2+pery << " " << x1+perx << " " << y1+pery;
}

Measured memory_bytes: 256
//worst O(E*log(V))
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>

using namespace std;

const int INF = 0x7fffffff;
const int MAXV=10000+5;

struct edge{ int to; double cost; };
struct Point { int x,y; };
typedef pair<double, int> P; //first is max distance, second is vertex id

int V,M;
vector<edge> G[MAXV];
Point pts[MAXV];
double maxcost[MAXV];    //min cost from set X to other vertices
bool used[MAXV]; //used = true means in set X

double prim(int ss)
{
    //make priority queue sort bigger integer first
    priority_queue<P, vector<P> > que;
    
    maxcost[ss]=0.0;
    double res = 0.0;
    que.push(P(0.0,ss));

    while(!que.empty())
    {
        P p = que.top(); que.pop();
        int v = p.second;
        if(used[v]) continue;
        used[v] = true;
        res += maxcost[v];
        for(int i=0;i<G[v].size();++i)
        {
            edge e = G[v][i];
            if(maxcost[e.to] < e.cost)
            {
                maxcost[e.to] = e.cost;
                if(!used[e.to])
                    que.push(P(e.cost, e.to));
            }
        }
    }

    return res;
}

double getDistance(const Point &p1, const Point &p2)
{
    return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}

int main()
{
    scanf("%d%d",&V,&M);
    {
        for(int i=0;i<V;++i) G[i].clear();
        for(int i=0;i<V;++i)
            scanf("%d%d",&pts[i].x,&pts[i].y);
        int from,to;
        double all=0.0;
        for(int i=0;i<M;++i){
            scanf("%d%d",&from,&to);
            from--; to--;
            double dis = getDistance(pts[from], pts[to]);
            all += dis;
            G[from].push_back(edge{to, dis});
            G[to].push_back(edge{from, dis});
        }

        fill(maxcost, maxcost+V, 0);
        fill(used, used+V, false);

        for(int i=0;i<V;++i) {
            if(!used[i]) {
                double res = prim(i);
                all -= res;
            }
        }
        printf("%lf\n", all);
        //cout<<all<<endl;
    }
    return 0;
}


Measured memory_bytes: 5200
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



int main() {
    string s,t;
    cin>>s>>t;
    bool flg=true;
    map<char, char> c, ic;
    for (int i = 0; i < s.size(); i++) {
        if(c.count(s[i]))if(c[s[i]]!=t[i]){
            flg=false;
            break;
        }
        if(ic.count(t[i]))if(ic[t[i]]!=s[i]){
            flg=false;
            break;
        }
        c[s[i]]=t[i];
        ic[t[i]]=s[i];
    }
    if(flg)puts("Yes");
    else puts("No");

    return 0;
}

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

int main(void){
  int n; 
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b.at(i);
  }
  
  vector<int> c(n-1);
  for (int i = 0; i < n-1; i++) {
    cin >> c.at(i);
  }
  
  int ans = 0;
  
  int position = a.at(0);
  ans += b.at(position-1);
  
  for (int i = 1; i < a.size(); i++) {
    position = a.at(i);
    ans += b.at(position-1);
    if (a.at(i-1) + 1 == position) {
      ans += c.at(a.at(i-1)-1);
    }
  }
  
  cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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; }

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> count(n+10);
  for (ll i=1; i<=n; i++){
    for (ll j=i; j<=n; j+=i){
      count[j]++;
    }
  }
  ll ans = 0;
  REP(i, n+1) ans += i * count[i];
  cout << ans << endl;
  return 0;
}



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

int main(){
    int a,b;
    char op;
    
    while(1){
        cin >> a >>op >> b;
        if(op == '?') break;

        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;
    }
    return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int now = 1;
        int count = 0;
        while (now < B) {
        	count++;
        	now += A - 1;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21972
import scala.collection.mutable.ArrayBuffer

object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
	
	val n = sc.nextInt
	val p = Seq.fill(n)(sc.nextInt)
	
	var min = p(0)
	
	pw.println( p.foldLeft(1)((z, pi) => z + (if (pi < min) {min = pi; 1} else 0)) )
	pw.flush()
}

Measured memory_bytes: 80872
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<int,int>
#define iii pair<ii, int>
#define se second
#define ld long double
#define mod 1000000007
#define popcount __builtin_popcountll
#define PI acos(-1.0)
using namespace std;
int a[22][22];
int n;
bool ok(int mask, int idx){
    for(int i=0;i<n;i++){
        if(i==idx)continue;
        if(a[idx][i]==-1)continue;
        if(a[idx][i]==0 && (mask&(1<<i)))return 0;
        if(a[idx][i]==1 && !(mask&(1<<i)))return 0;
    }
    return 1;
}
int main(){
    cin>>n;
    memset(a,-1,sizeof a);
    for(int i=0;i<n;i++){
        int m;
        scanf("%d", &m);
        for(int j=1;j<=m;j++){
            int x, y;
            scanf("%d%d", &x, &y);
            a[i][x-1] = y;
        }
    }
    int amid = 0;
    for(int mask = 0;mask<(1<<n);mask++){
        bool f = 1;
        vector<int>v1, v2;
        for(int i=0;i<n;i++){
            if(mask&(1<<i))v1.pb(i);
            else v2.pb(i);
        }
        int sz = v1.size();
        for(int i=0;i<sz;i++){
            int x = v1[i];
            if(ok(mask, x)==0)f = 0;
        }
        if(f)amid = max(amid, sz);
    }
    cout<<amid<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	n %= 10;
	if (n == 2 || n == 4 || n == 5 || n == 7 | n == 9) {
		cout << "hon" << endl;
	}
	else if (n == 3) {
		cout << "bon" << endl;
	}
	else {
		cout << "pon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(int argc, const char * argv[]) {

    /////////////////////
    // Write code below /
    /////////////////////
    int sumOfDistance = 0;
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int x_i;
        cin >> x_i;
        
        int distanceOfRobotA = x_i * 2;
        int distanceOfRobotB = abs(K - x_i) * 2;
        if (distanceOfRobotA < distanceOfRobotB) {
            sumOfDistance += distanceOfRobotA;
        } else {
            sumOfDistance += distanceOfRobotB;
        }
    }
    
    cout << sumOfDistance << endl;
    
    
    return 0;
}


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

using namespace std;

int main()
{
  while(1){
    int D,E;
    cin>>D;
    cin>>E;
    if(D == 0 && E == 0){
      break;
    }

    vector<pair<int,int>> place;
    for(int i = 0;i <= D;++i){
      place.push_back(make_pair(i,D-i));
    }

    bool check = false;
    double ans;
    for(pair<int,int> e : place){
      int x = e.first;
      int y = e.second;

      x = x * x;
      y = y * y;
      double sum = x + y;
      double sq = sqrt(sum);

      if(sq - E < 0){
        sq = -(sq - E);
      }
      else{
        sq = sq - E;
      }

      //cout<<sq<<endl;

      if(check == false){
        ans = sq;
        check = true;
      }
      else{
        if(sq < ans){
          ans = sq;
        }
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3216
#include<stdio.h>
int main ()
{
    long long int n,b,r,c,d,re;
    scanf("%lld %lld %lld",&n, &b, &r);
    if (b==0)
    {
        re=0;
    }
    else
    {
        d=n/(b+r);
        c=n%(b+r);
        if (c<=b)
        {
            re=d*b+c;
        }
        else
        {
            re=d*b+b;
        }
    }
    printf("%lld\n",re);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    int N2 = N;
    int sm = 0;
    while(N>0){
        sm+=N%10;
        N/=10;
    }
    cout << ((N2%sm == 0)?"Yes":"No") << endl;
}

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;


int main()
{
  ll x, y;
  cin >> x >> y;

  int ans = 0;
  while(x <= y){
    ans++;
    x *= 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
s = list(input())
p = 0 #1010
q = 0 #0101
n = len(s)
for i in range(n):
    if i % 2 == 0:
        if s[i] == "1":
            p += 1
        else:
            q += 1
    else:
        if s[i] == "1":
            q += 1
        else:
            p += 1

print(n - max(p,q)) 

Measured memory_bytes: 3956