akhauriyash/Code-Regression huggingface dataset:
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
void fx(vector<int> &a,int n, int m){

}

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

int arr[3000000];
void input(int n){
	for(int i=0;i<n;++i)
	cin>>arr[i];
}

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



void q1(){
	int n;
	cin>>n;
	n*=(n+1);
	n/=2;
	cout<<n;
}
// -----------------------------------------------------------------------


void q2(){
	string s,t;
	cin>>s;
	t="";
	int skip=0;
	for(int i=(int)s.size()-1;i>=0;i--){
		if(s[i]=='B'){
			skip++;
		} else{
			if(skip>0){
				skip--;
			} else{
				t+=s[i];
			}
		}
	}
	cout<<t.size();
}

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

void q3(){
	int n;
	input(n);
	ld sum=0;
	for(int i=0;i<n;++i){
		sum+=arr[i];
	}
	sum/=n;
	int l=sum;
	sum+=1;
	int u=sum;
	int pp,p;
	pp=0;
	for(int i=0;i<n;++i){
		pp+=((arr[i]-sum)*(arr[i]-sum));
	}p=0;
	for(int i=0;i<n;++i){
		p+=((arr[i]-sum)*(arr[i]-sum));
	}
	cout<<min(p,pp);
}


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

void q4(){
	string s;
	cin>>s;
	int xp=sz(s);
	for(int i=0;i<xp-2;++i){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			return ;
		}
		if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3<<endl;
			return ;
		}
	}
	if(s[xp-1]==s[xp-2]){
		cout<<xp-1<<" "<<xp<<endl;
		return ;
	}
	cout<<"-1 -1\n";
	return ;
}

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


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	q1();
	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++)

int n;	 
vector<int> x, y;

double dist(int i, int j){
	int dis = pow((x.at(i)-x.at(j)),2) + pow((y.at(i)-y.at(j)),2);
//  	cout << sqrt(dis) << endl;
  	return sqrt(dis);
}

double rt(vector<int> lst){
	double sm = 0;
  	rep(i,n-1){
    	sm += dist(lst.at(i),lst.at(i+1));
    }
  	return sm;
}

void dfs(vector<int> lst, int &cnt, double &dsm,int i){
  	if(count(lst.begin(),lst.end(),i) != 0) return;
  	else 	lst.push_back(i);
  	
	if(lst.size() == n){
    	cnt++;
      	dsm += rt(lst);
    	return;}
  	
  	rep(i,n) dfs(lst,cnt,dsm, i); 
	
  	return;
}

void ini(){
   	double dsm = 0;
  	int cnt = 0;
	rep(i,n) dfs(vector<int>(0),cnt,dsm,i);
//  	cout << (double)dsm/cnt << endl;
  	cout << fixed << setprecision(15) << (double)dsm/cnt << endl;
    return;
}	
	
int main() {
	cin >> n;
	x = y = vector<int>(n); rep(i,n){cin >> x.at(i) >> y.at(i);}
  	ini();
} 

