akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    int N, W;   cin>>N>>W;
    pii wv[N+1];    forI(i, 1, N) cin>>wv[i].ff>>wv[i].ss;

    int dp[N+1][W+1];

    forI(i, 0, W)   dp[1][i] = 0;
    dp[1][wv[1].ff] = wv[1].ss;

    forI(i, 2, N){
        forI(j, 0, W){
            dp[i][j] = dp[i-1][j];
            if(wv[i].ff > j)    continue;

            dp[i][j] = max(dp[i][j], wv[i].ss + dp[i-1][j - wv[i].ff]);
        }
    }

    int ans = -1;
    forI(i, 0, W)   ans = max(dp[N][i], ans);

    cout<<ans<<endl;
}

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

Measured memory_bytes: 81672
#include <cstdio>
#include <algorithm>
using namespace std;

int n,m,x,y,l,r;

int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        if (!l)
        {
            l=x;
            r=y;
        }
        else if (x>r || y<l)
        {
            l=0;
            break;
        }
        else
        {
            if (x>=l) l=x;
            if (y<=r) r=y;
        }
    }
    //printf("%d %d\n",l,r);
    if (!l) printf("0");
    else printf("%d",r-l+1);
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        int min = Integer.MAX_VALUE;
        boolean[] dp = new boolean[k+1];
        for(int i=0;i<n;i++)    {
            a[i] = in.nextInt();
            dp[a[i]] = true;
            min = Math.min(min, a[i]);
        }

        solve(dp, a, min);
        if(dp[k])   System.out.println("First");
        else        System.out.println("Second");
        in.close();
    }

    static void solve(boolean[] dp, int[] a, int min)    {
        for(int i=min+1;i<dp.length;i++)   {
            dp[i] = true;
            for(int j:a)    {
                if(i-j>-1)       dp[i] &= dp[i-j];
            }
            dp[i] = !dp[i];
        }
    }
}

Measured memory_bytes: 23892
MOD=10**9+7
M=2010
N,K=[int(s) for s in input().split()]
Bin=[[0 for i in range(M)] for j in range(M)]
Bin[0][0]=1
for n in range(1,M):
  Bin[n][0]=1
  for r in range(1,(n-1)//2+1):
    Bin[n][r]=(Bin[n-1][r]+Bin[n-1][r-1])%MOD
  if n%2==0:
    Bin[n][n//2]=(2*Bin[n-1][n//2-1])%MOD
def binom(n,r):
  if r<0 or r>n :
    return 0
  elif n-r<r:
    return Bin[n][n-r]
  else:
    return Bin[n][r]
for i in range(1,K+1):
  print((binom(N-K+1,i)*binom(K-1,i-1))%MOD)

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

using namespace std;
using ll = long long;


int main()
{
    map<int,int> mp;
    for(int i = 0; i < 3; i++){
        int a; cin >> a; mp[a]++;
    }
    for(auto i : mp){
        if(i.second == 1){
            cout << i.first << endl;
            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);

        String str = sc.next();
        if(str.matches("[A-Z]")){
            System.out.println("A");
        }
        else{
            System.out.println("a");
        }
    }
}

Measured memory_bytes: 35652
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#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 <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 100100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

map<pair<int,int>,int> kariEdge;
vector<pair<int,int>> trueEdge;

int parent[200005];
long long connectSize[200005];
int tall[200005];
 
int searchRoot(int V){
    //頂点Vの親==頂点Vということは頂点Vはその木の根である。
    if(parent[V] == V){
        return V;
    }
    else{
        //一回ごとにparent[V]を更新する。辺の縮約
        return parent[V] = searchRoot(parent[V]);
    }
}
 
bool same(int X,int Y){
    if(searchRoot(X) == searchRoot(Y)) return true;
    else return false;
}
 
void unite(int X,int Y){
    //X,Yの高さが高い方の木の「高さ0の根」に高さが低い方の根を付ける
    int Xroot = searchRoot(X);
    int Yroot = searchRoot(Y);
    //同じ根を持つ木を併合することはしなくてよい
    if(Xroot == Yroot) return;
    if(tall[Xroot] > tall[Yroot]){
        parent[Yroot] = Xroot;
        connectSize[Xroot] += connectSize[Yroot];
        connectSize[Yroot] = connectSize[Xroot];
    }
    else if(tall[Xroot] == tall[Yroot]){
        parent[Yroot] = Xroot;
        //高さが同じとき、YがXの根の下に入るのでYの深さはXより1深くなる
        tall[Yroot]++;
        connectSize[Xroot] += connectSize[Yroot];
        connectSize[Yroot] = connectSize[Xroot];
    }
    else {
        parent[Xroot] = Yroot;
        connectSize[Yroot] += connectSize[Xroot];
        connectSize[Xroot] = connectSize[Yroot];
    }
}

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

    int N;cin >> N;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);
    }
    long long ans = 0;
    for(int i = 0;i<N-1;i++){
        ans += retu.at(i)/2;
        retu.at(i) %= 2;
        if(retu.at(i) == 1 && retu.at(i+1) >= 1){
            ans++;
            retu.at(i+1)--;
        }
    }
    ans += retu.at(N-1)/2;
    cout << ans << endl;
}


