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


#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}
int nxt(){int a;cin >> a;return a;}

// no change 
const ll MOD = 1e9+7;  
int n;
const int mx = 2e5+1;
void Titan(){
	int m;
	read(n,m);
	vi gp[n+1];

	fo(m){
		int a,b;
		cin >> a >> b;
		gp[a].pb(b);
		gp[b].pb(a);
	}

	fo(i,1,n+1){
		cout << gp[i].size() << endl;
	}

	
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


Measured memory_bytes: 3656
import sys
N,M=map(int,input().split())

xyzlist=[]
for i in range(N):
  x,y,z=map(int,input().split())
  xyzlist.append((x,y,z))
#print(xyzlist)

answer=0
for b in range(2**3):
  bit=[0]*3
  for i in range(3):
    bit[i]=b%2
    b//=2    
  #print(bit)
  
  slist=[]
  for x,y,z in xyzlist:
    if bit[0]==1:
      x=-x
    if bit[1]==1:
      y=-y
    if bit[2]==1:
      z=-z      
    slist.append(x+y+z)
    
  slist.sort(reverse=True)
  answer=max(answer,sum(slist[:M]))
  
print(answer)
    

Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	int N,sum = 0; cin >> N;
	VI A(N); REP(i, N) cin >> A[i];
	REP(i, N) sum += A[i];
	bitset<4000000> dp(1);
	REP(i, N) dp |= dp << A[i];
	FOR(i, (sum + 1) / 2, sum + 1) {
		if (dp[i]) {
			cout << i << endl;
			break;
		}
	}
	cin >> N;
	return 0;
}



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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

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;
}
ll C[5010];
vector<bool> seen(5010, false);
Graph G;
ll INF = 1LL << 60;

int main() { 
    ll N, K;
    cin >> N >> K;
    vector<ll> P(5010);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
      	P[i]--;
    }
    
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    for (int i = 0; i < N; i++)
    {
        if(seen[i]) continue;
        int tmp = i;
        vector<ll> g;
        while(!seen[tmp])
        {
          	seen[tmp] = true;
            g.push_back(C[tmp]);
            tmp = P[tmp];
        }
      	G.push_back(g);
    }
    ll ans = -INF;
    for(auto g : G)
    {
        ll cmax = 0;
        ll total = 0;
        ll csize = g.size();
        ll ccnt = (K%csize==0)? K/csize-2:K/csize-1;
        ll amari = K-ccnt*csize;
        for (auto t : g)
        {
            total += t;
        }
        if(total>0)
        {
            cmax+=total*ccnt;
        }
        ll tmax = -INF;
        for (int i = 0; i < csize; i++)
        {
            ll tmp = 0;
            ll cnt = 0;
            int s = i;
           
            while(cnt < amari){
                tmp += g[s];
                if(s+1==csize)
                {
                    s=0;
                }else
                {
                    s++;
                }
                chmax(tmax, tmp);
                cnt++;
            }
        }
     	cmax += tmax;
        chmax(ans, cmax);
    }
    cout << ans << endl;
}

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

