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

using namespace std;

typedef long long ll;

int max(int a, int b) { return (a > b) ? a : b; }

const int MAXN = 100000;

int a[MAXN];
int b[MAXN];


const int INF = 1e9;

int w[MAXN];
int parent[MAXN];
int rankk[MAXN];
ll sum[MAXN];
int bad[MAXN];


int tim = 0;
vector<int> top;

vector<pair<int, pair<int, int>>> e;

void make_set (int v) {
    parent[v] = v;
    rankk[v] = 0;
    sum[v] = w[v];
    bad[v] = 0;
}

int find_set (int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set (parent[v]);
}

void union_sets (int a, int b) {
    a = find_set (a);
    b = find_set (b);
    if (a != b) {
        if (rankk[a] < rankk[b])
            swap (a, b);
        parent[b] = a;
        if (rankk[a] == rankk[b])
            ++rankk[a];
        sum[a] += sum[b];
        bad[a] += bad[b];
    }
}

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

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
    }
    e.resize(m);
    for (int i = 0; i < m; i++)
    {
        cin >> e[i].second.first >> e[i].second.second >> e[i].first;
        e[i].second.first--, e[i].second.second--;
    }
    sort(e.begin(), e.end());

    for (int i = 0; i < n; i++)
    {
        make_set(i);
    }

    for (auto& p : e)
    {
        int x = p.second.first;
        int y = p.second.second;
        int t = find_set(x);
        if (t != find_set(y))
        {
            union_sets(x, y);
            t = find_set(x);
        }
        if (sum[t] >= p.first)
        {
            bad[t] = 0;
        } else {
            bad[t]++;
        }
    }

    set<int> kek;
    for (int i = 0; i < n; i++)
    {
        kek.insert(find_set(i));
    }

    int ans = 0;
    for (int q : kek)
    {
        ans += bad[q];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3840
def main():
    baselist=[]
    anslist=[]
    N = input()
    baseword = input().rstrip()
    [baselist.append(i) for i in baseword]
    for index,value in enumerate(baselist):
        if int(index+1)<int(len(baselist)):
            if baselist[index]!=baselist[index+1]:
                anslist.append(baselist[index])
        else:
            anslist.append(baselist[index])
    print(len(anslist))

if __name__ == "__main__":
    main()

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

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        m[a]++;
    }

    int ans = 0;
    for (auto i = m.rbegin(); i != m.rend(); i++) {
        int x = 1 << (int)floor(log2((double)2 * (i -> first)));
        if (i -> first == x - i -> first) {
            ans += (i -> second) / 2;
            continue;
        }
        
        int c = min(i -> second, m[x - i -> first]);
        ans += c;
        m[x - i -> first] -= c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 64256
#include<math.h>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
#define    in   cin>>
using namespace std;

ll hako[200000];
int main()
{
  int n,m,x,y;
  string ans="War";
  in n>>m>>x>>y;
  int X[n];
  int Y[m];
  rep(i,n){in X[i];}
  rep(i,m){in Y[i];}

  sort(X,X+n,greater<int>());
  sort(Y,Y+m);
  if(max(x,X[0])<min(y,Y[0]))ans="No War";
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  cin>>n;
  int a[100],ans=0;
  int oddcount=0;
  rep(i,n){
    cin>>a[i];
    if(a[i]%2==1) oddcount++;
  }
  sort(a,a+n);
  bool b=true;
  rep(i,n){
    if(a[i]%2==1){
      if(oddcount%2==1 && b) b=false;
      else ans+=a[i];
    }
    else ans+=a[i];
  }
  cout<<ans/2<<endl;
  return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
const ll INF=1000000000;

int main(){
    ll N;
    cin>>N;
    vector<ll> P(N);
    for(ll i=0; i<N; i++){
        cin>>P[i];
        P[i] --;
    }
    vector<ll> Q(N);//iのある場所

    for(ll i=0; i<N; i++){
        Q[P[i]]=i;
    }

    set<ll> index;
    ll Ans=0;
    for(ll i=N-1; i>=0; i--){
        ll Place;
        Place=Q[i];
        ll c=0;
        index.insert(Place);
        vector<ll> low(2, -1);
      	vector<ll> high(2, N);
       	auto fi=index.find(Place);
        for(ll j=0; j<2; j++){
            if(index.begin()==fi)break;
            fi --;
            low[j]=*fi;
        }
        fi=index.find(Place);
        for(ll j=0; j<2; j++){
            fi ++;
            if(index.end()==fi)break;
            high[j]=*fi;
          	//cout<<"!";
        }
        c=(high[0]-Place)*(low[0]-low[1])+(high[1]-high[0])*(Place-low[0]);
        Ans+=c*(i+1);
      	//cout<<high[1]<<" "<<high[0]<<" "<<Place<<" "<<low[0]<<" "<<low[1]<<endl;
      	//cout<<c<<endl;
    }
    cout<<Ans<<endl;
    return 0;


}

Measured memory_bytes: 6528
h = input()
l = len(h)
n = 0
hitachi = False

if l % 2 == 1:
  hitachi = False
  
else:
  m = int(l / 2)
  for i in range(m):
    if h[(2 * i)] == "h":
      n += 1
    if h[(2 * i)+1] == "i":
      n += 1
  
  if n == l:
    hitachi = True
  else:
    hitachi = False
    
if hitachi:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int ans=0;
    string s;
    cin>>s;
    if(s[0]!='C')ans++;
    if(s[1]!='O')ans++;
    if(s[2]!='D')ans++;
    if(s[3]!='E')ans++;
    if(s[4]!='F')ans++;
    if(s[5]!='E')ans++;
    if(s[6]!='S')ans++;
    if(s[7]!='T')ans++;
    if(s[8]!='I')ans++;
    if(s[9]!='V')ans++;
    if(s[10]!='A')ans++;
    if(s[11]!='L')ans++;
    if(s[12]!='2')ans++;
    if(s[13]!='0')ans++;
    if(s[14]!='1')ans++;
    if(s[15]!='6')ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#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<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int a, b, h; cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



signed main(){
cin.tie(0);
ios::sync_with_stdio(false);



	int a,b,c;
	cin>>a>>b>>c;

	a-=b;
	a %= c;
	cout << a << endl;
	return 0;
}



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

int main(){
    ll n, m, c;
    cin>>n>>m>>c;
    ll ans=0;
    ll b[m];
    for(ll i=0;i<m;++i){
        cin>>b[i];
    }
    for(ll i=0;i<n;++i){
        ll a[m];
        ll flag=0;
        for(ll j=0;j<m;++j){
            cin>>a[j];
            flag += a[j]*b[j];
        }
        //cout<<flag<<endl;
        if(flag+c>0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int match[10] = {0,2,5,5,4,5,6,3,7,6};
string dp[100100];

void chmax(string &a, string b){
  if( a == "-"){ a = b; return ;}
  else{
    if( b.size() > a.size()){ a = b; return ;}
    else if( b.size() == a.size()){
      a = max(a,b); return ;}
  }
  return ;}

int main(){
int N,M;cin >> N >> M;
  vector<char> A(M);for(int i  =0; i < M; i++){ cin >> A[i];}
  //配るDPで一つずつ求めていく
  for(int i = 0; i < 10100; i++){ dp[i] = "-";}
  dp[0] = "";
  
  for(int i = 0; i < 10100; i++){
//ちょうどi本使う場合
    if(dp[i] == "-"){ continue;} //不可能　から配るのは不可能
    for(int j = 0; j < M; j++){
     chmax(dp[i+match[A[j]-'0']], dp[i]+A[j]);}
  }
  
  cout << dp[N] << endl; return 0;}
  
  

Measured memory_bytes: 47744
#include <iostream>
#include <bitset>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin>>s;
	cout<<s.substr(0,4)<<" "<<s.substr(4)<<endl;
	return 0;
}

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

#define f(i,n) for(i=0;i<n;i++)
#define vi vector<int>

int main()
{
    int n,m, i;cin >>n >> m;
    if(m<n)
    f(i,n) cout << m;
    else 
    f(i,m) cout << n;
}

Measured memory_bytes: 256
diceface = { "TOP"=>0,"FRONT"=>1,"RIGHT"=>2,"LEFT"=>3,"BACK"=>4,"BOTTOM"=>5 }

dice = gets.split( " " ).map { |val| val.to_i }
actions = gets.chomp
for i in ( 0 ... actions.length )
	t = 0
	case actions[i]
	when "E"
		t = dice[ diceface["TOP"] ]
		dice[ diceface["TOP"] ] = dice[ diceface["LEFT"] ]
		dice[ diceface["LEFT"] ] = dice[ diceface["BOTTOM"] ]
		dice[ diceface["BOTTOM"] ] = dice[ diceface["RIGHT"] ]
		dice[ diceface["RIGHT"] ] = t
	when "N"
		t = dice[ diceface["TOP"] ]
		dice[ diceface["TOP"] ] = dice[ diceface["FRONT"] ]
		dice[ diceface["FRONT"] ] = dice[ diceface["BOTTOM"] ]
		dice[ diceface["BOTTOM"] ] = dice[ diceface["BACK"] ]
		dice[ diceface["BACK"] ] = t
	when "S"
		t = dice[ diceface["TOP"] ]
		dice[ diceface["TOP"] ] = dice[ diceface["BACK"] ]
		dice[ diceface["BACK"] ] = dice[ diceface["BOTTOM"] ]
		dice[ diceface["BOTTOM"] ] = dice[ diceface["FRONT"] ]
		dice[ diceface["FRONT"] ] = t	
	when "W"
		t = dice[ diceface["TOP"] ]
		dice[ diceface["TOP"] ] = dice[ diceface["RIGHT"] ]
		dice[ diceface["RIGHT"] ] = dice[ diceface["BOTTOM"] ]
		dice[ diceface["BOTTOM"] ] = dice[ diceface["LEFT"] ]
		dice[ diceface["LEFT"] ] = t	
	end
end

puts( dice[ diceface["TOP"] ] )

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

typedef long long int ll;
typedef long double   ld;

//#include <ext/pb_ds/assoc_container.hpp>   
//#include <ext/pb_ds/tree_policy.hpp>  
//#include <functional> 
//using namespace __gnu_pbds;  
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> OST;  

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                       cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int t; cin >> t; while(t--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ook(x)                   order_of_key(x)
#define    fbo(x)                   find_by_order(x)

int main(){
     speed upp
     int l, r;
     cin >> l >> r;
     int ans = 2020;
     vector <int> v;
     int cnt = 0;
     f(i,l,r){
         v.pb(i%2019);
         cnt++;
         if(cnt >= 4500) break;
     }
     int size = sz(v);
     f(i,0,size-1){
         f(j,i+1,size-1){
             int temp = (v[i]*v[j])%2019;
             ans = min(ans , temp);
         }
     }
     cout << ans << '\n';
}

Measured memory_bytes: 256
import math
n = int(input())

index = 2
array = [0] * math.ceil(math.sqrt(n)+1)
while index <= math.sqrt(n):
  while n % index == 0:
    array[index] += 1 
    n //= index
    
  index += 1
  
ans = 0
if n >= len(array):
  ans += 1
elif n != 1:
  array[n] += 1
  
for i in range(len(array)):
  index = 1
  while index <= array[i]:
    array[i] -= index
    index += 1
    ans += 1
    
print(ans)

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll modpow(ll n, ll p) {
    ll ret = 1;
    ll t = n;
    while (p > 0) {
        if ((p & 1) == 1) {
            ret = ret * t % MOD;
        }
        p /= 2LL;

        t = (t * t) % MOD;
    }
    return ret;
}

ll P[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    memset(P, 0, sizeof(P));

    ll ans = 0;
    for (ll n = K; n >= 1; --n) {
        ll s = 0;
        ll m = 0;
        for (ll j = n; j <= K; j += n) {
            m++;
            s += P[j];
        }
        s %= MOD;

        ll p = modpow(m, N);
        P[n] = (MOD + p - s) % MOD;

        ans = (n * P[n] + ans) % MOD;

        //cout << n << " " << p << endl;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 4444
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n);
    REP(i,n){
        REP(j,d){
            int xc;
            cin >> xc;
            x[i].eb(xc);
        }
    }
    int tot = 0;
    REP(i, n)
    {
        REP(j,n){
            if (i<j){
                int dist=0;
                REP(k,d){
                    dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
                }
                int dist2 = round(sqrt(dist * 1.));
                if (dist2*dist2 == dist)
                    ++tot;
            }
        }
    }
    cout << tot << endl;
}

Measured memory_bytes: 256
x=sorted(list(map(int,input().split())))
a=x[0]
b=x[1]
c=x[2]
ans=0
ans+=c-b
b=c
a+=ans
if (c-a)%2==0:
    ans+=(c-a)//2
else:
    ans+=(c-a+1)//2+1
print(ans)



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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int c=0;
    for(int i=0; i<n; i++) if(s[i]=='E') c++;
    int mn=n;
    for(int i=0; i<n; i++){
        if(s[i]=='E') c--;
        mn=min(mn, c);
        if(s[i]=='W') c++;
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 900
import java.util.*;
public class Main{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    int ac=0,wa=0,tle=0,re=0;
    for(int i=0;i<n;i++)
    {
    	String s=in.next();
    	if(s.equals("AC"))
    		ac++;
    	else if(s.equals("WA"))
    		wa++;
    	else if(s.equals("TLE"))
    		tle++;
    	else
    		re++;
    }
    System.out.println("AC x "+ac);
    System.out.println("WA x "+wa);
    System.out.println("TLE x "+tle);
    System.out.println("RE x "+re);
    
  }
}


Measured memory_bytes: 58220
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++) 
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e5 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=998244353;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}

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

	int l=1;

	for(int i=0;i<n;i++){
		int x; cin >> x;
		if(x==l)l++;
	}

	if(l==1) cout << -1;
	else cout << n-(l-1);
}

Measured memory_bytes: 256
a = list(input())
b = list(input())
copy = [a[:], b[:]]
a.reverse()
b.reverse()
c = [a,
     b]
c.reverse()
if ''.join(c[0]) == ''.join(copy[0]) and ''.join(c[1]) == ''.join(copy[1]):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

const ll MXN=200000;
vl G[MXN];
vl B(MXN,0),d(MXN,0),ans(MXN,0);

void bfs(ll x,ll p){
  ans[x]=p;
  B[x]=1;
  rep(i,(ll)G[x].size()){
    if(B[G[x][i]]==0){
      bfs(G[x][i],p+d[G[x][i]]);
    }
  }
}
int main() {
  ll N,Q;
  cin >> N >> Q;
  rep(i,N-1){
    ll a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i,Q){
    ll p,x;
    cin >> p >> x;
    p--;
    d[p]+=x;
  }
  bfs(0,d[0]);
  rep(i,N){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 27392
s = input()
n = len(s)
R = [] # the number of consecutive 'R's on and toward the left
L = [] # the number of consecutive 'L's on and toward the right
ans = []

cnt = 0
for i in range(n):
    if s[i] == 'R':
        cnt += 1
    else:
        cnt = 0
    R.append(cnt)
R.append(0)

s = s[::-1]
cnt =0
for i in range(n):
    if s[i] == 'L':
        cnt += 1
    else:
        cnt = 0
    L.append(cnt)
L.append(0)

r= [0]*n # the number of children coming from 'R' series and stay there
for i in range(n):
    if R[i] != 0 and R[i+1] ==0:
        if R[i] % 2 == 1:
            r[i] = (R[i] + 1) // 2
            r[i+1] = (R[i] - 1) // 2
        else:
            r[i] = R[i] // 2
            r[i+1] = R[i] // 2

l = [0]*n # the number of children coming from 'L' series and stay there
for i in range(n):
    if L[i] != 0 and L[i+1] ==0:
        if L[i] % 2== 1:
            l[i] = (L[i] + 1) // 2
            l[i+1] = (L[i] - 1) // 2
        else:
            l[i] = L[i] // 2
            l[i+1] = L[i] // 2
l = l[::-1]

for i in range(n):
    ans.append(r[i]+l[i])

for i in range(n-1):
    print(ans[i], end = ' ')
print(ans[n - 1])

Measured memory_bytes: 16072
#include <iostream>
using namespace std;
int main(void){
    int h,w,x,y;
    while(1){
        cin >> h >> w;
        if (h==0&&w==0) break;
        for(x=0;x<h;x++){
            for(y=0;y<w;y++){
                cout << "#";
            }
            cout << endl;
        }
        cout <<endl;
    }
     
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define rg register 
#define ll long long
inline ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
		{
			f=-1;
		}
		c=getchar();
	}
	while(c<='9'&&c>='0')
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
}
int n,k;
ll a[200000];
ll s[200000];
ll ss[200000];
ll sum;
ll maxx;
int main()
{
	n=read();
	k=read();
	for(rg int i=1;i<=n; ++i)
	{
		a[i]=read();
		s[i]=s[i-1]+a[i];
		if(a[i]>0)//用来保存区间外面的正数 
		{
			ss[i]=ss[i-1]+a[i];
		}
		else
		{
			ss[i]=ss[i-1];
		}
	}
	for(rg int i=1;i<=n-k+1;++i)
	{
		sum=0;
		ll j=i+k-1;//右端点 
		if(s[j]-s[i-1]>=0)
		{
			sum+=s[j]-s[i-1];
		}
		sum+=(ss[n]-ss[j]);//统计区间外正数 
		sum+=(ss[i-1]-ss[0]);
		maxx=max(maxx,sum);	
	}
	cout<<maxx;
}

Measured memory_bytes: 3584
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))

if k == 0:
	print(max(a))
	exit()

suki = 1000000000
kirai = 0
while int(suki) != int(kirai):
	targ = (suki+kirai)/2
	cnt = 0
	mode = 1
	for i in range(n):
		cnt += (a[i]-1)//targ
		if cnt > k:
			mode = 0
			break
	if mode:
		suki = targ
	else:
		kirai = targ

print(math.ceil(suki))

Measured memory_bytes: 93672
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main()
{
	string s;
	string tmp = "CODEFESTIVAL2016";
	cin >> s;
	int cnt = 0;
	//cout << s.size();
	for (int i = 0; i < s.size(); i++)
	{
		
		if (s[i] != tmp[i])
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using p = pair<int,int>;

long long n;
bool memo[100000005] = {0};
bool dp[100000005] = {0};
vector<p> a;

bool asc(const p &l,const p &r){
    int cntl = 0,cntr = 0;
    for(int i = 0;i < n;++i) {
        cntl += (l.fi >> i) & 1;
        cntr += (r.fi >> i) & 1;
    }
    if(cntl != cntr)return cntl < cntr;
    return l.fi < r.fi;
}


long long solve();

int main(){
    cin >> n;
    a.resize((1LL << n));
    for(int i = 0;i < (1LL << n);++i){
        cin >> a[i].se;
        a[i].fi = i;
        memo[i] = a[i].se;
    }
    cout << solve() << endl;
    return 0;
}

long long solve(){
    sort(a.begin(),a.end(),asc);
    long long ans = 0;
    for(int i = 0;i < n;++i){
        for(int bit = 0; bit < (1LL << n);++bit){
            if(!((bit >> i) & 1))
                dp[bit + (1 << i)] |= memo[bit];
        }
    }
    for(int i = 0;i < (1LL << n);++i){
        if(dp[a[i].fi] && !a[i].se)return -1;
        if(a[i].se && !dp[a[i].fi])++ans;
    }
    return ans;
}


Measured memory_bytes: 13200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    for(int i = 1; ; i++){
        if(i*y + (i+1)*z > x){
            cout << i - 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int w,h,n;
  cin>>n>>w>>h;
  int x,y,B=2*(w+h),ans=n;
  char c;
  vector<P> m;
  for(int i=0;i<n;i++){
    cin>>x>>y>>c;
    if(c=='S')m.push_back(P(x+y,(x-y+B)%B));
    if(c=='E')m.push_back(P(w+y+(w-x),w+y-(w-x)));
    if(c=='N')m.push_back(P(w+h+(w-x)+(h-y),w+h+(w-x)-(h-y)));
    if(c=='W')m.push_back(P((w*2+h+(h-y)+x)%B,w*2+h+(h-y)-x));
  }
  sort(m.begin(),m.end());
  for(int i=0;i<n;i++){
    int tp=1,p=m[i].first;
    for(int j=0;j<n;j++){
      int s=m[(i+j)%n].second,g=m[(i+j)%n].first;
      if(s>g&&!(g<p&&p<s))continue;
      if(s<g&&s<=p&&p<=g)continue;
      tp++,p=g;
    }
    ans=min(tp,ans);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <ctype.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    char buf[100];

    scanf("%s",buf);

    buf[K-1] = tolower(buf[K-1]);

    //from the view of ascii, there is difference of 32 between 
    //lower alphabet and upper alphabet (lower > apper)
    //so line below is also works.
    //buf[K-1] += 32;

    cout << buf << endl;

    return 0;
}


Measured memory_bytes: 256
import math 

N,D=map(int,input().split())
a=[]
ans=0
for _ in range(N):
    tmp=list(map(int,input().split()))
    a.append(tmp)
for i in range(N-1):
    for k in range(i+1,N):
        dst=0
        for j in range(D):
            dst+=(a[i][j]-a[k][j])**2
        dst=math.sqrt(dst)
        if dst== int(dst):
            ans+=1
print(ans)

Measured memory_bytes: 9168
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#include<string.h>

long int min(long int a, long int b){
    return a<b ? a:b;
}

int main(){
    char col[100000];
    int i=0;
    int gb=0, gw=0, kb=0, kw=0;
    scanf("%s", col);
    while(col[i]=='0' || col[i]=='1'){
        if(i%2==0){
            if(col[i]=='0') gb++;
            else gw++;
        }else{
            if(col[i]=='0') kb++;
            else kw++;
        }
        i++;
    }
    int ans = (gb + kw)>(gw + kb)? gb+kw : gw+kb;
    printf("%d",i-ans);
    return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  string s;cin>>s;
  ll n=s.size();
  auto dp=vec(n+1,2,INF);
  dp[0][0]=0,dp[0][1]=1;
  rep(i,0,n){
    chmin(dp[i+1][0],dp[i][0]+(s[i]-'0'));
    chmin(dp[i+1][1],dp[i][0]+1+(s[i]-'0'));
    chmin(dp[i+1][0],dp[i][1]+('9'-s[i])+1);
    chmin(dp[i+1][1],dp[i][1]+('9'-s[i]));
  }
  cout<<dp[n][0]<<endl;
  return 0;
}

Measured memory_bytes: 55964
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N;
    string S;
    cin >>N >> S;
    char color = S.at(0);
    int count=1;
    for(int i=1; i<N; i++){
        if(S.at(i) != color){
            color = S.at(i);
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
var
	h,w,i,j,r,c:Longint;
	s:array[0..51]of string[52];
	dx:array[1..8]of Longint=(1,0,-1,0,1,1,-1,-1);
	dy:array[1..8]of Longint=(0,1,0,-1,1,-1,1,-1);
begin
	readln(h,w);
	for i:=1 to h do readln(s[i]);
	for i:=1 to h do begin
		for j:=1 to w do begin
			if s[i][j]='.' then begin
				c:=48;
				for r:=1 to 8 do begin
					if s[i+dx[r]][j+dy[r]]='#' then inc(c);
				end;
				s[i][j]:=chr(c);
			end;
		end;
		writeln(s[i]);
	end;
end.

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
	int N, R, S, P, K,Ans=0;
	cin >> N;
	cin >> K;
	char* T=new char[N];
	cin >> R;
	cin >> S;
	cin >> P;
	cin >> T;
	for (int i = 0;i<N;i++) {
		if (i-K>=0) {
			if (T[i - K] != T[i]) {
				if (T[i] == 'r') {
					Ans += P;
				}
				else if (T[i] == 's') {
					Ans += R;
				}
				else if (T[i] == 'p') {
					Ans += S;
				}
			}
			else {
				if (i + K <= N) {
					T[i] = 'L';
				}
			}
		}
		else {
			if (T[i] == 'r') {
				Ans += P;
			}
			else if (T[i] == 's') {
				Ans += R;
			}
			else if (T[i] == 'p') {
				Ans += S;
			}
		}
	}
	cout << Ans;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;


long long int n,a;

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int x = kb.nextInt();
		int y = kb.nextInt();
		int z = kb.nextInt();
		System.out.println(z + " " + x + " " + y);
		kb.close();
	}

}


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

int main(){
    int A,B,K,j=0;
    cin>>A>>B>>K;
    for(int i=min(A,B);i>=0;i--){
        if(A%i==0&&B%i==0){
            K--;
        }
        if(K==0){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
  ll x,k,d;
  cin >> x >> k >> d;
  x = abs(x);
  ll a = x-(x/d)*d;
  ll kk = k-x/d;
  if(kk <= 0) cout << x-k*d << endl;
  else{
    if(kk%2 == 1) cout << abs(a-d) << endl;
    else cout << a << endl;
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int>A(N);
    vector<int>B(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        B[i]=A[i];
    }
    sort(B.begin(), B.end());
    for(int i=0;i<N;i++){
        if(A[i]==B[N-1])cout<<B[N-2]<<endl;
        else cout<<B[N-1]<<endl;
    }
    }

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int K; int X;
    cin >> K >> X;
    for (int i = -1000000; i<=1000000; ++i) {
        if (abs(i - X) < K)
            cout << i << " ";
    }
}

Measured memory_bytes: 256
#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 rep(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace(x) cout << #x << ": " << x << endl
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
vii arr;
int main(){
  int n,a;
  cin >> n;
  rep(i,0,n){
    cin >> a;
    arr.pb(mp(a,i+1));
  }
  sort(all(arr));
  rep(i,0,n){
    if(i) cout << " "; 
    cout << arr[i].ss ;
  }
  cout << endl;
} 

Measured memory_bytes: 5296
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0216();
	}
	class AOJ0216{
		int now,w,set[];
		void fase_1(){
			now=1150;
			if(w>10){
				w-=10;
			}else w=0;
		}
		
		void fase_2(){
			if(w<=0)return;
			if(w>10){
				w-=10;
				now+=(125*10);
			}else if(w<=10){
				now+=(125*w);
				w=0;
			}
		}
		
		void fase_3(){
			if(w<=0)return;
			if(w>10){
				w-=10;
				now+=(140*10);
			}else if(w<=10){
				now+=(140*w);
				w=0;
			}
		}
		
		void fase_4(){
			if(w<=0)return;
			now+=(160*w);
			w=0;
		}
		
		public AOJ0216() {
			int before = 4280;
			while(true){
				w = in.nextInt();
				if(w==-1)break;
				fase_1();fase_2();fase_3();fase_4();
				System.out.println(before-now);
			}
		}

	}
}

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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9,mod=1e9+7;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int dp[10005];

int main(){
	//IO();
	dp[0]=0;
	scanf("%d%d",&k,&n);
	for(int i=0;i<n;i++)
		scanf("%d %d",&a[i],&b[i]);
	for(int i=1;i<=k;i++)
		dp[i]=1e9;
	for(int j=1;j<=k;j++)
		for(int i=0;i<n;i++)
			dp[j]=min(dp[j],dp[max(0,j-a[i])]+b[i]);
	printf("%d\n",dp[k]);
}


Measured memory_bytes: 2304
N = gets.to_i
a = gets.split(" ").map(&:to_i)
b = Array.new(8, false)
freecount = 0
N.times do |i|
	color = a[i] / 400
	if(color < 8)
		b[color] = true
	else
		freecount += 1
	end
end

if b.count(true) != 0
	min = b.count(true)
	max = min + freecount
else
	min = 1
	max = freecount
end

puts "#{min} #{max}"


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
 
typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

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

    if (N <= 99) {
        cout << min(9u,N) << endl;
    } else if (N <= 9999) {
        ull n = min(999u,N);
        cout << (9 + (n - 99)) << endl;
    } else if (N <= 999999u) {
        ull n = min(99999u,N);
        cout << (9 + 900 + (n - 9999)) << endl;
    } else if (N <= 99999999u) {
        ull n = min(9999999u,N);
        cout << (9 + 900 + 90000 + (n - 999999)) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	cin >> a;
	vector<pair<int, int> > pairs(a);
	for (int i = 0; i < a; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < a; i++)
	{
		if (i % 2 == 0)
		{
			b += x[i];
			if (b >= 0)
			{
				ans += b + 1;
				b = -1;
			}
		}
		else
		{
			b += x[i];
			if (b <= 0)
			{
				ans -= b - 1;
				b = 1;
			}
		}
	}
	c = ans;
	b = 0;
	ans = 0;
	for (int i = 0; i < a; i++)
	{
		if (i % 2 == 1)
		{
			b += x[i];
			if (b >= 0)
			{
				ans += b + 1;
				b = -1;
			}
		}
		else
		{
			b += x[i];
			if (b <= 0)
			{
				ans -= b - 1;
				b = 1;
			}
		}
	}
	cout << min(ans, c) << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

int main()
{
	int a[4],b[4],c[4][4];
	
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			cin >> c[i][j];
	
	for(a[1]=0;a[1]<=c[1][1];a[1]++)
	{
		for(a[2]=0;a[2]<=c[2][2];a[2]++)
		{
			for(a[3]=0;a[3]<=c[3][3];a[3]++)
			{
				for(int i=1;i<=3;i++)
					b[i]=c[i][i]-a[i];
				bool flag=true;
				for(int i=1;i<=3;i++)
					for(int j=1;j<=3;j++)
						if(c[i][j]!=a[i]+b[j])
							flag=false;
				if(flag==true)
				{
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define y1 ________y1
ld x1,x2,xp,y1,y2,yp,slope,ansx,ansy;
ll Q;
bool flx,fly;
signed main(){
	scanf("%Lf%Lf%Lf%Lf",&x1,&y1,&x2,&y2);
	if (y1==y2) flx=true;
	else if(x1==x2) fly=true;
	else slope=(y2-y1)/(x2-x1);
	x2-=x1,y2-=y1;
	scanf("%lld",&Q);while (Q--){
		scanf("%Lf%Lf",&xp,&yp);
		if(flx) printf("%.10Lf %.10Lf\n",xp*2-xp,y1*2-yp);
		else if(fly) printf("%.10Lf %.10Lf\n",x1*2-xp,yp*2-yp);
		else{
			ansx=(yp*x2*y2+xp*x2*x2-y1*y2*x2+x1*y2*y2)/(y2*y2+x2*x2);
			ansy=(-x2*ansx+yp*y2+xp*x2)/y2;
			printf("%.10Lf %.10Lf\n",ansx*2-xp,ansy*2-yp);
		}
	}
	fclose(stdin);fclose(stdout);return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 7;
int s[maxn];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &s[i]);
    sort(s + 1, s + 1 + n);
    if (s[n] - s[1] > 1) puts("No");
    else if (s[n] == s[1]) {
        if (s[1] == n - 1) puts("Yes");
        else if (2 * s[1] <= n) puts("Yes");
        else puts("No");
    } else {
        int mx = 0;
        for (int i = 1; i <= n; ++i) if (s[i] == s[1]) mx++;
        if (mx > s[1]) puts("No");
        else if (n - mx < 2 * (s[n] - mx)) puts("No");
        else puts("Yes");
    }
}

Measured memory_bytes: 640
import sys

input = sys.stdin.readline

N, M, Q = map(int, input().split())
t = [[0] * (N + 1) for _ in range(N + 1)]
# es[L][R]:=区間[L,R]を走る列車の本数

for _ in range(M):
    l, r = map(int, input().split())
    t[l][r] += 1

for L in range(1, N + 1):
    for R in range(1, N + 1):
        t[L][R] += t[L - 1][R]
        t[L][R] += t[L][R - 1]
        t[L][R] -= t[L - 1][R - 1]
        # 累積和のテーブルを作る
        # 最終的には
        # t[L][R]には区間が[L,R]に含まれる本数を入れるが、
        # 現時点では区間が[L,R]に一致する本数しか入っていない
        # ここに区間が[L-1,R]に含まれる本数と
        # 区間が[L,R-1]に含まれる本数を足すと
        # 区間が[L,R]に含まれる範囲をカバーできるが、
        # 区間が[L-1][R-1]の範囲が重複して足されている

for _ in range(Q):
    p, q = map(int, input().split())
    print(t[q][q] - t[p - 1][q] - t[q][p - 1] + t[p - 1][p - 1])
    # 2次元累積和


Measured memory_bytes: 13548
#include <stdio.h>

int main(void)
{
    int x,y;

    while(1)
    {
        scanf("%d %d",&x,&y);
        
        if (x==0 && y==0) break;

        if (x < y){
            printf("%d %d\n",x,y);
        }else{
            printf("%d %d\n",y,x);          
        }


    }
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const int INF=1e9;


int main(){
  int h,n;
  cin>>h>>n;
  int tot=0;

  rep(i,n){
    int a;
    cin>>a;
    tot+=a;
  }

  if(tot>=h){
    cout<<"Yes"<<endl;
    
  }else{
    cout<<"No"<<endl;
  }

}


Measured memory_bytes: 3632
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split_whitespace()
        .flat_map(|x| x.chars())
        .collect::<Vec<_>>();
    format!("{}{}{}", list[0], list[4], list[8]).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "ant
obe
rec" => "abc",
    test2: "edu
cat
ion" => "ean",
}


Measured memory_bytes: 4352
def calc(n):
  ans = 0
  while(n > 0):
    ans += n % 10
    n /= 10
  return ans

n,a,b = map(int, raw_input().split())
ans = 0
for i in range(1, n+1):
  s = calc(i)
  if a <= s and s <= b:
    ans += i
print ans


Measured memory_bytes: 2948
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const ll N = 1e5 + 7;
const ll mod = 1e18 + 7;

int n, t;
string ans = "Yes";

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGn
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> n;
    vector < pair < int, int > > vc(n);
    for ( int i = 0; i < n; i++ ) {
        cin >> vc[i].fi >> vc[i].se;
    }
    sort(all(vc), []( const pair < int, int > &a, const pair < int, int > &b ){ return a.se < b.se; });
    for ( int i = 0; i < n; i++ ) {
        t += vc[i].fi;
        if ( t > vc[i].se ) {
            ans = "No";
            break;
        }
    }
    cout << ans;
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        String[] arr = new String[2];
        for(int i = 0;i < arr.length;i++) {
            arr[i] = scanner.nextLine();
        }

        int n = Integer.parseInt(arr[0]);

        String[] line2 = arr[1].split(" ");

        int[] a = new int[line2.length];
        for (int i = 0; i < line2.length; i++) {
            a[i] = Integer.parseInt(line2[i]);
        }

        int[] answers = new int[n];
        for (int id : a) {
            answers[id - 1] ++;
        }

        for (int answer : answers) {
            System.out.println(answer);
        }

        scanner.close();
    }
}


Measured memory_bytes: 75512
#include<iostream>
using namespace std;
int main(){
	int t,n,i,y,h,a;
	double x=1000,w;
	cin >> n >> t >> a;
	for(i=0;i<n;i++){
		cin >> h;
		w=t-0.006*h-a;
		if(w<0)
			w=-w;
		if(w<x){
			x=w;
			y=i;
		}
	}
	cout << y+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    string s;

    cin >> s;

    for (int i = 0; i < s.size()-8; i++) cout << s[i];

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    ll A;
    double b;
    cin >> A >> b;
    b += 0.005;
    ll B = (b * 100);
    cout << (A * B)/100 << endl;
}

Measured memory_bytes: 3724
//edpc_g.cpp
//Sun Jan 27 15:03:43 2019

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

vector<vector<int>> path;
vector<int> memo;

int dp(int i){
	if (memo[i] != -1){
		return memo[i];
	}
	int ans = 0;
	for (auto itr=path[i].begin();itr!=path[i].end();++itr){
		ans = max(ans,dp(*itr)+1);
	}
	memo[i]=ans;
	return ans;
}

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

	path.resize(n);

	for (int i=0;i<m;i++){
		int x,y;
		cin >> x >> y;
		path[x-1].push_back(y-1);
	}

	memo.resize(n,-1);

	int ans = 0;
	for (int i=0;i<n;i++){
		ans = max(ans,dp(i));
	}

	cout << ans << endl;
}

Measured memory_bytes: 8192
/*
@Author: nonameless
@Date:   2020-05-19 11:13:49
@Email:  2835391726@qq.com
@Blog:   https://www.cnblogs.com/nonameless/
*/
#include <bits/stdc++.h>
#define first x
#define second y
#define push_back pb
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const double PI  = acos(-1.0);
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll LNF  = 0x3f3f3f3f3f3f;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline ll  gcd(ll  a, ll b)  { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }


int main(){

    int k; string s;
    cin >> k >> s;
    int len = s.size();
    if(len <= k) cout << s << endl;
    else{
        for(int i = 0; i < k; i ++) cout << s[i];
        puts("...");
    }
    return 0;
}


Measured memory_bytes: 3628
N,X = map(int,input().split())

nlen = [0] * (N+1)
nlen[0] = 1

for i in range(N):
    i += 1

    nlen[i] = 3 + nlen[i-1] * 2

    
    
num = [0] * (N+1)

p = 0
b = 0

amari = X


for i in range(N):

    i = N-i

    num[i-1] += 2 * num[i]
    p += num[i]
    b += num[i] * 2

    if 3 + 2 * nlen[i-1]  == amari :

        num[i-1] += 2

        p += 1
        b += 2

        amari = 0

    elif 2 + 2 * nlen[i-1] == amari:

        num[i-1] += 2

        p += 1
        b += 1

        amari = 0

    elif 2 + nlen[i-1] <= amari:

        num[i-1] += 1

        p += 1
        b += 1

        amari -= 2 + nlen[i-1]

    elif 1 + nlen[i-1] == amari:

        num[i-1] += 1

        b += 1

        amari = 0

    elif 1 <= amari:

        b += 1
        amari -= 1

print (p + num[0])

Measured memory_bytes: 38384
import math

N,H = [int(i) for i in input().split()]

A = list()
B = list()

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

maxA = max(A)
B.sort()
B.reverse()

cnt = 0
for i in B:
    if i > maxA:
        H = H - i
        cnt = cnt + 1
        if H <= 0:
            break

if H > 0:
    cnt = cnt + math.ceil(H/maxA)

print(cnt)


Measured memory_bytes: 11328
N = int(input())
k = []
ans = 0
flag = 0
for i in range(N):
  s,t = input().split()
  k.append([s,t])
X = input()
for i in range(N):
  if flag == 1:
    ans += int(k[i][1])
  if k[i][0] == X:
    flag += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <atcoder/all>
// $ g++ main.cpp -std=c++14 -I .
// https://atcoder.github.io/ac-library/document_ja/
using namespace std;
using namespace atcoder;

int main(){
    int n, m;
    cin >> n >> m;
    dsu d(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        d.merge(--a, --b);
    }
    cout << (d.groups().size() - 1) << endl;
}

Measured memory_bytes: 8916