Measured memory_bytes: 256
#include<stdio.h>

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

    for(unsigned long int i=1;i<=n;i++)
    {
        if(i%3 != 0 && i%5 != 0){
            sum = sum + i;
        }
    }
    
    printf("%lu\n",sum);

    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    ll w, h, x, y;
    cin>>w>>h>>x>>y;
    cout<<w * h / 2.0<<" ";
    if (x * 2 == w && y * 2 == h) {
        cout<<1<<endl;
    } else {
        cout<<0<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
p1=[]
pn=[]
for i in range(m):
  a,b=map(int,input().split())
  if a==1 and b==n:
    print("POSSIBLE")
    exit()
  elif a==1:
    p1.append(b)
  elif b==n:
    pn.append(a)

x=set(p1)
y=set(pn)
if x&y==set():
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

Measured memory_bytes: 21836
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a[2],k;
	cin >> a[0] >> a[1] >> k;
	for(int i = 0;i < 2;i++){
		int d = min(a[i],k);
		a[i] -= d;
		k -= d;
	}
	cout << a[0] << " " << a[1] << endl;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 59, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    string o, e;    cin >> o >> e;

    int p1, p2; p1 = p2 = 0;
    for(int i = 1;i <= o.size() + e.size();i++){
        if(i & 1)
            cout << o[p1++];
        else
            cout << e[p2++];
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

    int n, w;
    cin >> n >> w;

    vector<ll> dp(w + 1, 0);
    vector<int> a(n + 1, 0);
    vector<ll> b(n + 1, 0);

    for(int i = 1; i <= n; i ++)
        cin >> a[i] >> b[i];

    int lim = 0;
    for(int i = 1; i <= n; i ++) {
        for(int s = lim; s >= 0; s --)
            if(s + a[i] <= w)
                dp[s + a[i]] = max(dp[s] + b[i], dp[s + a[i]]);

        lim += a[i];
    }
    ll ans = 0;
    for(int i = 0; i <= w; i ++)
        ans = max(ans, dp[i]);
    cout << ans;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long

using namespace std;

long long maxPossibleValue(vector<pair<long long, long long>> &items, long long cur, long long maxWeight, long long totalWeight, vector<vector<ll>> &dp)
{
    if (cur == items.size())
    {
        return 0;
    }

    if (totalWeight <= maxWeight && dp[cur][totalWeight] != -1)
    {
        // cout << "MIRACLE" << endl;
        return dp[cur][totalWeight];
    }

    long long exclude = maxPossibleValue(items, cur + 1, maxWeight, totalWeight, dp);

    if (maxWeight == totalWeight + items[cur].first)
    {
        return max(exclude, (ll)items[cur].second);
    }

    if (maxWeight < totalWeight + items[cur].first)
    {
        return exclude;
    }

    long long include = items[cur].second + maxPossibleValue(items, cur + 1, maxWeight, totalWeight + items[cur].first, dp);

    dp[cur][totalWeight] = max(exclude, include);
    return max(exclude, include);
}

void solve()
{
    ll n, w;
    cin >> n >> w;

    vector<pair<long long, long long>> v;
    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, -1));
    long long a, b;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    // cout << v[0].first << " " << v[0].second << endl;
    cout << maxPossibleValue(v, 0, w, 0, dp);
}
int main()
{
    IOS;
    // int t;
    // cin>>t;
    // while(t>0)
    {
        solve();
        // t--;
    }
    return 0;
}

Measured memory_bytes: 80256
using System;
using System.Linq;
using System.Collections;

class Program
{
    public static void Main()
    {
        int[] n = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int[] arr = new int[n[2] + 1];
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int[] b = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        for (int i = 0; i < n[2]; i++) {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            arr[i] = a[input[0] - 1] + b[input[1] - 1] - input[2];
        }
        Array.Sort(a);
        Array.Sort(b);
        arr[n[2]] = a[0] + b[0];
        Array.Sort(arr);
        Console.WriteLine(arr[0]);
    }
}

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

#define xx first
#define yy second

const int N = 1e2 + 1;
const int K = 1e5 + 1;

int n, k, a[N], memo[K];

bool dp(int i) {
    if (memo[i] != -1)
        return memo[i];
    bool w = 0;
    for (int j = 0; j < n; j++)
        if (a[j] <= i)
            w |= !dp(i - a[j]);
    return memo[i] = w;
}

void solve() {
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    fill(memo, memo + k + 1, -1);
    cout << (dp(k) ? "First" : "Second") << '\n';    
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 8680
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);


int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n)cin >> a[i];
  int ans=0;
  rep(i,n){
    if(a[a[i]-1]==i+1)ans++;
  }
  
  cout << ans/2 << endl;
  return 0;
  
    
}


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