using namespace std;
int main(){
  int N,x;
  cin >> N >> x;
  vector<int> A;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(),A.end());
  int ans=0;
  for(auto a:A){
    if(x>=a){
      x-=a;
      ans++;}
    else {x=0;break;}
  }
  if(x>0) ans--;
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
conv = [0]*(N+1)
for i in range(1,N+1):
    for j in range(1,N//i+1):##その数の倍数をメモ
        conv[i*j-1] += 1
   
##print(conv)
print(sum([(i+1)*conv[i] for i in range(N)]))

Measured memory_bytes: 353344
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int N, K;
int A[102];

int M[100005];
int f(int x) {
    int &re = M[x];
    if (re > -1)RT re;
    re = 0;
    rep(i, N) {
        if (x >= A[i] && f(x - A[i]) == 0) {
            re = 1;
            break;
        }
    }
    RT re;
}

void solve() {
    MEM(M, -1);

    cin >> N >> K;
    rep(i, N)cin >> A[i];
    cout << (f(K) ? "First" : "Second") << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	string S;
	cin >> S;
	llint len;
	len = S.length();
	
	vector<char> T(len);
	rep(i,0,len) {
		T[i] = S[len-i-1];
	}
	
	
	//SOLVE
	llint ans=0;
	
	rep(i,0,len/2) {
		if (S[i] == T[i]) {
			
		} else {
			ans++;
		}
	}
	
	//OUTPUT
	cout << ans << endl;
	
	return 0;
}






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

int main(){
	
	int i,a[3],temp;
	int answer[3],final;
	
	for(i=0;i<3;i++)
	{
		cin >> a[i];
	}
	
	if(a[0] > a[1]){
		 temp = a[0];
		 a[0] = a[1];
		 a[1] = temp;
		 }
		 
	if(a[0] > a[2]){
		 temp = a[0];
		 a[0] = a[2];
		 a[2] = temp;
		 }
		 
	if(a[1] > a[2]){
		 temp = a[1];
		 a[1] = a[2];
		 a[2] = temp;
		 }
		 
	
	answer[0] = (a[2]-a[1])+(a[1]-a[0]);
	answer[1] = (a[2]-a[0])+(a[2]-a[1]);
	answer[2] = (a[1]-a[0])+(a[2]-a[0]);
	
	final = answer[0];
	if(final > answer[1]) final = answer[1];
	if(final > answer[2]) final = answer[2];
	
	
	cout << final <<endl;
	
	
	return 0;
}

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

using namespace std;
using ll = long long;

const ll MOD_VAL = 1e9+7;
ll dp[100][55][55];
ll ans[55][55];
ll tmp[55][55];
int n;
ll k;

void matmul(ll a[][55], ll b[][55], ll c[][55]){
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            tmp[i][j] = 0;
            for(int q=0;q<n;q++){
                tmp[i][j] += a[i][q] * b[q][j];
                tmp[i][j] %= MOD_VAL;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            c[i][j] = tmp[i][j];
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>dp[0][i][j];
        }
        ans[i][i] = 1;
    }
    for(int i=1;i<100;i++){
        matmul(dp[i-1], dp[i-1], dp[i]);
    }
    int cnt = 0;
    while(k>0){
        if(k%2){
            matmul(ans, dp[cnt], ans);
        }
        cnt++;
        k/=2;
    }
    ll sum = 0;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        sum += ans[i][j];
        sum %= MOD_VAL;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

string S, T;
int A, B;

int main() {
    string X;
    cin >> S >> T >> A >> B >> X;

    if (S == X)
        A--;
    else
        B--;

    int ans;

    cout << A << ' ' << B << endl;
    return 0;
}


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

int n,m;
vector<int> adj[100005];
vector<int> toposort;
int vis[100005];

void topo(int x){
	if(vis[x])return;
	vis[x]=1;
	for(int i=0;i<(int)adj[x].size();i++){
		if(vis[adj[x][i]])continue;
		topo(adj[x][i]);
	}
	toposort.push_back(x);
}

int main() {
	scanf("%d%d",&n,&m);
	int x,y;
	int indeg[n]; memset(indeg,0,sizeof(indeg));
	for(int i=0;i<m;i++){
		scanf("%d%d",&x,&y); x--; y--;
		adj[x].push_back(y);
		indeg[y]++;
	}
	int dp[n]; memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++){
		if(indeg[i]==0){
			topo(i);
		}
	}
	reverse(toposort.begin(),toposort.end());
	for(int i=0;i<(int)toposort.size();i++){
		for(int j=0;j<(int)adj[toposort[i]].size();j++){
			dp[adj[toposort[i]][j]]=max(dp[adj[toposort[i]][j]],dp[toposort[i]]+1);
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)ans=max(ans,dp[i]);
	printf("%d",ans);
}

Measured memory_bytes: 12156
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
  
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
		String s=sc.nextLine();
		long ans=0;
		

		
		for(int i=0;i<s.length();i++){
			ans+=(s.charAt(i)-'0');
		}
		
		if(ans%9==0)System.out.println("Yes");
		else System.out.println("No");
    	
    }
}

