akhauriyash/Code-Regression huggingface dataset:
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		int n = s.nextInt();
		int l = s.nextInt();
		String array[] = new String[n];
		for (int i = 0; i < array.length; i++) {
			array[i] = s.next();
		}
		s.close();
		System.out.println(Main.calc(n, l, array));
	}

	private static String calc(int n, int l, String[] array) {
		StringBuilder sb = new StringBuilder();
		java.util.Arrays.stream(array).sorted().forEach(sb::append);
		return sb.toString();
	}
}

Measured memory_bytes: 27192
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int n;cin >> n;
    vector<int> p(n);
    for(int i = 0; i<n; i++)cin>>p[i];
    sort(p.begin(), p.end(), greater<int>());
    int sum = 0;
    for(int i = 0; i<n; i++){
        if(!i) sum += (p[i] / 2);
        else sum += p[i];
    }
    cout << sum << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const int INF = 1001001001;

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

  int sum = 0;
  int mi = INF;
  rep(i, n){
    int a; cin >> a;
    sum += a;
    if(a%10 != 0) chmin(mi, a);
  }

  if(mi == INF){
    cout << 0 << endl;
    return 0;
  }

  if(sum % 10 != 0){
    cout << sum << endl;
  }
  else{
    cout << sum - mi << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0) break;
		vip a(m);
		for(int i=0;i<m;i++) cin>>a[i].first>>a[i].second.first>>a[i].second.second;
		sort(a.begin(),a.end());
		vi b(n);
		b[0]=1;
		for(int i=0;i<m;i++){
			P p=a[i].second;
			int u=p.first-1,v=p.second-1;
			if(b[u]) b[v]=1;
		}
		int res=0;
		for(auto i:b) res+=i;
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3412
A, B = map(int, input().split())

a_low = (A * 100 + 7) // 8
a_high = ((A + 1) * 100 + 7) // 8 - 1
b_low = (B * 100 + 9) // 10
b_high = ((B + 1) * 100 + 9) // 10 - 1

c = max(a_low, b_low)
if c <= min(a_high, b_high):
    print(c)
else:
    print(-1)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    for(ll N; cin >> N;){
        multiset<ll>S;
        S.insert(-INF);
        rep(i, N){
            ll a;
            cin >> a;
            auto it = S.lower_bound(a);
            it--;
            if(*it == -INF)S.insert(a);
            else{
                S.erase(it);
                S.insert(a);
            }
        }
        cout << S.size() - 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
int main(){
  int n,m=100000;
  scanf("%d",&n);
  while(n--){
    m=m*1.05;
    if(m%1000){
      m+=1000;
      m=m/1000;
      m*=1000;
    }
  }
  printf("%d\n",m);
  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int a[n];
    map<int, int> mp;

    rep(i, n) {
        int b;
        cin >> a[i] >> b;
        mp[a[i]] = b;
    }

    sort(a, a + n);

    cout << a[n - 1] + mp[a[n - 1]] << endl;

    return 0;
}



Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
  int n, cnt = 1;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n-1; i++) {
    if (s[i] != s[i+1]) {
      cnt++;
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 512
from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j], j+1, n) - j - 1
print(ans)


Measured memory_bytes: 3188
package main

import (
	"bufio"
	"container/list"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}
func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100000-2), 100000-2)
}

func main() {
	s := scanString()
	ls := list.New()
	for _, r := range s {
		ls.PushBack(string(r))
	}
	rv := false
	q := scanInt()
	for i := 0; i < q; i++ {
		t := scanInt()
		switch t {
		case 1:
			rv = !rv
		case 2:
			f, c := scanInt(), scanString()
			if rv {
				f = 3 - f
			}
			if f == 1 {
				ls.PushFront(c)
			} else {
				ls.PushBack(c)
			}
		}
	}

	var wr = bufio.NewWriter(os.Stdout)
	if rv {
		for e := ls.Back(); e != nil; e = e.Prev() {
			wr.WriteString(e.Value.(string))
		}
	} else {

		for e := ls.Front(); e != nil; e = e.Next() {
			wr.WriteString(e.Value.(string))
		}
	}
	wr.WriteString("\n")
	wr.Flush()
}


Measured memory_bytes: 21888
//      https://youtu.be/X_hMZYDMps4

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;    // 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nl                  "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define pf                  push_front
#define all(x)              x.begin(),x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"

int main()
{
    fast;
    ll t,i,j,k,l,m,n,o,p,q,temp,flag=0,mod=1000000007;
    cin>>n;
    ll a[n][3],ans[n][3];
    for(i=0;i<n;i++){
        for(j=0;j<3;j++) cin>>a[i][j];
        if(!i){
            for(j=0;j<3;j++) ans[i][j]=a[i][j];
        }else{
            ans[i][0]=a[i][0]+max(ans[i-1][1],ans[i-1][2]);
            ans[i][1]=a[i][1]+max(ans[i-1][0],ans[i-1][2]);
            ans[i][2]=a[i][2]+max(ans[i-1][0],ans[i-1][1]);
        }
    }
    cout<<max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
}


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

