akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int main(void){
    string n;
    cin >> n;
    int sum = 0;
    rep(i, n.size())
        sum = (sum + n[i] - '0') % 9;
    if(sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>

#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}

struct Vec2 {
	double x;
	double y;

	void rotate(double rad) {
		double s = sin(rad);
		double c = cos(rad);
		double tmpX = this->x*c - this->y*s;
		double tmpY = this->x*s + this->y*c;
		this->x = tmpX;
		this->y = tmpY;
	}
};

int main(void) {

	ll n, m;
	cin >> n >> m;

	unordered_map<ll, std::vector<ll>> routes;

	for (ll i = 0; i < m; ++i) {
		ll a, b;
		cin >> a >> b;
		routes[a].push_back(b);
		routes[b].push_back(a);
	}

	const ll ROUTE_INVALID_VALUE = n + 1;
	vector<ll> answers(n+1, ROUTE_INVALID_VALUE);

	queue<ll> queue;
	queue.push(1);

	while (!queue.empty()) {

		ll point = queue.front();
		queue.pop();

		bool isSet = false;
		for (ll i = 0; i < routes[point].size(); ++i) {
			ll targetPoint = routes[point][i];
			if (answers[targetPoint] == ROUTE_INVALID_VALUE) {
				answers[targetPoint] = point;
				queue.push(targetPoint);
			}
			
		}

	}

	bool isOK = true;
	// データが1始まり
	for (auto i = 1; i < answers.size(); ++i) {
		isOK &= answers[i] != ROUTE_INVALID_VALUE;
	}

	if (isOK) {
		cout << "Yes" << endl;
		// 始点はいらないので+1
		for (auto i = 2; i < answers.size(); ++i) {
			cout << answers[i] << endl;
		}
	}
	else {
		cout << "No";
	}



	return 0;
}


Measured memory_bytes: 16984
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
int A[100000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, N) cin >> A[i];
  map<int, int> mp;
  int cur = 0;
  long long s = 0;
  mp[cur]++;
  rep(i, N) {
    cur = (cur+A[i])%M;
    s += mp[cur]++;
  }
  cout << s << "\n";
  return 0;
}


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

}

Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

	int N; cin >> N;
	vector<int> p(N);
	REP(i,N) cin >> p[i];

	int cnt = 0;
	REP(i,N) {
		if (p[i] == i + 1) {
			cnt++;
			i++;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

typedef long long ll;
typedef pair<int, int> Pair;

// const int kMaxN;

int A, B, C, D;
int ans = 0;

signed main() {
  cin >> A >> B >> C >> D;

  ans = MIN(A, B) + MIN(C, D);

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


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


int main(void){
    int X;
    cin>>X;
    int a=1;
    int i,j;
    int b;
    for(i=1;i<X;i++){//2乗での数値を把握
        a=i*i;
        if(a>X){
            a=(i-1)*(i-1);
            b=i-1;
            break;
        }
        b=i;
    }
    if(X==1) b=1;
    //cout << "b:"<<b<<endl;
    int max=X;
    int s;
    for(i=1;i<b+1;i++){
        s=1;
        for(j=1;j<12;j++){
            s*=i;//iのj乗
            if(abs(X-s)<=max&&s<=X){
                max=abs(X-s);//差
                //cout<<max<<endl;
            }
        }
    }

    
    cout <<X-max<<endl;
    return 0;
}

Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
// #define int unsigned long long int
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int mul1 = 1003, mul2 = 5, mul3 = 8;
const int MOD3 = 179424673, MOD2 = 982451653, MOD1 = 1190494759;
const ld EPS = 1e-9;

ll h,w,m;
vp64 bombs;
set<p64> bombs_pos;
v64 h_c, w_c;
v64 h_max_id, w_max_id;

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

    forn(i,h)
    {
        h_c.pb(0);
    }

    forn(i,w)
    {
        w_c.pb(0);
    }
    forn(i, m)
    {
        ll h1,w1;
        cin >> h1 >> w1;
        bombs.push_back(mp(h1, w1));
        bombs_pos.insert(mp(h1, w1));
        h_c[h1-1]++;
        w_c[w1-1]++;
    }


    ll max_h=0, max_w=0;

    int max_h_id, max_w_id;
    forn(i,h)
    {
        if (h_c[i] > max_h)
        {
            max_h = h_c[i];
        }
    }

    forn(i,w)
    {
        if (w_c[i] > max_w)
        {
            max_w = w_c[i];
        }
    }

    forn(i,h)
    {
        if (h_c[i] == max_h)
        {
            h_max_id.pb(i);
        }
    }

    forn(i,w)
    {
        if (w_c[i] == max_w)
        {
            w_max_id.pb(i);
        }
    }

    forstl(h_idx, h_max_id)
    {
        forstl(w_idx, w_max_id)
        {
            if (bombs_pos.find(mp(h_idx+1, w_idx+1)) == bombs_pos.end())
            {
                cout << max_h + max_w << endl;
                return 0;
            }
        }
    }

    cout << max_w + max_h - 1 << endl;
    return 0;
}

Measured memory_bytes: 40132
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define rep(i, l, r) for(int i = (l); i <= (r); i++)
#define per(i, r, l) for(int i = (r); i >= (l); i--)
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> os;

const int N = 2e5 + 5;

char s[N];
int n, prel[N], prer[N],pos[N];
int main(){
  scanf("%s", (s + 1));
  n = strlen(s + 1);
  rep(i, 1, n) {
    if(s[i] == 'L') prel[i] = prel[i - 1] + 1;
    else prel[i] = 0;
  }
  per(i, n, 1) {
    if(s[i] == 'R') prer[i] = prer[i + 1] + 1;
    else prer[i] = 0;
  }
  rep(i, 1, n)  {
    if(s[i] == 'L'){
      int mx = prel[i], mxpos = i - prel[i];
      if(mx % 2 == 1) pos[mxpos + 1]++;
      else pos[mxpos]++;
    }
    else if(s[i] == 'R') {
      int mx = prer[i], mxpos = i + prer[i];
      if(mx % 2 == 1) pos[mxpos - 1]++;
      else pos[mxpos]++;
    }
  }
  rep(i, 1, n) cout << pos[i] << " ";
	return 0;
}


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


class graph{

public:

map<int,vector<int>> m;
map<int,int> dp;



void addEdge(int u, int v){

    m[u].push_back(v);

}



int maxPath( int src, map<int,bool> &visited ){

    visited[src]=true;

    if(dp.find(src)!=dp.end()){
        return dp[src];

    }

    int ans=0;

    for( int i: m[src]){
        
        if(!visited[i]){
            ans=max(ans,1+maxPath(i,visited));
            visited[i]=false;

        }
    }

    return dp[src]=ans;




}

int longestPath(){

    int ans=0;
    

    map<int,bool> visited;

    for( auto p: m){
        visited.clear();
        //dp.clear();

       ans=max(ans,maxPath(p.first,visited));


    }

    return ans;


}


};

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

graph g;

for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    g.addEdge(x,y);

}

cout<<g.longestPath();


}