Measured memory_bytes: 36376
fn main() {
    let s: Vec<char> = {
        let s = read::<String>();
        s.chars().into_iter().collect()
    };
    let t: Vec<char> = {
        let t = read::<String>();
        t.chars().into_iter().collect()
    };

    let mut ret = 0;
    for i in 0..3 {
        if s[i] == t[i] {
            ret += 1;
        }
    }

    println!("{}", ret);
}

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

Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
int main()
{
    lli n,i;
    cin>>n;
    vector<lli> vec(n);
    lli ans=0;
    unordered_map<lli,lli> umap;
    for(i=0;i<n;i++)
    {
        cin>>vec[i];
        umap[vec[i]]++;
    }
    for(auto it=umap.begin();it!=umap.end();it++)
    {
        if(it->first<it->second)
        {
            ans+=(it->second)-it->first;
        }
        else if(it->first>it->second)
        {
            ans+=it->second;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7984
#include <stdio.h>
#include <stdlib.h>

int stack[101], n;

int isFull() {
  return n == 100;
}

int isEmpty() {
  return n == 0;
}

void push(int a) {
  if(!isFull())
    stack[++n] = a;
}

int pop() {
  if(!isEmpty())
    return stack[n--];

  return 0;
}

int main(void) {
  int a, b;
  char str[100];
  n = 0;

  while(scanf("%s", str) != EOF) {
    switch(str[0]) {
      case '+':
        a = pop();
        b = pop();
        push(b + a);
        break;
      case '-':
        a = pop();
        b = pop();
        push(b - a);
        break;
      case '*':
        a = pop();
        b = pop();
        push(b * a);
        break;
      default:
        push(atoi(str));
        break;
    }
  }

  printf("%d\n", pop());

  return 0;
}



Measured memory_bytes: 2048
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int tree[8 * maxn];
int aux[8 * maxn];
bool vis[8 * maxn];
void go(int node, int l, int r)
{
	int mid = (l + r) / 2;
	if (vis[node])
	{
		vis[2 * node] = true; vis[2 * node + 1] = true;
		aux[2 * node] = aux[node]; aux[2 * node + 1] = aux[node] + mid - l + 1;
		tree[2 * node] = aux[2 * node];
		tree[2 * node + 1] = aux[2 * node + 1];
		vis[node] = false;
	}
}
void update(int l, int r, int node, int x, int y, int z)
{
	if (l > y || r < x)
		return;
	if (l >= x && r <= y)
	{
		vis[node] = true; aux[node] = z + l - x; tree[node] = z + l - x;
		return;
	}
	go(node, l, r);
	int mid = (l + r) / 2;
	update(l, mid, 2 * node, x, y, z); update(mid + 1, r, 2 * node + 1, x, y, z);
	tree[node] = min(tree[2 * node], tree[2 * node + 1]);
}
int query(int l, int r, int node, int x, int y)
{
	if (l > y || r < x)
		return lim;
	if (l >= x && r <= y)
		return tree[node];
	go(node, l, r);
	int mid = (l + r) / 2;
	return min(query(l, mid, 2 * node, x, y), query(mid + 1, r, 2 * node + 1, x, y));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h = 0, w = 0, xx = 0, yy = 0;
	cin >> h >> w;
	vector<int> x(h);
	vector<int> y(h);
	for (int i = 0; i < h; ++i)
	{
		cin >> x[i] >> y[i]; --x[i]; --y[i];
	}
	for (int i = 0; i < h; ++i)
	{
		if (x[i] > 0)
			update(0, w - 1, 1, x[i], y[i], query(0, w - 1, 1, x[i] - 1, x[i] - 1) + 1);
		else
			update(0, w - 1, 1, x[i], y[i], lim);
		if (tree[1] >= lim)
			cout << "-1";
		else
			cout << (tree[1] + i + 1);
		cout << endl;
	}
}

Measured memory_bytes: 9492
MOD =  1000000007

N, M = map(int, input().split())

a_list = set()
for _ in range(M):
	a_list.add(int(input()))

#print(a_list)

counts = [0] * (N + 3)
counts[0] = 1
for i in range(N):
	if not i in a_list:
		counts[i + 1] = (counts[i + 1] + counts[i]) % MOD
		counts[i + 2] = (counts[i + 2] + counts[i]) % MOD

#print(counts)
print(counts[N])


Measured memory_bytes: 11884
#include <iostream>
#include <tuple>
#include <set>
#include <queue>

using namespace std;

struct state {
	int a, b;
	bool operator<(const state &other) const
	{
		return tie(a, b) < tie(other.a, other.b);
	}
};

int main()
{
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	state ans = { 100 * A, 0 };

	set<state> visited;
	queue<state> waiting;

	auto visit = [&](int a, int b) {
		if (a + b <= F && b * (100 + E) <= E * (a + b)) {
			if (visited.insert({ a, b }).second) {
				waiting.push({ a, b });
			}
		}
	};
	visit(0, 0);

	while (!waiting.empty()) {
		state s = waiting.front();
		waiting.pop();

		if (ans.b * (s.a + s.b) < s.b * (ans.a + ans.b)) {
			ans = s;
		}
		visit(s.a + 100 * A, s.b);
		visit(s.a + 100 * B, s.b);
		visit(s.a, s.b + C);
		visit(s.a, s.b + D);
	}

	cout << ans.a + ans.b << " " << ans.b << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define MOD 1'000'000'007

ll dp1[112345]={0}, dp2[112345]={1};
char s[112345];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	REP(i, n){
		if(s[i]=='0'){
			dp1[i+1] = dp1[i] * 3 % MOD;
			dp2[i+1] = dp2[i];
		}else{
			dp1[i+1] = (dp1[i] * 3 + dp2[i]) % MOD;
			dp2[i+1] = dp2[i] * 2 % MOD;
		}
	}
	printf("%lld\n", (dp1[n] + dp2[n]) %MOD);
}


Measured memory_bytes: 1920
def main():
    N=int(input())
    h=list(map(int,input().split()))
    dp=[0]*N
    for i in range(1,N):
        if i==1:
            dp[i]=abs(h[i]-h[i-1])
        else:
            dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])
    print(dp[N-1])

if __name__=="__main__":
    main()

Measured memory_bytes: 13928
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
// } fio;
} ;