int arr[3];

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    arr[0] = a, arr[1] = b, arr[2] = c;
    sort(arr, arr + 3);
    cout << arr[0] + arr[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    int tmp;
    tmp = X;
    X = Y;
    Y = tmp;
    tmp = X;
    X = Z;
    Z = tmp;
    cout << X << " " << Y << " " << Z << endl;

}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	char a = sc.next().charAt(0);
	char b = sc.next().charAt(0);
	if(a=='H') System.out.println(b);
	else System.out.println((b=='H')?'D':'H');
    }
}

Measured memory_bytes: 20948
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N;
int ans = 0;

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        int num;
        cin >> num;
        bool flag = false;
        for(int j = 2; j * j <= num; j++){
            if(num % j == 0)flag = true;
        }
        if(!flag)ans++;
    }
    cout << ans << endl;


    return 0;
}

/*

*/


Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
	double a,b,c,d,e,f,x,y,a2,b2,c2,d2,e2,f2,tmp1,tmp2;
	
	
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF)
	{
		//	ax + by = c
		//	dx + ey = f
		
		//xの係数を同じにしyを求める
		b2=b*d;
		c2=c*d;	//(b2)y=(c2)
		e2=e*a;
		f2=f*a;	//(e2)y=(f2)
		tmp1=b2-e2;
		tmp2=c2-f2;	//(tmp1)y=(tmp2)
		y=tmp2/tmp1;
		//yの係数を同じにしxを求める
		a2=a*e;
		c2=c*e;	//(a2)x=(c2)
		d2=d*b;
		f2=f*b;	//(d2)x=(f2)
		tmp1=a2-d2;
		tmp2=c2-f2;	//(tmp1)x=(tmp2)
		x=tmp2/tmp1;
		
		if(x<0.0004 && x>-0.0004)	//-0.000を回避
			x=0.000;
		if(y<0.0004 && y>-0.0004)
			y=0.000;	
			
		printf("%.3lf %.3lf\n",x,y);	//勝手に四捨五入する
	}
	return 0;
}

Measured memory_bytes: 648
n = int(input())
li = list(map(int,input().split()))
li.sort(reverse = True)
count = 0
for i in range(1,n+1):
    count = 0
    while True:
        if li:
            if li[-1]==i:
                count+=1
                li.pop()
            else:
                break
        else:
            break
    print(count)

Measured memory_bytes: 92324
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, A, B;
  cin >> N;
  A=0;
  B=0;
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  if (N==1) {
    A=a.at(0);
  }
  else {
    if (N%2==0) {
      for (int j=0; j<N/2; j++) {
        A=A+a.at(2*j);
        B=B+a.at(2*j+1);
      }
    }
    else {
      for (int k=0; k<(N-1)/2; k++) {
        A=A+a.at(2*k);
        B=B+a.at(2*k+1);
      }
      A=A+a.at(N-1);
    }
  }
  cout << A-B << endl;
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int n;
vector<vector<int>> to;
vector<int> memo;

int dp(int x){
    if(memo[x]>=0) return memo[x];
    if(to[x].size()==0){
        memo[x]=0;
        return 0;
    }
    int len=0;
    for(int y : to[x]){
        len=max(len,dp(y));
    }
    len++;
    memo[x]=len;
    return len;
}