Measured memory_bytes: 20736
import java.util.Scanner;
import java.util.Stack;

import javax.rmi.ssl.SslRMIClientSocketFactory;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scan=new Scanner(System.in);
		
		Stack<Integer> s1=new Stack<>();
		Stack<Integer> s2=new Stack<>();
		Stack<Integer> s3=new Stack<>();
		
		int sum=0;
		int a;
		String str=scan.nextLine();
		int n=str.length();
		char[] ch=str.toCharArray();
		
		for(int i=0;i<n;i++){
			char c=ch[i];
			if(c=='\\'){
				s1.push(i);
			}
			else if(c=='/'&&s1.size()>0){
				int j=s1.pop();
				sum+=i-j;
				a=i-j;
				while(s2.size()>0&&s2.peek()>j){
					a+=s3.pop();
					s2.pop();
				}
				s2.push(j);
				s3.push(a);
			}
		}
		int m=s3.size();
		int[] ans=new int[m];
		System.out.println(sum);
		System.out.print(m);
		for(int i=m-1;i>=0;i--)
			ans[i]=s3.pop();
		for(int i=0;i<m;i++)
			System.out.print(" "+ans[i]);

		System.out.println();
	}

}



Measured memory_bytes: 30024
#include <iostream>
using namespace std;
int main(){
  int n,cnt=0;
  char s[1000];
  cin>>n>>s;
  for(int i=0; i<n; i++){
    if(s[i]=='A' && s[i+1]=='B' &&s[i+2]=='C'){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
int n,b[2][101];
int m[2][101];


int saiiki(int p,int q,int no){
if(m[p][q]==0)return 1000;
m[p][q]=0;
int i,j;
if(b[p][q]==1){
i=q;
while(b[p][i+1]==1)i++;
q=i;
}
else if(b[p][q]==2){
i=q;
while(b[p][i]==2)i--;
q=i;
}
if(q==n-1)return no;

if(q==n-2)return saiiki(1-p,q+1,no+1);
else return saiiki(1-p,q+2,no+1);
}


int main(void){
while(1){
scanf("%d",&n);
if(n==0)break;
int i,j;
for(i=0;i<2;i++){
for(j=0;j<n;j++){
scanf("%d",&(b[i][j]));
}
b[i][n]=0;
}

memset(m,-1,sizeof(m));

i=saiiki(0,0,0);
	
memset(m,-1,sizeof(m));

j=saiiki(1,0,0);
if(i!=1000 || j!=1000){
	printf("%d\n",i<j?i:j);
}
else printf("NA\n");
}
return 0;
}

Measured memory_bytes: 1040
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

basecost = 100

##saiki
def dfs(i, total, cnt, nokori):
    global ans
    if i == d:
        if total < g:
            use = max(nokori)
            n = min(data[use - 1][0], -(-(g - total) // (use * basecost)))
            cnt += n
            total += n * use * basecost + data[use - 1][1]
        if total >= g:
            ans = min(ans, cnt)
    else:
        dfs(i + 1, total, cnt, nokori)
        dfs(i + 1, total + (i + 1) * data[i][0] * basecost + data[i][1], cnt + data[i][0], nokori - {i+1})


d, g = map(int, input().split())
data = getSomeInputListInt(d)

ans = sys.maxsize

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)


Measured memory_bytes: 13880
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
//		new A().doIt();
//		new B().doIt();
		new C().doIt();
//		new D().doIt();
	}
	class A{
		void doIt(){
			int A[] = new int[3];
			for(int i = 0;i < 3;i++)A[i] = Integer.parseInt(sc.next());
			int five = 0;
			int seven = 0;
			for(int i = 0;i < 3;i++) {
				if(A[i] == 5)five++;
				else if(A[i] == 7)seven++;
			}
			if(five == 2 && seven == 1)System.out.print("YES");
			else System.out.println("NO");
		}
	}
	class B{
		void doIt(){
			int N = sc.nextInt();
			int L = sc.nextInt();
			String str[] = new String[N];
			for(int i = 0;i < N;i++) {
				str[i] = sc.next();
			}
			Arrays.sort(str);
			for(int i = 0;i < N;i++) {
				System.out.print(str[i]);
			}
			System.out.println();
		}
	}
	class C{
		void doIt(){
			int N = sc.nextInt();
			int K = sc.nextInt();
			boolean D[] = new boolean[10];
			for(int i = 0;i < K;i++)D[sc.nextInt()] = true;
			System.out.println(Output(N,D));
		}
		int Output(int N, boolean D[]) {
			for(int i = N;i < 100000;i++) {
				if(D[i % 10])continue;
				if(i >= 10)if(D[(i % 100) / 10])continue;
				if(i >= 100)if(D[(i % 1000) / 100])continue;
				if(i >= 1000)if(D[(i % 10000) / 1000])continue;
				if(i >= 10000)if(D[(i % 100000) / 10000])continue;
				return i;
			}
			return N;
		}
	}
	class D{
		void doIt(){
			
		}
	}
}


Measured memory_bytes: 21716
#include<iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;

    if(a>b && b!=1)
     cout<<"Alice"<<endl;
    else if(b>a && a!=1)
     cout<<"Bob"<<endl;
    else if(a==1 && b!=1)
     cout<<"Alice"<<endl;
    else if(b==1 && a!=1)
     cout<<"Bob"<<endl;
    else
     cout<<"Draw"<<endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    double a[]=new double[n];
    for (int i=0;i<n;i++) {
      a[i]=sc.nextInt();
    }

    double total=0;

    for (int i=0;i<n;i++) {
      total+=1/a[i];
    }

    System.out.println(1/total);
  }
}