class union_find
{
	int  _setnum;
	vector<int> par, nume;
public:
	union_find(){
	}
	
	union_find(int x){
		par.resize(x);
		nume.resize(x);
		init();
	}
	
	~union_find(){
		//
		
	}
	
	void clear(){
		_setnum = 0;
		par.clear();
		nume.clear();
	}
	
	void init(){
		_setnum = par.size();
		for(int i = 0; i < par.size(); i++){
			par[i] = i;
			nume[i] = 1;
		}
	}
	
	void resize(int x){
		
		par.resize(x);
		nume.resize(x);
		init();
	}

	int find(int x){
		return par[x] == x ? x : par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
	
		if(x == y)return;
		
		_setnum--;
		
		if(nume[x] > nume[y]) std::swap(x,y);
		
		par[x] = y;
		nume[y] += nume[x];
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
	
	int numel(int x){
		return nume[find(x)];
	}
	
	int size(){
		return par.size();
	}
	
	int setnum(){
		return _setnum;
	}
};

signed main(){
	cout<<fixed<<setprecision(10);
	
	int H, W;
	vector<string> s;
	vector<vector<int>> num;
	union_find uf;
	
	cin>>H>>W;
	
	uf.resize(H * W);
	s.resize(H);
	// num.resize(H + 100, vector<int>(W + 100));
	num.resize(200, vector<int>(200));
	
	for(int i = 0; i < H; i++){
		cin>>s[i];
	}
	
	for(int i = 0; i + 5 < num.size(); i += 4){//cout<<i<<endl;
		for(int j = 0; j + 5 < num[0].size(); j += 4){ 
			num[i][j] = 6;
			num[i][j+1] = 3;
			num[i][j+2] = 1;
			num[i][j+3] = 4;
			
			num[i+1][j] = 2;
			num[i+1][j+1] = 2;
			num[i+1][j+2] = 2;
			num[i+1][j+3] = 2;
			
			num[i+2][j] = 1;
			num[i+2][j+1] = 3;
			num[i+2][j+2] = 6;
			num[i+2][j+3] = 4;
			
			num[i+3][j] = 5;
			num[i+3][j+1] = 5;
			num[i+3][j+2] = 5;
			num[i+3][j+3] = 5;
		}
	}
	
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){ //cout<<num[i][j];
			if(s[i][j] == '#') continue;
			if(num[i][j] != s[i][j] - '0') continue;
			
			if(i && s[i-1][j] != '#' && num[i-1][j] == s[i-1][j] - '0') {
				uf.unite(i * W + j, (i - 1) * W + j);
			}
			if(j  && s[i][j-1] != '#' && num[i][j-1] == s[i][j-1] - '0') {
				uf.unite(i * W + j, i * W + j - 1);
			}
		}//cout<<endl;
	}
	
	if(uf.same(0, (H-1) * W + W-1)) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}


Measured memory_bytes: 3516
import sys, math
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    S = input()
    r = S.count('R')
    if r == 0:
        print(0)
    elif r == 1:
        print(1)
    elif r == 2:
        print(2 if 'RR' in S else 1)
    else:
        print(3)

if __name__ == '__main__':
    main()

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

