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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

ll dx[] = {0, 0, 1, -1};
ll dy[] = {1, -1, 0, 0};

int main()

{

    ll n, m;
    map<string,ll> b, p;
    cin >> n;
    vector<string> v;
    ll ans = 0;
    for(ll i = 0; i < n; i++)
    {

        string ss;
        cin >> ss;
        v.pb(ss);
        b[ss]++;
    }
    cin >> m;
    vector<string> v2;
    for(ll i = 0; i < m; i++)
    {

        string ss;
        cin >> ss;
        v2.pb(ss);
        p[ss]++;
    }

    for(ll i = 0; i < v.size(); i++)
    {

        ll x = b[v[i]];
        ll y = p[v[i]];
        x-=y;
        ans = max(ans, x);
    }
    cout << ans;
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
minvalue = 0
list1 = []
for i in range(1, 101):
    for j in range(len(X)):
        minvalue += (X[j]-i)**2
    list1.append(minvalue)
    minvalue = 0
minvalue1 = 10**200
for x in range(len(list1)):
    if minvalue1 > list1[x]:
        minvalue1 = list1[x]
print(minvalue1)



Measured memory_bytes: 39152
# 数列の長さを入力
n = int(input())

# 数列の要素を入力
p = list(map(int, input().split()))

# カウント用変数を0で初期化
count = 0

# 条件を満たすケースをカウント
for i in range(n - 2):
    
    if sorted(p[i:i + 3])[1] == p[i:i + 3][1]:
    
        count = count + 1
        
print("{}".format(count))

Measured memory_bytes: 3064
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 


// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int s, w;
    cin >> s >> w;
    if(w>=s)
        cout << "unsafe";
    else
        cout << "safe";

    return 0;
}  //4 5


Measured memory_bytes: 3640
using System;

class Prob0000
{
    static void Main(string[] args)
    {
        for (int i = 1; i < 10; i++)
        {
            for (int j = 1; j < 10; j++)
            {
                Console.WriteLine("{0}x{1}={2}", i, j, i * j);
            }
        }
    }
}



Measured memory_bytes: 15820
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

// dist[v] に頂点 s から頂点 v への距離を入れる関数
void dijkstra(int s, Graph &G, vector<ll> &dist){
  fill(all(dist), INF);
  dist[s] = 0;

  priority_queue<P, vector<P>, greater<P>> pq;//距離が小さい順に取り出す
  pq.push(P(0,s)); // 頂点 s からスタート

  while (!pq.empty()) {
    P p = pq.top(); pq.pop();
    int v = p.second;
    if(dist[v] < p.first) continue;// 既に v に辿り着く短い経路有ならスルー (これはただの高速化)

    for(auto e : G[v]){// v から行ける頂点 nv 達を走査
      int nv = e.to;
      ll w = e.weight;
      if(dist[nv] > dist[v] + w){
        dist[nv] = dist[v] + w;
        pq.push(P(dist[nv], nv));
      }
    }
  }
}

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};


const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int A,B,C,D,E,F;

bool ok(int a, int b, int c, int d){
  if(100*a*A+100*b*B+c*C+d*D <= F && c*C + d*D <= E*(a*A+b*B)) return true;
  else return false;
}