int main() {
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  int cnt = 0;
  if (a[0] % 2 != a[1] % 2 || a[1] % 2 != a[2] % 2 || a[2] % 2 != a[0] % 2) {
    ++cnt;
    if (a[0] % 2 == a[1] % 2) {
      ++a[0];
      ++a[1];
    } else if (a[1] % 2== a[2] % 2) {
      ++a[1];
      ++a[2];
    } else {
      ++a[2];
      ++a[0];
    }
  }
  sort(a, a + 3);
  cout<<cnt + (a[2] - a[0]) / 2 + (a[2] - a[1]) / 2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int min(int a,int b){
    return a<b?a:b;
}
int main(void){
    int n,m;
    cin >> n >> m;
    string ans;
    if(n == m)ans = "Yes";
    else ans="No";
    cout << ans << endl;
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

set<ll> s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>x>>n;
    for(int i=0;i<n;i++){
        cin>>y;
        s.insert(y);
    }
    t = LLMAX;
    for(int i=-1;i<105;i++){
        if(!s.count(i)){
            if(abs(i-x)<t){
                t = abs(i-x);
                z = i;
            }
        }
    }
    cout<<z;
    
    


    return 0;
}

Measured memory_bytes: 3644
function main() {
  process.stdin.resume();
  process.stdin.setEncoding("utf8");
  var chunks = "";

  process.stdin.on("data", function (chunk) {
    chunks += chunk;
  });

  process.stdin.on("end", function () {
    var inputs = chunks.trim().split("\n");
    var nums = inputs[0].split(" ");
    var go = 0;
    var shichi = 0;

    nums.forEach((n) => {
      if (n === "5") {
        go += 1;
      } else if (n === "7") {
        shichi += 1;
      }
    });

    go === 2 && shichi === 1 ? console.log("YES") : console.log("NO");
  });
}

main();


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

typedef long long int ll;

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

    if(n.size() == 2){
        cout << 9;
    }
    else if(n.size() == 4){
        cout << 909;
    }
    else if(n.size() == 6){
        cout << 90909; 
    }
    else if(n.size() == 1){
        cout << n;
    }
    else if(n.size() == 3){
        ll t = stoi(n) - 100 + 1;
        t += 9;
        cout << t;
    }
    else{
        ll t = stoi(n) - 10000 + 1;
        t += 909;
        cout << t;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from bisect import bisect_left
N = int(input())
#S = input()[:-1]
#N,M = map(int,input().split())
#S,T = map(str,input().split())
A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
d = 0
A.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        s = A[i]+A[j]
        dex = bisect_left(A,s)
        if dex > j:
          d += dex -j -1
print(d)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int n;
   cin>>n;
   int arr[n];
   rep(i,n)cin>>arr[i];
   int sum=0;
   rep(i,n)sum+=arr[i];
   int ans=INT_MAX;
   int temp=0;
   rep(i,n-1)
   {
     temp+=arr[i];
     ans=min(ans,abs(temp-(sum-temp)));
   }
   cout<<ans<<endl;

   return 0;
}


Measured memory_bytes: 256
a, b = [int(i) for i in input().split()]

aaa = []

for i in range(1, a + 1):
    w = i
    cnt = 0
    while w < b:
        w = w * 2
        cnt += 1
    cntcnt = 0.5 ** cnt
    aaa.append(cntcnt)

print(sum(aaa) / len(aaa))

Measured memory_bytes: 6296
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1
print("AC x {}\nWA x {}\nTLE x {}\nRE x {}".format(ac,wa,tle,re))

Measured memory_bytes: 9136
#include<stdio.h>

int partition(int[], int, int);

int partition(int A[], int p, int r)
{
  int x,i,j,temp;
  x = A[r];
  i = p-1;
  for( j = p ; j < r ; j++ ){
    if( A[j] <= x )
      {
      i++;
  temp = A[i];
  A[i] = A[j];
  A[j] = temp;
      }
  }
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;
  return i+1;
}

int main()
{
  int n,i,q;
  scanf("%d",&n);
  int A[n];

  for( i = 0 ; i < n ; i++ )
    scanf("%d",&A[i]);

  q = partition(A,0,n-1);

  for( i = 0 ; i < n-1 ; i++ )
    {
      if( i == q)
	printf("[%d] ",A[i]);
	  else
    printf("%d ",A[i]);
    }
  printf("%d\n",A[i]);
  

    
  return 0;
}

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

using namespace std;

bool check(long long x, vector<long long> &a) {
	long long n = x;
	for (auto aaa : a) {
		x = x / aaa * aaa;
	}
	return x == 2;
}

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

	vector<long long> a(k, 0);
	for (int i = 0; i < k; i++) {
		cin >> a[i];
	}

	if (a.back() != 2) {
		cout << -1 << endl;
		return 0;
	}

	long long mini = a.back();

	for (int i = k - 2; i >= 0; i--) {
		if (a[i] >= 2 * mini) {
			cout << -1 << endl;
			return 0;
		}
		mini = max(mini, a[i]);
		if (mini % a[i] > 0) {
			mini = mini - (mini % a[i]) + a[i];
		}
	}
	if (!check(mini, a)) {
		cout << -1 << endl;
		return 0;
	}

	long long lower = mini;
	long long upper = 9e18;

	while (upper - lower > 1) {
		long long mid = (lower + upper) / 2;
		if (check(mid, a)) {
			lower = mid;
		} else {
			upper = mid;
		}
	}

	long long maxi = lower;
	cout << mini << " " << maxi << endl;
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    
    if(e <= c){
        cout << min(e*a,b) << endl;
    }
    else{
        cout << min(e*a,b+(e-c)*d) << endl;
    }
    
    return 0;
}


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

