akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

typedef long long Weight;

const Weight INF = 1000000000000ll;

struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
// The costs of edges must be 0 or 1 (Verified: TCO 2014 Round 2C Medium)
void bfs01(Graph &g, vector<Weight> &d, int s) {
  fill(d.begin(), d.end(), INF);
  d[s] = 0;
  typedef pair<Weight,int> P;
  queue<P> que, zero;
  que.push(P(0, s));
  while (!zero.empty() || !que.empty()) {
    P top = zero.empty() ? que.front() : zero.front();
    if (zero.empty()) que.pop(); else zero.pop();
    Weight dist = top.first; int v = top.second;
    if (d[v] < dist) continue;
    REP(i, g[v].size()) {
      Edge e = g[v][i];
      if (d[e.dest] > d[v] + e.weight) {
        d[e.dest] = d[v] + e.weight;
        if (e.weight) que.push(P(d[e.dest], e.dest));
        else zero.push(P(d[e.dest], e.dest));
      }
    }
  }
}

bool is_mbl(char c){
  return c=='.'||c=='s'||c=='g'||c=='*';
}

bool is_bembl(char c){
  return c=='.'||c=='s';
}

int main() {
  int w,h;
  cin>>w>>h;
  vector<string> t(h);
  REP(i,h)cin>>t[i];
  int s,gix;
  REP(i,h)REP(j,w){
    if(t[i][j]=='s'){
      s=i*w+j;
    }else if(t[i][j]=='g'){
      gix=i*w+j;
    }
  }
  Graph g(h*w+1);
  REP(i,h)REP(j,w){
    if(!is_mbl(t[i][j]))continue;
    int di[]={1,0,-1,0};
    int dj[]={0,1,0,-1};
    int six = i*w+j;
    REP(k,4){
      int ni=i+di[k];
      int nj=j+dj[k];
      if(ni<0||nj<0||ni>=h||nj>=w)continue;
      if(!is_bembl(t[ni][nj]))continue;
      int tix = ni*w+nj;
      g[six].push_back({six,tix,1});
    }
    if(t[i][j]=='*'){
      g[h*w].push_back({h*w,six,0});
    }
  }
  Array dg(h*w+1);
  Array ds(h*w+1);
  bfs01(g, dg, gix);
  bfs01(g, ds, h*w);
  long double v=1e+10;
  long double ex_spr = 0;
  while(v > 1e-14){
    long double dist_sum = 0;
    int cnt=0;
    REP(i,h*w){
      if(!is_bembl(t[i/w][i%w]))continue;
      dist_sum += min((long double)(dg[i]), ds[i] + ex_spr + v);
      ++cnt;
    }
    if (ex_spr + v < (dist_sum/cnt)) {
      ex_spr += v;
    }
    v /= 2.0;
  }
  cout << setprecision(14) << fixed << min((long double)(dg[s]), ds[s] + ex_spr) << endl;
  return 0;
}

Measured memory_bytes: 30692
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATwoIntegers solver = new ATwoIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATwoIntegers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.print(a % b == 0 ? -1 : a);
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    
    int i,local_tmp;
    int line_feed;
    string ans;
    
    cin >> line_feed;
    
    //初期化
    
    local_tmp = line_feed;
    ans = "No";
    
    for (i=0;i<3;i++){
        
        
        if ((local_tmp - local_tmp % int(std::pow(10,2.0-double(i)))) % 7 == 0){
        
            if(local_tmp == 0){
                
                break;
                
            }
              
          ans = "Yes";
        
        }
        
        local_tmp = local_tmp % int(std::pow(10,2.0-double(i)));

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

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int n;
int l[110],r[110];
int ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&l[i],&r[i]);
		if(l[i]==r[i])
		{
			ans++;
		}
		else
		{
			ans=0;
		}
		if(ans==3)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
vector<vl> Adj;
vector<bool> visited;
vector<ll> CCNum;
ll cc = 1;
void Explore(ll u)
{
    visited[u] = true;
    CCNum[u] = cc;
    for(ll v : Adj[u])
    {
        if(!visited[v])
        {
            Explore(v);
        }
    }
}
void dfs(ll n)
{
  pragi(1,n + 1)
  {
      if(!visited[i])
      {
          Explore(i);
          cc++;
      }
  }
}

void Compute(ll n,ll m)
{
    KAKA
    Adj.resize(n + 1);
    visited.resize(n + 1,false);
    CCNum.resize(n + 1);
    pragi(0,m)
    {
        ll u,v;
        cin>>u>>v;
        Adj[u].eb(v);
        Adj[v].eb(u);

    }
    //for(auto v : Adj[1]) cout<<v<<" ";
    //cout<<"\n";
    dfs(n);
    ll mx = *max_element(CCNum.begin(),CCNum.end());
   /* pragi(1,n + 1)
    {
        cout<<CCNum[i]<<" ";
    }*/
    vector<ll> vec(mx + 1,0);
    pragi(1,n + 1)
    {
        vec[CCNum[i]]++;
    }
    ll groups = *max_element(vec.begin() + 1,vec.end());
    cout<<groups<<"\n";
}
int main()
{
    KAKA
    ll n,m;
    cin>>n>>m;
    Compute(n,m);
}