int main(){
    int m;
    cin>>n>>m;
    to.resize(n);
    memo.resize(n,-1);
    rep(i,m){
        int x, y;
        cin>>x>>y;
        x--;
        y--;
        to[x].push_back(y);
    }
    int ans=0;
    rep(i,n) ans=max(ans,dp(i));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <sstream>
#include <queue>

using namespace std;

#define li long int

void showvec(vector<int> &vi){
  for(int i=0;i<vi.size();++i){
    std::cerr<<i<<","<<vi[i]<<endl;
  }
}

// variables
int N;
vector<int> ls;
vector<int> cnts;
int main(){
  cin >> N;
  int maxL = -1;
  ls.resize(N);
  for(int i=0;i<N;++i){
    cin >> ls[i];
    if(ls[i]>maxL){
      maxL = ls[i];
    }
  }
  showvec(ls); //debug  
  int minL = maxL/2 + maxL%2;
  cerr<<"maxL = " << maxL<< " minL = "<<minL<<endl; //debug
  cnts.resize(maxL);
  for(int i=0;i<N;++i){
    cnts[ls[i]-1] += 1;
  }
  showvec(cnts); // debug

  for(int i=0;i<maxL;++i){
    if( i+1 < minL){
      if(cnts[i]>0 ){
	cerr<<"too small l "<<i+1<<","<<cnts[i]<<","<<minL<<endl; //debug
	cout<<"Impossible"<<endl;
	return 0;
      }
    }
    else if( i+1 == minL){
      if(maxL%2 == 0){
	if(cnts[i]!=1){
	  cerr<<"invalid hinge l even "<<i+1<<","<<cnts[i]<<","<<minL<<endl; //debug
	  cout<<"Impossible"<<endl;
	  return 0;
	}
      }else{
	if(cnts[i]!=2){
	  cerr<<"invalid hinge l odd "<<i+1<<","<<cnts[i]<<","<<minL<<endl; //debug
	  cout<<"Impossible"<<endl;
	  return 0;

	}
      }
    }else{
      if(cnts[i]<2){
	cerr<<"invalid load "<<i+1<<","<<cnts[i]<<","<<minL<<endl; //debug
	cout<<"Impossible"<<endl;
	return 0;
      }
    }
  }
  cout<<"Possible"<<endl;
  return 0;
}

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

using vi = std::vector<int64_t>;

bool check(const vi &v, int t, int64_t a, int64_t b) {
    auto t2 = t;
    a -= b;
    for (auto x : v) {
        x -= t * b;
        if (x <= 0) return true;
        t2 -= (x + a - 1) / a;
        if (t2 < 0) return false;
    }
    return t2 >= 0;
}

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


    int n; std::cin >> n;
    int64_t a, b; std::cin >> a >> b;

    vi v(n);
    for (auto &x : v) std::cin >> x;
    std::sort(v.begin(), v.end(), std::greater<int64_t>());
    int l = 0, r = v.front() / b + 1;
    while (r - l > 1) {
        int m = l + (r - l) / 2;
        (check(v, m, a, b) ? r : l) = m;
    }
    std::cout << r << std::endl;
}



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