using namespace std;

int main() {
    int N, M;
    vector <vector<int> > data(100000);
    int p[100000];
    int y[100000];

    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> p[i] >> y[i];

        data[p[i]-1].push_back(y[i]);
    }

    for (int i = 0; i < N; i++) {
        sort(data[i].begin(), data[i].end());
    }

    for (int i = 0; i < M; i++) {
        int idx = lower_bound(data[p[i]-1].begin(), data[p[i]-1].end(), y[i]) -
            data[p[i]-1].begin();

        printf("%06d%06d\n", p[i], idx+1);
    }

    return 0;
}



Measured memory_bytes: 7808
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
r = 0
p = N
for a in A:
  r += B[a - 1]
  if p == a - 1:
    r += C[p - 1]
  p = a
print(r)

Measured memory_bytes: 9132
a,b,c = map(int,input().split())

# if 2*(a+b)<c:
#     print("Yes")
#     exit()
if c<=a+b:
    print("No")
    exit()

if a**2+b**2+c**2<(a-b)**2+(b-c)**2+(c-a)**2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n,a[3005];

ll dp[3005][3005];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n-i+1;j++){
            if(i%2==n%2){
                dp[i][j]=max(dp[i-1][j+1]+a[j],dp[i-1][j]+a[j+i-1]);
            }
            else{
                dp[i][j]=min(dp[i-1][j+1]-a[j],dp[i-1][j]-a[j+i-1]);
            }
        }
    }
    cout << dp[n][1];
}


Measured memory_bytes: 70016
#pragma comment(linker, "/STACK:102400000,102400000")
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#define LL long long
using namespace std;
const int M = 1e5 + 5, INF = 0x3f3f3f3f, mod = 1000007;
char s[M];
int main() {
    while(scanf("%s",s)!=EOF){
        for(int j=0;j<4;j++) printf("%c",s[j]);
        printf(" %s\n",s+4);
    }
    return 0;
}


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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(b-a<1)
    cout << "delicious" << endl;
  else if(b-a<x+1)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
}

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

