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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

const long long MAX = 510000;  // 最大を決めておく
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理、先にやっておく
void nCr_init() {
  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;
  }
}

// nCrを計算する (前処理は忘れないように)
long long nCr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

// nHrを計算する (nCrとセットです)
// n個の区別する箱にr個の区別しない玉を入れる組み合わせ
long long nHr(int n, int r) {
  return nCr(n + r - 1, r);
}

// ====================================================================

int main() {
  nCr_init();
  ll n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    cout << nCr(k - 1, i - 1) * nHr(i - 1 + 2, (n - k - (i - 1))) % MOD << endl;
  }
}


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

int main(){
    int a;
    cin >> a;
    if(a >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
H,W=map(int,input().split())
S=[input() for i in range(H)]
table=[[0]*(H+W-1) for i in range(H+W-1)]
for j in range(H):
    for i in range(W):
        table[i+j][i-j+H-1]=S[j][i]
yoko=[[0]*(H+W) for i in range(H+W-1)]
for j in range(H+W-1):
    for i in range(1,H+W):
        if table[j][i-1]=='#':
            yoko[j][i]=yoko[j][i-1]+1
        else:
            yoko[j][i]=yoko[j][i-1]
tate=[[0]*(H+W-1) for i in range(H+W)]
for j in range(1,H+W):
    for i in range(H+W-1):
        if table[j-1][i]=='#':
            tate[j][i]=tate[j-1][i]+1
        else:
            tate[j][i]=tate[j-1][i]

ans=0
for y in range(H+W-1):
    for x in range((y+H-1)%2,H+W-1,2):
        if table[y][x]!='#':
            continue
        for z in range(x+2,H+W-1,2):
            if table[y][z]=='#':
                d=z-x
                if y+d<H+W-1:
                    ans+=yoko[y+d][z+1]-yoko[y+d][x]
                    #print(1,'.',ans,':',x,y,z)
                if y-d>=0:
                    ans+=yoko[y-d][z+1]-yoko[y-d][x]
                    #print(2,'.',ans,':',x,y,z)
        for w in range(y+2,H+W-1,2):
            if table[w][x]=='#':
                e=w-y
                if x+e<H+W-1:
                    ans+=tate[w][x+e]-tate[y+1][x+e]
                    #print(3,'.',ans,':',x,y,w)
                if x-e>=0:
                    ans+=tate[w][x-e]-tate[y+1][x-e]
                    #print(4,'.',ans,':',x,y,w)

print(ans)



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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    int n, m;
    cin >> n >> m;
    int ans = 0;
    int lmax = 0, rmin = 100100;
    rep(i, m){
        int l, r;
        cin >> l >> r;
        lmax = max(lmax, l);
        rmin = min(rmin, r);
    }

    if(rmin - lmax >= 0){
        cout << rmin - lmax + 1 << endl;
    }else{
        cout << 0 << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    int d = 1;
    int64_t result = 0;
    rep(i, n)
    {
        if (i == 0) {
            result += a[i] - 1;
            d = 2;
        } else {
            int q = a[i] / d, r = a[i] % d;
            if (r == 0) {
                result += q - 1;
                if (q == 1) {
                    d++;
                }
            } else {
                result += q;
            }
        }
    }
    cout << result << endl;

    return 0;
}

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

int main() {
  int n;
  string s;
  cin>>n>>s;
  int cnt=0;
  rep(i,n){
    if(s[i]=='A' && i+1<n && i+2<n){
      if(s[i+1]=='B' && s[i+2]=='C'){
        cnt++;
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}

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


using namespace std;

int main(){
   int n;
   cin>>n;
   int k;
   int cnt=0;
   cin>>k;
    vector<int>H;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        H.push_back(x);
    }
    for(int i=0;i<n;i++){
        if(H[i]>=k){
            cnt++;
        }
    }
cout<<cnt;

}

Measured memory_bytes: 892
#include <stdio.h>
#define N 500000
#define inf 2000000000
void merge(int *,int,int,int,int);
void mergeSort(int *,int,int,int);
int cnt;
int L[N/2+2],R[N/2+2];
int main()
{
  int n,A[N],i;
  cnt = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
{
  scanf("%d",&A[i]);
}
mergeSort(A,n,0,n);
for(i=0;i<n;i++)
{
  printf("%d",A[i]);
  if(i!=n-1)
    printf(" ");
}
printf("\n");
printf("%d\n",cnt);
return 0;
}
void merge(int *A,int n,int left,int mid,int right)
{
  int i,j,k,n1, n2;
  n1 = mid - left ;
  n2 = right - mid;
  for(i=0;i<n1;i++)
    L[i] = A[left + i];
  for(i=0;i<n2;i++)
    R[i] = A[mid + i];
  L[n1] = inf;
  R[n2] = inf;
  i = 0;
  j = 0;
  for(k=left;k<right;k++)
    {
      cnt++;
      if(L[i] <= R[j])
        {
          A[k] = L[i++];
        }
      else
        {
          A[k] = R[j++];
        }
    }
}
void mergeSort(int *B,int n,int left,int right)
{
  int mid;
  if(left+1 < right)
  {
    mid = (left + right)/2;
     mergeSort(B,n,left,mid);
     mergeSort(B,n,mid,right);
    merge(B,n,left,mid,right);
  }
}



Measured memory_bytes: 5644
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: i32,
        t: i32
    }
    println!("{}", std::cmp::max(x-t,0));
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
map<int,bool>m;
int main(){    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x,n;
    cin>>x>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        m[a]=1;
    }
    int mn=1e9,ans=0;
    for(int i=-101;i<=101;i++){
        if(abs(x-i)<mn&&!m[i]){
            ans=i;
            mn=abs(x-i);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3676
def culc_factrial(n):
    factrial = [1]*(n+1)
    for i in range(1, n+1):
        factrial[i] = factrial[i-1] * i

    return factrial


factrial = culc_factrial(2000)
N, K = map(int, input().split())
for i in range(1, K+1):
    hoge = factrial[N-K+1] // (factrial[i]*factrial[N-K+1-i])
    fuga = factrial[K-1] // (factrial[i-1]*factrial[K-i])
    print(hoge*fuga % 1000000007)


Measured memory_bytes: 5748
N, M = map(int,input().split())
PY = [list(map(int,input().split()))+[0] for _ in range(M)]
sort_PY = sorted(PY, key = lambda x: x[1])
city = {}
for py in sort_PY:
  if(py[0] in city):
    city[py[0]] += 1
  else:
    city[py[0]] = 1
  py[2] = city[py[0]]
for py in PY:
  print(str(py[0]).zfill(6) + str(py[2]).zfill(6))

Measured memory_bytes: 30096
// IlyM

#include <bits/stdc++.h>
#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=998244353;
int a[4][4],n,b[N];
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	fo(i,0,2) fo(j,0,2) cin>>a[i][j];
	cin>>n;
	fo(i,0,n-1) {
		cin>>b[i];
		fo(j,0,2) fo(k,0,2) if (a[j][k]==b[i]) a[j][k]=0;
	}
	bool t=false;
	fo(i,0,2) if (a[i][0]+a[i][1]+a[i][2]==0) t=true;
	fo(i,0,2) if (a[0][i]+a[1][i]+a[2][i]==0) t=true;
	if (a[0][0]+a[1][1]+a[2][2]==0) t=true;
	if (a[2][0]+a[1][1]+a[0][2]==0) t=true;
	if (t) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
int main()
{
	int n;
	ll x;
	cin >> n >> x;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	ll count = 0;
	rep(i, n)
	{
		if (x >= a[i])
		{
			x -= a[i];
			count++;
		}
	}
	// 飴が余っていたら一人にだけあまりを全て与える。ほしい数ちょうどじゃないのでcount--
    if (count == n && x > 0) count--;
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
long long int Max(long long int a,long long int b){
    if(a>=b)return a;
    else return b;
}
long long int comb(long long int n,long long int r){
    vector<vector<long long int> > v(n+1,vector<long long int>(n+1,0));
    long long int i,j;
    rep(i,0,n+1){
        v.at(i).at(0)=1;
        v.at(i).at(i)=1;
    }
    rep(i,0,n+1){
        rep(j,0,i)v.at(i).at(j)=v.at(i-1).at(j-1)+v.at(i-1).at(j);
    }
    return v.at(n).at(r);
}
int main(void){
    int N,i,sum=0,m;
    cin>>N;
    m=N+1;
    vector<int> data(N);
    rep(i,0,N)cin>>data.at(i);
    rep(i,0,N){
        if(data.at(i)<m)sum++;
        m=min(m,data.at(i));
    }
    cout<<sum<<endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int a[5];
int main()
{
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	cout<<a[3]-a[1];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int D;
long long G;
vector<long long> p, c;

int main() {
        cin >> D >> G;
        p.resize(D); c.resize(D);
        rep(i,D) cin >> p[i] >> c[i];

        long long res = 1<<29;
        rep(i, 1<<D) {
                long long sum = 0;
                long long num = 0;
                rep(j,D) {
                        if (i & (1<<j)) sum += c[j] + p[j] * 100 * (j+1), num += p[j];
                }
                if (sum >= G) {
                        res = min(res, num);
                }
                else {
                        for (int j = D-1; j >= 0; j--) {
                                if (i & (1<<j)) continue;
                                for (int k = 0; k < p[j]; ++k) {
                                        if (sum >= G) break;
                                        sum += 100 * (j+1);
                                        ++num;
                                }
                        }
                        res = min(res, num);
                }
        }
        cout << res << endl;
}


Measured memory_bytes: 764
import collections
found = (-1,-1)
s = raw_input()
if len(s) ==2:
	found = (1,2) if s[0] == s[1] else (-1,-1)

	print found[0], found[1]
	 
else:		
	for i in range(len(s)-2):
		cs = collections.Counter(s[i:i+3])
		if sorted(cs.values())[-1] >=2 and len(cs)>=2:
			found = (i+1,i+3)
			break

	print found[0], found[1]


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

int main() {
    std::string order; std::cin >> order;
    int num_of_o; num_of_o = std::count(order.cbegin(), order.cend(), 'o');
    printf("%d\n", 700 + 100 * num_of_o);

    return 0;
}

Measured memory_bytes: 764
N, K = map(int,input().split())
edges = []

if K > (N-1)*(N-2)//2:
    print(-1)
else:
    edges.append((1,2))
    for i in range(3, N+1):
        edges.append((2, i))
    sa = (N-1)*(N-2)//2 - K
    for i in range(min(sa, N-2)):
        sa -= 1
        edges.append((1, i+3))
    if sa != 0:
        i = 3
        j = 4
        while sa > 0:
            while j <= N and sa > 0:
                edges.append((i, j))
                j += 1
                sa -= 1
            i += 1
            j = i + 1
        print(len(edges))
        for i in range(len(edges)):
            print(edges[i][0], edges[i][1])
    else:
        print(len(edges))
        for i in range(len(edges)):
            print(edges[i][0], edges[i][1])
    

Measured memory_bytes: 3992
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - i18n
            string s = Console.ReadLine();

            int count = s.Length - 2;
            string left = s.Substring(0, 1);
            string right = s.Substring(s.Length - 1, 1);

            Console.WriteLine(left + count + right);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	int n,a,b;
	scanf("%d",&n);
	if(n==1){
		printf("Hello World");return 0;
	}
	else{
		scanf("%d%d",&a,&b);
		printf("%d",a+b);
	}
	return 0;
}

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

int main(void){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int area1 = A* B;
    int area2 = C* D;
    int ans = max(area1, area2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define LL long long
using namespace std;
LL a[200001],sum=0;
int main()
{
    LL a[200001],sum=0;
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]>i||i>0&&(a[i]-1>a[i-1]))
        {
            printf("-1\n");
            return 0;
        }
        if(a[i]-1==a[i-1]&&i>0)
            sum++;
        else
            sum+=a[i];
    }
    cout<<sum; 

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<string> vs(N);
        for(auto& s : vs) cin >> s;
        int res = 0;
        for(int i=0;i<N;i++){
            bool ok = true;
            for(int j=0;j<N;j++){
                for(int k=j+1;k<N;k++){
                    if(vs[j][(k+i)%N] != vs[k][(j+i)%N]) ok = false;
                }
            }
            if(ok) res += N;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 384
S = input()
T = input()
count = 0
forecastlist = []
realweatherlist = []
for forecast in S:
  forecastlist.append(forecast)
for weather in T:
  realweatherlist.append(weather)
  
for i in range(3):
  if forecastlist[i] == realweatherlist[i]:
    count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <set>

struct NodeValue
{
    int elevation;
    std::set<int> linked_nodes;
};

int main()
{
    std::map<int, NodeValue> nodes;

    int N, M;
    std::cin >> N >> M;

    for (int n = 0; n < N; ++n)
    {
        NodeValue value;
        std::cin >> value.elevation;

        nodes.emplace(n + 1, value);
    }

    for (int m = 0; m < M; ++m)
    {
        int A, B;
        std::cin >> A >> B;

        nodes[A].linked_nodes.insert(B);
        nodes[B].linked_nodes.insert(A);
    }

    int result = 0;

    for (const auto& node : nodes)
    {
        if (node.second.linked_nodes.empty())
        {
            ++result;
            continue;
        }

        bool bad = false;
        for (const auto& other_node : node.second.linked_nodes)
        {
            if (node.second.elevation <= nodes[other_node].elevation)
            {
                bad = true;
                break;
            }
        }

        if (!bad)
        {
            ++result;
        }
    }

    std::cout << result << std::endl;
}


Measured memory_bytes: 23868
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  int ans = 0;
  for(int i=1;i<n-1;i++){
    if(A[i-1]<A[i] && A[i]<A[i+1]){
      ans++;
    }
    else if(A[i-1]>A[i] &&A[i]>A[i+1]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, std::vector<long long> L){
  sort(all(L));
  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    for (int l = i+1; l < N; l++) {
      auto it = lower_bound(all(L),L[i]+L[l]);
      ans += (int)(it - L.begin() - 1) - l;
    }
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U> void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
using ld = long double;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type>
ostream& operator<<(ostream& os, T const& v) { os << "{"; for (auto const& x : v) os << " " << x; return os << " }"; }
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } my_init;

template <class T, size_t d, class = typename enable_if<(d == 0)>::type> constexpr auto make_v(T const& x = {}) { return x; }
template <class T, size_t d, class... U, class = typename enable_if<(d > 0)>::type> constexpr auto make_v(size_t n, U... x) { auto val = make_v<T,d-1>(x...); return vector<decltype(val)>(n, move(val)); }
template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> constexpr bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> constexpr bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> constexpr auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
const ll INF = (1LL<<62)-1; // ~ 4.6e18
////////////////////////////////

int32_t main() {
    int n,ww; cin >> n >> ww;
    vector<int> w(n), v(n);
    rep (i,n) cin >> w[i] >> v[i];
    const int NN = 1e5+10;
    vector<int> dp(NN);
    rep (i,n) repR (j,NN) if (j+w[i] < NN) chmax(dp[j+w[i]], dp[j]+v[i]);
    cout << dp[ww] << endl;
}


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

long long dp[2222][2222];

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(auto &i:A)cin >> i;
	vector<pair<long long,int>> c(N);
	for(int i=0;i<N;i++)c[i]=make_pair(A[i],i);
	
	sort(c.begin(),c.end());
	reverse(c.begin(),c.end());
	
	for(int xy=1;xy<=N;xy++){
		long long C=c[xy-1].first;
		int p=c[xy-1].second;
		for(int x=0;x<=min(N,xy);x++){
			int y=xy-x;
			if(0<x && x<N)dp[x][y]=max(dp[x][y],dp[x-1][y]+C*(p-(x-1)));
			if(0<y && y<N)dp[x][y]=max(dp[x][y],dp[x][y-1]+C*((N-1)-(y-1)-p));
		}
	}
	
	long long ans=0;
	for(int i=0;i<=N;i++)ans=max(ans,dp[i][N-i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 26960
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

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

	int n;
	cin >> n;

	vector<pair<string, ll>> songs(n);
	for (auto& pr : songs) cin >> pr.first >> pr.second;

	string tar;
	cin >> tar;

	ll res = 0;
	for (int i = n-1; i >= 0; --i) {
		if (songs[i].first == tar) break;
		res += songs[i].second;
	}
	cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int num[5];
  int result = 0;
  int min = 123;
  int min_index = -1;

  for(int i=0; i<5; ++i)
  {
    cin >> num[i];
    if(num[i]%10 !=0 && num[i]%10 < min)
    {
      min = num[i]%10;
      min_index = i;
    }
  }

  for(int i=0; i<5; ++i)
  {
    if(i != min_index && num[i]%10 !=0)
    {
      result += 10-num[i]%10;
    }
    result += num[i];
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  unordered_map<int, int> c;
  rep(i, n) c[a[i]]++;

  int ans = 0;
  FOR(i, 1, 99999) ans = max(ans, c[i - 1] + c[i] + c[i + 1]);
  cout << ans << endl;




  
  return 0;
}

Measured memory_bytes: 4772
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 100010
int cnt[N];

int main(){
	int n;
	cin>>n;
	rep(i, n){
		int a;
		cin>>a;
		rep(j, 3) cnt[a+j-1]++;
	}
	ll res = 0;
	rep(i, N) res = max<ll>(res, cnt[i]);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>          
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

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

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	cin >> k;
	cout << k / 2 * (k - k/2 ) << '\n';
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = n-1
for i in range(30):
  a -= 26**(i+1)
  if a < 0:
    b = i
    c = a + 26**(i+1)
    break
l = []
for i in range(b+1):
  l.append(c % 26)
  c = c //26
cha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
ans = ""
for i in range(b+1):
  t = cha[l[b-i]]
  ans += t
print(ans)

Measured memory_bytes: 9224
def read_tokens():
    return input().strip().split(' ')

def read_ints():
    return [int(token) for token in read_tokens()]

def connected(edges):
    n = len(edges)
    vis = [False] * n
    def dfs(u):
        if vis[u]:
            return
        vis[u] = True
        for v in edges[u]:
            dfs(v)
    dfs(0)
    return all(vis)

def good(edges):
    n = len(edges)
    s = []
    for i in range(n):
        s.append(sum(edges[i]) + len(edges[i]))
    return min(s) == max(s)

# n, = read_ints()
# m = n * (n - 1) // 2
# for mask in range(1, 2**m):
#     edges = [[] for _ in range(n)]
#     mm = mask
#     for u in range(n):
#         for v in range(u + 1, n):
#             if mm % 2 > 0:
#                 edges[u].append(v)
#                 edges[v].append(u)
#             mm = mm // 2
#     # print(mask, edges)
#     if connected(edges) and good(edges):
#         print(edges)

def out(edges):
    print(sum(len(a) for a in edges) // 2)
    for idx, a in enumerate(edges):
        for v in a:
            if idx < v:
                print(idx+1, v+1)


def even(n):
    edges = [[] for _ in range(n)]
    s = (n + 1) * (n - 2) // 2
    sums = [s] * n
    for i in reversed(range(n)):
        # print(i, sums, edges)
        for j in reversed(range(i)):
            # if j + 1 <= sums[i] and i + 1 <= sums[j]:
            if i + j != n - 1:
                sums[i] -= j + 1
                sums[j] -= i + 1
                edges[i].append(j)
                edges[j].append(i)
    assert(max(sums) == 0 and min(sums) == 0)
    return edges

def odd(n):
    edges = [[] for _ in range(n)]
    s = n * (n - 1) // 2
    sums = [s] * n
    for i in reversed(range(n)):
        # print(i, sums, edges)
        for j in reversed(range(i)):
            # if j + 1 <= sums[i] and i + 1 <= sums[j]:
            if i + j != n - 2:
                sums[i] -= j + 1
                sums[j] -= i + 1
                edges[i].append(j)
                edges[j].append(i)
    assert(max(sums) == 0 and min(sums) == 0)
    return edges

n, = read_ints()
if n % 2 == 0:
    out(even(n))
else:
    out(odd(n))

Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n + 1];
        boolean[] same = new boolean[n + 1];
        for (int i = 1; i <= n; i++) {
            p[i] = sc.nextInt();
            if (p[i] == i) {
                same[i] = true;
            }
        }

        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            if (!same[i]) {
                continue;
            }
            cnt++;
            if (i < n && same[i + 1]) {
                i++;
            }
        }
        System.out.println(cnt);
    }

}


Measured memory_bytes: 49524
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s: String = read();
    let s = s.chars().collect::<Vec<_>>();
    let mut dp = vec![vec![vec![vec![vec![vec![vec![0; 3]; 2]; 2]; 2]; 2]; 2]; s.len() + 1];

    dp[0][0][0][0][0][0][0] = 1;
    for i in 0..s.len() {
        for j in 0..2 {
            for k in 0..2 {
                for l in 0..2 {
                    for m in 0..2 {
                        for mm in 0..2 {
                            for mmm in 0..3 {
                                let lim = if j == 1 { 9 } else { s[i].to_digit(10).unwrap() };
                                for d in 0..lim + 1 {
                                    let idx1 = if j == 1 || d < lim { 1 } else { 0 };
                                    let idx2 = if k == 1 || d == 3 { 1 } else { 0 };
                                    let idx3 = if l == 1 || d == 5 { 1 } else { 0 };
                                    let idx4 = if m == 1 || d == 7 { 1 } else { 0 };
                                    let idx5 = if mm == 1 || (d != 0 && d != 3 && d != 5 && d != 7) { 1 } else { 0 };
                                    let mut idx6 = 2;
                                    if mmm == 0 && d == 0 {
                                        idx6 = 0;
                                    } else if mmm == 0 && d != 0 {
                                        idx6 = 1;
                                    } else if mmm == 1 && d != 0 {
                                        idx6 = 1;
                                    }
                                    dp[i + 1][idx1][idx2][idx3][idx4][idx5][idx6] += dp[i][j][k][l][m][mm][mmm];
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    let mut ans = 0;
    for j in 0..2 {
        for mmm in 0..2 {
            // println!("{:?}", dp[i][j][1][1][1][0][mmm]);
            ans += dp[s.len()][j][1][1][1][0][mmm];
        }
    }
    println!("{:?}", ans);
}


Measured memory_bytes: 4352
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int calc(vector<pair<int, int> > v) {
	int n = v.size();
	int lm = 0, ls = 0, lp = -1;
	for(int i = 0; i < n; ++i) {
		if(lm < v[i].first) {
			lm = v[i].first;
			lp = i;
		}
		ls += v[i].first;
	}
	if(lm * 2 <= ls) return 0;
	for(int i = 0; i < n; ++i) {
		if(i != lp) ls += v[i].second - v[i].first;
	}
	if(lm * 2 <= ls) return 0;
	return lm * 2 - ls;
}
vector<int> dfs(int pos, int pre, const vector<vector<int> > &G, const string &S) {
	int ch = (S[pos] == '1' ? 1 : 0);
	vector<pair<int, int> > d;
	int rm = 0;
	for(int i : G[pos]) {
		if(i == pre) continue;
		vector<int> res = dfs(i, pos, G, S);
		d.push_back(make_pair(res[0], res[1]));
		ch += res[2];
		rm += res[1];
	}
	int lm = calc(d);
	return vector<int>({lm + ch, rm + ch, ch});
}
int main() {
	int N; string S;
	cin >> N >> S;
	vector<vector<int> > G(N);
	for(int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ans = inf;
	for(int i = 0; i < N; ++i) {
		vector<pair<int, int> > d;
		int sum = 0;
		for(int j : G[i]) {
			vector<int> res = dfs(j, i, G, S);
			sum += res[1];
			d.push_back(make_pair(res[0], res[1]));
		}
		int ret = calc(d);
		if(sum % 2 == 0 && ret == 0) {
			ans = min(ans, sum / 2);
		}
	}
	cout << (ans < inf ? ans : -1) << endl;
	return 0;
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    vector<ll> A(N+1);
    for(int i = 0; i <= N; ++i) cin >> A[i];
    corner(N==0&&A[0]==1,1);
    corner(A[0]!=0,-1);
    vector<ll> L(N+1),R(N+1),X(N+1,0);
    L[N]=A[N],R[N]=A[N];
    for(int i = N-1; 0 <= i; --i) {
        R[i] = R[i+1];
        L[i] = L[i+1]/2 + L[i+1]%2;
        L[i] += A[i];
        R[i] += A[i];
    }
    corner(L[0] > 1 || 1 > R[0],-1);
    X[0] = 1;
    for(int i = 1; i <= N; ++i) {
        X[i] = 2*(X[i-1]-A[i-1]);
        chmin(X[i],R[i]);
    }
    cout << accumulate(ALL(X),0LL) << endl;
    return 0;
}


Measured memory_bytes: 6548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	public void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		StringTokenizer st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}
		int q = Integer.parseInt(reader.readLine());
		st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < q; i++) {
			if (subsetSum(Integer.parseInt(st.nextToken()), a)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		reader.close();
	}
	
	private boolean subsetSum(int s, int[] a) {
		return subsetSum(0, s, a);
	}
	
	private boolean subsetSum(int i, int s, int[] a) {
		if (s == 0) {
			return true;
		}
		if (i >= a.length) {
			return false;
		}
		return subsetSum(i+1, s-a[i], a) || subsetSum(i+1, s, a);
	}
}


Measured memory_bytes: 24948
from datetime import date

while True:
    m, d = map(int, input().split())
    if (m, d) == (0, 0):
        break
    weeks = {1:'Monday',2:'Tuesday',3:'Wednesday',4:'Thursday',5:'Friday',6:'Saturday',7:'Sunday'}
    w = date.isoweekday(date(2004, m, d))
    print(weeks[w])

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

#define MAX_N 200000

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

    vector<int> ans(N+1);
    ans[0] = 0;
    for (int i = 1; i <= N; i++) {
        bitset<20> bs(i);
        int k = bs.count();
        ans[i] = 1 + ans[i%k];
    }

    int mod = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '1') mod++;
    }

    int pmod = mod + 1;
    int nmod = mod - 1;

    vector<int> pamari(MAX_N+1);
    vector<int> namari(MAX_N+1);

    pamari[0] = 1 % pmod;
    for (int i = 1; i <= MAX_N; i++) {
        pamari[i] = (pamari[i-1] * 2) % pmod; 
    }

    int psum = 0;
    int nsum = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '1') psum += pamari[N-i-1];
        psum %= pmod;
    }

    if (nmod != 0) {
        namari[0] = 1 % nmod;
        for (int i = 1; i <= MAX_N; i++) {
            namari[i] = (namari[i-1] * 2) % nmod; 
        }
        for (int i = 0; i < N; i++) {
            if (S[i] == '1') nsum += namari[N-i-1];
            nsum %= nmod;
        }
    }

    for (int i = 0; i < N; i++) {
        int ssum;
        if (S[i] == '1') {
            if (nmod > 0) {
                ssum = nsum - namari[N-i-1];
                ssum = (ssum + nmod) % nmod;
                cout << 1 + ans[ssum] << endl;
            } else {
                cout << 0 << endl;
            }
        } else {
            ssum = psum + pamari[N-i-1];
            ssum %= pmod;
            cout << 1 + ans[ssum] << endl;
        }
    }
}

Measured memory_bytes: 6032
#include<bits/stdc++.h>
using namespace std;
int main()
{

   long long int a,b,c,d,i,j,k,l;
   int cnt=0;
   cin>>a>>b>>c;
   int a1[b];
   for(i=0;i<b;i++)
    cin>>a1[i];
   while(a--)
   {
       int a2[b];
       for(i=0;i<b;i++)
       {
           cin>>a2[i];
       }
       long int sum=0;
       for(i=0;i<b;i++)
        sum+=a2[i]*a1[i];
       if(sum+c>0)
       {
           cnt++;
       }
   }
   cout<<cnt;


}


Measured memory_bytes: 256
#!/usr/bin/ruby
# coding: utf-8

PI = Math.acos(-1)
EPS = 0.00001

while true
  line = gets
  break if line == nil
  x1,y1,x2,y2,xq,yq = line.chomp.split(',').map{|x| x.to_f}

  xp, yp = 0, 0

  if x2 != x1
    m = (y2 - y1) / (x2 - x1)

    xq -= x1
    yq -= y1
    xp = (1-m*m) * xq + 2*m * yq
    yp = 2*m * xq + (m*m-1) * yq
    xp /= 1 + m*m
    yp /= 1 + m*m

    xp += x1
    yp += y1
  else
    xp = 2*x1 - xq
    yp = yq
  end

  puts "#{xp} #{yp}"

end

Measured memory_bytes: 6160
#include<bits/stdc++.h>
using namespace std;
const int N=1e9;
int main()
{
  int n,k,s;
  cin>>n>>k>>s;
  for(int i=0;i<k;i++)
  {
    cout<<s<<" ";
  }
  for(int i=k;i<n;i++)
    if(s!=N)
    cout<<s+1<<" ";
  	else
      cout<<s-1<<" ";
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

ll dp[100][2][2];

int main() {
  ll N;
  cin >> N;
  ++N;
  vector<int> bit;
  while (N > 0) {
    bit.push_back(N & 1);
    N >>= 1;
  }
  dp[0][0][0] = 1;
  for (int i = 0; i < bit.size(); i++) {
    for (int carry = 0; carry < 2; carry++) {
      for (int less = 0; less < 2; less++) {
        for (int add = 0; add <= 2; add++) {
          ll cur = dp[i][carry][less];
          int sum = carry + add;
          int v = sum & 1;
          int c = sum >> 1;
          if (less) {
            if (v == bit[i]) {
              (dp[i+1][c][1] += cur) %= MOD;
            }
          } else {
            (dp[i+1][c][0] += cur) %= MOD;
            if (v < bit[i]) {
              (dp[i+1][c][1] += cur) %= MOD;
            }
          }
        }
      }
    }
  }
  cout << dp[bit.size()][0][1] << endl;
  return 0;
}


Measured memory_bytes: 256
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
   ll n;
   cin >> n;
   vll l(n);
   rep(i,n) cin >> l[i];
   sort(all(l));
   ll ans =0;
   rep(i,n){
       if(i != n-1) ans += l[i];
   }
   if(ans > l[n-1]) cout << "Yes\n";
   else cout<<"No\n";
   return 0;
}  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] array = sc.next().toCharArray();
		for (int i=0; i<4; i++) System.out.print(array[i]);
		System.out.print(" ");
		for (int i=4; i<12; i++) System.out.print(array[i]);
		System.out.println();
		sc.close();
	}

}


Measured memory_bytes: 9676
import java.io.*;
import java.util.*;

public class Main {
private void compute(){
	Scanner scanner = new Scanner(System.in);
	for(int i =0; i < 7 ; i++){
	   int nHigh = scanner.nextInt();
	   int nLow = scanner.nextInt();
	   System.out.println(nHigh - nLow);
	}
	
}
	public static void main(String[] args) {
		new Main().compute();
		
	}

}

Measured memory_bytes: 17172
<?php
  list($h,$w) = explode(" ", trim(fgets(STDIN)));
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a = explode(" ", trim(fgets(STDIN)));

  $ans = [];
  for($i=0;$i<$h;$i++){
    $ans[$i]=[];
    for($j=0;$j<$w;$j++){
      $ans[$i][$j] = 0;
    }
  }
  $count=0;
  $v = [];
  for($i=0;$i<count($a);$i++){
    for($j=0;$j<$a[$i];$j++){
      $v[$count]=$i+1;
      $count++;
    }    
  }

  $y = 0;
  $x = 0;
  $count = 0;
  $dir = 0; // 0:down, 1:right; 2:up; 3:left
  for($i=0;$i<$h*$w;$i++){
    $ans[$y][$x] = $v[$count];
    $count++;
    if($dir == 0){
      if($y+1 >= $h || $ans[$y+1][$x]!=0){
        $dir = 1;
        $x++;
      }else{
        $y++;
      }
    }else if($dir == 1){
      if($x+1 >= $w || $ans[$y][$x+1]!=0){
        $dir = 2;
        $y--;
      }else{
        $x++;
      }
    }else if($dir == 2){
      if($y == 0 || $ans[$y-1][$x]!=0){
        $dir = 3;
        $x--;
      }else{
        $y--;
      }
    }else{
      if($x == 0 || $ans[$y][$x-1]!=0){
        $dir = 0;
        $y++;
      }else{
        $x--;
      }
    }  
  }
  for($i=0;$i<$h;$i++){
    echo implode(" ", $ans[$i]);
    echo PHP_EOL;
  }


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
ll mod = 998244353;
#define EPS 1e-1
#define PI 3.14159265

#define iofile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;

ll fastpow(ll base, ll pow)
{
    if (!base)
        return 0;
    if (!pow)
        return 1;
    if (pow == 1)
        return base;
    ll x = fastpow(base, pow / 2) % mod;
    x *= x;
    x %= mod;
    if (pow % 2)
        x *= base;
    return x % mod;
}

ll inverse(ll x)
{
    return fastpow(x, mod - 2) % mod;
}

ll fact[(int)1e6 + 5], inv[(int)1e6 + 5];
void init()
{
    fact[0] = inv[0] = 1;
    for (int i = 1; i <= 1e6; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = inverse(fact[i]);
    }
}

void factorize(ll x, map<int, int> &ss)
{
    while (x % 2 == 0)
        ss[2]++, x /= 2;
    for (int i = 3; i <= sqrt(x); i += 2)
        while (x % i == 0)
            ss[i]++, x/= i;
    if (x > 2)
        ss[x]++;
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

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

int n;
ll arr[(int)1e5 + 5];
ll dp[(int)1e5 + 5];

ll solve(int idx)
{
    if (idx == n)
        return 0;
    if (dp[idx] != -1)
        return dp[idx];
    ll res = 1e9;
    if (idx + 1 < n)
        res = min(res, abs(arr[idx] - arr[idx + 1]) + solve(idx + 1));
    else if (idx + 1 == n)
        res = min(res, solve(idx + 1));
    if (idx + 2 < n)
        res = min(res, abs(arr[idx] - arr[idx + 2]) + solve(idx + 2));
    else if (idx == n)
        res = min(res, solve(idx + 2));
    return dp[idx] = res;
}

int main()
{
    fastio
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0);
    return 0;
}


Measured memory_bytes: 4992