int main(){
  cin>>A>>B>>C>>D>>E>>F;
  double tmp = 0;
  int W = 0,S = 0;
  rep(a,F/(100*A)+1) rep(b,F/(100*B)+1) rep(c,F/C+1) rep(d,F/D+1) {
    //printf("a:%d b:%d c:%d d:%d\n", a, b, c, d);
    if(!ok(a,b,c,d)) continue;
    int w = 100*(a*A + b*B);
    int s = c*C + d*D;
    if(s+w == 0) continue;
    double x = double(s)/double(w + s);
    if(x >= tmp){
      tmp = x;
      W = w;
      S = s;
    }
  }

  cout << W+S << " " << S << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[1]*n

for i in range(m):
    a,b=map(int,input().split())
    a,b,=a-1,b-1
    if h[a]==h[b]:
        ans[a],ans[b]=0,0
    elif h[a]>h[b]:
        ans[b]=0
    else:
        ans[a]=0
print(ans.count(1))


Measured memory_bytes: 19908
#include <bits/stdc++.h>
#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(void){
  int n; cin >> n;
  string s; cin >> s;
  ll r = 0,b = 0,g=0;
  rep(i,n){
    if(s.at(i) == 'R'){
      r++;
    }
    else if(s.at(i) == 'B'){
      b++;
    }
    else g++;
  }
  if(r == 0 || b == 0 || g == 0){
    
  }
  ll sub = 0;
  for(int i = 0; i < n-2; i++){
    for(int j = i+1; j < n-1; j++){
      if(2*j - i > n-1) continue;
      else if(s.at(i) != s.at(j) && s.at(i) != s.at(j + (j-i)) &&
      s.at(j) != s.at(j + (j-i))){
        sub++;
      }
    }
  }
  ll k = r * b * g;
  cout << k - sub << endl;
  return 0;
}