int main(){
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    for(int i=0; i<M; i++){
        int A, B;
        cin >> A >> B;
        A--, B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    bool ans=true;
    vector<int> sign(N, -1);
    queue<int> que;
    vector<int> dist(N, -1);
    sign[0]=0;
    dist[0]=0;
    que.push(0);
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(auto nv: G[v]){
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
            sign[nv]=v+1;
        }
    }
    for(int i=0; i<N-1; i++){
        if(sign[i] == -1) ans=false;
    }
    if(ans){
        cout << "Yes" << endl;
        for(int i=1; i<N; i++){
            cout << sign[i] << endl;
        }
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 10660
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

template<int MOD> struct MInt {
  long long val;
  MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt operator*(const MInt& n) const { return MInt(val) *= n; }
  MInt operator/(const MInt& n) const { return MInt(val) /= n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
using mint = MInt<1000000007>;

struct Graph {
  vector<vector<int>> edge;
  Graph(int n = 0) { resize(n); }
  void resize(int n) {
    edge.resize(n, vector<int>());
  }
  void addEdge(int from, int to, bool directed = false) {
    edge[from].push_back(to);
    if (!directed)
      edge[to].push_back(from);
  }
};
Graph G;

constexpr int MAX_N = 1e5+1;
bool visited[MAX_N][2];
mint dp[MAX_N][2];
mint dfs(int cur, int parent, bool filled) {
  if (visited[cur][filled])
    return dp[cur][filled];
  mint ans = 1;
  for (const auto& to : G.edge[cur]) {
    if (to == parent)
      continue;
    ans *= filled ? dfs(to, cur, false)
      : dfs(to, cur, true) + dfs(to, cur, false);
  }
  visited[cur][filled] = true;
  return dp[cur][filled] = ans;
}

int main() {
  int in(N);
  G.resize(N);

  rep(i, N-1) {
    int x, y;
    ins(x, y);
    --x, --y;
    G.addEdge(x, y);
  }

  cout << dfs(0, -1, false) + dfs(0, -1, true) << endl;

  return 0;
}


Measured memory_bytes: 15872
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    string A, B; cin >> A >> B;
    string C = A + B;
    int N = stoi(C);
    if (fmod(sqrt(N), 1.0) == 0)puts("Yes");
    else puts("No");
}





Measured memory_bytes: 3632
n,k=map(int,input().split())
a=list(map(int,input().split()))

def imo(a):
    imos=[0]*(n+1)

    for i in range(n):
        imos[max(0,i-a[i])]+=1
        imos[min(n,i+a[i]+1)]-=1
    
    immo=[0]*(n+1)
    immo[0]=imos[0]
    for i in range(n):
        immo[i+1]=immo[i]+imos[i+1]

    return immo[:n]

for i in range(min(k,41)):
    a=imo(a)
    
print(*a)


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

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

    ll n,x;
    cin >> n >> x;
    vector<ll> a(n),sum(n-1);
    ll ans = 0;
    for(ll i = 0; i < n; i++) cin >> a[i];
    for(ll i = 0; i < n-1; i++) sum[i] = a[i]+a[i+1];
    for(ll i = 0; i < n-2; i++){
        if(sum[i] > x){
            if(a[i+1] >= sum[i]-x){
                ans += sum[i]-x;
                a[i+1] -= sum[i]-x;
                sum[i+1] -= sum[i]-x;
                sum[i] = x;
            } else {
                ans += sum[i]-x;
                sum[i+1] -= a[i+1];
            }
        }
    }
    ans += max((ll)0,sum[n-2]-x);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4748
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <queue>
#include <utility>

using namespace std;

char space[60][11];
const int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
int w, h;

double hps(int on[60][10],int x,int y){
	int flag[60][10], i, j, cnt;
	double xsum, M;
	queue<int> xq,yq;
	memset(flag,0,sizeof(flag));
	xq.push(x);
	yq.push(y);

	while(xq.size()){
		x = xq.front();
		y = yq.front();
		xq.pop();
		yq.pop();
		flag[y][x] = 1;
		for(i = 0;i < 4;i++){
			if(x + dx[i] >= 0 && x + dx[i] < w && y + dy[i] >= 0 && y + dy[i] < h && !flag[y + dy[i]][x + dx[i]] && (space[y][x] == space[y + dy[i]][x + dx[i]] || (dy[i] == 1 && on[y + dy[i]][x]))){
				xq.push(x + dx[i]);
				yq.push(y + dy[i]);
			}
		}
	}
	cnt = xsum = 0;
	for(i = 0;i < h;i++){
		for(j = 0;j < w;j++){
			if(flag[i][j]){
				cnt++;
				xsum += j + 0.5;
			}
		}
	}
	M = (double)xsum / cnt;
	return M;
}


int main(void){
	int i, j, k, xl, xr;
	int flag[60][10];
	int past[60][10];
	queue<double> M;
	queue<int> l, r, qx, qy;
	scanf("%d%d%*c",&w,&h);
	memset(flag,0,sizeof(flag));
	memset(past,0,sizeof(past));
	while(w != 0 || h != 0){
		for(i = h - 1;i >= 0;i--){
			for(j = 0;j < w;j++)
				space[i][j] = getchar();
			getchar();
		}

		for(i = 0;i < h;i++)
			for(j = 0;j < w;j++) if((i == 0 && isdigit(space[i][j])) || (i != 0 && isdigit(space[i][j]) && isdigit(space[i - 1][j]) && space[i][j] != space[i - 1][j])) flag[i][j] = 1;

		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				if(flag[i][j]){
					M.push(hps(flag,j,i));
					int x, y;
					qx.push(j);
					qy.push(i);
					xr = -1;
					xl = 11;
					char tmp = space[i][j];
					while(qx.size()){
						x = qx.front();
						y = qy.front();
						qx.pop();
						qy.pop();
						if(flag[y][x] && xr < x)
							xr = x;
						if(flag[y][x] && xl > x)
							xl = x;
						space[y][x] = '.';
						flag[y][x] = 0;
						for(k = 0;k < 4;k++){
							if(x + dx[k] >= 0 && x + dx[k] < w && y + dy[k] >= 0 && y + dy[k] < h && tmp == space[y + dy[k]][x + dx[k]]){
								qx.push(x + dx[k]);
								qy.push(y + dy[k]);
							}
						}
					}
					r.push(xr + 1);
					l.push(xl);
				}
			}
		}
		while(M.size()){
			if(l.front() < M.front() && M.front() < r.front()){
				M.pop();
				r.pop();
				l.pop();
				continue;
			}else
				break;
		}
		if(!M.size())
			printf("STABLE\n");
		else
			printf("UNSTABLE\n");
		while(M.size()){
			M.pop();
			r.pop();
			l.pop();
		}
		scanf("%d%d%*c",&w,&h);
	}
	return 0;
}

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

int main(){
    string n;
    cin >> n;
    rep(i, 3){
        if(n[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

const int N = 5001;
const int INF = 1 << 29;

struct UnionFind{
  int par[N], rank[N];  

  UnionFind(){
    clear();
  }

  void clear(){
    for(int i=0;i<N;i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]) par[x] = y;
    else {
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

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

struct data{
  string a;
  int x;
};


int n,m;
data v[N];
map<string, int> num;
UnionFind uf;

void solve(){
  int res[N], resn[N];
  fill(res, res+N, INF);
  fill(resn, resn+N, 0);

  for(int i=0;i<n;i++){
    int f = uf.find(i);
    res[f] = min(res[f], v[i].x);
    resn[f]++;
  }

  int ans = 0;
  for(int i=0;i<n;i++) ans += res[i] * resn[i];
  cout << ans << endl;
}

int main(){
  while(cin >> n){
    num.clear();
    uf.clear();
    for(int i=0;i<n;i++){
      cin >> v[i].a >> v[i].x;
      num[v[i].a] = i;
    }
    cin >> m;
    for(int i=0;i<m;i++){
      string s,t;
      cin >> s >> t;
      uf.unite(num[s], num[t]);
    }
    solve();
  }
}

Measured memory_bytes: 1940
from math import hypot

N = int(input())
pts = [tuple(map(int, input().split())) for _ in range(N)]

EPS = 10**-10
def isLE(a, b):
    return not (a > b+EPS)

def getIntersectionLCs_L(a, b, c, xC, yC, r):
    e = a*xC + b*yC + c
    ab2 = a**2 + b**2
    v = r**2 * ab2 - e**2
    if v < 0:
        return []
    elif v == 0:
        xP = xC + -a*e / ab2
        yP = yC + -b*e / ab2
        return [(xP, yP)]
    else:
        v = v**0.5
        xP1 = xC + (-a*e + b*v) / ab2
        yP1 = yC + (-b*e - a*v) / ab2
        xP2 = xC + (-a*e - b*v) / ab2
        yP2 = yC + (-b*e + a*v) / ab2
        return [(xP1, yP1), (xP2, yP2)]
def getIntersectionCCs(x1, y1, r1, x2, y2, r2):
    xC, yC = x2-x1, y2-y1
    c = -(xC**2 + yC**2 + r1**2 - r2**2) / 2
    intCCs = getIntersectionLCs_L(xC, yC, c, 0, 0, r1)
    intCCs = [(x1 + x, y1 + y) for x, y in intCCs]
    return intCCs

def isOK(r):
    for i in range(N):
        x1, y1 = pts[i]
        for j in range(i+1, N):
            x2, y2 = pts[j]
            intCCs = getIntersectionCCs(x1, y1, r, x2, y2, r)
            for xC, yC in intCCs:
                dist = max([hypot(x-xC, y-yC) for x, y in pts])
                if isLE(dist, r):
                    return True
    return False

ng, ok = 0, 2000
while abs(ok-ng) > 10**-12:
    mid = (ng+ok) / 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid

print(ok)


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

using namespace std;

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

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

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

ll N, K;
VL a, sum, opt;

int main() {
    cin >> N >> K;
    a.resize(N);
    sum.resize(N + 1);
    opt.resize(N + 1);
    VECCIN(a);
    REP(i, N) {
        sum[i + 1] += sum[i] + a[i];
        opt[i + 1] += opt[i] + (a[i] > 0 ? a[i] : 0);
    }
    ll ans = 0;
    REP(i, N - K + 1) {
        ll tmp = opt[i] + max(0LL, sum[i + K] - sum[i]) + (opt[N] - opt[i + K]);
        ans = max(tmp, ans);
    }
    cout << ans << "\n";
}


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

int main() {
	int n,t;
	cin >> n >> t;
	vector<int> c(n), time(n);
	for(int i = 0 ;i < n; i++){
		cin >> c[i] >> time[i];
	}
	int ans = 1000;
	bool f = false;
	for(int i = 0; i < n; i++){
		if(time[i] <= t){
			f = true;
			ans = min(ans, c[i]);
		}
	}
	if(!f) cout << "TLE" << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))

res = 0
for i in range(n):
    a = list(map(int, input().split()))
    ans = 0
    for j in range(m):
        ans += a[j] * b[j]
    
    if ans + c > 0:
        res += 1

print(res)

Measured memory_bytes: 9116
n = gets.chomp.to_i

ans = (1..n).reduce(0) {|s, a|
  t = (1..n).reduce(0) {|t, b|
    g = a.gcd(b)
    u = (1..n).reduce(0) {|u, c|
      u + g.gcd(c)
    }
    t + u
  }
  s + t
}

puts ans

Measured memory_bytes: 14356
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int T=1;	
	while(T--)
	{
	 	string s;
	 	cin>>s;
	 	int ans=0,ct=0;
	 	for(int i=0;i<3;i++)
	 	{
	 		if(s[i]=='R')	ct++;
	 		else
	 		{
	 			ans=max(ans,ct);ct=0;
	 		}
	 	}
	 	cout<<max(ct,ans);
	}
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

int n;
int h[114514];

int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> h[i];
  int mini = INT_MAX/2;
  for(int i=n-1;i>=0;i--){
    if (mini + 1 < h[i]){
      cout << "No" << endl; return 0;
    }
    mini = min(mini, h[i]);
  }
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(){
    char a[100];
    int l;
    scanf("%s",a);
    l=strlen(a);
    int i,j,k;
    for(i=0;i<l;i++){
        for(j=i;j<l;j++){
            char temp;
            if(a[i]>a[j]){
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    }
    //int a[26];
    int c=0,f=1;
    for(i=0;i<l-1;i++){
        if(a[i]==a[i+1]) c++;
        else{
            if(c%2==0){
                f=0;
                break;
            }
            c=0;
        }
    }
    if(f==0||l==1) printf("No\n");
    else printf("Yes\n");
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<climits>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005

int n;
ll arr[MAX], dp[MAX]={0};

void bottomUp(){
    dp[1] = abs(arr[1]-arr[0]);
    
    for(int i=2; i<n; i++){
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

ll solve(int pos){
    if(pos == 0) return 0;

    if(pos<0) return INT_MAX;

    if(dp[pos] != -1) return dp[pos];

    ll opt1 = solve(pos-1)+abs(arr[pos-1] - arr[pos]);
    ll opt2 = solve(pos-2)+abs(arr[pos-2]-arr[pos]);

    dp[pos]=min(opt1, opt2);
    return dp[pos];
}

void topDown(){
    memset(dp, -1, sizeof(dp));
    cout<<solve(n-1)<<endl;
}

int main(){
    cin>>n;
    ip(arr, n);
    // bottomUp();
    topDown();
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int N, D;
  cin >> N >> D;
  vector<vector<ll>> X(N, vector<ll>(D));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      cin >> X.at(i).at(j);
    }
  }
  vector<ll> l(0);
  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      ll sum = 0;
      for(int k = 0; k < D; k++){
        sum += (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
      }
      l.push_back(sum);
    }
  }
  int lsize = l.size();
  int result = 0;
  for(int i = 0; i < l.size(); i++){
    ll sq = sqrt(l.at(i));
    if(l.at(i) == sq * sq) result++;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
class PriorityQueue
  class Node
    include Comparable
    attr_reader :id
    attr_accessor :priority, :value
    @@next_id=0
    def initialize(priority,value=nil)
      @id=@@next_id
      @@next_id+=1
      @priority=priority
      @value=value
    end
    def <=>(other)
      return @priority<=>other.priority
    end
    def reset
      @@next_id=0
    end
  end

  def initialize
    @nodes = [nil]
    @id2index = {}
  end

  def <<(new_node)
    @nodes << new_node
    @id2index[new_node.id]=@nodes.size - 1
    bubble_up(@nodes.size - 1)
  end

  def pop
    return nil if empty?
    exchange(1, @nodes.size - 1)
    max = @nodes.pop
    @id2index.delete(max.id)
    bubble_down(1)
    max
  end

  def push(new_node)
    self << new_node
  end

  def empty?
    return @nodes.size==1
  end

  def change_priority(id, new_priority)
    index=@id2index[id]
    return false if index.nil?
    @nodes[index].priority=new_priority
    bubble_up(index)
    bubble_down(index)
    return true
  end

  def bubble_up(index)
    parent_index = index/2
    return if index <= 1
    return if @nodes[parent_index] >= @nodes[index]

    exchange(index, parent_index)
    bubble_up(parent_index)
  end
  def bubble_down(index)
    child_index = (index * 2)
    return if child_index > @nodes.size - 1
    child_index += 1 if child_index<@nodes.size-1 && @nodes[child_index+1]>@nodes[child_index]
    return if @nodes[index] > @nodes[child_index]
    
    exchange(index, child_index)
    bubble_down(child_index)
  end
  
  def exchange(source, target)
    @id2index[@nodes[source].id], @id2index[@nodes[target].id] = @id2index[@nodes[target].id], @id2index[@nodes[source].id]
    @nodes[source], @nodes[target] = @nodes[target], @nodes[source]
  end
end














N=gets.to_i
pq=PriorityQueue.new()

tree=Array.new(N){Array.new}
(N-1).times do
  a,b=gets.split.map(&:to_i)
  tree[a-1] << b-1
  tree[b-1] << a-1
end
C=gets.split.map(&:to_i)
C.sort_by!{|i| -i}
nodes=[]
N.times do |i|
  node=PriorityQueue::Node.new(-tree[i].size)
  nodes << node
  pq << node
end

ret=[]
N.times do |i|
  node=pq.pop
  from=node.id
  ret[from]=C.pop
  tree[from].each do |to|
    if nodes[to].priority<0
      pq.change_priority(to,nodes[to].priority+1)
    end
  end
end

sum=0
N.times do |from|
  tree[from].each do |to|
    sum+=[ret[from],ret[to]].min
  end
end

puts sum/2
puts ret.join(" ")

Measured memory_bytes: 6920
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[500][500];
int flag[500][500];
int sum[500];
int dfs(int l, int r) {
    if (l == r) return 0;
    if(flag[l][r]) return dp[l][r];
    flag[l][r] = true;
    int tmp = INF2;
    REP(m, l, r) {
        tmp = min(tmp, dfs(l, m)+dfs(m + 1, r));
    }
    return dp[l][r] = tmp + sum[r + 1] - sum[l];
}


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[500];
    rep(i, N) cin >> a[i];
    rep(i, N) sum[i + 1] = sum[i] + a[i];
    //rep(i, N) rep(j, N) cout << i << "-" << j << "->" << sum[j + 1] - sum[i] << endl;
    cout << dfs(0, N - 1) << endl;
    return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int d = sc.nextInt();
			long sum = 0;
			for(int i = 0 ; i <= 600 - d ; i = i+d){
				sum += Math.pow(i,2) * d;
			}
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 17196
s = input()
dp = [[0 for i in range(13)] for j in range(len(s)+1)]

mod = 10**9+7
dp[0][0] = 1

for i in range(len(s)):
  for j in range(10): #j=今見ている桁の数字
    if s[i] != "?" and int(s[i]) != j:
      continue
    for k in range(13): #k=一桁前までのあまり
      dp[i+1][(j+10*k)%13] += dp[i][k]
      dp[i+1][(j+10*k)%13] %= mod
      
print(dp[-1][5])

Measured memory_bytes: 96424
package main
 
import "fmt"
 
func main() {
  var a, b, c, x int
  fmt.Scan(&a, &b, &c, &x)
  
  var count int
  count = 0
  for i := 0; i <= a; i++ {
    for j := 0; j <= b; j++ {
      for k := 0; k <=c; k++ {
        if x == 500 * i + 100 * j + 50 * k {
        	count++
        }
      }
    }
  }
  fmt.Println(count)
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        sc.close();

        int[] years = new int[10];
        years[0] = x;

        for (int i = 1; i <= 10; i++) {
            int xx = r * years[i - 1] - d;
            System.out.println(xx);
            if (i != 10) {
                years[i] = xx;
            }
        }
    }
}


Measured memory_bytes: 23636
import sys
s = sorted(input())
t = sorted(input(),reverse=True)
N = min(len(s),len(t))

for i in range(N):
    if s[i] > t[i]:
        print('No')
        sys.exit()
    elif s[i] < t[i]:
        print('Yes')
        sys.exit()
if len(s) < len(t):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
int n,x,a[100],res;
int main(){
    std::cin>>n>>x;
    for(int i=0;i<n;i++) std::cin>>a[i];
    std::sort(a,a+n);
    for(int i=0;i<n;i++)
        if(x>=a[i]) x-=a[i],res++;
        else break;
    res-=(res==n && x);
    std::cout<<res;
}


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

int main() {
	int a;
	cin >> a;
	vector<int>s(a);
	for (int b = 0; b < a; b++)cin >> s[b];
	auto c = s.begin();
	c++;
	for (;; c++) {
		sort(s.begin(), c);
		for (int p = 0; p < a - 1; p++)cout << s[p] << " ";
		cout << s[a-1] << endl;
		if (c == s.end())break;
	}
}

Measured memory_bytes: 3104
x,n = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    hoge = [i for i in range(x - n, x + n + 1)]
    sabun = list(set(hoge) - set(p))
    min_ = 300
    index_ = 0
    for i, v in enumerate(sabun):
        if abs(x - v) < min_:
            min_ = abs(x - v)
            index_ = i
    print(sabun[index_])

Measured memory_bytes: 9168
a,b = map(int,input().split())
s = list(input())
a_lis = s[:(a-1)]
b_lis = s[-b:]
if s[a] == "-":
  if "-" not in a_lis:
    if "-" not in b_lis:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
    int sum,tmp;
    std::vector<int> v;

    for (int i = 0; i < 3; i++)
    {
        scanf("%d", &tmp);
        v.push_back(tmp);
    }

    sum=std::accumulate(v.begin(), v.end(), 0);
    if(sum == v[0]*3){
        printf("Yes\n");
    }else
    {
        printf("No\n");
    }
    

    return 0;
}


Measured memory_bytes: 256
#2問目
#ナップザック問題
N = int(input())
S = []
count = 0
for i in range(N):
    s = int(input())
    S.append(s)
S.sort()
#最大値はlistの中をすべて足し合わせた数
DP = [0] * (sum(S) + 1)
DP[0] += 1
for i in S:
    #選ぶ時
    for j in range(len(DP)-1, -1, -1):
        if DP[j] != 0:
            DP[i+j] = 1

flag = False

for i in range(len(DP)-1, -1, -1):
    if(DP[i] != 0 and i % 10 != 0 and flag == False):
        print(i)
        flag = True
        
if flag != True:
    print(0)

Measured memory_bytes: 3064
A,b,c = gets.split.map &:to_i
K = gets.to_i

ans = "No"
K.times do 
    if b <= A then
        b *= 2
    elsif c<=b then
        c *= 2
    end

    if A<b && b<c then
        ans = "Yes"
        break
    end
end

puts ans

Measured memory_bytes: 14352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll N; cin >> N;
    ll ans = 0;
    REP(i, N) {
        ll a; cin >> a;
        if (i%2==0 && a%2!=0) ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdio>

using namespace std;



int main() {
   int n;
   for(int i=1;  ;i++){
       cin>>n;
      
       if(n==0) break;
        cout<<"Case "<< i <<": "<< n <<endl;
   }
   
}


Measured memory_bytes: 3084
import sys
N = int(input())
S = (str(x) for x in sys.stdin.read().split())
cnt = {}
for s in S:
  if cnt.get(s):
    cnt[s] = cnt[s] + 1
  else:
    cnt[s] = 1
max_cnt = max(cnt.values())
keys = [k for k, v in cnt.items() if v == max_cnt]
for k in sorted(keys):
  print(k)

Measured memory_bytes: 38092
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	var N = parseInt(input[0][0], 10);
	var M = parseInt(input[0][1], 10);
	var T = 1800 * M + 100 * N;
	var ans = Math.pow(2, M) * T;
	console.log(ans);
}
  
Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 29512
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nums;
        int h, w, i, j;
        while (true) {
            nums = br.readLine().split(" ");
            h = Integer.parseInt(nums[0]);
            w = Integer.parseInt(nums[1]);
            if (h == 0 && w == 0) break;
            for (i = 0; i < h; i++) {
                for (j = 0; j < w; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 30664
import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] t = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
			sum += t[i];
		}
		int m = sc.nextInt();
		int[] p = new int[m];
		int[] x = new int[m];
		for (int i = 0; i < m; i++) {
			p[i] = sc.nextInt();
			x[i] = sc.nextInt();
		}
		for (int i = 0; i < m; i++) {
			int ans = sum - t[p[i]-1] + x[i];
			System.out.println(ans);
		}
	}
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;
struct segtree{
    static const int SEG=1<<17;
    vint dat;
    segtree():dat(SEG*2){}
    void update(int k,int x){
        k+=SEG-1;
        dat[k]=x;
        while(k){
            k=(k-1)/2;
            dat[k]=min(dat[k*2+1],dat[k*2+2]);
        }
    }
    int query(int a,int b,int k=0,int l=0,int r=SEG){
        if(r<=a||b<=l)return INF;
        if(a<=l&&r<=b)return dat[k];
        return min(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
    }
};

int N,E,T;
int X[111111];
int dp[111111];
signed main(){
    cin>>N>>E>>T;
    X[0]=0;
    for(int i=1;i<=N;i++)cin>>X[i];

    segtree segA;
    segtree segB;
    segA.update(0,-2*X[1]);
    segB.update(0,0);
    for(int i=1;i<=N;i++){
        int lb=-1,ub=i;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if(2*(X[i]-X[mid+1])<T)ub=mid;
            else lb=mid;
        }
        int val=INF;
        if(ub)val=segA.query(0,ub)+3*X[i];
        if(ub!=i)chmin(val,segB.query(ub,i)+T+X[i]);
        dp[i]=val;
        segA.update(i,val-X[i]-2*X[i+1]);
        segB.update(i,val-X[i]);
    }
    cout<<dp[N]+E-X[N]<<endl;
    return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
const int MOD =2019;
ll n;
string bfs()
{
	if(n==1) return "1";
 int r=1;
 vector<string> dp(n);
 dp[1]="1";
	queue<int> q;
	q.push(r);
	while(!q.empty()){
		int rm=q.front();
		q.pop();
		if(rm==0)
		return dp[rm];
		//for(int digit:{0,1})
		{
			int new_r=(10*rm)%n;
			if(dp[new_r].size()==0)
			{
				q.push(new_r);
				dp[new_r]=dp[rm]+'0';
			}
			new_r=(10*rm+1)%n;
			if(dp[new_r].size()==0)
			q.push(new_r),dp[new_r]=dp[rm]+'1';
		}
		
	}
}
bool check(int n)
{
	n++;
	while(n%10==0)
	n/=10;
	return n==1;
}
int numofdigit(int n)
{
	int cnt=0;
	while(n)
	{
		cnt++;
		n/=10;
	}
	return cnt;
}
int main() {
	// your code goes here
	int t=1;
	//cin>>t;
	while(t--)
	{
		
		string s;
		cin>>s;
		ll ans=0;
		int pot=1;
		map<int,int> suf;
		int cur_suf=0;
		suf[cur_suf]++;
		for(int j=s.size()-1;j>=0;j--)
		{
			cur_suf=cur_suf+(s[j]-'0')*pot;
			cur_suf%=MOD;
			pot=pot*10 %MOD;
			ans+=suf[cur_suf];
			suf[cur_suf]++;
		}
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3732
a,b,k = gets.chomp.split(' ').map(&:to_i)
if a>=k
  a-=k
  k = 0
else
  k-=a
  a = 0
end

if b>=k
  b-=k
else
  k-=b
  b=0
end
puts [a,b].join(' ')

Measured memory_bytes: 1916
n = int(input())
a = list(map(int,input().split()))
s = [0]
d = [0]
for i in range(n):
    s.append(s[i]+a[i])
a = list(reversed(a))
for i in range(n):
    d.append(d[i]+a[i])

ans = float('inf')
for i in range(1,n):
    ans = min(ans,abs(s[i]-d[n-i]))
print(ans)

Measured memory_bytes: 35616