int main(void)
{
	int weight;
	int i, j;
	bool flag;

	while (scanf("%d", &weight) != EOF) {
		flag = false;
		for (i = 0; i < 10; i++) {
			if (weight & (1 << i)) {
				if (flag == true) putchar(' ');
				printf("%d", (1 << i));
				flag = true;
			}
		}
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
    int n, x[100], y[100];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i];
    for (int i = 0; i < n; i++) cin >> y[i];
    
    double d[4];
    for (int i = 0; i < 4; i++) d[i] = 0.0;
    
    for (int p =1; p <= 3; p++){
        for (int i = 0; i < n; i++){
            d[p]+= pow(fabs(x[i] - y[i]), p);
            
        }
        d[p] = pow(d[p], 1.0/p);
        
    }
    for (int i = 0; i < n; i++) {
        d[0] = (d[0] < fabs(x[i]- y[i])?fabs(x[i] - y[i]):d[0]);
        
    }
    printf("%lf\n",d[1] );
    printf("%lf\n", d[2]);
    printf("%lf\n", d[3]);
    printf("%lf\n", d[0]);
    return 0;
    
    
}


Measured memory_bytes: 3336
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define fr(i,x,n) for(int i=x;i<=n;i++)
#define rf(i,n,x) for(int i=n;i>=x;i--)
#define mst(x,i) memset(x,i,sizeof(x))
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define PB push_back
#define X first
#define Y second
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int maxn=1E5+5;
const int maxm=1E5+5;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const LL mod=1E9+7;
const double eps=1E-6;
const double PI=acos(-1.0);
LL dp[maxn],w[maxn],v[maxn];
void solve(){
    int n,W;
    cin>>n>>W;
    rep(i,n) cin>>w[i]>>v[i];
    rep(i,n){
        rf(j,W,w[i]){
            dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout<<*max_element(dp,dp+W+1)<<"\n";
}
int main(){
    IOS;
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

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

struct point{ int x; int y;};
int main(){
	int n;
	cin >> n;
	struct point p[n];
	rep(i,n)cin >> p[i].x >> p[i].y;
	double ans=0;
	rep(i,n){
		rep(j,n){
			ans+=sqrt(pow(p[i].x-p[j].x, 2.0) + pow(p[i].y-p[j].y, 2.0));
		}
	}
	ans = ans / n;
	printf("%.7lf\n", ans);
	return 0;
}


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

int main(void)
{
	char str[3][4];
	int h[3][256], w[3][256], n[3][256];
	int i, j;
	char flag;
	
	while (1){
		
		memset(h, 0, sizeof(h));
		memset(w, 0, sizeof(w));
		memset(n, 0, sizeof(n));
		
		for (i = 0; i < 3; i++){
			scanf("%s", str[i]);
			if (str[i][0] == '0') return (0);
			for (j = 0; j < 3; j++){
				h[i][str[i][j]]++;
				w[j][str[i][j]]++;
				if (i == j) n[0][str[i][j]]++;
				if (i + j == 2) n[1][str[i][j]]++;
			}
		}
		
		flag = 0;
		for (i = 0; i < 3; i++){
			if (h[i]['b'] == 3 || w[i]['b'] == 3 || n[i]['b'] == 3){
				printf("b\n");
				flag = 1;
				break;
			}
			if (h[i]['w'] == 3 || w[i]['w'] == 3 || n[i]['w'] == 3){
				printf("w\n");
				flag = 1;
				break;
			}
		}
		if (!flag){
			printf("NA\n");
		}
	}
}

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

const int INF = 1 << 28;

int main()
{
  int n;
  while (cin >> n) {
    vector<vector<int> > dp(n, vector<int>(n, INF));
    for (int i = 0; i < n; ++i) {
      int r, k;
      cin >> r >> k;
      --r;
      for (int j = 0; j < k; ++j) {
	int t;
	cin >> t;
	--t;
	dp[r][t] = 1;
      }
    }

    for (int k = 0; k < n; ++k) {
      for (int i = 0; i < n; ++i) {
	for (int j = 0; j < n; ++j)
	  dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
      }
    }

    int p;
    cin >> p;
    while (p--) {
      int s, d, v;
      cin >> s >> d >> v;
      --s;
      --d;
      if (dp[s][d] < v)
	cout << dp[s][d]+1 << endl;
      else
	cout << "NA" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using Pi = pair<int, int>;
using ll = long long;

int main() {
    int N;
    set<int> st;
    Pi data[200005];
    ll ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> data[i].first;
        data[i].second = i;
    }
    sort(data, data + N);
    st.insert(-1);
    st.insert(N);
    for (int i = 0; i < N; i++) {
        ll p = data[i].second;
        ll r = *st.lower_bound(p);
        ll l = *(--st.lower_bound(p));
        ans += (r - p) * (p - l) * data[i].first;
        st.insert(p);
    }

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

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    IOS
    long double n;
    cin>>n;
    long double res=(n*n*n)/((long double)27);
    cout<<fixed<<setprecision(9)<<res;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC107A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            Console.WriteLine(a - b + 1);
            Console.ReadKey();
        }
    }
}


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

int main() {
    long a,b;
    int count=0;

    cin >> a;
    cin >> b;

    for(long i=a; i<=b; i++) {
        if((i/10000)==(i%10) && ((i%10000)/1000)==((i/10)%10)) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial
from pprint import pprint

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N = int(input())

BA = []
for i in range(N):
    a, b = [int(x) for x in input().split()]
    BA.append((b, a))

BA.sort()

c = 0
ans = True
for i in range(N):
    b, a = BA[i]
    c += a
    # print("i:{}, c:{}, a:{},b:{}".format(i, c, a, b))
    if c > b:
        ans = False
        break

if ans == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 30248
N = int(input())
A = list(map(int,input().split())) 


cnt_yes = 1
cnt_no = 0
for i in range(N):
    if A[i] != cnt_yes:
        cnt_no+=1
    else:
        cnt_yes+=1

flag = False
for a in A:
    if a ==1:
        flag = True
    
if flag:
    print(cnt_no)
else:
    print('-1')     

Measured memory_bytes: 24744
#include<stdio.h>

//Card's struct
typedef struct{
  char c;
  int n;
}Card;


int main()
{
  int N;
  Card card1[36], card2[36], card3[36];
  Card copy;
  char c;
  int mini;
  int i, j, k;

  //Read N and Cards
  scanf("%d\n", &N);
  for(i=0; i<N; i++)
    {
      scanf("%c%d", &card1[i].c, &card1[i].n);
      //this operation is a step to read ' '.
      scanf("%c", &c);
    }

  //Copy to card_selectiotn and order
  for(i=0; i<N; i++)card2[i]=card1[i];

  //this sort is very stable.
  k=0;
  for(i=1; i<=9; i++)
    {
      for(j=0; j<N; j++)
	{
	  if(card1[j].n==i)
	    {
	      card3[k]=card1[j];
	      k++;
	    }
	}
    }

  //---------------------start----------------------------
  //Begin Bubble Sort
  for(i=0; i<N; i++)
    {
      for(j=1; j<N; j++)
	{
	  if(card1[j].n<card1[j-1].n)
	    {
	      copy=card1[j];
	      card1[j]=card1[j-1];
	      card1[j-1]=copy;
	    }
	}
    }

  //print
  for(i=0; i<N; i++)
    {
      if(i!=N-1)printf("%c%d ", card1[i].c, card1[i].n);
      else printf("%c%d\n", card1[i].c, card1[i].n);
    }

  //Is this Stable?
  k=0;
  for(i=0; i<N; i++)
    {
      if(card1[i].c!=card3[i].c)
	{
	  printf("Not stable\n");
	  k++;
	  break;
	}
    }
  if(k==0)printf("Stable\n");

  //------------------------------------------
  //Selection Sort
  for(i=0; i<N; i++)
    {
      mini=i;
      for(j=i; j<N; j++)
	{
	  if(card2[j].n<card2[mini].n)mini=j;
	}
      copy=card2[i];
      card2[i]=card2[mini];
      card2[mini]=copy;
    }


  //print
  for(i=0; i<N; i++)
    {
      if(i!=N-1)printf("%c%d ", card2[i].c, card2[i].n);
      else printf("%c%d\n", card2[i].c, card2[i].n);
    }

  //Is this Stable?
  k=0;
  for(i=0; i<N; i++)
    {
      if(card2[i].c!=card3[i].c)
	{
	  printf("Not stable\n");
	  k++;
	  break;
	}
    }
  if(k==0)printf("Stable\n");
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second




int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 0;i < t.size();i++)s += t[i];
	int a = stoi(s);
	if (sqrt(a) == (int)sqrt(a))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 long long INF = 1LL << 60;
long long dp[100010];

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < 100010; i++)
    {
        dp[i] = INF;
    }
    dp[0] = 0;

    for (int i = 0; i < N; i++)
    {
        chmin(dp[i + 1], dp[i] + 1);
        for (int j = 1; j < 100010; j++)
        {
            if (pow(6, j) > N - i)
            {
                break;
            }
            int num = pow(6, j);
            chmin(dp[i + num], dp[i] + 1);
        }
        for (int j = 1; j < 100010; j++)
        {
            if (pow(9, j) > N - i)
            {
                break;
            }
            int num = pow(9, j);
            chmin(dp[i + num], dp[i] + 1);
        }
    }

    cout << dp[N] << endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string s;
	cin>>s;
	if(s=="Sunny")cout<<"Cloudy"<<endl;
	if(s=="Cloudy")cout<<"Rainy"<<endl;
	if(s=="Rainy")cout<<"Sunny"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = {}
ans = 0


for i in range (0,n):
    temp = 0
    linp =  sorted(input())
    inp = ''.join(linp)
    if inp in d:
        ans = ans + d[inp]
        d[inp] = d[inp] + 1
    else:
        d[inp] = 1
print(ans)
 


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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> l;
	vector<int> r;
	for(int i = 0; i<n; i++){
		int x;
		cin >> x;
		if(x<0){
			l.push_back(-x);
		}
		else{
			r.push_back(x);
		} 
	}
	sort(l.begin(),l.end());
	sort(r.begin(),r.end());
	int ans = 1000000000;
	for(int i = 0; i<=l.size() && i<=k; i++){
		int a = 0;
		if(i>0){
			a = l[i-1];
		}
		int rem = k-i;
		if(rem>r.size()){
			continue;
		}
		int b = 0;
		if(rem>0){
			b = r[rem-1];
		}
		ans = min(ans,a+b+min(a,b));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1020
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int arr[10]={1,2,4,8,16,32,64,128,256,512}; 
  
 int main()
 {
   int N;
   while(cin>>N)
   {
     int count=0;
     int num[10]={0};
     while(N)
     {
       num[count++]=N%2;
       N/=2;        
     }      
     for(int i=0;i<count-1;i++)
     {
       if(num[i]) cout<<arr[i]<<" ";
     }
     if(num[count-1]) cout<<arr[count-1]<<endl;
     else cout<<endl;           
   }
   //while(1);     
   return 0;  
 }
 

Measured memory_bytes: 3088
using System;

class D
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		long n = h[0], k = h[1];

		long r = 1, M = n * (n + 1) / 2, m = M;
		for (long i = n; i >= k; i--)
			r += (M -= n - i) - (m -= i) + 1;
		Console.WriteLine(r % 1000000007);
	}
}


Measured memory_bytes: 27528
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll>pairs;
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c,f;
	string s;
	cin>>s;
	c=0;
	f=0;
	for(i=0;i<s.length();i++)
	{
	    if(s[i]=='W')
	    f+=c;
	    else
	    c++;
	}
	cout<<f;
	return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,t,t2;
  cin >> n >> t;
  ll ans = 0;
  t2 = 0;
  rep(i,n){
    ll k;
    cin >> k;
    if(t2+t < k){
      ans += t;
      t2 = k;
    }
    else{
      ans += (k-t2);
      t2 = k;
    }
  }
  ans += t;
  cout << ans << endl;
  return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;

struct Comb
{
	const long long mod;
	vector<long long> fac, ifac;

	Comb(long long n, long long m) : mod(m)
	{
		fac.resize(n+1);
		ifac.resize(n+1);

		fac[0] = 1;
		ifac[0] = 1;
		for (long long i = 0; i < n; ++i)
		{
			(fac[i+1] = fac[i]*(i+1)) %= mod;
			(ifac[i+1] = ifac[i]*mpow(i+1, mod-2)) %= mod;
		}
		
	}

	long long mpow(long long x, long long n)
	{ 
		long long ans = 1;
		while(n != 0){
			if(n&1) ans = ans*x % mod;
			x = x*x % mod;
			n = n >> 1;
		}
		return ans;
	}

	long long comb(long long a, long long b)
	{ 
		if(a == 0 && b == 0)return 1;
		if(a < b || a < 0)return 0;
		long long tmp = ifac[a-b]* ifac[b] % mod;
		return tmp * fac[a] % mod;
	}
};


int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	Comb cb(2010, MOD);
	ll N, K; cin >> N >> K;

	for (ll i = 1; i <= K; ++i)
	{
		ll tmp = cb.comb(N-K+1, i) * cb.comb(K-1, i-1);
		std::cout << tmp % MOD << std::endl;
	}
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, D;
  IN(N,D);
  ll ans = 0;
  ll X, Y;
  REP(i,N){
    IN(X,Y);
    if(X*X+Y*Y<=D*D){
      ans++;
    }
  }

  OUT(ans);

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t = ""; cin >> s;
    int n = s.size(), st = 0;
    int ans = 0;
    if (n == 1) cout << 1 << "\n";
    else {
        rep (i, 1, n + 1) {
            // if (string u = s.substr(st, i - st); u != t) {
            if (s.substr(st, i - st) != t) {
                t = s.substr(st, i - st);
                eprintf("%s ", t.c_str());
                st = i;
                ans++;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 720
fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map(String::toInt)

    if(B == 1){
        println(0)
        return
    }

    var sum = A
    var cnt = 1
    while (true) {
        if (sum >= B) {
            println(cnt)
            return
        }
        sum += A - 1
        cnt++
    }

}


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

struct UF {
    vector<int> par;
    UF(int N) : par(N) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> nums(n);
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
        nums[i]--;
    }
    UF uf(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        uf.unite(x, y);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (uf.same(i, nums[i])) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

vector<int> G[100005];
int dg[100005];
int D[100005];
int n, m;

int getLongestPath() {
    queue<int> Q;
    for (int i = 1; i <= n; ++i) {
        if (dg[i] == 0) {
            Q.push(i);
        }
    }
    
    int ans = 0;
    
    while (!Q.empty()) {
        int nod = Q.front();
        Q.pop();
        
        ans = max(ans, D[nod]);
        
        for (auto& dest: G[nod]) {
            --dg[dest];
            if (dg[dest] == 0) {
                Q.push(dest);
                D[dest] = D[nod] + 1;
            }
        }
    }
    
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    
    cin >> n >> m;
    
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        
        G[a].push_back(b);
        ++dg[b];
    }
    
    cout << getLongestPath();
    
    return 0;
}

Measured memory_bytes: 6528
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();

        if (u.equals(s)) {
            a -= 1;
        } else {
            b -= 1;
        }

        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 21716
using System;
class Program {
  static void Main(string[] args) {
    string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
    ulong h = ulong.Parse(str[0]);
    ulong w = ulong.Parse(str[1]);
    if(h == 1 || w == 1){
      Console.Write(1);
    }else{ 
      ulong output = h * w;
      Console.Write(output%2==0?output/2:output/2+1);//改行なし出力
    }
  }
 }

Measured memory_bytes: 11092