int main (void) {
    string sO, sE, ans;

    cin >> sO;
    cin >> sE;

    int n = sO.length() + sE.length();

    for(int i=0;i<n;i++){
        if(i%2 == 0){
            ans += sO[i/2];
        }else{
            ans += sE[i/2];
        }
    }

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



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

typedef long long lint;
typedef long double louble;

#define so(a) ((int)((a).size()))

const char lf = '\n';

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1 << 15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 8007 , __ = 66667 , mo = 998244353 , gmo = 3 , igmo = 332748118;

template<typename T1,typename T2> inline T1 ad(T1 &a,T2 b){return a=a+b>=mo?a+b-mo:a+b;}
template<typename T1,typename T2> inline T1 dl(T1 &a,T2 b){return a=a>=b?a-b:a-b+mo;}
template<typename T1,typename T2> inline T1 add(T1 a,T2 b){return a+b>=mo?a+b-mo:a+b;}
template<typename T1,typename T2> inline T1 del(T1 a,T2 b){return a>=b?a-b:a-b+mo;}

lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

lint jc[__],rjc[__];

void fuck(int n=__-1)
{
	jc[0]=jc[1]=rjc[0]=1;
	for(int i=2;i<=n;i++)jc[i]=jc[i-1]*i%mo;
	rjc[n]=inva(jc[n]);
	for(int i=n-1;i>=1;i--)rjc[i]=rjc[i+1]*(1ll+i)%mo;
}

lint C(int n,int m)
{
	if(n<m || n<0 || m<0)return 0;
	return jc[n]*rjc[m]%mo*rjc[n-m]%mo;
}

int rev[__];

int nttmake(int n)
{
	int nn=1,lg=0;
	while(nn<n)nn<<=1,lg++;
	rev[0]=0;
	for(int i=1;i<nn;i++)rev[i]=(rev[i>>1]>>1)|((i&1)<<(lg-1));
	return nn;
}

void ntt(lint a[],int nn,int dir)
{
	for(int i=0;i<nn;i++)if(i<rev[i])swap(a[i],a[rev[i]]);
	for(int i=1;i<nn;i<<=1)
		for(int j=0,g=powa(dir>0?gmo:igmo,(mo-1)/(i+i));j<nn;j+=i+i)
			for(int k=0,ig=1,x,y;k<i;k++,ig=1ll*ig*g%mo)
				x=a[j+k],y=1ll*ig*a[j+k+i]%mo,a[j+k]=add(x,y),a[j+k+i]=del(x,y);
	if(dir<0)for(int i=0,x=inva(nn);i<nn;i++)a[i]=a[i]*x%mo;
}

int n,m,nn;
lint f[__]={0},pa[__]={0},pb[__]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	fuck();

	n=ty(),m=ty();

	nn=nttmake(n+n+2);
	f[0]=1;
	for(int i=1;i<=n;i++)pa[i]=rjc[i+2];
	ntt(pa,nn,1);

	for(int i=1;i<=m;i++)
	{
		for(int j=0;j<=n;j++)pb[j]=f[j]*rjc[j]%mo;
		for(int j=n+1;j<nn;j++)pb[j]=0;
		ntt(pb,nn,1);
		for(int j=0;j<nn;j++)pb[j]=pb[j]*pa[j]%mo;
		ntt(pb,nn,-1);
		for(int j=0;j<=n;j++)f[j]=add(f[j]*add(1ll*j*(j+1)/2,1)%mo,pb[j]*jc[j+2]%mo);
	}

	lint ans=0;
	for(int i=0;i<=n;i++)ad(ans,f[i]*C(n,i)%mo);
	cout<<ans<<lf;
	
	return 0;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {

    int N;
    cin >> N;
    vector<ll> A(N + 1, 0);
    vector<ll> B(N + 1, 0);
    REP(i, 1, N + 1) {
        cin >> A[i];
    }
    int flag = 0;
    int ans = 1;
    REP(i, 1, N) {
//        cout << A[i] << " ";
        //flagが0ならA[i]とA[i+1]に応じた値を入れる
        if (flag == 0) {
            if (A[i] == A[i + 1]) flag = 0;
            else if (A[i + 1] - A[i] < 0) flag = -1;
            else flag = 1;
        }
        //flagが0出ないならflagとA[i+1] - A[i]の符号が異なる時
        else{
            if( (A[i+1] - A[i]) * flag < 0 ){
//                i++;
                ans++;
                flag = 0;
//                cout << "|";
            }
        }
    }
//    cout << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 2e5 + 5;
int a[N];
ll b[N];

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

    int n;
    cin >> n;

    ll ans = 0;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans += b[a[i]];
        b[a[i]]++;
    }

    for (int i = 0; i < n; i++) {
        cout << ans - b[a[i]] + 1 << "\n";
    }

    return 0;   
}   

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> numbers(N);
    rep(i,N){
        cin >> numbers[i];
    }
    double b = 0.0;
    rep(i,N){
        b += 1.0/numbers[i];
    }
    cout << setprecision(16) << 1.0/b << endl;
 }

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