Measured memory_bytes: 21932
while True:
    n=int(input())
    if n==0:
        break
    lst=[int(i) for i in input().split()]
    m=sum(lst)/len(lst)
    a_2=0
    for l in range(n):
        value=lst[l]
        a_2+=pow(value-m,2)/n
    print(pow(a_2,0.5))


Measured memory_bytes: 5676
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C, K = map(int, read().split())

x = 0
n = min(A,K)
K -= n
x += n
n = min(B,K)
K -= n
x -= K

print(x)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
const double PI=acos(-1.0);
struct Complex {
    double x,y;
    Complex(){}
    Complex(double x,double y):x(x),y(y){}
    Complex operator +(const Complex &t)const{return Complex(x+t.x,y+t.y);}
    Complex operator -(const Complex &t)const{return Complex(x-t.x,y-t.y);}
    Complex operator *(const Complex &t)const{return Complex(x*t.x-y*t.y,x*t.y+y*t.x);}
}a[N<<2],b[N<<2];
int rev[N<<2],limit=1;
ll m;
void FFT(Complex a[],int n,int t) {
    for(int i=1,j=0;i<n-1;i++) {
        for(int s=n;j^=s>>=1,~j&s;);
        if(i<j) swap(a[i],a[j]);
    }
    for(int d=0;(1<<d)<n;d++) {
        int m=1<<d,m2=m<<1;
        Complex wn={cos(PI/m),t*sin(PI/m)};
        for(int i=0;i<n;i+=m2) {
            Complex w{1,0};
            for(int j=0;j<m;j++) {
                Complex p=a[i+j],q=w*a[i+j+m];
                a[i+j]=p+q,a[i+j+m]=p-q;
                w=w*wn;
            }
        }
    }
}
int main() {
    int n;
    scanf("%d%lld",&n,&m);
    for(int i=1,t;i<=n;i++) {
    	scanf("%d",&t);
    	a[t].x++;
    }
    for(int i=0;i<N;i++) b[i].x=a[i].x;
    while(limit<=N*2) limit<<=1;
    FFT(a,limit,1);
    FFT(b,limit,1);
    for(int i=0;i<=limit;i++) a[i]=a[i]*b[i];
    FFT(a,limit,-1);
	ll ans=0;
    for(int i=N*2;i>=0;i--) {
    	ll num=(ll)(a[i].x/limit+0.5);
    	if(num<=m) ans+=num*i,m-=num;
    	else {
    		ans+=m*i;
    		break;
    	}
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 11392
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

string s;
typedef long long ll;
typedef string::const_iterator Iter;
typedef set<ll>::const_iterator SIter;

Iter skip_par(Iter it) {
  it++;
  for(int cnt=1;; it++) {
    if(*it == '(') cnt ++;
    if(*it == ')') cnt --;
    if(cnt == 0) break;
  }
  return it;
}

bool number(Iter st, Iter ed, ll& ret) {
  ret = 0;
  for(Iter curr=st; curr!=ed; curr++) {
    if(isdigit(*curr)) {
      ret *= 10;
      ret += (*curr)-'0';
    }
    else { return false; }
  }
  return true;
}

set<char> opes={'+','-','*','/'};

set<ll> exp(Iter st, Iter ed) {
  bool ok=false; if(*st=='('){Iter ii = st; ii = skip_par(ii);if(ii==ed-1) ok=true;}
  if(ok && *st == '(' && *(ed-1) == ')') { return exp(st+1, ed-1); }
  {ll num; if(number(st, ed, num)) { return {num}; } }
  set<ll> ret;
  for(Iter curr=st; curr!=ed;curr++) {
    if(*curr == '(') {
      curr = skip_par(curr);
    }
    else if(opes.count(*curr)) {
      set<ll> l = exp(st, curr);
      set<ll> r = exp(curr+1,ed);
      for(SIter i=l.begin(); i!=l.end(); i++) {
        for(SIter j=r.begin(); j!=r.end(); j++) {
          switch(*curr) {
            case '+': ret.insert(*i+*j); break;
            case '-': ret.insert(*i-*j); break;
            case '*': ret.insert(*i**j); break;
            case '/': if(*j!=0) { ret.insert(*i/(*j)); } break;
          }
        }
      }
    }
  }

  return ret;
}

int main()
{
  for(int i=0;i++,getline(cin, s);) {
    if(s=="#") { break; }
    Iter it = s.begin(), ed = s.end();
    cout << exp(it, ed).size() << endl;
  }

  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

const double PI = acos(-1);

int main(){

    int A, B, C, K;

    cin >> A >> B >> C >> K;

    if (K <= A) {
        cout << K << endl;
    } else if (K < A+B) {
        cout << A << endl;
    } else {
        cout << A - (K - A - B) << endl;
    }

    return 0;
}


Measured memory_bytes: 3160
n = int(input())

for i in range(1, n + 1):
    if i % 3 == 0:
        print(" " + str(i), end = "")
        continue
    x = i
    while True:
        if x % 10 == 3:
            print(" " + str(i) , end = "")
            break
        elif x == 0:
            break
        x //= 10
print()


Measured memory_bytes: 5868
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <queue>
#include <list>
#include <numeric>
#include <stack>
#include <unordered_map>
#include <map>
#include <set>
 
using namespace std;
 
#define sz(a) int((a).size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
#define watch(x) cout << #x << " : " << x << endl;
 
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef vector<ii> vii;
 
const int N = int(2e5)+10;
const int K = 10005;
// const int MOD = int(1e9)+7;
const int INF = int(1e9)+5;
const ll INF64 = 1e18;

const ll MOD = 1e9 + 7;
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

ll h[N];
bool good[N];

void solve () {
    int n,m;cin>>n>>m;
    for (int i=1;i<=n;i++) {
        good[i] = true;
        cin>>h[i];
    }
    for (int i=1;i<=m;i++) {
        int a,b;cin>>a>>b;
        if (h[a] <= h[b]) good[a] = false;
        if (h[b] <= h[a]) good[b] = false;
    }
    int cnt = 0;
    for (int i=1;i<=n;i++) {
        if (good[i]) cnt++;
    }
    cout<<cnt<<endl;
}

int main () {
    FastIO
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int t;
    // cin>>t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;

typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

//constexpr long long MOD = (ll) 1e9+7;
constexpr long long MOD = 998244353;

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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

//素因数分解
void factoring(ll n, vector<P>& vec) {
 	for (ll i = 2; i * i <= n; i++) {
        ll con=0;
  		while (n % i == 0) {
   			con++;
   			n /= i;
  		}
        if(con>0) vec.push_back({i,con});
 	}
 	if (n != 1) vec.push_back({n,1});
}


//最大公約数
ll gcd(ll m, ll n) {
 if (n == 0)return m;
 return gcd(n, m % n);
}//gcd

//最小公倍数
ll lcm(ll m, ll n) {
 return m / gcd(m, n) * n;
}

class Combination {
public:
 Array fact;//n！
 Array inv;//n!の逆元
 ll mod;
 Combination(ll n, ll _mod) {
  mod = _mod;
  fact.resize(n + 1);
  fact[0] = 1;
  REP(i, n) {
   fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
  }
  inv.resize(n + 1);
  inv[n] = mod_inv(fact[n]);
  for(int i=n;i>0;i--) {
   inv[i - 1] = inv[i] * i % mod;
  }
 }
 //modの逆元
 ll mod_inv(ll x) {
  ll n = mod - 2;
  ll res = 1LL;
  while (n > 0) {
   if (n & 1) res = res * x % mod;
   x = x * x % mod;
   n >>= 1;
  }
  return res;
 }
 ll nCr(ll n, ll r) {
  return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
 }
 ll nPr(ll n, ll r) {
  return (fact[n] * inv[n - r]) % mod;
 }
 ll nHr(ll n, ll r) {
  //重複組み合わせ：n種類のものからr種類選ぶ
  return nCr(r + n - 1, r);
 }
};

Combination comb(101010,MOD);


ll check(vec<P> x) {
    ll sum=0;
    ll mul=1;
    for(auto i:x){
        (sum+=i.second)%=MOD;
        (mul*=comb.fact[i.second])%=MOD;
    }
    return comb.fact[sum]*comb.mod_inv(mul)%MOD;
}

void solve() {
    ll a,b;
    cin>>a>>b;
    if(a*b%2) cout<<"Odd"<<en;
    else cout<<"Even"<<en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 3e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const int II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    ll a,b;
    cin >> a >> b;
    a > b ? cout << "safe" << endl : cout << "unsafe" << endl;
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(void)
{
    int n,s1=2,s=2;
    
    scanf("%d",&n);
    
    if(n==1){
     printf("1\n");
     return 0;
    }
    while(s<=n){
    s=s*s1;
    s1=2;
    }
    
    if(s!=n)
    printf("%d\n",s/2);
    else
    printf("%d\n",s);
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;


signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N,X,T;
	cin>>N>>X>>T;
	cout<<T*((N+X-1)/X)<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector< ii > vii;
typedef long long LL;
LL find(LL a, LL b)
{
	if(a<= b) swap(a, b);
	if(a%b == 0) return 2*(a/b-1)*b+b;
	return 2*(a/b)*b + find(a%b, b);
}
int main()
{
	LL a, b; scanf("%lld %lld", &a, &b);
	printf("%lld\n", a+find(a-b, b));
	return 0;
}

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

int main() {
    int n;
    int c[1000005];
    for(int i=0; i<=1000000; i++) c[i]=0;
    cin >> n;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        c[x]++;
    }
    int s=0;
    for(int i=1; i<=1000000; i++){
        if (c[i] == 0) continue;
        if (c[i] == 1) s++;
        for(int j=1; j<=1000000; j++){
            if(i*j>1000000)break;
            c[i*j] =0;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 7536
a,b,k=map(int,input().split())

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

lst=cf(a,b)
lst.insert(0,1)

print(lst[-k])

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

int main(){
    int N;
    cin >> N;
    vector<int> C(N), V(N), P(N);
    for(int i = 0;i < N; ++i){
        cin >> V[i];
    }
    for(int i = 0;i < N; ++i){
        cin >> C[i];
    }
    for(int i = 0;i < N; ++i){
        P[i] = V[i] - C[i];
    }
    int ans = 0;
    for(int i = 0; i < N; ++i){
        if(P[i] > 0){
            ans += P[i];
        }
    }

    cout << ans << endl;
}

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

const ll siz = 1e6 + 10;
const ll mod = 1e9 + 7;
const ll MAXX = 1e17;
const ll base = 31;

int n;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN.INP", "r", stdin);
//    freopen ("OUT.OUT", "w", stdout);
    cin >> n;
    cout << n / 2 + n % 2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;

ll read ()
{
	ll f = 1,x = 0;
	char ch = getchar ();
	while ( ! isdigit ( ch ) )
	{
		if ( ch == '-' )
		   f = -1;
		ch = getchar ();
	}
	while ( isdigit ( ch ) )
	{
		x = x * 10 + ch - '0';
		ch = getchar ();
	}
	
	return x * f;
	 
}

const int MAXN = 1e5 + 5;
int n,m,i;
int fa[MAXN];

struct EDGE
{
	int u,v;
} e[MAXN];

ll ans[MAXN],sz[MAXN];

int get_fa ( int x )
{
	if ( x == fa[x] )
	   return x;
	return fa[x] = get_fa ( fa[x] );
}

int main ()
{
	ios :: sync_with_stdio ( 0 );
	cin.tie ( 0 );
	n = read ();
	m = read ();
	
	for ( i = 1 ; i <= m ; ++ i )
	{
		e[i].u = read ();
		e[i].v = read ();
	}
	
	for ( i = 1 ; i <= n ; ++ i )
	   fa[i] = i,sz[i] = 1;
	
	ans[m] = ( ll ) n * ( n - 1 ) / 2;
	
	for ( i = m ; i >= 1 ; -- i )
	{
		int u = get_fa ( e[i].u ),v = get_fa ( e[i].v );
		if ( u == v )
		   ans[i-1] = ans[i];
		else
		{
			ans[i-1] = ans[i] - sz[v] * sz[u];
			sz[v] += sz[u];
			fa[u] = v;
		}
	}
	
	for ( i = 1 ; i <= m ; ++ i )
	    cout << ans[i] << endl;
	
	return 0;
	
}

Measured memory_bytes: 4096
#include <iostream>

using namespace std;

int gcd( int m, int n ){
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

int lcm( int m, int n ){
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

int main(){
 int a, b;
 while (cin >> a >> b) cout << gcd(a,b) << " "<< lcm(a,b) << endl;
}

Measured memory_bytes: 3028
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
  if p[i - 1] < p[i] < p[i + 1] or p[i - 1] > p[i] > p[i + 1]:
    count += 1
print(count)

Measured memory_bytes: 3060
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

K,X=LI()

print("Yes" if 500*K >= X else "No")


Measured memory_bytes: 3064
#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;

pll A[200005];
pll B[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
        B[i].first = A[i].first - A[i].second;
        B[i].second = A[i].first + A[i].second;
    }

    ll ans = 0;
    {
        ll mx = B[0].first, mn = B[0].first;
        REP(i, N) {
            mx = std::max(B[i].first, mx);
            mn = std::min(mn, B[i].first);
        }
        ans = mx - mn;
    }
    {
        ll mx = B[0].second, mn = B[0].second;
        REP(i, N) {
            mx = std::max(B[i].second, mx);
            mn = std::min(mn, B[i].second);
        }
        ans = std::max(ans, mx - mn);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  long long INF = 1000000007;
  long long ans=1;
  vector<int> div;
  for(int i=1; i<=N; i++){
    int temp = i;
    for(int j=2; j<=i; j++){
      while(temp%j==0){
        div.push_back(j);
        temp/=j;
      }
    }
  }
  sort(div.begin(), div.end());
  div.push_back(INF);
  int cnt=1;
  for(int i=0; i<div.size()-1; i++){
    if(div.at(i)==div.at(i+1)){
      cnt++;
    }
    else{
      ans=ans*(cnt+1)%INF;
      cnt=1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import math
import sys

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, m = map(int,input().split())

if n == 1 and m == 1:
  print('0')
  sys.exit()
  
if n <= 1:
  print(comb(m, 2))
  sys.exit()
  
if m <=1:
  print(comb(n, 2))
  sys.exit()

print(comb(n, 2) + comb(m, 2))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int A[20],n;
int solve(int i,int m)
{
	if(m == 0)
		return 1;
	if(i >= n)
		return 0;
	int res = solve(i + 1,m) || solve(i + 1,m - A[i]);
	return res;
}
 
int main()
{
	//freopen("input.txt","r",stdin); 
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		scanf("%d",&A[i]);
	}
	int q,x;
	scanf("%d",&q);
	for(int i = 0;i < q;i++){
		scanf("%d",&x);
		if(solve(0,x)){
			printf("yes\n");
		}
		else{
			printf("no\n");
		}
	
	}
	
	
	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll s;
    cin>>s;
    ll mod=1000000007;
    vector<ll> dp(s+1, 0);
    for(int i=3;i<=s;i++){
        ll x=0;
        for(int j=3;j<=i;j++){
            x += dp[i-j];
            x %= mod;
        }
        dp[i] = (1+x)%mod;
    }
    cout<<dp[s];
}

Measured memory_bytes: 3600
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    n, *numbers = (int(x) for x in sys.stdin.read().split())
    still_can_be_divided = True
    count = 0
    while still_can_be_divided:
        for i in range(n):
            if numbers[i] % 2 == 0: 
                numbers[i] //= 2
            else: 
                still_can_be_divided = False
        if still_can_be_divided:
            count += 1        

    print(count)

if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
import sys

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

x = int(input())
yakusu = make_divisors(x)
for i in yakusu:
    for a in range(-int(x**(1/4)+1),int(x**(1/4)+2)):
        b = i + a
        if a**5 - b**5 == x:
            print(a,b)
            exit()
        b = -i + a
        if a**5 - b**5 == x:
            print(a,b)
            exit()

Measured memory_bytes: 9480
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);
	static int N; //static?????´??°???public static???main?????????????????§????????????????????????

	public static void main(String[] args){

		N = scan.nextInt();
		String[] cards = new String[N];
		String[] copys = new String[N];
		int[] nary = new int[N];
		int[] mary = new int[N];
		boolean stable;
		for(int i = 0; i < N; i++){
			cards[i] = scan.next();
			copys[i] = cards[i];
			nary[i] = i;
			mary[i] = i;
		}

		//?????????????????????????????????????????????
		for(int i = 0; i < N; i++){
			for(int j = N-1; j >= i+1; j--){
				String sj = cards[j].substring(1);
				String sjj = cards[j-1].substring(1);
				int vj = Integer.parseInt(sj);
				int vjj = Integer.parseInt(sjj);
				if(vj < vjj){
					String work = cards[j];
					cards[j] = cards[j-1];
					cards[j-1] = work;
					int nwork = nary[j];
					nary[j] = nary[j-1];
					nary[j-1] = nwork;
				}
			}
		}

		stable = true;
		for(int i = 0; i < N-1; i++){
			if(cardComp(cards[i], cards[i+1]) == 0){
				if(nary[i] > nary[i+1]){
					stable = false;
					break;
				}
			}
		}

		for(int i = 0; i < N; i++)
			System.out.printf(i != N-1? "%s " : "%s\n", cards[i]);
		System.out.printf("%s\n", stable? "Stable" : "Not stable");

		//???????????????
		for(int i = 0; i < N; i++){
			int minj = i;
			for(int j = i; j < N; j++){
				String sj = copys[j].substring(1);
				String sjj = copys[minj].substring(1);
				int vj = Integer.parseInt(sj);
				int vjj = Integer.parseInt(sjj);
				if(vj < vjj)
					minj = j;
			}
			//?????????????????????minj??¨i???????????????
			if(minj != i){
				String work = copys[minj];
				copys[minj] = copys[i];
				copys[i] = work;
				int mwork = mary[minj];
				mary[minj] = mary[i];
				mary[i] = mwork;
			}
		}

		stable = true;
		for(int i = 0; i < N-1; i++){
			if(cardComp(copys[i], copys[i+1]) == 0){
				if(mary[i] > mary[i+1]){
					stable = false;
					break;
				}
			}
		}

		for(int i = 0; i < N; i++)
			System.out.printf(i != N-1? "%s " : "%s\n", copys[i]);
		System.out.printf("%s\n", stable? "Stable" : "Not stable");
	}

	private static int cardComp(String left, String right){
		char l = left.charAt(1);
		char r = right.charAt(1);
		return (l-r);
	}
}

Measured memory_bytes: 26972
class SegmentTree:
    def __init__(self, initial_values, f=max, zero=0, converter=lambda x:x):
        self.__f, self.__z, self.__c, self.__size = f, zero, converter, len(initial_values)
        self.__n = 1 << ((self.__size - 1).bit_length())
        self.__dat = [zero] * (2 * self.__n)
        zi = self.__get_leaf(0)
        for i, v in enumerate(initial_values): self.__dat[zi + i] = converter(v)
        for i in range(zi-1, -1, -1): self.__dat[i] = f(*self.__get_children(i))
    
    def update(self, index, value):
        i, v = self.__get_leaf(index), self.__c(value)
        if self.__dat[i] == v: return
        self.__dat[i] = v
        while i:
            i = self.__get_parent(i)
            self.__dat[i] = self.__f(*self.__get_children(i))
    
    def query(self, from_inclusive, to_exclusive):
        ans = self.__z
        if to_exclusive <= from_inclusive: return ans
        l, r = self.__get_leaf(from_inclusive), self.__get_leaf(to_exclusive) - 1
        while r - l > 1:
            if self.__is_right(l): ans = self.__f(ans, self.__dat[l])
            if self.__is_left(r): ans, r = self.__f(ans, self.__dat[r]), r-1
            l, r = l//2, self.__get_parent(r)
        ans = self.__f(ans, self.__dat[l])
        if l != r: ans = self.__f(ans, self.__dat[r])
        return ans

    def __get_leaf(self, i): return self.__n + i - 1
    def __get_parent(self, i): return (i-1)//2
    def __get_children(self, i): return (self.__dat[2*i+1], self.__dat[2*i+2])
    def __is_left(self, i): return i&1 == 1
    def __is_right(self, i): return i&1 == 0

N = int(input())
S = input()
tree = SegmentTree(S, f=lambda x,y:x|y, converter=lambda c: 1 << (ord(c)-ord('a')))
Q = int(input())
for _ in range(Q):
    t, a, b = input().split()
    if t == '1': tree.update(int(a)-1, b)
    else: print(bin(tree.query(int(a)-1, int(b))).count('1'))

Measured memory_bytes: 80072
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,
    }
    let mut g = G::new(n);
    g.dfs(vec![], 'a');
    for s in g.ans {
        for &c in s.iter() {
            print!("{}", c);
        }
        println!();
    }
}
struct G {
    n: usize,
    ans: Vec<Vec<char>>,
}
impl G {
    fn new(n: usize) -> G {
        G {
            n: n,
            ans: Vec::<Vec<char>>::new(),
        }
    }
    #[fastout]
    fn dfs(&mut self, st: Vec<char>, mx: char) {
        if st.len() == self.n {
            // self.ans.push(st);
            for &c in st.iter() {
                print!("{}", c);
            }
            println!();
        } else {
            let cc = charconv(mx, 'a');
            for ch in 0..=cc {
                let mut nx = st.clone();
                nx.push(('a' as u8 + ch as u8) as char);
                self.dfs(nx, if ch == cc { (mx as u8 + 1) as char } else { mx });
            }
        }
    }
}

pub fn charconv(c: char, base: char) -> usize {
    return (c as u8 - base as u8) as usize;
}


Measured memory_bytes: 2212
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int sum = 0;
		for(int i = 0; i < n; i++){
		    sum += sc.nextInt();
		}
		
		// 計算
		
		// 出力
		System.out.println(sum - n);
	}
}


Measured memory_bytes: 25520
n, m = map(int, input().split())
switch_list = []
for _ in range(m):
  tmp = list(map(int, input().split()))
  switch_list.append(tmp[1:])
p_list = list(map(int, input().split()))

all_on_cnt = 0

for i in range(2**n):
  light_list = [0 for _ in range(m)]
  on_off = [0 for _ in range(n)]
  
  cnt = 0
  while i!=0:
    on_off[cnt] = i%2
    i//=2
    cnt+=1
  
  for j in range(m):
    tmp = switch_list[j]
    on_cnt = 0
    for k in tmp:
      on_cnt += on_off[k-1]
    if on_cnt%2==p_list[j]:
      light_list[j]=1
  if sum(light_list)==m:
    all_on_cnt+=1
print(all_on_cnt)
      

Measured memory_bytes: 9236
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            List<int>[] node = new List<int>[N];

            for (int i = 0; i < N; i++)
            {
                node[i] = new List<int>();
            }

            for (int i = 0; i < N - 1; i++)
            {
                string[] nodes = Console.ReadLine().Split(' ');

                int in0 = int.Parse(nodes[0]) - 1;
                int in1 = int.Parse(nodes[1]) - 1;

                node[in0].Add(in1);
                node[in1].Add(in0);
            }

            int mostNode = -1;
            int startIndex = -1;
            for (int i = 0; i < N; i++)
            {
                if ( node[i].Count > mostNode)
                {
                    mostNode = node[i].Count;
                    startIndex = i;
                }
            }

            int[] score = new int[N];
            string[] scores = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                score[i] = int.Parse(scores[i]);
            }

            // 小さい順にソート
            Array.Sort(score);

            int[] newScore = new int[N];
            int scoreIndex = score.Length - 1;
            int totalScore = CalcTotal(node, startIndex, score, ref scoreIndex, newScore);
            totalScore -= score[score.Length - 1];

            Console.WriteLine(totalScore);
            for (int i = 0; i < N; i++)
            {
                Console.Write("{0} ", newScore[i]);
            }

            Console.WriteLine("");
        }

        static int CalcTotal(List<int>[] node, int nodeIndex, int[] score, ref int scoreIndex, int[] newScore)
        {
            // すでに到達している
            if (newScore[nodeIndex] > 0)
            {
                return 0;
            }

            // 新しいスコアを割り当て
            int ret = score[scoreIndex];
            newScore[nodeIndex] = score[scoreIndex];
            scoreIndex--;

            for (int i = 0; i < node[nodeIndex].Count; i++)
            {
                ret += CalcTotal(node, node[nodeIndex][i], score, ref scoreIndex, newScore);
            }

            return ret;
        }
    }
}


Measured memory_bytes: 21216
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,k,num[25],list[5];
double time[25];

void swap (int* x,int* y){
	int z;
	z=*x;
	*x=*y;
	*y=z;
}

int main(){
	time[24]=9999;
	list[2]=24;list[3]=24;
	for(i=0;i<3;i++){
	list[0]=24;list[1]=24;
		for(k=8*i;k<8*i+8;k++){
			j=k;
			scanf("%d %lf",&num[j],&time[j]);
			if(time[j]<time[list[0]])swap(&j,&list[0]);
			if(time[j]<time[list[1]])swap(&j,&list[1]);
			if(time[j]<time[list[2]])swap(&j,&list[2]);
			if(time[j]<time[list[3]])swap(&j,&list[3]);
		}
		printf("%d %.2lf\n",num[list[0]],time[list[0]]);
		printf("%d %.2lf\n",num[list[1]],time[list[1]]);
	}
	printf("%d %.2lf\n",num[list[2]],time[list[2]]);
	printf("%d %.2lf\n",num[list[3]],time[list[3]]);
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int) 1e9 + 9;
const int maxn = (int) 1e6 + 6;
//const mod = (int) 1e9 + 7;
using namespace std;

signed main() {
      int h, a;
      cin >> h >> a;
      int ans = h/a;

      if(h % a > 0) ans++;
      cout << ans;


return 0;

}

Measured memory_bytes: 256
var std = process.stdin;
std.resume();
std.setEncoding('utf8');
std.on('data', function (chunk) {
    var data = chunk.replace(/\n/, '').split(' ').map(Number);
    
    console.log(
        Math.floor(data[0] / data[1]) + " " +
        data[0] % data[1]  + " " +
        (data[0] / data[1]).toFixed(6)
    );
});

Measured memory_bytes: 15840
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>

using namespace std;


int main()
{
  int A, B, C;
  cin >> A >> B >> C;

  if(A == 5 && B == 5 && C == 7)  cout << "YES" << endl;
  else if(A == 5 && B == 7 && C == 5)  cout << "YES" << endl;
  else if(A == 7 && B == 5 && C == 5)  cout << "YES" << endl;
  else  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100100;
const long long MOD = 1000000007;
typedef pair<long long,int> P;

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

    return res %= MOD;
}

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

int parent[100005];
int tall[100005];
 
int searchRoot(int v){
    if(parent[v] == v) return v;
    return parent[v] = searchRoot(parent[v]);
}
 
void unite(int x,int y){
    int rootX = searchRoot(x);
    int rootY = searchRoot(y);
    if(rootX == rootY) return;
    if(tall[x] > tall[y]){
        parent[rootY] = rootX;
    }
    else if(tall[x] < tall[y]){
        parent[rootX] = rootY;
    }
    else {
        tall[y]++;
        parent[rootY] = rootX;
    }
}
 
bool same(int x,int y){
    if(searchRoot(x) == searchRoot(y)) return true;
    else return false;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    int M;cin >> M;
    for(int i = 0;i<N;i++){
        parent[i] = i;
        tall[i] = 0;
    }
    //Union-Findで同じカードを共有するものは1個調べると全て一意に決まる！（天才か？）
    for(int i = 0;i<M;i++){
        int a,b,c;cin >> a >> b >> c;
        //矛盾がないのでcは無視してよい
        a--;b--;
        unite(a,b);
    }
    set<int> already;
    int ans = 0;
    for(int i = 0;i<N;i++){
        int root = searchRoot(i);
        if(!already.count(root)){
            already.insert(root);
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 9016
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];


int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

cin>>k;
    if(!(k&1)){
        cout << -1;
        return 0;
    }
    n = 0;
    for(int i = 1;i<=1000000;++i){
        n = ((n*10) + 7)%k;
        //bug(n)
        if(n == 0){
            cout << i;
            return 0;
        }
    }
    cout << -1;
   
 eNd();
  return 0;
 
}

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

using namespace std;

int main() {
	long long total, vet[212345], res=0, MOD = 1e9+7;
	int N;
	scanf("%d", &N);

	for (int i = 0;i < N;i++) {
		scanf("%lld", &vet[i]);
		if (i) {
			vet[i] += vet[i-1];
		}
	}
	total = vet[N-1];

	for (int i = 0;i < N-1;i++) {
		if (!i){
			res = (vet[i] * ((total-vet[i])%MOD))%MOD;
		}else{
			res = res + (((vet[i]-vet[i-1])%MOD)*((total-vet[i])%MOD))%MOD;
		}
	}

	printf("%lld\n", res%MOD);

	return 0;
}

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

int main() {
  string a,b,c;cin>>a>>b>>c;
  cout<<(char)(a[0]-('a'-'A'))<<(char)(b[0]-('a'-'A'))<<(char)(c[0]-('a'-'A'))<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>
 
using namespace std;
 
int main(int argc, const char * argv[]) {
	int N, D;
	int zone;
	int ans;
 
	cin >> N >> D;
	zone = (2 * D) + 1;
	ans = N / zone;
	if(N % zone != 0){ ans++;}

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


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,s=0,i,d[100010]={};
  scanf("%d",&n);
  for(i=0;i<n;i++){
   scanf("%d",&d[i+1]);
   s+=abs(d[i]-d[i+1]);
  }
  s+=abs(d[i]);
  for(i=1;i<=n;i++){
    printf("%d\n",s-abs(d[i-1]-d[i])-abs(d[i]-d[i+1])+abs(d[i-1]-d[i+1]));
  }
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)

int main(){
	int n;
	cin >> n;
	ull a[n], b[n];
	for(int i=0; i<n; i++){
		cin >> a[i];
		b[i]=a[i];
	}
	sort(a, a+n);
	ull mid1=a[n/2 -1], mid2=a[n/2];
	for(int i=0; i<n; i++){
		if(b[i]<=mid1) cout << mid2 << endl;
		else cout << mid1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string s;
    cin>>s;
    bool c=false,cf=false;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C') c=true;
        if(c && s[i]=='F') cf=true;
    }
    if(cf) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 384
import sys

def isEven(s):
  half = len(s) // 2
  if (s[:half] == s[half:]):
    return True
  else:
    return False
st = input()
tail = 0
if (len(st) % 2 == 0):
  tail = len(st) - 2
else:
  tail = len(st) - 1
while(tail >= 0):
  if (isEven(st[:tail]) == True):
    print(tail)
    sys.exit()
  else:
    tail -= 2

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
import sys
 
sys.setrecursionlimit(10**7)

def dfs(num,hiyo):
    ans[num]=hiyo
    for to,cos in way[num]:
        if ans[to]==-1:
            dfs(to,hiyo+cos)
    
    return 

N=int(input())

way=[[] for i in range(N)]
ans=[-1]*N

for _ in range(N-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    way[u].append([v,w])
    way[v].append([u,w])

#lis.sort(key=lambda x:(x[0],x[1]))

dfs(0,0)
#print(ans)
for item in ans:
    print(item%2)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main()
{
    using vi = vector<int>;
    using vvi = vector<vi>;
    using vvvi = vector<vvi>;
    using ll = long long;

    int N;
    cin >> N;
    if(N % 2 == 0)
        cout << 0.5 << endl;
    else
        cout << ((N-1)/2 + 1) / (double)N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>

void test_case()
{
    ll x;
    cin >> x;
    for(ll a=-118; a<= 119; a++) {
        for(ll b=-119; b<=118; b++) {
            if((a*a*a*a*a - b*b*b*b*b)==x) {
                cout<<a<<" "<<b;
                return;
            }
        }
    }
}


int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
typedef pair<int, int> P;

char c[55][55];
int sx,sy;
int gx,gy;
int d[55][55];
int n,m;

int bfs(){
    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};

    queue<P> que;

    for(int i = 0 ; i < n ; i++){
        for(int j = 0; j < m ; j++){
            d[i][j] = INF;
        }
    }

    que.push(P(0,0));
    d[0][0] = 0;

    while(!que.empty()){
        P p = que.front();
        que.pop();
        if(p.first == n-1 && p.second == m-1) break;

        for(int i = 0 ; i < 4 ; i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if(nx>=0&&ny>=0&&nx<n&&ny<m&&c[nx][ny] != '#'&&d[nx][ny] == INF){
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[n-1][m-1];
}



int main(){

    cin >> n >> m;
    int cnt = 0;
    
    for(int i = 0; i < n ; i++){
        for(int j = 0; j < m ; j++){
            cin >> c[i][j];
            if(c[i][j] == '.'){
                cnt++;
            }
        }
    }

    int ans = bfs();
    if(ans == INF){
        ans = -1;
    }else{
        ans = (cnt-1) - ans;
    }

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

Measured memory_bytes: 256