Measured memory_bytes: 23764
#include<stdio.h>
#include<cmath>

int main(){
    double a, b, C;
    scanf("%lf %lf %lf", &a, &b, &C);
    
    double S, l, h;
    
    double PI = acos(-1);
    double rad = C * PI / 180;
    
    S = a * b * sin( rad ) / 2;
    
    double c =  sqrt( a*a + b*b - a*b*cos(rad)*2 );
    l = a + b + c;
    
    h = S / a * 2;
    
    printf("%lf %lf %lf\n", S, l, h);
    
    return 0;
}


Measured memory_bytes: 2872
def main():
    s = input()
    if s[0]=='R' and s[1]=='R' and s[2]=='R':
        print(3)
    elif (s[0]=='R' and s[1]=='R') or (s[1]=='R' and s[2]=='R'):
        print(2)
    elif 'R' in s:
        print(1)
    else:
        print(0)
   
if __name__=='__main__':
    main()


Measured memory_bytes: 9108
#include <stdlib.h>
#include <stdio.h>
int gcd(int a,int b){
    if(a<b){
        int tmp=a;
        a=b;
        b=tmp;
    }
    int r=a%b;
    while(r>0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int compare(const void *a,const void *b){
    if(*(int *)a<*(int *)b)return 1;
    return -1;
}
int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int lr[n],rl[n];
    lr[0]=a[0];
    rl[n-1]=a[n-1];
    for(int i=1;i<n;i++){
        lr[i]=gcd(a[i],lr[i-1]);
    }
    for(int i=n-2;i>=0;i--){
        rl[i]=gcd(a[i],rl[i+1]);
    }
    int ans[n];
    ans[0]=rl[1];
    ans[n-1]=lr[n-2];
    for(int i=1;i<n-1;i++){
        ans[i]=gcd(lr[i-1],rl[i+1]);
    }
    qsort(ans,n,sizeof(int),compare);
    printf("%d",ans[0]);
    return 0;
}


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

using namespace std;

vector<int> M[10000];
vector<int> m[10000];
int mark[10000]={0};

int main(){
  int V;
  int E;
  int s,t;
  cin >> V >> E;
  for(int i=0;i<E;i++){
    cin >> s >> t;
    M[s].push_back(t);
    m[t].push_back(s);
  }

  for(int i=0;i<V;i++){
    for(int j=0;j<V;j++){
      if(m[j].size()==0&&mark[j]!=1){
        mark[j]=1;
        cout << j <<endl;
        for(int k=0;k<M[j].size();k++){
          for(int l=0;l<m[M[j][k]].size();l++){
            if(m[M[j][k]][l]==j){
              m[M[j][k]].erase(m[M[j][k]].begin() + l);
            }
          }
        }
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4380
#include <iostream>

using namespace std;

int main(){
    int r, g, b, n; cin >> r >> g >> b >> n;
    int ans=0;
    for(int ri=0; ri<=n; ++ri){
        for(int gi=0; gi<=n; ++gi){
            if(n-(ri*r+gi*g)>=0 && (n-(ri*r+gi*g))%b==0) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;
typedef pair<int,int> P;
#define mp make_pair
#define pb push_back
#define INF 1000000000
struct edge
{
  int to,cost;
  edge(int a,int b):to(a),cost(b){}
};
vector<edge> PP[3005];
int d[3005];
int ep[3005];
int V;
int E;
int C;
void dijkstra(int s)
{
  priority_queue<P,vector<P>,greater<P> >pque;
  fill(d,d+V,INF);
  pque.push(mp(0,s));
  d[s]=0;
  while(!pque.empty())
    {
      P p=pque.top();
      pque.pop();
      if(d[p.second]<p.first)
	{
	  continue;
	}
      for(int i=0;i<PP[p.second].size();i++)
	{
	  P a=p;
	  if(d[PP[a.second][i].to]>d[a.second]+PP[a.second][i].cost){
	    d[PP[a.second][i].to]=d[a.second]+PP[a.second][i].cost;
	    pque.push(mp(d[PP[a.second][i].to],PP[a.second][i].to));
	  }
	}
    }
}

int main()
{
  scanf("%d %d %d",&V,&E,&C);
  for(int i=0;i<E;i++)
    {
      int a,b,c;
      scanf("%d %d %d",&a,&b,&c);
      a--;
      b--;
      PP[a].pb(edge(b,c));
      PP[b].pb(edge(a,c));
    }
  fill(ep,ep+V,INF);
  for(int i=0;i<C;i++)
    {
      int we;
      scanf("%d",&we);
      dijkstra(we-1);
      for(int j=0;j<V;j++)
	{
	  ep[j]=min(ep[j],d[j]);
	}
    }
  int rp=0;
  for(int i=0;i<V;i++)
    {
      for(int j=0;j<PP[i].size();j++)
	{
	  rp=max(rp,(ep[i]+ep[PP[i][j].to]+1+PP[i][j].cost)/2);
	}

    }

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

Measured memory_bytes: 4032
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var result = GettingStarted.Watch();
            System.Diagnostics.Trace.WriteLine(result);
            Console.WriteLine(result);
        }
    }

    public static class GettingStarted
    {
        public static string Watch()
        {
            var input = int.Parse(Console.ReadLine());
            var hours = input / 3600;
            input = input % 3600;
            var minutes = input / 60;
            var days = input % 60;
            return string.Format("{0}:{1}:{2}", hours, minutes, days);
        }

    }
}

Measured memory_bytes: 19956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
string s="";
ll n,l;
bool Main(){
    cin>>n>>l;
    vector<string> ds(n);
    For(i,0,n){
        cin>>ds.at(i);
    }
    sort(ds.begin(),ds.end());
    For(i,0,n){
        s+=ds.at(i);
    }
    cout<<s<<endl;
}
int main(){
    Main();
    return 0;
}

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

int main() {
  int a, b;
  string s;
  bool j = true;
  cin >> a >> b;
  cin >> s;
  while (1) {
    if (b == 0) break;
    int n = s[a+b]-'0';
    if (!(0 <= n && n <= 9)) {
      // printf("b=%d\n", b);
      j = false;
    }
    b--;
  }
  if (s[a] != '-') {
    j = false;
  }
  while (1) {
    if (a == 0) break;
    int n = s[a-1]-'0';
    if (!(0 <= n && n <= 9)) {
      j = false;
    }
    a--;
  }
  if (j) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;

	int keta = log10(N) + 1;
	int cnt = 0;
	rep(i, keta) {
		if(i%2==0) { // 奇数桁
			if(i<keta-1) cnt += pow(10, i) * 9;
			else { //i-1==keta
				cnt += N - pow(10, i) +1;
			}
		}
	}
	cout << cnt << endl;
	
  return 0;
}

Measured memory_bytes: 256
while True:
    a,op,b = (x for x in input().split())
    a = int(a)
    b = int(b)    
    if op == '?':
        break
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)        
    elif op == '*':
        print(a*b)
    else:
        print(int(a/b))


Measured memory_bytes: 5604
#include <stdio.h>
int main(void){
	int n,i;
	scanf("%d",&n);
	while(1){
		int m=n;
		while(1){
			if(m%2==0||m==1){
				m=m>1?m/2:1;
				if(m==1){printf("%d",n);return 0;}
			}
			else{break;}
		}
		n--;
	}
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
int main() {
    int N;
    cin >> N;
    rep(i, N, 1000) {
        int k1 = i / 100;
        int k2 = (i % 100) / 10;
        int k3 = i % 10;
        if(k1 == k2 && k2 == k3) {
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>

using namespace std;

int main(){
	
	while(1){
		int max;
		int maxnum;
		max=0;
		for(int i=0;i<5;i++){
			int a,b;
			scanf("%d%d",&a,&b);
			if(a==0 && b==0){
				goto A;
			}
			if(a+b>max){
				max=a+b;
				maxnum=i;
			}
		}
		printf("%c %d\n",'A'+maxnum,max);
	}
	A:
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <map>
#include <set>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010

int n, m;
int a[N], b[N], f[N];
ll siz[N];
ll ans = 0, sum = 0, res[N];
int find(int x) {
    if(f[x] == x) return x; 
    else return f[x] = find(f[x]);
}
int main() {
    in(n), in(m);
    sum = (ll)(n * (n - 1ll) / 2ll);
    for(int i = 1; i <= m; ++i) in(a[i]), in(b[i]);
    for(int i = 1; i <= n; ++i) f[i] = i, siz[i] = 1ll;
    for(int i = m; i; --i) {
        res[i] = sum - ans;
        int x = find(a[i]), y = find(b[i]);
        if(x != y) {
            ans += (ll)siz[x] * siz[y];
            siz[x] += siz[y];
            f[y] = x; 
        }
    }
    for(int i = 1; i <= m; ++i) printf("%lld\n", res[i]);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> x(100), y(100), h(100);

bool check(int cx, int cy, int ch) {
  for (int i = 0; i < n; i++) {
    if (h[i] != max(ch - abs(x[i] - cx) - abs(y[i] - cy), 0)) {
      return false;
    }
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int base = -1;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] > 0){
      base = i;
    }
  }



  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++){
      int ch = h[base] + abs(x[base] - cx) + abs(y[base] - cy);
      if (check(cx, cy, ch)){
        cout << cx << ' ' << cy << ' ' << ch << '\n';
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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 dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1,s2="";
    cin>>s1;
    int n = s1.size();
    REP(i,n){
        if(i==n-1) s2.push_back(s1[i]);
        else{
            if(s1[i]=='B'&&s1[i+1]=='C') s2.push_back('D'),i++;
            else s2.push_back(s1[i]);
        }
    }
    int tmp=0;
    ll ans=0;

    REP(i,s2.size()){
        if(s2[i]=='A') tmp++;
        else if(s2[i]=='D') ans+=tmp;
        else tmp=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 916
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair



int main(){
    string s;
    cin>>s;
    string ans;
    for(int i=0;i<s.size();i+=2){
        ans.push_back(s[i]);
    }
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 512
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,child,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, M;
  cin >> N >> M;
  map<int, int> m;
  rep(i, N){
    int k;
    cin >> k;
    rep(j, k){
      int a;
      cin >> a;
      m[a]++;
    }
  }
  int ans = 0;
  rep(i, M){
    if(m[i + 1] == N) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String s = sc.next();
		String t = sc.next();
		
		boolean ans = true;
		int len = s.length();
		
		for(int i = 0; i < len; i++) {
			ans = true;
			for(int j = 0; j < len; j++) {
				if(s.charAt((i + j) % len) != t.charAt(j)) {
					ans = false;
					break;
				}
			}
			if(ans) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
    }
}


Measured memory_bytes: 23636
#include <stdio.h>

void swap(int *i, int *j)
{
	*i += *j;
	*j = *i - *j;
	*i -= *j;
}

float max(float i, float j)
{
	if (i < j){
		return (j);
	}
	
	return (i);
}

int main(void)
{
	int n;
	int a, b;
	int i, j;
	float ans;
	int num;
	int data[100];
	
	
	scanf("%d", &n);
	scanf("%d %d", &a, &b);
	scanf("%d", &num);
	
	for (i = 0; i < n; i++){
		scanf("%d", &data[i]);
	}
	
	for (i = 0; i < n - 1; i++){
		for (j = i + 1; j < n; j++){
			if (data[i] < data[j]){
				swap(&data[i], &data[j]);
			}
		}
	}
	
	ans = num / a;
	for (i = 0; i < n; i++){
		num += data[i];
		a += b;
		ans = max(ans,  (float)num / (float)a);
	}
	
	printf("%d\n", (int)ans);
	
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
typedef long long int lli;
typedef pair<int, int> ii;

int main() {
    int N;
    int C[509], S[509], F[509];
    cin >> N;
    for (int i = 0; i < N-1; i++) {
        cin >> C[i] >> S[i] >> F[i];
    }

    for (int i = 0; i < N; i++) {
        int t = 0;
        for (int j = i; j < N - 1; j++) {
            if (t < S[j]) t = S[j];
            else if (t % F[j] != 0) t += (F[j] - t % F[j]);
            t += C[j];
        }
        cout << t << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main(void)
{
	char string[1200];
	int i=0;
	gets(string);
	
	while(string[i]!='\0')
	{
		if(islower(string[i]))
				printf("%c",toupper(string[i++]));
		
		else if(isupper(string[i]))
			printf("%c",tolower(string[i++]));
		else
			printf("%c",string[i++]);		
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define MOD 1000000007
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n;
struct ga{
	long long con[51][51];
	ga(){
		memset(con,0,sizeof(con));
	}
}g,h;
ga floyd(ga x,ga y){
	ga z;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				z.con[i][j]+=x.con[i][k]*y.con[k][j];
				z.con[i][j]%=MOD;
			}
		}
	}
	return z;
}
long long k;
ga FP(ga a,long long b){//a floyd b次 
	ga ret=a;
	b--;
	while(b!=0){
		if(b&1)//2N+1
			ret=floyd(ret,a);
		a=floyd(a,a);//2N
		b/=2;
	}
	return ret;
}
long long add(ga a){
	long long res=0LL;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++){
			res+=a.con[i][j];
			res%=MOD;
		}
	return res;
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>g.con[i][j];
	//g floyd 2N次=(g floyd N次) floyd (g floyd N次)
	//g floyd 2N+1次=(g floyd 2N次) floyd g
	//用快速幂做 
	h=FP(g,k);
	cout<<add(h)<<endl;
	return 0;
}


Measured memory_bytes: 512
N = [int(el) for el in list(input())]

def result(N):
    if N[0]+N[1]+N[2]+N[3] ==7:
        print('{}+{}+{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]+N[2]+N[3]==7:
        print('{}-{}+{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]+N[1]-N[2]+N[3]==7:
        print('{}+{}-{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]+N[1]+N[2]-N[3]==7:
        print('{}+{}+{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]-N[2]+N[3]==7:
        print('{}-{}-{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]+N[2]-N[3]==7:
        print('{}-{}+{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]+N[1]-N[2]-N[3]==7:
        print('{}+{}-{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]-N[2]-N[3]==7:
        print('{}-{}-{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
result(N)

Measured memory_bytes: 3188
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final int N = Integer.parseInt(scanner.next());
    final int M = Integer.parseInt(scanner.next());
    final int C = Integer.parseInt(scanner.next());

    final List<List<Integer>> a = new ArrayList<>();
    final List<Integer> b = new ArrayList<>();

    for (int i = 0; i < M; i++) {
      b.add(Integer.parseInt(scanner.next()));
    }
    for (int i = 0; i < N; i++) {
      final List<Integer> tmp = new ArrayList<>();
      for (int j = 0; j < M; j++) {
        tmp.add(Integer.parseInt(scanner.next()));
      }
      a.add(tmp);
    }

    final int size = a.stream()
        .filter(e -> {
          int result = 0;
          for (int i = 0; i < M; i++) {
            result += e.get(i) * b.get(i);
          }
          result += C;
          return result > 0;
        })
        .collect(Collectors.toList())
        .size();
    System.out.println(size);
  }
}


Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
 
int main ()
{
    int n,m,c=0;
    double s=0;
    cin>>n>>m;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
        s+=x[i];
    }
    sort(x,x+n);
    s=s/(4*m);
    for(int i=n-1;i>=0;i--)
    {
        if(x[i]>=s)c++;
        else break;
    }
 
    if(c>=m)cout<<"Yes\n";
    else cout<<"No\n";
 
    return 0;
}

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

double dp[3005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    dp[0] = 1;
    for (int i = 1; i <= N; i++)
    {
        double p;
        cin >> p;
        dp[i] = p * dp[i - 1];
        for (int j = i - 1; j; j--) dp[j] = p * dp[j - 1] + (1 - p) * dp[j];
        dp[0] *= 1 - p;
    }
    double res = 0;
    for (int i = (N + 1) / 2; i <= N; i++) res += dp[i];
    cout << setprecision(12) <<res << '\n';
    return(0);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int pn(int x, int sqrtX){
    int i;
    for(i = 3; i <= sqrtX; i = i + 2){
        if(x % i == 0){
            return 0;
        }
    }

    return 1;
}

int main(){
    int x;
    int sqrtX;
    int i;
    int flag = 0;

    scanf("%d", &x);

    if(x != 2){
        while(1){
            sqrtX = sqrt(x);

            if(x % 2 != 0){
                flag = pn(x, sqrtX);
            }

            if(flag == 1){
                printf("%d", x);
                break;
            }else{
                x++;
            }
        }
    }else{
        printf("%d", x);
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int odd = 0;
    for (int i = 1; i <= n; i++){
        if (i % 2 != 0){
            odd++;
        }
    }
    double n1 = n;
    double res = odd/n1;
    printf("%.9f",res);
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

#include <bits/stdc++.h>
using namespace std;


int main()
{

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

	vector<int> arr {};
	arr.push_back(k);

	int k_left = k, k_right = k;

	for (int i = 1; i < n; i++) {
		k_left -= 1;
		k_right += 1;
		arr.push_back(k_left);
		arr.push_back(k_right);
	}

	sort(arr.begin(), arr.end());

	for (int x : arr)
		cout << x << " ";

	
	return 0;

}

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

double distance(int xs,int ys,int xg,int yg){
    int ss=(xs-xg)*(xs-xg)+(ys-yg)*(ys-yg);
    return pow(ss,1.0/2);
}
int main(){
    int n;cin>>n;
    vector<pair<int,int> > city(n);
    vector<int> num(n);
    for(int i=0;i<n;i++){
        int x,y;cin>>x>>y;
        city[i]=make_pair(x,y);
        num[i]=i;
    }

    double sum=0;
    long long way=0;
    do{
        for(int i=1;i<n;i++){
            sum+=distance(city[num[i-1]].first,city[num[i-1]].second,city[num[i]].first,city[num[i]].second);
        }
        way++;
    }while(next_permutation(num.begin(),num.end()));
    double ans=sum/way;
    printf("%.14f\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN (1<<20)
struct seg{
  int d[MAXN+1];
  int n;
  void init(){
    n = MAXN/2;
  }
  void set(int id,int k){
    id += n - 1;
    d[id] = k;
    while( id > 0 ){
      id = (id-1)/2;
      d[id] = max(d[2*id+1],d[2*id+2]);
    }
  }
  int query(int a,int b,int k,int l,int r){
    if( r <= a || b<=l) return 0;
    if( a <= l && r <= b ) return d[k];
    else {
      return max( query(a,b,2*k+1,l,(l+r)/2),
		  query(a,b,2*k+2,(l+r)/2,r) );		  
    }
  }
  int query(int a,int b){ return query(a,b,0,0,n); }
};

seg S;
int N,Q;
int main(){
  cin >> N >> Q;
  S.init();
  int rmax  = 0;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    S.set(a,a);
    rmax = max(a,rmax);
  }
  for(int i=0;i<Q;i++){
    int a;
    cin >> a;
    int ret = 0;
    for(int j=0;j<=rmax;j+=a){
      int st= S.query(j,j+a);
      ret = max( ret, st%a );
      if( ret == a-1 ) break;
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 4420
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a,b,ans;
int main(void){
    cin>>n;
    for(int i=1LL;i<=n;i++){
        a=n/i;
        b=a*(a+1)/2;
        ans+=b*i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    rep(i, n) cin >> a[i], sum += a[i];

    int cnt = 0;
    rep(i, n) if (a[i] * 4 * m >= sum) cnt++;
    cout << (cnt >= m ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(){
    long long   n, tmp, sum=0;
    scanf("%lld", &n);

    int num[100000+1]={0};
    for(int i=0; i<n; i++){
        scanf("%lld", &tmp);
        num[tmp]++;
        sum += tmp;
    }

    long long q;
    scanf("%lld", &q);
    for(int i=0; i<q; i++){

        long long b, c;
        scanf("%lld %lld", &b, &c);

        //和
//      sum = sum - num[b]*b;
//      sum = sum + num[b]*c;
        sum += ((c-b)*num[b]);
        printf("%lld\n", sum);

        //各要素の値変化
        num[c] += num[b];
        num[b]  = 0;
    }
    return 0;
}

Measured memory_bytes: 2084
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int fa[200015],n,p[200015][2],maxi=1e5;
int get(int x){
    if(fa[x]==x)RE x;
    RE fa[x]=get(fa[x]);
}
void up(int x,int y){
    x=get(x);
    y=get(y);
    if(x!=y){
        fa[y]=x;
    }
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
    int x,y;
    FOR(i,1,2*maxi)fa[i]=i;
    FOR(i,1,n){
        cin>>x>>y;
        up(x,y+maxi);
    }
    int ans=0;
    FOR(i,1,maxi)p[get(i)][0]++;
    FOR(i,maxi+1,maxi*2)p[get(i)][1]++;
    FOR(i,1,2*maxi){
        ans=ans+p[i][0]*p[i][1];
    }
    cout<<ans-n;
	RE 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define invrep(i,n) for(int i = (int)(n); i > 0; i++)
using ll = long long;

int main() {
    string n;
    cin >> n;

    int bon = 3;
    int pon[4] = {0, 1, 6, 8};

    if ((n[n.size() - 1] - '0') == bon) {
        cout << "bon" << endl;
        return 0;
    }

    rep(i, 4) {
        if ((n[n.size() - 1] - '0') == pon[i]) {
            cout << "pon" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{
    int n,m;
    cin >> n >> m;
    priority_queue<double> pq;
    rep(i,n)
    {
        double ai;
        cin >> ai;
        pq.push(ai);
    }

    rep(i,m)
    {
        double pqi = pq.top();
        pq.pop();
        pq.push(pqi/2);
    }

    i64 sum = 0;
    while(!pq.empty())
    {
        sum += int(pq.top());
        pq.pop();
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>
//#define int long long
using namespace std;
signed main(){
	int n,m;
	cin>>n>>m;
	int l[m+1],r[m+1];
	for(int i=1;i<=m;++i)
		cin>>l[i]>>r[i];
	int f[n+1];
	f[1]=1;
	f[0]=0;
	for(int i=2;i<=n;++i){
		f[i]=f[i-1];
		for(int j=1;j<=m;++j){
			if(l[j]>=i)
				continue;
			int L,R;
			L=i-l[j];
			R=i-r[j];
			if(R<=0)
				R=1;
			f[i]=(((f[L]-f[R-1])%998244353+998244353)%998244353+f[i])%998244353;
		}
	}
	cout<<((f[n]-f[n-1])%998244353+998244353)%998244353;
	return 0;
}

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

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

    if (n < 10)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        for (int i = 2; i < 10; i++)
        {
            if (n % i == 0 && (n / i) < 10)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int n = scan.nextInt();
		int sum = IntStream.range(0, n).map(i -> scan.nextInt()).sum();

		System.out.println(sum >= h ? "Yes" : "No");
		scan.close();
	}
}

Measured memory_bytes: 51032
import sys
def input():
    return sys.stdin.readline()[:-1]

H,W,A,B = map(int,input().split(' '))

ANS = [None]*H
for i in range(H):
    ANS[i] = ['0']*W
for i in range(H):
    for j in range(W):
        if j<A and i>=B:
            ANS[i][j] = '1'
        elif j>=A and i<B:
            ANS[i][j] = '1'
for i in range(H):
    print(''.join(ANS[i]))


Measured memory_bytes: 11892
# Meaningful mean
N, K = map(int, input().split())
d = []
for _ in range(N):
    a = int(input())
    d.append(a-K)
b = [0 for i in range(N)]
b[0] = [d[0], 0]
for i in range(1, N):
    d[i] += d[i-1]
    b[i] = [d[i], i]
rev = 0
for i in range(N):
    if d[i] < 0:
        rev += 1
para = 1

b.sort()

b[0][0] = para

for i in range(1, N):
    now = b[i-1][1]
    next_ = b[i][1]
    if d[now] == d[next_]:
        b[i][0] = para
    else:
        para += 1
        b[i][0] = para
b.sort(key=lambda x: x[1])
for i in range(N):
    d[i] = b[i][0]

# 0<=i<=j<=Nで a_i<=a_jを満たす物の個数をカウントする


ans = N*(N+1)//2
# 反転すうを求める


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)

    def to_sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += (i & -i)

    def get(self, i, j):
        return self.to_sum(j)-self.to_sum(i-1)


ans = N*(N+1)//2

tree = BIT(N+1)

for index, p in enumerate(d):
    tree.add(p, 1)
    rev += index+1-tree.to_sum(p)
    
ans -= rev
print(ans)

Measured memory_bytes: 97828
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(void){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int dx = (x2-x1);
    int dy = y2-y1;
    cout << x2 - dy << ' ' << y2 + dx << ' ' << x1 - dy << ' ' << y1 + dx << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string> 
#include <math.h>
#include <set>
#include <vector>
#define rep(i,n) for(int i=0; i< (int)(n); i++)
using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,m;
	cin >> n >> m;
	
	const int NMMAX = 50;
	int a[NMMAX],b[NMMAX];
	rep(i,m) cin >> a[i] >> b[i] ;

	int road[NMMAX];
	rep(i,n) road[i] = 0;

	rep(i,m){
		road[a[i] - 1] += 1;
		road[b[i] - 1] += 1;
	} 
	rep(i,n) cout << road[i] << "\n";


} 



Measured memory_bytes: 256
n = gets.to_i
a, b = gets.split.map(&:to_i)
  .each_with_object(Hash.new(0)) { |a, h| h[a] += 1 }
  .select { |k, v| v >= 2 }
  .sort_by { |k, v| [-k] }
  .take(2)

if [a, b].all?(&:nil?)
  puts 0
else
  puts a[1] >= 4 ? a[0] ** 2 : a[0] * b[0]
end


Measured memory_bytes: 17520
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=210;
char s[N];
int w[N];
int main() {
    int n,m,s1=0,s2=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++) {
	scanf("%s",s);
	for(int j=0;j<m;j++) ++w[s[j]-'a'];
    }
    if(n&1) {
	if(m&1) ++s1;
	s2+=m/2;
    }
    if(m&1) s2+=n/2;
    for(int i=0;i<26;i++)
	if(w[i]&1) {
	    if(s1) --w[i],--s1;
	    else return puts("No"),0;
	}
    for(int i=0;i<26;i++)
	if(w[i]%4) {
	    if(s2) --s2,w[i]-=2;
	    else return puts("No"),0;
	}
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256