Measured memory_bytes: 4008
N = int(input())

half = int(N**(1/2) + 1)

a=1
b=10**12
for i in range(1,half+1):
    if N%i == 0:
        if abs(a-b) > abs(i - N/i):
            a = i
            b = N//i

print(abs(a-1+b-1))

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

int main() {
    long long  a, b;
    double a_d, b_d;
    cin >> a >> b;
    a_d = (double)a;
    b_d = (double)b;
    //cout << a / b << ' ' << a % b << ' ' << a_d / b_d << endl;
    printf("%d %d %.5f\n", a / b, a % b, a_d / b_d);
    return 0;
}


Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int[] num = {64, 32, 16, 8, 4, 2, 1};
		
		for (int i = 0; i < 7; i++) {
			if (n >= num[i]) {
				System.out.println(num[i]);
				break;
			}
		}
		sc.close();
	}
}

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

int main()
{
  long long a,b,c,d,ans=0;
  cin>>a>>b>>c>>d;
  vector <long long> v={a*c,a*d,b*c,b*d};
  cout<<*max_element(v.begin(),v.end())<<"\n";}

Measured memory_bytes: 3580
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define lim 100000ll
#define siz 1000005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define MAX lim
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll power(ll a, ll b) {
  if( b == 0 ) return 1;
  ll ret = 1;
  while(b) {
    if(b&1) ret = (ret*a) %MOD;
    a = (a * a) % MOD;
    b/=2;
  }
  return ret;
}