int main()
{
    int a, b;
    cin >> a >> b;
    if(((a + b) % 3) == 0 || a%3 == 0 || b%3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {

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

  public static void main(String[] args) {

    int N = sc.nextInt();
    int M = sc.nextInt();

    ArrayList<City> cities = new ArrayList();
    for (int i=0; i<M; i++) {
      cities.add(new City(i, sc.nextInt(), sc.nextInt()));
    }

    cities.sort((x, y) -> {
      if (x.p == y.p) {
        return x.y - y.y;
      } else {
        return x.p - y.p;
      }
    });

    String[] ids = new String[M];

    int count = 0;
    for (int i=0; i<M; i++) {
      City c = cities.get(i);
      if (i == 0 || c.p != cities.get(i-1).p) count = 0;
      else count++;
      ids[c.i] = padding0(c.p, 6) + padding0(count+1, 6);
    }

    for (int i=0; i<M; i++) {
      System.out.println(ids[i]);
    }

  }

  static String padding0(int n, int m) {
    String s = Integer.toString(n);
    while (m - s.length() > 0) s = "0" + s;
    return s;
  }


  static class City {
    int i, p, y;
    City (int i, int p, int y) {
      this.i = i;
      this.p = p;
      this.y = y;
    }
  }

}


Measured memory_bytes: 107476
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
diff=len(s)-len(t)
x= t if diff > 0 else s
x+=[" "]*abs(diff)

for i in range(len(s)):
  if s<t:
    print("Yes")
    exit()

print("No")


Measured memory_bytes: 9120
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n, k; cin >> n >> k;
  vector<int> v(n), dp(n,1001001001);
  for(int&e:v)cin >> e;
  dp[0] = 0;
  for(int i = 0; i < n; ++i){
    vector<int> idx(k), dif(k);
    for(int j = 0; j < k; ++j)idx[j] = min(n - 1,i + j + 1);
    for(int j = 0; j < k; ++j)dif[j] = abs(v[i] - v[idx[j]]);
    for(int j = 0; j < k; ++j){
      int idx = min(n - 1,i + j + 1);
      int dif = abs(v[i] - v[idx]);
      dp[idx] = min(dp[idx], dp[i] + dif);
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}	

Measured memory_bytes: 1024
/**
 * Title:
 * Url:
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    vector<int> x(n);
    for(int i=0; i<n; i++) cin >> x[i];
    int anss = 1000000000;
    for(int j=1; j<=100; j++) {
        int ans = 0;
        for(int i=0; i<n; i++) {
            ans += (x[i]-j)*(x[i]-j);
        }
        anss = min(anss, ans);
    }
    cout << anss << endl;

    return 0;
}

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

int main(){
  string S;
  int w;
  cin >> S >> w;
  string ans="";
  for(int i=0; i<S.size(); i+=w){
    ans+=S[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut p = vec![0; n];
    let mut q = vec![0; n];
    for i in 0..n {
        p[i] = sc.read::<usize>() - 1;
    }
    for i in 0..n {
        q[i] = sc.read::<usize>() - 1;
    }

    let mut count = vec![0; n];
    for i in 0..n {
        let mut cur = p[i];
        while cur != i {
            cur = q[cur];
            count[i] += 1;
            if cur == p[i] {
                println!("-1");
                return;
            }
        }
    }

    let mut cycle = vec![0; n];
    for i in 0..n {
        let mut cur = i;
        loop {
            cur = q[cur];
            cycle[i] += 1;
            if cur == i {
                break;
            }
        }
    }

    let a = chinese_remainder_theorem(&count, &cycle);
    match a {
        Some((a, _)) => {
            println!("{}", a);
        }
        None => {
            println!("-1");
        }
    }
}
pub fn extended_gcd(a: i64, b: i64, p: &mut i64, q: &mut i64) -> i64 {
    if b == 0 {
        *p = 1;
        *q = 0;
        a
    } else {
        let d = extended_gcd(b, a % b, q, p);
        *q -= a / b * *p;
        d
    }
}

pub fn chinese_remainder_theorem(b: &Vec<i64>, modulo: &Vec<i64>) -> Option<(i64, i64)> {
    let (mut r, mut m) = (0, 1);
    for i in 0..b.len() {
        let (mut p, mut q) = (0, 0);
        let d = extended_gcd(m, modulo[i], &mut p, &mut q);
        if (b[i] - r) % d != 0 {
            return None;
        }
        let tmp = ((b[i] - r) / d * p) % (modulo[i] / d);
        r += m * tmp;
        m *= modulo[i] / d;
    }
    Some(((r % m + m) % m, m))
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



Measured memory_bytes: 3084
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	sc.Split(bufio.ScanWords)

	s := nextLine()
	
	data := []string{"A", "C", "G", "T"}

	sum := 0
	max := 0

	for _, v1 := range s {
		isExists := true
		for _, v2 := range data {
			if string(v1) == v2 {
				sum++
				isExists = true
				break
			} else {
				isExists = false
			}
		}
		if sum >= max {
			max = sum
		}
		if !isExists {
			sum = 0
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 640
from sys import stdin
from itertools import groupby

n,k = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()

kohuku = 0

for i in range(len(s)-1):
    if s[i] == "R" and s[i+1] == "R":
        kohuku += 1
    elif s[i] == "L" and s[i+1] == "L":
        kohuku += 1

print(min(n-1,kohuku+2*k))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , K;
  cin >> N >> K;
  int sum = 0 ;
  for ( int i=0 ; i < N ; i++ ) {
    int x ;
    cin >> x ;
    int d ;
    int m ;
    d= min ( K-x , x ) ;
    sum += 2*d ;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	char s[300003];
	ll n;
	ll w[300003]={},e[300003]={};

	cin>>n;
	for(ll i=1; i<n+1; i++){
		cin>>s[i];
		if(s[i]=='W'){
			w[i]=w[i-1]+1;
			e[i]=e[i-1];
		}else if(s[i]=='E'){
			e[i]=e[i-1]+1;
			w[i]=w[i-1];
		}
	}
	ll total=0;
	ll total2=0;

	total2=e[n];

	for(ll j=2; j<n; j++){
		if(s[j]=='W'){
			total=e[n]-e[j];
			total+=w[j];
			total2=min(total2,total);
		}else if(s[j]=='E'){
			total=e[n]-e[j];
			total+=w[j];
			total2=min(total2,total);
		}
	}

	total2=min(total2,w[n]);

	cout<<total2<<endl;
	return 0;
}


Measured memory_bytes: 5248
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数

MAX = 1
i = 1
while i <= n ** 0.5:
    if n % i == 0:
        MAX = max(MAX, i)
    i += 1
ans = abs(n // MAX + MAX - 2)
print(ans)

Measured memory_bytes: 40684
#include <iostream>

using namespace std;

int main() {
	long int n, a[10000];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
        long int minX = a[0],
		maxX = a[0],
		sum = 0;
	for (int i = 0; i < n; i++)
		if (minX > a[i])
			minX = a[i];
	for (int i = 0; i < n; i++)
		if (maxX < a[i])
			maxX = a[i];
	for (int i = 0; i < n; i++)
		sum += a[i];
	cout << minX << " " << maxX << " " << sum << endl;
}

Measured memory_bytes: 1240
#include <iostream>
#include <algorithm>
using namespace std;
int n, s, i, a[105];
int main() {
    cin >> n;
    for (i=0; i<n; i++) cin >> a[i];
    sort(a, a+n, greater<int>());
    for (i=0; i<n; i++) i%2 ? s-=a[i] : s+=a[i];
    cout << s;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for(int i = 0; i < n; i++){
        cin >> x.at(i) >> y.at(i);
    }
    double distsum = 0.0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            distsum = distsum + sqrt( pow( x.at(i) - x.at(j) , 2) + pow( y.at(i) - y.at(j) , 2));  
        }
    }
    double pattern = (double)n*(n-1)/2;
    cout << fixed << setprecision(8) << distsum/pattern*(n-1);
}

Measured memory_bytes: 256
#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 <functional>
#include <numeric>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int K, A, B;
	cin >> K >>A >> B;
	int ans = 0;
	for (int i = A; i <= B; i++) {
		if (i%K == 0) ans++;
	}
	if (ans > 0) cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <array>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

long long int lucas(int n)
{
    return n == 0 ? 2 : (n == 1 ? 1 : lucas(n-1)+lucas(n-2));
}

int main(){

    int n;
    cin >> n;
    
    
    array<long long int,87> l;
    /*
    for (int i = 0; i <= 86;i++){
        l[i] = lucas(i);
        cout << i << endl;
    }*/
    l[0] = 2;
    
    l[1] = 1;
   
    for (int i = 2; i <= 86; i++){
        l[i] = l[i - 1] + l[i - 2];
    }    
    cout << l[n] << endl;
    
    return 0;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        int hon = N % 10;
        if (hon == 3) {
            System.out.println("bon");
        } else if (hon == 2 || hon == 4 || hon == 5 || hon == 7 || hon == 9 ){
            System.out.println("hon");
        } else {
            System.out.println("pon");
        }
    }
}

Measured memory_bytes: 35816
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int X = scan.nextInt();
        boolean ans = false;

        while(!(ans)) {
            if(PrimeNumber(X)) {
                ans = true;
                System.out.println(X);
            }
            X++;
        }
    }

    private static boolean PrimeNumber(int X) {
        for(int i = 2; i < X/2; i++) {
            if(X % i == 0){
                return false;
            }
        }
        return true;
    }
}

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