Measured memory_bytes: 3616
fun main(args: Array<String>) {
    val (N, C) = readInputLine().split(" ").map { it.toInt() }
    val recListTmp = mutableListOf<Triple<Int, Int, Int>>()
    
    for (i in 1..N) {
        val (s, t, c) = readInputLine().split(" ").map { it.toInt() }
        recListTmp.add(Triple(s, t, c))
    }
    
    recListTmp.sortBy { it.first }
    recListTmp.sortBy { it.third }

    val recList = mutableListOf<Triple<Int, Int, Int>>()
    recList.add(recListTmp.first())
    
    for (r in recListTmp.drop(1)) {
        val lastElem = recList.last()
        if (lastElem.third == r.third && lastElem.second == r.first) {
            recList.removeAt(recList.lastIndex)
            recList.add(Triple(lastElem.first, r.second, r.third))
        } else {
            recList.add(r)
        }
    }

    val reserved = IntArray(100002 * 2)
    
    for (r in recList) {
        reserved[r.first * 2 - 1]++
        reserved[r.second * 2 + 1]--
    }
    
    for (i in 1 until 100002 * 2) {
        reserved[i] += reserved[i - 1]
    }
    
    println(reserved.max())
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int>cnt(m);
  for(int i=0;i<n;i++){
    int k;
    cin >> k;
    for(int j=0;j<k;j++){
      int a;
      cin >> a;
      a--;
      cnt[a]++;
    }
  }
  int ans=0;
  for(int i=0;i<m;i++){
    if(cnt[i]==n){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import io.StdIn.readLine
object Main extends App {
  val s = readLine
  assert(isEvenString(s))
  println(solve(s.dropRight(2)))

  def solve(s: String): Int = {
    if (s.isEmpty) 0
    else if (isEvenString(s)) s.length
    else solve(s.dropRight(2))
  }
  
  def isEvenString(s: String) = {
    if (s.length % 2 != 0) false
    else (s.dropRight(s.length / 2) == s.drop(s.length / 2))
  }
}


Measured memory_bytes: 25540
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(int i=0; i<n; i++)
#define rep(i,start,n) for(int i=start; i<n; i++)

void solve(){
	string s;cin>>s;

	int len = s.length();
	int n = len+1;
	int a[n]={0};

	int i = 0;
	int cnt = 0;
	while(s[i]=='>' && i<len){cnt++;i++;}

	int ans = cnt;
	a[0]=cnt;
	int p=1;
	while(cnt--){a[p++]=cnt;ans+=cnt;}

	// loop(n)cout<<a[i]<<" ";

	for(;i<len;i++){

		int inc = 0;
		int dec = 0;
		while( s[i]=='<' && i<len ){inc++;i++;}
		while( s[i]=='>' && i<len ){dec++;i++;}

		// cout<<" -> "<<i<<" "<<inc<<" "<<dec<<endl;

		if(inc<dec){
			//take dec
			ans+=( dec*(dec+1) )/2;
			ans+=( inc*(inc-1) )/2;
		}
		else{
			ans+=( inc*(inc+1) )/2;
			ans+=( dec*(dec-1) )/2;
		}
		i--;
		
	}
	cout<<ans<<endl;
	//			0
	
 	// <    +   3  
	// >>>  - - - 2 1 0

	// <<   + +  1 2
	// >    -    0

	// <<<<< + + + + + 1 2 3 4 5
	// >>>   - - -     2 1 0

 	// <     + 1


	
}
	
signed main(){
    fast;    
    // int t;cin>>t;while(t--)
    solve();    
    return 0;
}


Measured memory_bytes: 7640
//24
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

struct S{
  int x,y,t;
};

int main(){
  for(int t,n;cin>>t>>n,t|n;){
    bool p[128][128]={{}};
    bool o[128][128]={{}};
    while(n--){
      int x,y;
      cin>>x>>y;
      o[y+64][x+64]=true;
    }
    int sx,sy;
    cin>>sx>>sy;
    queue<S> que;
    S is={sx+64,sy+64,t};
    que.push(is);
    while(!que.empty()){
      S c=que.front();
      que.pop();
      if(p[c.y][c.x]++)continue;
      if(c.t){
	for(int i=0;i<6;i++){
	  int dy[]={1,1,0,-1,-1,0};
	  int dx[]={0,1,1,0,-1,-1};
	  int x=c.x+dx[i];
	  int y=c.y+dy[i];
	  if(x<0||128<x||y<0||128<y||o[y][x]){
	    continue;
	  }else{
	    S ns={x,y,c.t-1};
	    que.push(ns);
	  }
	}
      }
    }
    cout<<count(p[0],p[128],true)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1272
/**
       **********    ************
	  Author : Avi J Patel
	  University : DA-IICT
       **********    ************
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
} 
int pow(int x, int n, int d) {
    if(x==0)
    {
        return 0;
    }
    long long int result=1;
    long long int x1=(long long int)x;
    long long int n1=(long long int)n;
    long long int d1=(long long int)d;
    x1=x1%d1;
    while(n1>0)
    {
        if(n1&1)
        {
            result=(result*x1)%d1;
        }
        n1=n1>>1;
        x1=(x1*x1)%d1;
    }
    if(x==-1 && n&1)
    {
        return (int)(d1-1);
    }
    else if(x==-1 && !(n&1))
    {
        return 1;
    }
    else if (x==1)
    {
        return 1;
    }
    else if(x<-1)
    {
        return (int)(result+d1);
    }
    else if(x>1)
    {
        return (int)result;
    }
}
int main()
{
	FAST
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n%2==1)
	{
		cout<<"No";
	}
	else
	{
		if(s.substr(0,n/2)==s.substr(n/2,n/2))
		{
			cout<<"Yes";
		}
		else
		cout<<"No";
	}
	return 0;
}























Measured memory_bytes: 256
def dfs(now,parents):
    global ans
    global n
    for i in vert[now]:
        if i not in parents:
            dfs(i,parents+[now])
    if len(parents) == n:
        ans += 1
n,m = map(int,input().split())
vert = [[0] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    vert[a].append(b)
    vert[b].append(a)
parents = [0]
now = 1
ans = 0
dfs(1,parents)
print(ans)
# while parents:
#     if len(vert[now]) > 1:
#         next_place = vert[now].pop()
#         if vert[next_place][0] == 0:
#             now = next_place
#             vert[now][0] = 1



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){//桁数
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){//最小公倍数
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){//最大公約数
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,c,d=0;
  cin>>a;
  vector<int> b(a),e;
  fo(i,a)
    cin>>b[i];
  Sort(b);
  for(int i=0;i<a;i=i){
    c=b[i];
    d=0;
    while(i<a){
      if(b[i]==c){
        d++;
        i++;
      }
      else
        break;
    }
    for(int k=0;k<d/2;k++)
      e.push_back(b[i-1]);
  }
  Sort(e);
  rev(e);
  if(e.size()<2)
    cout<<0<<endl;
  else
    cout<<e[0]*e[1]<<endl;
}


Measured memory_bytes: 1660
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 100000000
#define NUM 1000000007
#define all(x) begin(x), end(x)

int main() {
	string s;
	cin >> s;
	int size = s.size();

	//cout << size << endl;

	bool flag1 = false, flag2 = false, flag3 = true;
	if (s[0] == 'A') {
		flag1 = true;
	}
	
	int ccnt = 0;
	for (int i = 2; i <= size - 2; i++) {
		if (s[i] == 'C') ccnt++;
	}
	
	if (ccnt == 1) flag2 = true;

	for (int i = 0; i < size; i++) {
		if (s[i] == 'A' || s[i] == 'C') {
			continue;
		} else if(isupper(s[i])){
			flag3 = false;
		}
	}

	if (flag1 && flag2 && flag3) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}

	return 0;
}

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

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

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

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

int main(){
    string s, t; cin>>s>>t;
    int n=s.size();
    for(char cha='a'; cha<='z'; cha++){
        bool flag=false;
        char cur;
        for(int i=0; i<n; i++){
            if(s[i] == cha){
                if(!flag){ // first
                    cur=t[i];
                    flag=true;
                    continue;
                }
                if(flag){ // not first
                    if(t[i] != cur){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    for(char cha='a'; cha<='z'; cha++){
        char cur;
        bool flag=false;
        for(int i=0; i<n; i++){
            if(t[i] == cha){
                if(!flag){ // first
                    cur=s[i];
                    flag=true;
                }
                if(flag){ // not first
                    if(s[i] != cur){
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;
using int64 = long long int;

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

	int ans = 0;
	while (n > 0)
	{
		ans++;
		n /= k;
	}

	cout << ans << endl;
}

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

struct Team {
    char name;
    int win, lose;
};

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        Team* team = new Team [n];
        for (int i = 0; i < n; i++) {
            cin >> team[i].name;
            for (int j = 0; j < n - 1; j++) {
                int score;
                cin >> score;
                if (score == 0) {
                    team[i].win++;
                } else if (score == 1) {
                    team[i].lose++;
                }
            }
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = 0; j < n - 1 - i; j++) {
                if (team[j].win < team[j + 1].win
                    || (team[j].win == team[j + 1].win && team[j].lose > team[j + 1].lose)) {
                    Team temp = team[j];
                    team[j] = team[j + 1];
                    team[j + 1] = temp;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            cout << team[i].name << endl;
        }
    }
}

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

int main(){ 
    int n,l;
    int a=0;
    cin>>n>>l;
    if(l>0){
        a=(n-1)*l+n*(n-1)/2;
    }else if(n+l-1<0){
        a=(n-1)*l+n*(n-1)/2-n+1;
    }else{
        a=(n-1)*l+n*(n-1)/2+l;
    }
    cout<<a;
    return 0;
}


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

bool used[10][20];

int main(){
    int h, w;
    while(cin >> h >> w, h+w){
        char mat[h][w];
        for(int i = 0; i < h; i++)  for(int j = 0; j < w; j++)  cin >> mat[i][j];
        map<string,int> cnt;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                for(int di = -1; di <= 1; di++){
                    for(int dj = -1; dj <= 1; dj++){
                        if(di == 0 && dj == 0)  continue;
                        memset(used, 0, sizeof(used));
                        string acc = "";
                        int si = i, sj = j;
                        while(!used[si][sj]){
                            acc += mat[si][sj];
                            cnt[acc]++;
                            used[si][sj] = true;
                            si += di, sj += dj;
                            si = (si + h) % h;
                            sj = (sj + w) % w;
                        }
                    }
                }
            }
        }
        string ans = "0";
        for(pair<string,int> p : cnt){
            if(p.second > 1 && p.first.length() > ans.length()) ans = p.first;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 37808
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n);
	cin>>a;
	ll l=min(a),r=max(a);
	if(l==r){
		Yn(l==n-1 or n>=l*2);
	}else if(r-l==1){
		int cnt=count(all(a),l);
		Yn(r>=cnt+1 and n-cnt>=(r-cnt)*2);
	}else{
		Yn(0);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
vector<ll> adj[1000005];
ll vis[1000005];
void dfs(ll v){
	vis[v]=1;
	for(auto &u:adj[v]){
		if(vis[u])continue;
		dfs(u);
	}
}
int main(){
	
	ll n,m;
	cin>>n>>m;
	for(ll i=1;i<=m;i++){
		ll x,y;
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	ll c=0;
	for(ll i=1;i<=n;i++){
		if(!vis[i]){
		   c++;
		   dfs(i);	
		}
	}
	cout<<c-1;
	
}

Measured memory_bytes: 32180
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int w = ms.nextInt();
        int[] wt = new int[n];
        int[] val = new int[n];
        for (int i = 0; i < n; i++) {
            wt[i] = ms.nextInt();
            val[i] = ms.nextInt();
        }

        out.println(maxProfit(wt, val, w, 0, new HashMap<>(), new Long[n+1][w+1]));
        out.close();
    }

    private static long maxProfit(int[] wt, int[] val, int w, int ind, Map<String, Long> cache, Long[][] dp) {
        if (w < 0) {
            return Long.MIN_VALUE;
        }
        if (w == 0 || ind == wt.length) {
            return 0;
        }
       // String key = ind + "#" + w;
        if (dp[ind][w] == null) {
            long include = maxProfit(wt, val, w - wt[ind], ind + 1, cache, dp) + val[ind];
            long exclude = maxProfit(wt, val, w, ind + 1, cache, dp);
           // cache.put(key, Math.max(include, exclude));
            dp[ind][w] = Math.max(include, exclude);
        }
        return dp[ind][w];
       // return cache.get(key);
    }

}

class ModScanner {

    BufferedReader br;
    StringTokenizer st;

    public ModScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double nagai, mizikai;
    mizikai = 6 * m;
    nagai = 30 * h + 0.5 * m;
    double kakudo = min(abs(mizikai - nagai), 360 - abs(mizikai - nagai));
    double ans = a * a + b * b - 2 * a * b * cos(PI * kakudo / 180);
    cout << sqrt(ans) << en;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, k, c;
	string s;
	cin >> n >> k >> c >> s;
	c++;
	vector<int> l(k + 2), r(k + 2);
	l[0] = -c;
	for(int i = 1; i <= k; ++ i) {
		int idx = l[i - 1] + c;
		while(s[idx] == 'x') idx++;
		l[i] = idx;
	}
	r[k + 1] = n + c - 1;
	for(int i = k; i >= 1; --i) {
		int idx = r[i + 1] - c;
		while(s[idx] == 'x') idx--;
		r[i] = idx;
	}
	for(int i = 1; i <= k; ++ i) {
		if(l[i] == r[i]) cout << l[i] + 1 << '\n';
	}
}


Measured memory_bytes: 3348
process.stdin.resume();
process.stdin.setEncoding('utf8');

class AtCoder {
    main(inputs: Array<string>){
        const input: Array<string> = inputs;
        this.answer(input);
    }

    answer(input: Array<string>): void {
        const N: number = parseInt(input[0]);
        const A: Array<number> = input[1].split(" ").map(s => parseInt(s));

        const L: Array<number> = A
            .reduce((p: Array<number>, c: number): Array<number> => {
                if (p.length === 0) {
                    p.push(this.gcd(c, c));
                } else {
                    p.push(this.gcd(p.slice(-1)[0], c));
                }
                return p;
            }, []);

        const R: Array<number> = A
            .reverse()
            .reduce((p: Array<number>, c: number): Array<number> => {
                if (p.length === 0) {
                    p.push(this.gcd(c, c));
                } else {
                    p.push(this.gcd(p.slice(-1)[0], c));
                }
                return p;
            }, []);

        let gcd_arr: Array<number> = [];
        for (let i = 0; i < N; i++) {
            if (i === 0) {
                gcd_arr.push(R.slice(-2)[0]); 
            } else if (i === N - 1) {
                gcd_arr.push(L.slice(-2)[0]);
            } else {  
                gcd_arr.push(this.gcd(L[i - 1], R[N - 2 - i])); 
            }
        }
        
        console.log(gcd_arr.reduce((p, c) => p < c ? c : p, 0));
    }

    private gcd(a: number, b: number): number{
        if (a > b) {
            const c = a;
            a = b;
            b = c;
        }

        if (a === 0) {
            return b;
        }
        
        return this.gcd(b % a, a);
    }
}

let g_input: string = '';
process.stdin.on('data', chunk => { g_input += chunk; });
process.stdin.on('end', () => {
    (new AtCoder()).main(g_input.split(/\r?\n/));
});

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

int main() {
    string S, T;
    int ans = 0;
    cin >> S >> T;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) ans++;
    }

    cout << ans << endl;

}


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


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    while(t--){
        int n;
        cin>>n;
        map<string,int> mp;
        while(n--){
            string s; cin>>s; mp[s]++;
        }
        cout<<"AC x "<<mp["AC"]<<'\n';
        cout<<"WA x "<<mp["WA"]<<'\n';
        cout<<"TLE x "<<mp["TLE"]<<'\n';
        cout<<"RE x "<<mp["RE"]<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

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

  vector<ll> A(N);
  vector<ll> B(N);
  ll sum = 0;
  REP(i, N){
    cin >> A[i];
    sum+=A[i];
    B[i]=sum;
  }
  
  ll MIN = INF;
  REP(i,N-1){
    MIN = min(MIN,abs(B[i]-(B[N-1]-B[i])));
  }

  cout << MIN << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  int K;
  cin>>K;
  map<string, int> amap;
  vector<string> arr;
  int N = S.size();
  for(int i=0;i<S.size();++i) {
    for(int j=0;j<=min(5, N-i);++j) {
      if(amap[S.substr(i, j)]==0) arr.push_back(S.substr(i, j));
      amap[S.substr(i, j)]++;
    }
  }
  sort(arr.begin(), arr.end());
  cout<<arr[K]<<endl;
}



Measured memory_bytes: 4784
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	m = 1000000007
)

func main() {
	H := readInt()
	W := readInt()
	a := make([]string, 2)
	a[0] = readString()
	a[1] = readString()

	dp := make([][]int, 2)
	dp[0] = make([]int, W)
	dp[1] = make([]int, W)
	dp[0][0] = 1

	for i := 0; i < H-1; i++ {
		for j := 0; j < W-1; j++ {
			if a[0][j+1] != '#' {
				dp[0][j+1] = (dp[0][j+1] + dp[0][j]) % m
			}
			if a[1][j] != '#' {
				dp[1][j] = dp[0][j]
			}
		}
		if a[1][W-1] != '#' {
			dp[1][W-1] = dp[0][W-1]
		}

		a[0], a[1] = a[1], readString()
		dp[0], dp[1] = dp[1], dp[0]
		for j := 0; j < W; j++ {
			dp[1][j] = 0
		}
	}
	for j := 0; j < W-1; j++ {
		if a[0][j+1] != '#' {
			dp[0][j+1] = (dp[0][j+1] + dp[0][j]) % m
		}
	}

	fmt.Println(dp[0][W-1])
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<pair<int,int>> a;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin>>x;
        a.push_back(make_pair(x, i + 1));
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++)
    {
        cout<<a[i].second<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 1780
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d%d", &a, &b);

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) printf("Possible");
    else printf ("Impossible");

    return (0);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
class Program
{
 
    static void Main(string[] args)
    {
        int[] S = GetInputsInt();
 
        int s = (S[0] - 1);
        for (int i = S[1] - s; i <=S[1] + s; i++)
        {
            Console.Write(i + " ");
        }
 
    }
 
 
 
    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static long GetInputLong()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
 
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  
  int ans = 0;
  for (int i = 1; i < n; i++) {
   	 // count unhappy people
     if (s[i] != s[i-1]) ans++;
  }
  ans = n - (ans + 1); // a person at either ends is always unhappy
  ans = min(n - 1, ans + 2*k);
  cout << ans;
}

Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    ll gap = abs(A - B);
    if( (gap%2)==0 ){
        cout << gap/2 << endl;
    }else{
        //ぼつ
        ll dis0_A = A - 1;
        ll dis0_B = B - 1;
        ll dis0 = max(dis0_A,dis0_B);
        ll disN_A = abs(A - N);
        ll disN_B = abs(B - N);
        ll disN = max(disN_A,disN_B);
        //ll ans = min(dis0,disN);

        ll ans = min(dis0_A,disN_B) + 1 + (B-A-1)/2;//相対距離は変わっていないので，早く折り返しができる方に向かう

        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  int c = 0;
  
  for(int i = 0 ; i<3; i++){
  if(str.at(i) == '1'){
    c++;
  }
  }
  cout << c << endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

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


int cnt[10000005] = {};

void Main() {
	int N; cin >> N;
	ll sum = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = i; j <= N; j += i) cnt[j]++;
		sum += (ll)cnt[i] * i;
	}
	cout << sum << endl;	
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 42668
/*      ex6_2
        Tarara  */
#include <stdio.h>
#include <string.h>

#define MAX_LENGTH 110

int main(void)
{
    char word[MAX_LENGTH];
    int length;

    scanf("%s", word);

    length = strlen(word);
    printf("%c%d%c\n", word[0], length - 2, word[length - 1]);
    return 0;
}

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

typedef long long ll;
typedef pair<ll,ll> P;

int main()
{	
	int n;cin >> n;
	cout << n/3 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n; cin >> n;
  vector<int> h(n);  for(auto &x : h) cin >> x;
  int ans = h[0];
 
  // 結局単調増加な山を登るだけ
  for (int i = 1; i < n; i++) {
    if(h[i] - h[i-1] > 0) ans += h[i] - h[i-1];
  }
 
  std::cout << ans << '\n';
}

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


int main()
{
	ll X;
	cin>>X;
	ll head=0;
	ll tail=X;
	while(tail-head>1)
	{
		ll mid=head+(tail-head)/2;
		if(mid*(mid+1)/2>=X)
		{
			tail=mid;
		}
		else
		{
			head=mid;
		}
	}
	cout<<tail<<endl;
	return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a, b, c;
		int count = 0;
		Scanner scan = new Scanner(System.in);
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();

		for (int j = a; j <= b; j++) {
			if (c % j == 0)
				count++;
		}

		System.out.println(count);

	}
}


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

#define pb push_back
#define ll long long int
#define mpi map<int, int>
#define vi vector<int>
#define qi queue<int>
#define si set<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define vs vector<string>
#define pri priority_queue<int>
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define For(i, n) for (int i = 0; i < n; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, x, y) for (int i = x; i <= y; i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

double tick()
{
    static clock_t oldt, newt = clock();
    double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
    oldt = newt;
    return diff;
}

inline ll read()
{
    ll f = 1, x = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

ll fastExpo(ll a, ll n)
{
    ll res = 1;
    while (n)
    {
        if (n % 2)
            res = res * a;
        n /= 2;
        a = a * a;
    }
    return res;
}

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

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    For(i, n)
    {
        ans += (i + 1) * (1 + n / (i + 1)) * (n / (i + 1)) / 2;
    }
    cout << ans << endl;
    cerr << "execution time is: " << tick() << "\n";
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

struct Info{

	bool operator<(const struct Info &arg) const{

		if(value != arg.value){

			return value < arg.value;

		}else if(weight != arg.weight){

			return weight < arg.weight;

		}else if(type != arg.type){

			return type < arg.type;

		}else if(date != arg.date){

			return date < arg.date;
		}else{

			return name < arg.name;
		}
	}

	ll value,weight,date;
	string type,name;
};

int N;
Info info[SIZE];

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		cin >> info[i].value >> info[i].weight >> info[i].type >> info[i].date >> info[i].name;
	}

	sort(info,info+N);

	for(int i = 0; i < N; i++){

		printf("%lld %lld %s %lld %s\n",info[i].value,info[i].weight,info[i].type.c_str(),info[i].date,info[i].name.c_str());
	}

	return 0;
}



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

int main (void){
  int n = 0,Y = 0,x = 0,y = 0,z = 0,h = 0;

  cin >> n >> Y;

  if(Y % 1000 != 0){
    cout << "-1 -1 -1\n";
    return 0;
  }

  Y = Y / 1000;
  h = n;

  while(Y){
    if(Y - 10 >= 0){
      x++;
      Y = Y - 10;
    }else if(Y - 5 >= 0){
      y++;
      Y = Y - 5;
    }else{
      z++;
      Y = Y - 1;
    }
  }

  while(x + y + z < h){
    if(h - x-y-z >= 9 && x > 0){
      x--;
      z = z+10;
    }else if(h - x-y-z >= 4 && y > 0){
      y--;
      z = z+5;
    }else if(h - x-y-z >= 1 && z > 0){
      x--;
      y = y + 2;
    }
  }

  if(x+y+z > h || x < 0 || y < 0 || z < 0){
    cout << "-1 -1 -1\n";
  }else{
    cout << x << " " << y << " " << z <<endl;
  }

  return 0;

}

Measured memory_bytes: 256
#include "iostream"
#include "cmath"
using namespace std;

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

  int x[n + 5][d + 5];
  for (int i = 0; i < n; i++) for (int j = 0; j < d; j++) cin >> x[i][j];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      double sum = 0.0L;
      for (int k = 0; k < d; k++) {
        sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      sum = sqrt(sum);
      if (sum - (int)sum == 0.0L) ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef pair<ll,const char*> parsed;

parsed expr(const char*);
parsed term(const char*);
parsed fact(const char*);

parsed expr(const char* s)
{
	parsed now=term(s);
	while(*now.second=='+' || *now.second=='-'){
		char op=*now.second;
		parsed next=term(now.second+1);
		if(op=='+')
			now=parsed(now.first+next.first,next.second);
		else
			now=parsed(now.first-next.first,next.second);
	}
	return now;
}

parsed term(const char* s)
{
	parsed now=fact(s);
	while(*now.second=='*' || *now.second=='/'){
		char op=*now.second;
		parsed next=fact(now.second+1);
		if(op=='*')
			now=parsed(now.first*next.first,next.second);
		else
			now=parsed(now.first/next.first,next.second);
	}
	return now;
}

parsed fact(const char* s)
{
	if(s[0]=='('){
		parsed res=expr(s+1);
		res.second++;
		return res;
	}
	else{
		const char* p=s;
		if(*p=='-')
			p++;
		ll n=0;
		while(isdigit(*p)){
			n=n*10+(*p-'0');
			p++;
		}
		return parsed(n,p);
	}
}

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		cout<<expr(s.c_str()).first<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
char s[10005];
int main(){
        while(~scanf("%s",s)){
                int l=strlen(s);
                F(i,0,l) printf("x");
                puts("");
        }
}

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

typedef pair<int, int> P;

int main() {
  int N;
  cin >> N;
  long long K;
  cin >> K;
  vector<P>v(N);
  for (int i = 0; i < N; i++) {
    cin >> v.at(i).first >> v.at(i).second;
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < N; i++) {
    K -= v.at(i).second;
    if (K <= 0) {
      cout << v.at(i).first;
      break;
    }
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	string str;
	cin>>str;
	int n=str.length();
    for(int i=n-1;i>=0;i--)
    {
        if(str[i]=='?')
        {
            str[i]='D';
        }
    }
    cout<<str<<endl;
	return 0;
}



Measured memory_bytes: 3752