signed main(){ 
    IOS
    //io_set();
    ll a, b;
    cin >> a >> b;
    ll x = (a+b)/2;
    ll y = (a+b)%2;
    if(y){
        cout << "IMPOSSIBLE\n";
    }
    else{
        cout << x << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#define ll long long
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll x,y,a,b,c,ans=0; cin>>x>>y>>a>>b>>c;
	vector<ll> p(a),q(b),r(c);
	for(int i=0;i<a;i++) cin>>p[i];
	for(int i=0;i<b;i++) cin>>q[i];
	for(int i=0;i<c;i++) cin>>r[i];
	sort(p.begin(),p.end(),greater<ll>());
	sort(q.begin(),q.end(),greater<ll>());
	sort(r.begin(),r.end());
	while(p.size() != x)p.pop_back();
	while(q.size() != y)q.pop_back();
	for(int i=0;i<p.size();i++) ans += p[i];
	for(int i=0;i<q.size();i++) ans += q[i];
	while(1){
		if(r.empty()) break;
		int pcom = (p.size() ? r.back() - p.back() : -1);
		int qcom = (q.size() ? r.back() - q.back() : -1);
		if(pcom <=0 && qcom <=0) break;
		if(pcom > qcom){
			ans -= p.back();
			p.pop_back();
		}else{
			ans -= q.back();
			q.pop_back();
		}
		ans += r.back();
		r.pop_back();
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 2560
n = int(input())
f = [0]*(n+1)
for x in range(1, n):
    if x*x >= n: break
    for y in range(1, n):
        if y*y >= n: break
        if x*y >= n: break
        for z in range(1, n):
            if z*z >= n: break
            k = x*x + y*y + z*z + x*y + y*z + z*x
            if 1 <= k <= n: f[k] += 1
for i in range(1, n+1): print(f[i])


Measured memory_bytes: 9048
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 500000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int N,M,R,z[1010],dL[210][210],dS[210][210],dp[1010][210];

int main(){
	while(cin>>N>>M && N){
		
		rep(i,N)rep(j,N) dL[i][j] = dS[i][j] = (i==j ? 0:INF);
		
		rep(i,M){
			int x,y,t;
			char sl;
			cin>>x>>y>>t>>sl;
			x--; y--;
			if(sl=='L') dL[x][y] = dL[y][x] = min(dL[x][y], t);
			else dS[x][y] = dS[y][x] = min(dS[x][y], t);
		}
		
		cin>>R;
		rep(i,R)cin>>z[i], z[i]--;
		
		rep(k,N)rep(i,N)rep(j,N){
			dL[i][j] = min(dL[i][j], dL[i][k]+dL[k][j]);
			dS[i][j] = min(dS[i][j], dS[i][k]+dS[k][j]);
		}
		
		rep(i,R)rep(j,N) dp[i][j]=INF;
		dp[0][z[0]]=0;
		
		rep2(i,1,R)rep(j,N)rep(k,N){
			if(j==k) dp[i][k] = min(dp[i][k], dp[i-1][j] + dL[z[i-1]][z[i]]);
			else dp[i][k] = min(dp[i][k], dp[i-1][j] + dL[z[i-1]][j] + dS[j][k] + dL[k][z[i]]);
		}
		
		int ans=INF;
		rep(i,N) ans=min(ans,dp[R-1][i]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 2028
#include<bits/stdc++.h>
using namespace std;
bool custom(int a, int b){
  return abs(a) < abs(b);
}
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  int cnt = 0;
  long long sum = 0;
  for(int i = 0; i < n; ++i){
    if(v[i] < 0) cnt++;
    sum += abs(v[i]);
  }
  sort(v.begin(), v.end(), custom);
  if(cnt % 2) cout << sum - abs(v[0]) * 2 << endl;
  else cout << sum << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for(int i=0; i<N ; i++){
    cin >> vec[i];    
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int a =0;
  int b =0;
  
  for(int i=0;i<N;i+=2){
    a += vec[i];
  }
  for(int i=1;i<N;i+=2){
    b += vec[i];
  }
  
  cout << a - b <<endl;  
  
  
}


Measured memory_bytes: 256
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 610
#define mdn 1000000007
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=1ll*ans*bs%mdn;
		bs=1ll*bs*bs%mdn; mi>>=1;
	}
	return ans;
}
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
int fac[N],inv[N],a[N],ans,n,k,r[N],b[N];
char ch[N]; bool vis[N];
void init()
{
	fac[0]=1;
	for(int i=1;i<N;i++)	fac[i]=1ll*fac[i-1]*i%mdn;
	inv[N-1]=ksm(fac[N-1],mdn-2);
	for(int i=N-1;i;i--)	inv[i-1]=1ll*inv[i]*i%mdn;
}
int C(int n,int m){return n<m?0:1ll*fac[n]*inv[m]%mdn*inv[n-m]%mdn;}
int solve(int tot,int dat)
{
	int cur=fac[tot],cnt=0;
	for(int i=1;i<=tot;i++)
	{
		if(a[i]==a[i-1])	cnt++;
		else	cur=1ll*cur*inv[cnt]%mdn,cnt=1;
	}
	cur=1ll*cur*inv[cnt]%mdn;
	int pt=1; memset(vis,0,n+1);
	for(int i=1;i<=k;i++)	if(ch[i]=='r')
		if(pt<=tot)	r[pt]=i,pt++,vis[i]=1;
	if(pt<=tot)	return 0; pt=1;
	for(int i=1;i<=k;i++)	if(ch[i]=='b')
		if(pt<=tot&&r[pt]<i&&a[pt]>=2)	b[pt]=i,pt++,vis[i]=1;
	if(pt<=tot&&a[pt]>=2)	return 0; pt=1; int qwq=a[pt]-2;
	for(int i=1;i<=k;i++)	if(!vis[i])
		if(pt<=tot&&b[pt]<i&&qwq>0)
		{
			qwq--; if(!qwq)	pt++,qwq=a[pt]-2;
		}
	if(qwq>0)	return 0;
	return 1ll*dat*cur%mdn;
}
void dfs(int val,int x,int ful,int wei)
{
	if(ful<wei)	return;
	if(!val)	return upd(ans,solve(x-1,C(ful,wei)));
	for(int i=1;i<=min(val,a[x-1]);i++)	a[x]=i,dfs(val-i,x+1,ful+(i>=2?2:0),wei+2*i);
}
int main()
{
	n=read(),k=read(); init();
	scanf("%s",ch+1); a[0]=n+1; int flag=0,flag1=0;
	for(int i=2;i<=k;i++)	if(ch[i]=='b'&&ch[i-1]=='r')	flag=1;
	for(int i=1;i<=k;i++)	if(ch[i]=='r')	flag1=1;
	if(n==1)	return puts(!flag1?"1":flag?"3":"2"),0; 
	for(int i=1;i<=n;i++)	dfs(i,1,n+1,0);
	printf("%d\n",(ans+1)%mdn);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>

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

  int ans = 0;
  if(k) {
    ans += std::min(a, k) * 1;
    k -= std::min(a, k);
  }
  if(k) {
    ans += std::min(b, k) * 0;
    k -= std::min(b, k);
  }
  if(k) {
    ans += std::min(c, k) * -1;
    k -= std::min(c, k);
  }

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


Measured memory_bytes: 3832
#include<stdio.h>
#include<iostream>
using namespace std;
int judge(int k)
{
    int cot=0;
    for(int i=1;i<=k;i++)
        if(k%i==0) cot++;
    return cot;
}
int main()
{
    int n,cot=0;
    cin>>n;
    for(int i=1;i<=n;i+=2)
    {
        if(judge(i)==8)
            cot++;
    }
    cout<<cot<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int sum=0,q,n,i,l,r;
  cin>>n;
  long long int p;
  vector<long long int>b(1000000,0);
  for(i=1;i<=n;i++)
  {
    cin>>p;
    sum=sum+p;
    b[p]++;
  }
  cin>>q;
  while(q--)
  {
    cin>>l>>r;
    sum=sum+(b[l]*(r-l));
    b[r]=b[l]+b[r];
    b[l]=0;
  cout<<sum<<endl;
  }
}


Measured memory_bytes: 11096
nums = input().split()
W = int( nums[0])
H = int( nums[1])
x = int( nums[2])
y = int( nums[3])
r = int( nums[4])
if (x - r) >= 0 and (x + r) <= W:
    if (y - r) >= 0 and (y + r) <= H:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long x = sc.nextLong();
		long y = sc.nextLong();
		
		long temp = x;
		int count = 0;
		
		while(temp <= y) {
			temp *= 2;
			count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21972
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

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

const long long MOD = 1e9+7;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

ll f(int n) {
    return (ll)n * (n - 1) / 2;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;

    ll sum = 0;
    map<int, int> mp;
    rep(i, n) mp[a[i]]++;
    for (auto p: mp) sum += f(p.second);

    rep(i, n) {
        cout << sum - f(mp[a[i]]) + f(mp[a[i]] - 1) << endl;
    }
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int x;
  cin >> x;
  
  int s1 = (x % 200) / 100;
  int s2 = (x % 20) / 10;
  int s3 =  x % 2;
  
  cout << s1 + s2 + s3;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
struct Edges { int to, next; } e[MAXN];
int head[MAXN], tot;
int c[MAXN], v[MAXN], res[MAXN];
int p[MAXN], n;
int cost[MAXN], val[MAXN], cnt;
int f[MAXN];

inline void addedge(int from, int to) {
  e[++tot] = (Edges){to, head[from]};
  head[from] = tot;
}

inline bool cmp(int x, int y) { return v[x] * c[y] > v[y] * c[x]; }

void Dfs(int now) {
  v[now] = 1;
  for (RI i = head[now]; i; i = e[i].next) {
    Dfs(e[i].to);
    v[now] += v[e[i].to];
    c[now] += c[e[i].to];
  }
}

inline int Get(int x) {
  if (x < 0) return -0x7f7f7f7f;
  int re = 0;
  for (RI i = 1; i <= n; ++i) {
    int tim = min(res[p[i]], x / c[p[i]]);
    re += tim * v[p[i]];
    x -= tim * c[p[i]];
  }
  return re;
}

void Split(int res, int c, int v) {
  for (RI i = 1; i <= res; i <<= 1) {
    ++cnt;
    cost[cnt] = i * c;
    val[cnt] = i * v;
    res -= i;
  }
  ++cnt;
  cost[cnt] = res * c;
  val[cnt] = res * v;
}

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int x, d; read(n), read(x), read(d);
  for (RI i = 1; i <= n; ++i) {
    read(c[i]);
    if (i == 1)
      res[i] = 0x7f7f7f7f;
    else {
      res[i] = d;
      int x; read(x);
      addedge(x, i);
    }
    p[i] = i;
  }
  Dfs(1);
  sort(p + 1, p + 1 + n, cmp);
  for (RI i = 1; i <= n; ++i) {
    Split(min(n, res[i]), c[i], v[i]);
    res[i] -= min(n, res[i]);
  }
  int SI = 0;
  memset(f, 0x7f, sizeof(f));
  f[0] = 0;
  for (RI i = 1; i <= cnt; ++i) {
    SI += val[i];
    for (RI j = SI; j >= val[i]; --j)
      f[j] = min(f[j], f[j - val[i]] + cost[i]);
  }
  int ans = Get(x);
  for (RI i = 1; i <= SI; ++i)
    ans = max(ans, i + Get(x - f[i]));
  printf("%lld\n", ans);

  return 0;
}

// created by Daniel yuan
/*
     ________
    /        \
   / /      \ \
  / /        \ \
  \            /
   \  ______  /
    \________/
*/


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
int main() {
    long n,k; cin>>n>>k;
    vector<long> a(n),b(n);
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    long MAX=0,mask=0;
    for(int i=0;i<=30;i++){
        if(i==0||(k&(1<<i))!=0){
            long cmask= mask|((k>>(i+1))<<(i+1));
            if(i==0) cmask=k;
            long sum=0;
            for(int i=0;i<n;i++){
                if((cmask|a[i]) == cmask)
                    sum+=b[i];
            }
            MAX=max(sum,MAX);
        }
        mask|=(1<<i);
    }
    cout<<MAX;
}

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

int main(){
  long long int n, m;
  cin >> n >> m;
  
  long long int a[10000];
  for(int i=0; i<m; i++){
    cin >> a[i];
  }
  
  for(int i=0; i<m; i++){
    n = n - a[i];
    if(n<0){
      cout << -1;
      return 0;
    }
  }
  cout << n;
  
  return 0;
}

Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner stdin = new Scanner(System.in);
		String data = null;
		double x = 0;
		double h = 0;
		double s = 0;
		while(stdin.hasNext()) {

			x = stdin.nextDouble();
			h = stdin.nextDouble();
			if(x == 0 && h == 0)
				break;
			s = x * Math.sqrt(4 * h * h + x * x) + x * x;
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 27516
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	

	ll N;
	cin >> N;
	vll A(N);
	for (int i = 0; i < N-1; i++)
	{
		cin >> A[i];
		A[i]--;
	}

	vll ans(N);
	for (int i = 0; i < N; i++)
	{
		ans[i] = 0;
	}

	for (int i = 0; i < N - 1; i++)
	{
		ans[A[i]] ++;
	}

	for (int i = 0; i < N; i++)
	{
		cout << ans[i] << endl;
	}


}





Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(ll i=a;i<b;i++)
#define ll long long

int main()
{
  int n;
  cin>>n;
  int a[n+1];
  int r[n+1][n+1];
  for(int i =0;i<=n;i++){ for(int j=0;j<=n;j++) r[i][j]=0; }; 
  for(int i=1;i<=n;i++) r[i][i] = i;
  ll prefix[n+1];
  for(int i=0;i<=n;i++) prefix[i] = 0;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
    prefix[i] = prefix[i-1]+a[i];
  }
  vector<vector<ll>> dp(n+1,vector<ll> (n+1,0));
  ll small;
  for(int d=0;d<n;d++)
  {
    for(int i=1;i+d<=n;i++)
    {
      int j= i+d;
      if(i==j)
      {
        r[i][j] = i;
        dp[i][j] = 0; 
      }
      else
      {
        dp[i][j] = 1e14;
        for(int k=r[i][j-1];k<=min(r[i+1][j],n-1);k++)
        {
          if(dp[i][j]>dp[i][k] + dp[k+1][j])
          {
            dp[i][j] = dp[i][k] + dp[k+1][j];
            r[i][i+d] = k;
          }
        }
        dp[i][i+d] += prefix[i+d]-prefix[i-1];
      }
    }
  }
  cout<<dp[1][n];
  return 0;
}

Measured memory_bytes: 5440
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector> // vectorを使うためにインクルードする
using namespace std;

int main() {
	vector<int> vc;
	int a;
	int b;
	int k;
	scanf("%d%d%d", &a, &b, &k);

	int no = 0;

	int min = (std::min)(a,b);

	for (int i = 1; i <= min;i++) {
		if (a%i == 0 && b%i == 0) {
			vc.push_back(i);
		}
	}
	printf("%d", vc[vc.size()-k]);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    pair<int,int> pai[n];
    for(int i = 0;i < n;i++)
    {
        cin >> pai[i].first >> pai[i].second;
    }
    if(n == 1)
    {
        cout << "1\n";
        return 0;
    }
    int ans = INT_MAX;
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < n;j++)
        {
            if(i == j)
            {
                continue;
            }
            int p = pai[i].first - pai[j].first;
            int q = pai[i].second - pai[j].second;
            int temp = 0;
            for(int k = 0;k < n;k++)
            {
                for(int l = 0;l < n;l++)
                {
                    if(k == l)
                    {
                        continue;
                    }
                    if(pai[k].first - pai[l].first == p && pai[k].second - pai[l].second == q)
                    {
                        temp++;
                    }
                }
            }
            if(n - temp < ans)
            {
                ans = n - temp;
            }
        }
    }
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const int MAX_N = 1e5;
vector <int> dp(MAX_N + 1, -1);
vector <vector <int> > edge(MAX_N + 1);

int rec(int n) {
  if (dp[n] >= 0) {
	  return dp[n];
	}
  dp[n] = 0;
  for (auto itr = edge[n].begin(); itr != edge[n].end(); itr++) {
	  dp[n] = max(dp[n], rec(*itr) + 1);
	}
  return dp[n];
}

int main() {
  int n, m;
  cin >> n >> m;
  REP(i, m) {
	int u, v;
	cin >> u >> v;
	edge[u].push_back(v);
  }
  int ans = 0;
  REP1(i, n) {
	ans = max(ans, rec(i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    s += 'X';
    vector<char> t;
    int ans = 0;
    rep(i,n) {
        if (s[i] == s[i+1]) ans++;
        else t.push_back(s[i]);
    }
    int n_t = t.size();
    if (n_t&1) {
        ans += 2*min(k,n_t/2);
    } else {
        if (k <= n_t/2-1) ans += 2*k;
        else ans += 2*(n_t/2-1)+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;

	string s;
	cin>>s;

	int Max=0,cnt=0;

	for(i=0;s[i];i++)
	{
		if(s[i]=='R')
		{
			cnt++;
			Max=max(Max,cnt);
		}
		else
		{
			cnt=0;
		}
	}
	cout<<Max<<endl;
	

}

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

int main() {
	int N ; cin >> N ; 
	vector<int>H(N+1,0) ; 
	for ( int i=1; i<=N; ++i ) {
		cin >> H[i] ; 
	}
	vector<int>dp(N+1,0) ;
	dp[2] = abs(H[1]-H[2]) ; 
	for ( int i=3; i<=N; ++i ) {
		dp[i] = min(dp[i-1]+abs(H[i-1]-H[i]),dp[i-2]+abs(H[i-2]-H[i])) ;
	}
	cout << dp[N] << endl ; 
	return 0 ; 
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

static class Program
{
    static IEnumerable<bool> Solve(int N, int K, int[] A)
    {
        var q = new Queue<int>();
        for (int i = 0; i < K; ++i) { q.Enqueue(A[i]); }
        var ans = new List<bool>();
        for (int i = K; i < N; ++i)
        {
            int a = q.Dequeue();
            ans.Add(A[i] > a);
            q.Enqueue(A[i]);
        }
        return ans;
    }

    static void Main(string[] args)
    {
        var V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var ans = Solve(V[0], V[1], A).Select(e => e ? "Yes" : "No");
        Console.WriteLine(string.Join("\n", ans));
    }
}


Measured memory_bytes: 49660
# ABC 147: B – Palindrome-philia
S = input()

length = len(S)
half = length // 2
head = S[:half]
tail = ''

if length % 2 == 0:
    tail = S[half:]
else:
    tmp = half + 1
    tail = S[tmp:]

tail = tail[::-1]

count = 0
for i in range(half):
    if head[i] != tail[i]:
        count += 1

print(count)

Measured memory_bytes: 3064
//                                               KEEP GRINDING
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>   new_data_set;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define MOD 1000000007
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<"\n========================================\n";
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define PQ priority_queue
#define LB lower_bound  
#define UB upper_bound   

#define fr first
#define sc second
#define sz(x) (int)(x).size()

int power(int x, int y, int m=MOD) { 
    if (y == 0) return 1; 
    int p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  	return (y%2 == 0)? p : (x * p) % m; 
}  
void solve(){
	int n,k,pos=0,sign=1;
	cin>>n>>k;
	vector<int> a(n);
	f(i,0,n){
		cin>>a[i];
		if(a[i]>0)pos++;
	}
	if( n == k or (pos == 0 and k&1 ) ){
		sort(allr(a));
		int ans=1;
		f(i,0,k){
			ans=(ans*a[i])%MOD;
		}
		cout<<(ans%MOD+MOD)%MOD;
		return;
	}
	auto cmp=[&](int x,int y){
		return abs(x)>abs(y);
	};
	sort(all(a),cmp);
	int ans=1;
	f(i,0,k){
		ans=(ans*a[i])%MOD;
		sign*=( a[i]>=0 ? 1 : -1 );
	}
	if(sign>0){
		cout<<ans;
	}else{
		int MAXP=0,MAXN=-1e12,MINP=1e12,MINN=0;
		f(i,0,k){
			if(a[i]<0)MAXN=max(MAXN,a[i]);
			else	  MINP=min(MINP,a[i]);
		}
		f(i,k,n){
			if(a[i]<0)MINN=min(MINN,a[i]);
			else	  MAXP=max(MAXP,a[i]);
		}
		if( abs(MAXP*MINP)<abs(MAXN*MINN)){
			cout<<( ( (abs(ans)*abs(MINN))%MOD + MOD )*power(MINP,MOD-2) )%MOD;
		}else{
			cout<<( ( (abs(ans)*MAXP)%MOD + MOD )*power(abs(MAXN),MOD-2) )%MOD;
		}
    }
}
signed main(){
    fastio
    int t=1;
    for(;t--;solve());
}

Measured memory_bytes: 4764
public class Main{
    public static void main(String[]args){

        // int n = new java.util.Random().nextInt(10);
        // int arrays[] =new int[n];
        // for(int i=0;i<=n;i++){
        //     int r = new java.util.Random().nextInt(10);
        //     arrays[i] = r;
        // }
        // System.out.println(arrays);

        String s  =new java.util.Scanner(System.in).next();
        int n = s.length();
       // System.out.println(s.substring(0,1));//文頭
        String a = s.substring(0,1);//0,1の間を取得
        String b = s.substring(n-1);

        System.out.println(a+(n-2)+b);
        // System.out.println(a);
     }
}

Measured memory_bytes: 21844
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/random.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;
namespace rnd = boost::random;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> D;

  invec<int> c(26);
  vector<vector<int>> s(D, vector<int>(26));
  for (auto&& i : s)
    for (auto&& j : i)
      cin >> j;
  vector<int> t(D), highest;
  ll high = -9999999999, cost = 0;
  rnd::mt19937 mt;
  rnd::uniform_int_distribution rnd_plan(1, 26);
  rnd::uniform_real_distribution<> dist2(0.0, 1.0);

  REP(i, 26) {
    cost += c[i];
  }

  const int tier = cost;
  
  int lastf[26] = {0};
  REP(i, D) {
    pair<int, int> cand = {-999999999, 0};
    
    REP(j, 26)
      cand = max(cand, make_pair(s[i][j] + c[j] * (i + 1 - lastf[j]), j));
    t[i] = cand.second + 1;
    
    const int plan = t[i] - 1;
    lastf[plan] = i + 1;
  }  
  
  const int ITER = 677721600 / D;
  long double temp = 0.6;
  const long double temp_down = temp * pow(0.1, 1.0 / (double)ITER);
  
  REP(loop, ITER) {
    int r = 0;
    int last[26] = {0};
    
    const int update = loop % D;
    const int told = t[update];
    t[update] = rnd_plan(mt);
    
    REP(i, D) {
      const int plan = t[i] - 1;
      r += s[i][plan];
      cost -= c[plan] * (i + 1 - last[plan]);
      last[plan] = i + 1;
      r -= cost;
      cost += tier;
    }
    
    if (r > high) {
      high = r;
      highest = t;
    }
    else if (dist2(mt) > exp((double)(r - high) / 128.0 / temp))
      t[update] = told;
    cost = tier;
    temp *= temp_down;
  }
  
  for (auto i : highest)
    cout << i << endl;
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}




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

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

Measured memory_bytes: 256
#include<stdio.h>
 #include<string.h>
 int main(void)
 {
     char S[28];
     int i,j,k=0;

     scanf("%s",S);

     for(i=0;i<strlen(S);++i){
       for(j=i+1;j<strlen(S);++j){
          if(S[i]==S[j]) { printf("no\n"); return 0; }
       }
           k++;
     }

     if(k==strlen(S)) printf("yes\n");

     return 0;
 }



Measured memory_bytes: 128
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = Array(m) { sc.nextInt() }
    val isbroken = BitSet(n + 1)
    for (i in 0 until m) {
        isbroken[a[i]] = true
    }
    val dp = Array(n + 1) { 0L }
    dp[0] = 1
    for (i in 0 until n) {
        if (!isbroken[i + 1]) {
            dp[i + 1] = dp[i] + (if (i > 0) dp[i - 1] else 0)
            dp[i + 1] %= 1000000007L
        }
    }
    println(dp[n])
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 40380
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();
    int[] A = new int[Q];
    int[] correct = new int[N];

    for (int i = 0; i < Q; i++) {
      A[i] = sc.nextInt() - 1;
      correct[A[i]]++;
    }

    sc.close();
    
    for (int i = 0; i < N; i++) {
      if (0 < correct[i] + K - Q) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }

  }

}

Measured memory_bytes: 59204
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll n;
  cin >> n;
  ll p[n];
  rep(i, n) cin >> p[i];
  ll ans = 0;
  repi(i, 1, n-1)
    if((p[i-1] - p[i]) * (p[i] - p[i+1]) > 0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    A, B = map(int, input().split())
    print(A * B)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int K; cin >> K;
  string S; cin >> S;
  if(S.size()<=K){
    cout << S << endl;
    return 0;
  }
  cout << S.substr(0,K) << "..." << endl;
  return 0;
}

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

#define N 100 + 1 //交差点の数

int main(void) {
	int road[N] = {}; //各交差点の次数
	int a, b;
	
	//1,2がつながっていると仮定するとオイラーグラフ
	road[1] = road[2] = 1;
	
	while(cin >> a >> b) {
		if(a == 0 && b == 0) {
			bool flag = true;
			for(int i = 0; i < N; ++i) {
				if(!flag) continue;
				if(road[i] % 2 == 1) flag = false;
			}
			if(flag) cout << "OK" << endl;
			else cout << "NG" << endl;
			
			//リセット
			for(int i = 0; i < N; ++i) {
				road[i] = 0;
			}
			road[1] = road[2] = 1;
		} else {
			++road[a];
			++road[b];
		}
	}
	
	return 0;
}


Measured memory_bytes: 2968
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <complex>
using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef vector<vector<string> > vss;
typedef pair<int, int> pii;
#define INF 0x7fffffff
//#define INFLL 0x7fffffffffffffff
#define INFLL LLONG_MAX
#define SIZE(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()
#define FOR(i,x) for(int i=0;i<x;i++)
#define FORic(i,y,x) for(int i=y;i<=x;i++)
#define FORdc(i,y,x) for(int i=y;i>=x;i--)
#define FILL(a,v) memset(a, v, sizeof(a))
#define PI 3.14159265358979323846

typedef complex<double> P; /* _ */
typedef pair<P, double> C; /* ~ */
struct L { P p, q; L(P p, P q) : p(p), q(q) {} }; /* üª */

const double EPS = 1e-13;

// complexÉå¬ÖWªKvÈê(intersCSÅgp)
bool operator < (const P &a, const P &b) {
	return make_pair(real(a),imag(a)) < make_pair(real(b),imag(b));
}


// ~Ìð_ðÔ·(æÉð·»èK{)
pair<P,P> crossCC(C c1, C c2){
	double r1 = c1.second;
	double r2 = c2.second;
	double r3 = abs(c1.first-c2.first);
	double rc = (r3*r3+r1*r1-r2*r2)/(2*r3);
	double rs = sqrt(r1*r1-rc*rc);
	P dif = (c2.first-c1.first)/r3;
	P p1 = c1.first+dif*P(rc,rs);
	P p2 = c1.first+dif*P(rc,-rs);
	return make_pair(p1,p2);
}

int main(){
	int n;
	while(cin>>n){
		if(!n) break;
		vector<P> all;
		FOR(i, n){
			double x, y;
			cin>>x>>y;
			all.push_back(P(x,y));
		}
		vector<P> couho;
		FOR(i, n-1){
			FORic(j, i+1, n-1){
				if(abs(all[j]-all[i])<=2+EPS){
					pair<P,P> temp = crossCC(C(all[i], 1), C(all[j], 1));
					couho.push_back(temp.first);
					couho.push_back(temp.second);
				}
			}
		}
		if(SIZE(couho)==0){
			cout<<1<<endl;
			continue;
		}
		int ans = 0;
		FOR(i, SIZE(couho)){
			int count = 0;
			FOR(j, n){
				if(abs(couho[i]-all[j])<=1+EPS){
					count++;
				}
			}
			ans = max(ans, count);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1532
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

from collections import deque
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, W = na()
weight = [0] * 110
value = [0] * 110
for i in range(N):
    v, w = na()
    weight[i], value[i] = w, v
dp = [[0] * 10010 for _ in range(110)]
for i in range(N):
    for w in range(W+1):
        if w >= weight[i]:
            dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[N][W])



Measured memory_bytes: 46084
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000000

int main() {
    int N, T; cin >> N >> T;
    int64_t time = 0;
    int t = 0;
    for (int i = 0; i < N; i++) {
        int tn; cin >> tn;
        if (tn - t > T) time += T;
        else time += (tn - t);
        t = tn;
    }
    cout << time + T << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    
    int i,j;
    
    for(i=0;i<=n/4;i++){
        for(j=0;j<=n/7;j++){
            if(4*i+7*j==n){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF 1LL<<60
#define pi 3.14159265358979323846
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
    int h,w;cin>>h>>w;
    vector<string> a(h);
    for(int i=0;i<h;i++){
        cin>>a[i];
    }

    int numy=0,numx=0;
    while(1){
        bool cantgo=true;
        while(numx<w && numy<h && a[numy][numx]=='#'){
            a[numy][numx]='.';
            numx++;
            cantgo=false;
        }
        numx--;
        numy++;

        while(numx<w && numy<h && a[numy][numx]=='#'){
            a[numy][numx]='.';
            numy++;
            cantgo=false;
        }
        numy--;
        numx++;

        if(cantgo){break;}
    }

    bool ok=true;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#') ok=false;
        }
    }

    if(ok) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A;
  int B;
  int sum=1;
  cin>>A >> B;
  int counting=0;
  while(sum<B)
  {
    sum=sum-1+A;
    counting++;
  }
  cout<<counting<<endl;
}

Measured memory_bytes: 256