int main()
{   
    int x;
    cin>>x;
    int y=8;
    for(int i=400;i<2000;i++)
      {   int c=i+199;
          if(x >=i && x<=c)
            { cout<<y<<endl;
              break;
            }
         i=c;    
         y--;    
      }
      
}


Measured memory_bytes: 3640
#include<iostream>

using namespace std;

int main() {
	int k, a, b;
	cin >> k >> a >> b;

	for(int i = 0;;i++) {
			if (i * k >= a && i * k <= b) {
					cout << "OK" << endl;
					break;
			}
			
			if (i * k > b) {
					cout  << "NG" << endl;
					break;
			}
	}
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#include <stdio.h>
int main() {
  string s; cin >> s;
  int count=0;
  for (int i; i<3; i++){
    if ( s.at(i) == 'o' ) count++;
  }
  cout << 700+count*100 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cfloat>
#include <cmath>
#include <random>
#include <algorithm>
#define norm(X) ((X) * (X))
using namespace std;
using ll = long long;
    
struct Point {
    ll x, y;
    ll z;
};

int main() {
    ll n;
    Point e[105];
    double ans = 0;
    ll sx[4] = {};
    ll sy[4] = {};

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> e[i].x >> e[i].y;

        e[i].z = 0;
        if (e[i].y > 0) {
            e[i].z |= 2;
        }
        if (e[i].x > 0) {
            e[i].z |= 1;
        }

        sx[e[i].z] += e[i].x;
        sy[e[i].z] += e[i].y;
    }

    mt19937 rnd(1710);
    ll x, y;

    for (int z = 0; z < 4; z++) {
        
        for (int k = 0; k < 30000; k++) {
            x = sx[z];
            y = sy[z];

            for (int i = 0; i < n; i++) {
                ll zz = 0;
                if (e[i].y > 0) zz |= 2;
                if (e[i].x > 0) zz |= 1;
                e[i].z = (zz == z ? -1 : 1);
            }

            for (int j = 0; j < 300; j++) {
                ll indx = rnd() % n;

                if (e[indx].z != -1) {
                    if (norm(x) + norm(y) < norm(x + e[indx].x) + norm(y + e[indx].y)) {
                        x += e[indx].x;
                        y += e[indx].y;
                        e[indx].z = -1;
                    }
                }
                else {
                    if (norm(x) + norm(y) < norm(x - e[indx].x) + norm(y - e[indx].y)) {
                        x -= e[indx].x;
                        y -= e[indx].y;
                        e[indx].z = 1;
                    }
                }
            }

            ans = max(ans, hypot(x, y));
        }
    }
    
    printf("%.*lf\n", DBL_DIG, ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int R = scanner.nextInt();
		
		if (N < 10) {
			System.out.println(R + 100 * (10 - N));
		} else {
			System.out.println(R);
		}
		
	}
}	

Measured memory_bytes: 22740
#include <stdio.h>
int main(void) {
  int sum=0,i,n,a[100000],r[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%d",&a[i]);
    sum += a[i];
  }
  r[0] = sum;
  for(i=1;i<n-1;i+=2) {
    r[0] -= 2*a[i];
  }
  printf("%d\n",r[0]);
  for(i=1;i<n; i++) {
    r[i] = 2*a[i-1] - r[i-1];
    printf("%d\n",r[i]);
  }
  return 0;
}

Measured memory_bytes: 2048