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

//#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main() {
    int d, t, s;
    cin >> d >> t >> s;
    if(d <= t * s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    float r;
    cin >> r;
    cout << 3 * pow(r, 2) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int arr[10] = {};
int main() {
    for (int i = 1; i <= 5; i++)
        cin >> arr[i];
    for (int i = 1; i <= 5; i++)
        if (arr[i] == 0) {
            cout << i << '\n';
            break;
        }
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int num;
		while(true){
			if(x>y){
				num = y;
				y = x;
				x = num;
			}else if(x<y || x == y){
				System.out.println(x+" "+y);
				x = sc.nextInt();
				y = sc.nextInt();
				if(x == 0 && y == 0){
					break;
				}
			}
		}
	}
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }

int main()
{
  vector<double> vec;
  double ans = 0;
  int n, k, coin = 1, index = 0, num = 1;

  cin >> n >> k;
  vec.push_back(coin);
  while (coin < k)
  {
    index++;
    coin *= 2;
    vec.push_back(coin);
  }
  vector<int> vec_count(index + 1, 0);
  int i = index;
  // cout << index << endl;
  // cout << coin << endl;
  while (num <= n)
  {
    while (k <= num * coin)
    {
      i--;
      coin /= 2;
    }
    vec_count[i + 1]++;
    num++;
  }
  index++;
  while (index--)
  {
    // cout << index << ' ' << vec[index] << ' ' << vec_count[index] << endl;
    if (vec_count[index] > 0)
      ans += (double)vec_count[index] / vec[index];
  }
  cout << fixed << setprecision(10) << ans / n << endl;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int n; string s, t; cin >> n >> s >> t;
	rep(i, n + 1) {
		for (int j = i; j < n; j++) {
			if (s[j] != t[j - i])goto ng;
		}
		cout << n + i << endl;
		return 0;
	ng:;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  int n=s.size();
  rep(i,n) {
    if(s[i]=='?') s[i]='D';
  }
  pr(s);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

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

int bfs(const vector<string> &v, int x, int y) {
  int h = v.size(), w = v[0].size();
  vector<vector<int>> dist(h, vector<int>(w, -1));
  queue<P> que;
  int res = 0;
  que.push(make_pair(x, y));
  dist[x][y] = 0;
  while (!que.empty()){
    P p = que.front(); que.pop();
    res = max(res, dist[p.first][p.second]);
    for (int i = 0; i < 4; i++){
      int ny = p.second + dy[i], nx = p.first + dx[i];
      if(0 <= nx && nx < h && 0 <= ny && ny < w && v[nx][ny] != '#' && dist[nx][ny] == -1){
        dist[nx][ny] = dist[p.first][p.second] + 1;
        que.push(make_pair(nx, ny));
      }
    }
  }
  return res;
}

int main() {
  int H, W;
  cin >> H >> W;
  int res = 0;
  vector<string> v(H);
  rep(i, H) cin >> v[i];
  rep(x, H){
    rep(y, W){
      if(v[x][y] == '#') continue;
      res = max(res, bfs(v, x, y));
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc  = new Scanner(System.in);

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

        println((int)Math.ceil((double)N/(D*2+1)));
    }

    static void println(Object o){
        System.out.println(o);
    }
    static void print(Object o){
        System.out.print(o);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int num[1000005],tree[1000005],vis[1000005],ans[1000005];
int n,q;
struct node{
    int l,r,pos;
}ask[1000005];
bool cmp(node x,node y){
    return x.r<y.r;
}
int lowbit(int x){
    return x&(-x);
}
void add(int x,int p){
    while(x<=n){
        tree[x]+=p;
        x+=lowbit(x);
    }
}
int sum(int x){
    int ans=0;
    while(x!=0){
        ans+=tree[x];
        x-=lowbit(x);
    }
    return ans;
}
int main(){
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++)
        scanf("%d",&num[i]);
    for(int i=1;i<=q;i++){
        scanf("%d%d",&ask[i].l,&ask[i].r);
        ask[i].pos=i;
    }
    sort(ask+1,ask+q+1,cmp);
    int next=1;
    for(int i=1;i<=q;i++){
        for(int j=next;j<=ask[i].r;j++){
            if(vis[num[j]]) 
                add(vis[num[j]],-1);
            add(j,1);
            vis[num[j]]=j;
        }
        next=ask[i].r+1;
        ans[ask[i].pos]=sum(ask[i].r)-sum(ask[i].l-1);
    }
    for(int i=1;i<=q;i++)
        printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 17412
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  long a, b, c=0, d=0, e, f, g, h, n;
  cin >> n >> a;
  long x[n];
  rep(i,0,n) cin >> x[i];
  sort(x, x+n); reverse(x, x+n);
  
  if(a<n) rep(i,a,n) c+=x[i];
  co(c);
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) (((long long)mod_x)%modulo)


int main(){
	
	long long N,A,B,C,D;
	cin>>N>>A>>B>>C>>D;
	
	string S;
	cin>>S;
	
	for(int i=A-1;i<C-1;i++){
		if(S[i]=='#'&&S[i+1]=='#'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	
	for(int i=B-1;i<D-1;i++){
		if(S[i]=='#'&&S[i+1]=='#'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	bool flag = false;
	if((B-A)*(D-C)<0){
		
		for(int i=max(A,B)-2;i<min(C,D)-1;i++){
			if(i<0)continue;
			if(i+2>=N)continue;
			if(S[i]=='.'&&S[i+1]=='.'&&S[i+2]=='.'){
				flag=true;
			}
		}
	}
	else flag=true;
	
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

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

int main()
{
  int N, M, C;
  cin >> N >> M >> C;

  vector<int> B(M);
  for (int i = 0; i < M; i++)
    cin >> B.at(i);

  int ans = 0;
  int tmpA;

  for (int i = 0; i < N; i++)
  {
    int sum = 0;

    for (int j = 0; j < M; j++)
    {
      cin >> tmpA;
      sum += tmpA * B.at(j);
    }

    if (sum + C > 0)
      ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3576
n= int(input())
l=list(map(int,input().split()))

l.sort()
maxnum=l[len(l)-1]
flag=[0]*(maxnum+1)

for num in l:
    flag[num]+=1
    if flag[num]>1:
        continue
    for j in range(num*2, maxnum+1, num):
        flag[j]+=1
#print(flag)
ans=0

for num in l:
    if flag[num]==1:
        ans+=1
print(ans)


Measured memory_bytes: 32236
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N, M;
    scan(N, M);

    auto cost = new int[][](N, N);
    fillAll(cost, inf);
    foreach (i ; 0 .. M) {
        int u, v, d;
        scan(u, v, d);
        cost[u][v] = d;
    }

    auto dp = new int[][](1 << N, N);
    fillAll(dp, inf);
    foreach (i ; 1 .. N) {
        dp[1 << i][i] = cost[0][i];
    }

    foreach (mask ; 0 .. 1 << N) {
        foreach (u ; 0 .. N) if (mask & 1 << u) {
            auto sub = mask ^ 1 << u;
            foreach (v ; 0 .. N) if (sub & 1 << v) {
                chmin(dp[mask][u], dp[sub][v] + cost[v][u]);
            }
        }
    }

    auto ans = dp[(1 << N) - 1][0];
    if (ans == inf) ans = -1;
    writeln(ans);
}



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

const ll oo=1e12;
int main()
{
    ll n,w;
    cin>>n>>w;
    ll arr[n+1],val[n+1],i,j,max_val=0;
    for(i=1;i<=n;i++)
    {
        cin>>arr[i]>>val[i];
        max_val+=val[i];
    }
    
    ll mat[n+1][max_val+1];
    for(i=0;i<=n;i++)
        mat[i][0]=0;
    for(i=1;i<=max_val;i++)
        mat[0][i]=oo;
    
    ll curr_sum=0;
    for(i=1;i<=n;i++)
    {
        curr_sum+=val[i];
        for(j=1;j<=max_val;j++)
        {
            if(j<val[i] || j>curr_sum)
                mat[i][j]=mat[i-1][j];
            else
                mat[i][j]=min(mat[i-1][j], mat[i-1][j-val[i]]+arr[i]);
        }
    }
    ll ans_val=0;
    for(i=1;i<=max_val;i++)
    {
        if(mat[n][i]!=oo && i>ans_val && mat[n][i]<=w)
        {
            ans_val=i;
        }
    }
    cout<<ans_val;
    return 0;
    
}

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

int s_to_i(string s){
	int n=0;
	for(int i=0 ; i<(int)s.size() ; i++ ){
		n *= 10;
		n += s[i] - '0';
	}
	return n;
}

vector<int> vs_to_vi(vector<string> vs){
	vector<int> vi;
	for(int i=0 ; i<(int)vs.size() ; i++ ){
		vi.push_back( s_to_i(vs[i]) );
	}
	return vi;
}

vector<string> split(string s){
	vector<string> vc;
	string s_;
	
	for(int i=0 ; i<(int)s.size() ; i++ ){
		char c = s[i];
		
		if( s[i] == ',' ){
			vc.push_back( s_ );
			s_.clear();
		}else{
			s_.push_back( c );
			if( i == (int)s.size()-1 ){
				vc.push_back( s_ );
			}
		}
	}
	return vc;
}

int main(){
	string s;
	vector<int> a[101];
	int b[101][101] = {0};
	int i;
	
	for(i=0 ; getline(cin,s) ; i++ ){
		vector<string> vc = split( s );
		a[i] = vs_to_vi( vc );
		//i++;
		//if( i==9 ) break;
	}
	b[0][0] = a[0][0];
	for(int j=1 ; j<i ; j++ ){
		if( j <= i/2 ){
			for(int k=0 ; k <= j ; k++ ){
				if( k == 0 ){
					b[j][k] = a[j][0] + b[j-1][k];
				}else{
					b[j][k] = a[j][k] + max( b[j-1][k] , b[j-1][k-1] );
				}
			}
		}else{
			for(int k=0 ; k < i-j ; k++ ){
				b[j][k] = a[j][k] + max( b[j-1][k] , b[j-1][k+1] );
			}
		}
	}
	cout << b[i-1][0] << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};
const ll n_max=300;
Matrix<ll> mat(n_max, vector<ll>(n_max, LLONG_MAX));

template< typename T >
T kruskal(Edges< T > &edges, int V, Matrix< T > &a, T INF) {
  sort(begin(edges), end(edges), [](const edge< T > &a, const edge< T > &b) {
    return (a.cost < b.cost);
  });
  UnionFind tree(V);
  T ret = 0;
  for(auto &e : edges) {
    //    if(tree.unite(e.src, e.to)){
    if(a[e.src][e.to]<mat[e.src][e.to]){
      ret += e.cost;
      mat[e.src][e.to]=e.cost;
      mat[e.to][e.src]=e.cost;
      rep(l,2){
	int k=0;
	if(l==0) k=e.src;
	else k=e.to;
	for(int i = 0; i < mat[0].size(); i++) {
	  for(int j = 0; j < mat[0].size(); j++) {
	    if(mat[i][k] == INF || mat[k][j] == INF) continue;
	    mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
	  }
	}
      }
    }
  }
  return (ret);
}
/*
template< typename T >
void warshall_floyd(Matrix< T > &g, T INF) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i][k] == INF || g[k][j] == INF) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}
*/
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  Edges<ll> edges;
  //  int a[n][n];
  Matrix<ll> a(n_max, vector<ll>(n_max, LLONG_MAX));
  rep(i,n)rep(j,n){
    cin >> a[i][j];
    if(i==j) mat[i][j]=0;
    edges.emplace_back(i,j,a[i][j]);
  }
  ll ans=kruskal(edges, n, a, LLONG_MAX);
  //  warshall_floyd(mat,LLONG_MAX);
  rep(i,n){
    rep(j,n){
      if(a[i][j]!=mat[i][j]){
	cout << -1 << endl;
	return 0;
      }
      
      //      cout << mat[i][j] <<" ";
    }
    //    cout << "" << endl;
  }
  cout << ans << endl;
  
  return 0;
    
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;
typedef pair<int, int> P;

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

    int mod = 1e9 + 7;
    int m = max(n-k+1, k-1);
    vector<vector<ll> > comb(m+1, vector<ll>(m+1));
    comb[0][0] = 1;
    for (int i=0; i<m; i++) {
        comb[i+1][0] = 1;
        comb[i+1][i+1] = 1;
        for (int j=1; j<=i; j++) {
            comb[i+1][j] = comb[i][j-1] + comb[i][j];
            comb[i+1][j] %= mod;
        }
    }

    ll ans;
    rep(i, k) {
        if (n-k >= i) {
            ans = (comb[n-k+1][i+1] * comb[k-1][i]) % mod;
            cout << ans << endl;
        } else {
            cout << 0 << endl;
        }
        
    }
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;

  int a = 0; // R->W に変更する回数
  int b = 0; // W->R に変更する回数

  // ### 0回目
  // 全て白にするケースについて、回数を数える。
  // 以下の場合だと、Rが4つあるので a=4 となる。
  //
  // * before: WRWWRWRR
  // * after:  WWWWWWWW
  //
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'R') {
      a++;
    }
  }

  int ans = max(a, b);
  for (int i = 0; i < n; i++) {
    // i番目の要素がRの場合、R->W が R->R に変わったため、a の実行回数が減る
    if (s.at(i) == 'R') {
      a--;
    // i番目の要素がWの場合、W->W が W->R に変わったため、b の実行回数が増える
    } else {
      b++;
    }
    // 実行回数は「a, b の最大の方」が、操作の最小回数となる。
    // 逆に言うと a, b の最小の方の回数だけ swap を行い、残りの回数だけ R と W の色を入れ替える。
    //
    // 例えば a = 3, b = 2 の場合、
    // * swap を2回行う
    //   * a (R->W) が -2 となる
    //   * b (W->R) が -2 となる
    // * a について、R->W を1回行う
    //   * a (R->W) が -1 となる
    int now = max(a, b);
    ans = min(ans, now);
  }

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


Measured memory_bytes: 3704
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n;
  rep(i, 2 * n) cin >> a[i];
  sort(a, a + 2 * n);
  for (ll i = 0; i < 2 * n; i += 2) {
    ans += a[i];
  }
  Cout(ans);

  return 0;
}

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

int main()
{
  int n;
  int s=0;
  cin>>n;
  for(int i=1; i<=n; i++)
  {
    int l,r;
    cin >> l>>r;
    s+=(r-l+1);
  }
  cout <<s<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b = input().split()

    if a == "H":
        if b == "H":
            ans = True
        else:
            ans = False
    else:
        if b == "H":
            ans = False
        else:
            ans = True

    if ans:
        print("H")
    else:
        print("D")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61912
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

const int INF = 1e9;

int n;
string s;
int memo[512000][32];

int dp(int p, int c) {
  if (p >= n) return INF;
  if (memo[p][c] != -1) return memo[p][c];
  int ch = s[p] - 'a';
  // if (ch == c) return p + 1;
  int next = p + 1;
  memo[p][ch] = p + 1;
  REP(loop,26) {
    if (ch < 26) {
      next = dp(next, ch);
      ++ch;
      memo[p][ch] = next;
    }
    else {
      // if (ch == 26) return memo[p][c] = dp(next, c);
      memo[p][ch % 26] = dp(next, ch % 26);
      ++ch;
    }
  }
  return memo[p][c];
  
  // if (next == INF) return memo[p][c] = INF;
      // if (ch == c) return next;

    // if (c == 0) {
  //   int emp = dp(p, 26);
  //   return memo[p][c] = dp(emp, c);
  // }
  // int next = dp(p, c - 1);
  // int res = dp(next, c - 1);
  // return memo[p][c] = res;
}

int t[20][512000];

void solve(ll Q, vector<ll> l, vector<ll> r) {
  memset(memo, -1, sizeof(memo));
  n = s.size();
  REP(i,n) {
    t[0][i] = dp(i, 26);
    // cout << t[0][i] << " ";
  }
  REP(i,20) t[i][n] = n;
  // cout << endl;
  REP(i,19) {
    REP(j,n) {
      int next = t[i][j];
      t[i+1][j] = (next == INF ? INF : t[i][next]);
    }
  }
  REP(q,Q) {
    int pos = l[q] - 1;
    int goal = r[q];
    for (int i = 19; i >= 0; --i) {
      if (t[i][pos] > goal) continue;
      pos = t[i][pos];
      if (pos == goal) break;
    }
    cout << (pos == goal) << endl;
  }
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll Q;
	cin >> s;
	scanf("%lld", &Q);
	vector<ll> l(Q-1+1);
	vector<ll> r(Q-1+1);
	for (int i = 0 ; i <= Q-1 ; i++) {
	  scanf("%lld", &l[i]);
	  scanf("%lld", &r[i]);
	}
	solve(Q, l, r);
	return 0;
}


Measured memory_bytes: 147456
# ABC073 D - joisino's travel
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))

inf = 10**18
dist = [[inf]*N for _ in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    dist[A-1][B-1] = dist[B-1][A-1] = C

dist = floyd_warshall(dist)

ans = inf
for rr in permutations(r):
    cost = 0
    for i in range(R-1):
        cost += dist[rr[i]-1][rr[i+1]-1]
    ans = min(ans, cost)
print(int(ans))

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

int main() {
    ll N;
    cin >> N;   
    string ans = "";
    while(N) {
        N--;
        ans = string(1,'a' + N % 26) + ans;
        N /= 26;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
// #include <math.h>
// #include <cmath>
// #include <vector>
// #include <utility> 
// #include <unordered_map>
#include <map>
// #include <string>

using namespace std;
typedef long long int lli;

#define M_PI_H  3.14159265358979323846/2  /* pi by two*/
#define rep(i, start, end) for(int i = start; i < end; i++) 
#define repr(i, start, end) for(int i = start; i >= end; i--)   //INCLUSIVE



int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	
	lli n; cin>>n;
	lli a[n];

	rep(i, 0, n){
		cin>>a[i];
	}
	lli xr = a[0];
	rep(i, 1, n){
		xr = xr^a[i];
	}

	rep(i, 0, n){
		cout<<to_string(xr^a[i])<<" ";
	}
	
    return 0;
}

Measured memory_bytes: 5200
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define MP make_pair

int main(){
	ll n,a[100000],maxx = 0,maxi = 0;
	vector<ll> x(100000);
	cin >> n;

	for(int i=0;i<n;i++){
		x[i] = 0;
		cin >> a[i];
		maxx = max(maxx,a[i]);
		if (maxx == a[i]) {
			maxi = i;
		}
		if (i != 0) {
			x[i] = a[i-1] + x[i-1];
		}
	}
	x[n] = x[n-1] + a[n-1];
	ll length = x[n] / 3;
	if (maxx > length) {
		length = (x[n] - maxx)/2;
		ll i = maxi+1;
		ll llll = x[n] - maxx;
		ll mama = 0;
		while (1) {
			if (i > maxi) {
				if((x[i] - x[maxi+1]) >= length) {
					mama = min(x[i]-x[maxi+1],x[maxi]-x[i]);
					break;
				}
			} else {
				if(x[n]-x[maxi+1]+x[i] >= length) {
					mama = min(x[n]-x[maxi+1]+x[i],x[maxi]-x[i]);
					break;
				}
			}
			i = (i+1) % (n+1);
		}
		cout << mama << endl;
		return 0;
	} 

	ll mi = 0;
	ll ma = 0;
	for (int i=0;i<n;i++) {
		ll tmp = x[i] + length;
		mi = x[n-1] + 1;
		ll p1 = 0, p2 = 0;
		for (int j=i;j<n;j++) {
			if (x[j] >= tmp) {
				if (p1 == 0) {
					p1 = j;
					tmp = (x[n] - x[p1] + x[i])/2 + x[p1];	
				} else {
					p2 = j;
					break;
				}
			}
		}
		tmp = x[i] + length;
		ll q1 = 0, q2 = 0;
		for (int j=i;j<n;j++) {
			if (x[j] >= tmp) {
				if (q1 == 0) {
					q1 = j-1;
					tmp = (x[n] - x[q1] + x[i])/2 + x[q1];	
				} else {
					q2 = j;
					break;
				}
			}
		}
		mi = min(mi, x[p1] - x[i]);
		mi = min(mi, x[p2] - x[p1]);
		mi = min(mi, x[n] - x[p2] + x[i]);
		ma = max(ma,mi);
		mi = x[n] + 1;
		mi = min(mi, x[p1] - x[i]);
		mi = min(mi, x[p2-1] - x[p1]);
		mi = min(mi, x[n] - x[p2-1] + x[i]);
		ma = max(ma,mi);
		mi = x[n] + 1;
		mi = min(mi, x[q1] - x[i]);
		mi = min(mi, x[q2] - x[q1]);
		mi = min(mi, x[n] - x[q2] + x[i]);
		ma = max(ma,mi);
		mi = x[n] + 1;
		mi = min(mi, x[q1] - x[i]);
		mi = min(mi, x[q2-1] - x[q1]);
		mi = min(mi, x[n] - x[q2-1] + x[i]);
		ma = max(ma,mi);
	}
	cout << ma << endl;
}

Measured memory_bytes: 2592
# チェックに漏れがあり、kyasper 11/21 2:28:53のプログラムだと間違い
# ----------
# 例：
# 3
# -2 1
# 1 0
# 1 -2
# ----------

from math import *

def L(xi, di):
    return xi - di

def R(xi, di):
    return xi + di

def D(yi, di):
    return yi - di

def U(yi, di):
    return yi + di

def main():
    N = int(input())
    x_list = [list(map(int, input().split())) for i in range(N)]
    sum_list = [abs(x[0]) + abs(x[1]) for x in x_list]
    checker = sum_list[0] % 2

    for wa in sum_list:
        if wa % 2 != checker:
            print("-1")
            return

    arm_list = []
    if checker == 0:
        arm_list.append(1)

    pow_i = 0
    max_sum = max(sum_list)
    while max_sum > sum(arm_list):
        arm_list.append(2 ** pow_i)
        pow_i += 1
    arm_list = sorted(arm_list, key=lambda x: -x)
    print(len(arm_list))
    print(" ".join(map(str, arm_list)))

    for c in x_list:
        now_c = [0,0]
        order = ""

        for arm in arm_list:
            dx = c[0] - now_c[0]
            dy = c[1] - now_c[1]

            if abs(dx) > abs(dy):
                if dx > 0:
                    order += "R"
                    now_c[0] = R(now_c[0], arm)
                else:
                    order += "L"
                    now_c[0] = L(now_c[0], arm)
            else:
                if dy > 0:
                    order += "U"
                    now_c[1] = U(now_c[1], arm)
                else:
                    order += "D"
                    now_c[1] = D(now_c[1], arm)
        print(order)

if __name__ == "__main__":
    main()

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

using namespace std;

int GCD(int a, int b) {
    return a == 0 ? b : GCD(b % a, a);
}

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> a(n);
    vector<int> b(n);

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

    for (int i = 0; i < n; ++i) {
        int g = GCD(a[i], b[i]);
        a[i] /= g;
        b[i] /= g;
    }

    long long a0 = a[0];
    long long b0 = b[0];

    for (int i = 1; i < n; ++i) {
        long long k1 = a0 / a[i] + (a0 % a[i] == 0 ? 0 : 1);
        long long k2 = b0 / b[i] + (b0 % b[i] == 0 ? 0 : 1);
        long long k = max(k1, k2);
        a0 = k * a[i];
        b0 = k * b[i];
    }

    cout << a0 + b0 << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    map<char,int> P;
    for(int i=0;i<s.size();i++){
        P[s[i]]++;
    }
    for(auto x:P){
        if(x.second!=1){cout<<"no"<<endl;return 0;}
    }
    cout<<"yes"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=605,mod=1000000007;
int v[N],f[N][N],g[N][N];
inline void add(int &a,int b){
	a=a+b>=mod?a+b-mod:a+b;
}
int main(){
	int n=read(),cnt=0;
	ll ans=1;
	for(int i=1;i<=n;i++){
		int x=read(),y=read();
		if(x!=-1&&y!=-1){v[x]=v[y]=-1; continue;}
		if(x!=-1)v[x]=1; if(y!=-1)v[y]=1;
		if(x==-1&&y==-1)ans=ans*++cnt%mod;
	}
	f[0][0]=1;
	for(int i=1;i<=2*n;i++)if(v[i]!=-1){
		memset(g,0,sizeof(g));
		if(v[i]){
			for(int j=0;j<=i;j++){
				for(int k=0;k<=i;k++)if(f[j][k]){
					add(g[j+1][k],f[j][k]);
					if(k)add(g[j][k-1],(ll)f[j][k]*k%mod);
				}
			}
		}else{
			for(int j=0;j<=i;j++){
				for(int k=0;k<=i;k++)if(f[j][k]){
					add(g[j][k+1],f[j][k]);
					add(g[j+1][k],f[j][k]);
					if(j)add(g[j-1][k],f[j][k]);
				}
			}
		}
		swap(f,g);
	}
	cout<<ans*f[0][0]%mod<<endl;
}
/*
f[i][j]表示还有i个确定数,j个不确定方案数 
-1不管
1表示钦定了，要和0配
0表示没钦定，可以和自己配
*/


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=1e9+7;
const int MAX=300010;

//Union-Find木


int siz[200010];
int par[200010];
int depth[200010];
void init(int n){
  for(int i=0;i<=n;i++){
      par[i]=i;
      depth[i]=0;
  }
  rep(i,n+1){
      siz[i]=1;
  }
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return root(x)==root(y);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  ll sx=siz[x];
  ll sy=siz[y];
  if(x==y)return;
  if(depth[x]<depth[y]){
      par[x]=y;
  }else{
      par[y]=x;
      if(depth[x]==depth[y])depth[x]++;
  }
  siz[root(x)]=sx+sy;
}



signed main(){
    ll n,m;cin>>n>>m;
    init(n);
    rep(i,m){
        ll a,b;cin>>a>>b;
        unite(a,b);
    }
    ll ans=1;
    REP(i,1,n+1){
        ans=max(ans,siz[root(i)]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8320
{-# LANGUAGE Strict #-}
import qualified Data.Vector.Unboxed as V


main :: IO ()
main = do
  [n, x, y] <- map read . words <$> getLine
  V.forM_ (solve n x y) (putStrLn . show)

solve :: Int -> Int -> Int -> V.Vector Int
solve n x y = V.accum (+) (V.replicate (n - 1) 0)
  [(f i j - 1, 1) | i <- [1 .. n - 1], j <- [i + 1 .. n]]
  where f i j = minimum [ j - i
                        , abs (x - i) + 1 + abs (y - j)
                        , abs (y - i) + 1 + abs (x - j)]


Measured memory_bytes: 5212
import itertools

def main():
    n = int(input())
    p_list = list(map(int, input().split()))
    q_list = list(map(int, input().split()))

    l = []
    for i in range(1,n+1):
        l.append(i)

    l = list(itertools.permutations(l, n))

    p_tu = tuple(p_list)
    q_tu = tuple(q_list)

    p_count = l.index(p_tu)

    q_count = l.index(q_tu)

    print(abs(p_count-q_count))

if __name__ == '__main__':
    main()

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		String a,b;
		int cnt=0;

		Scanner sc = new Scanner(System.in);

		a = sc.next();
		b = sc.next();

		for(int i = 0; i < a.length(); i++) {
			if(a.charAt(i)==b.charAt(i))
				cnt++;
		}

		System.out.println(cnt);
	}

}

Measured memory_bytes: 23124
N = int(input())
S = input()
S_set = set(S)
dict_right = {}
dict_left = {}
num_list = [0]

for st in S_set:
    dict_right[st] = S.count(st)
    dict_left[st] = 0
for s in S:
    if dict_left[s] == 0 and dict_right[s] != 1:
        num_list.append(num_list[-1] + 1)
    elif dict_left[s] != 0 and dict_right[s] == 1:
        num_list.append(num_list[-1] - 1)
    dict_right[s] -= 1
    dict_left[s] += 1
print(max(num_list))


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

int main(){
    string str; cin >> str; std::reverse(str.begin(), str.end());
    
    string d2 = "dreamer"; // odered by greter length
    string e2 = "eraser";
    string d1 = "dream";
    string e1 = "erase";
    vector<string> vecDE = {d2, e2, d1, e1};
    for(int i=0; i<vecDE.size(); ++i){ std::reverse(vecDE[i].begin(), vecDE[i].end()); }
    
    for(;;){
        bool TF=false;
        for(int i=0; i<vecDE.size(); i++){
            if(str.compare(0, vecDE[i].size(), vecDE[i])==0){
                const char* pStr = str.c_str();
                string buf = &pStr[vecDE[i].size()];
                swap(str, buf);
                TF=true;
                break;
            }
        }
        if(TF==false){ cout << "NO"; return 0; }
        if(str.size()==0){ break; }
    }
    cout << "YES"; 
    
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<unordered_set>
#include<map>
#include<utility>
#include<string>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define int  unsigned long long
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define LM LONG_MAX
#define LS LONG_MIN
#define cfM 998244353
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define sp setprecision(9)
int max(int b,int a)
{if(b>a)return b;else return a;}
int min(int b,int a)
{if(b<a)return b;else return a;}
int ab(int b)
{if(b<0) return (-1*b);else return(b);}
int32_t main()
{
	//CHECK IF NEGATIVE INPUT UNSIGNED->SIGNED
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	vector<pair<int,int> >v;
	for(int i=0;i<n;i++)
	{
		//cout<<"Enter"<<endl;
		int cnt1=0,cnt2=0;
		if(i!=0){
			for(int j=0;j<=i-1;j++)
			{
				if(arr[j]<arr[i])
					cnt1++;
			}
		}
		//cout<<"Enter"<<endl;
		if(i!=n){
			for(int j=i+1;j<n;j++)
			{
				if(arr[j]<arr[i])
					cnt2++;
			}
		}
		//cout<<cnt1<<" "<<cnt2<<endl;
		v.pb({cnt1,cnt2});
	}
	int ans=0;
	//fr(i,v.size())
	//cout<<v[i].F<<" "<<v[i].S<<endl;
	for(int i=0;i<n;i++)
	{
		int ans1=((k)*(v[i].S))%ccM;
		int j=k-1;
		int l=k;
		if((j)%2==0)
		{
			j/=2;
		}
		if((l)%2==0)
		{
			l/=2;
		}
		//cout<<j<<" "<<l<<endl;
		int ans2=(((v[i].S+v[i].F)%ccM)*((k*(k-1)/2)%ccM))%ccM;
		//cout<<ans1<<" "<<ans2<<endl;
		ans=(ans%ccM+ans1%ccM+ans2%ccM)%ccM;
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

lint euclidean_gcd(lint a, lint b) {
  lint r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	lint n, k; cin>>n>>k;
	cout<<min(n%k,k-(n%k))<<endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll A,B,K;
    cin >> A >> B >> K;
    if (A > K) {
        print(A - K << " " << B);
    } else if (A+B > K) {
        print("0 " << A+B-K);
    } else {
        print("0 0");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int l=0, i=0, H,N;
  
	cin >> H >> N;
  
  	vector<int> A(N);
  
  	for(;i<N;i++)cin >> A.at(i);

  	for(i=0;i<N;i++)H-=A.at(i);
  	if(H<=0)cout << "Yes";
  	else cout << "No";
  
  	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
const int nmax=8;
bool graph[nmax][nmax];
bool used[nmax];
int N,M;
int ans;

#define rep(i, n) for(int i = 0; i < (n); i++)
void dfs(int v, int cnt){
    if(cnt == N){
      ans ++;
      return;
    }
    used[v] = true;
    rep(i, N){
        if((!used[i]) && graph[i][v]){
            dfs(i, cnt + 1);
        }
    }
    used[v] = false;
}


int main() {
    cin >> N >> M;
    rep(i, M){
        int s,e;
        cin >> s >> e;
        s --;
        e --;
        graph[s][e] = graph[e][s] = true;
    }
    dfs(0, 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int T = Integer.parseInt(sc.next());
        int A = Integer.parseInt(sc.next());

        int index = -1;

        double minError = Double.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            int h  = Integer.parseInt(sc.next());

            double error = Math.abs(T - h * 0.006 - A);

            if (error < minError) {
                index = i;
                minError = error;
            }
        }

        System.out.println(index + 1);
    }
}


Measured memory_bytes: 24532
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ma=0;
  for(int i=1;i<n;i++){
    int cn=0;
    for(int c=0;c<26;c++){
      int cnt1=0,cnt2=0;
      for(int j=0;j<i;j++) if(s.at(j)==(char)((int)'a'+c)) cnt1=1;
      for(int j=i;j<n;j++) if(s.at(j)==(char)((int)'a'+c)) cnt2=1;
      if(cnt1==1&&cnt2==1) cn++;
    }
    if(cn>ma) ma=cn;
  }
  cout << ma << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	var s string
	fmt.Scan(&n, &a, &b, &s)

	var ac, ec int
	for _, c := range s {
		if c == 'a' {
			if ac < a+b {
				ac++
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		} else if c == 'b' {
			if ac < a+b && ec < b {
				ac++
				ec++
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 2568
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    if(A == B){
        if (A==C)
        {
            cout <<"No";
        }else
        {
            cout << "Yes";
        }    
    }else if (A==C)
    {
        cout << "Yes";
    }else if (B==C)
    {
        cout << "Yes";
    }else
    {
        cout << "No";
    }   
}

Measured memory_bytes: 256
def main():
    n = int(input())
    _next, state, d, f = [], [False] * n, [0] * n, [0] * n
    for _ in range(n):
        u, k, *v = map(lambda s: int(s) - 1, input().split())
        _next.append(sorted(v, reverse=True))
    stack = []
    time = 0

    while True:
        for i in range(n):
            if not state[i]:
                stack.append(i)
                state[i] = True
                time += 1
                d[i] = time
                break
        if not stack:
            break
        while stack:
            u = stack[-1]
            if _next[u]:
                v = _next[u].pop()
                if not state[v]:
                    state[v] = True
                    time += 1
                    d[v] = time
                    stack.append(v)
            else:
                time += 1
                f[u] = time
                stack.pop()

    for i in range(n):
        print(i + 1, d[i], f[i])


if __name__ == '__main__':
    main()



Measured memory_bytes: 5640
while True:
    h, w = [int(i) for i in input().split()]
    if (h == 0) & (w == 0):
        break
    
    for i in range(w):
        print('#', end='')
    print('')

    for i in range(h - 2):
        print('#', end='')
        for j in range(w - 2):
            print('.', end='')
        print('#', end='')
        print('')

    for i in range(w):
        print('#', end='')
    print('')
    print('')

Measured memory_bytes: 9116
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    ll n;
    cin>>n;
    ll ans = n/2 + n%2;
    cout<<ans;
}

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-08-02
**/

#include <bits/stdc++.h>
using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<bool> start(n+1), end(n+1);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        if (u == 1) {
            start[v] = true;
        }
        else if (v == n) {
            end[u] = true;
        }
    }
    
    for (int i = 2; i < n; i++) {
        if (start[i] && end[i]) {
            cout << "POSSIBLE" << '\n';
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << '\n';
    return 0;
}

Measured memory_bytes: 3644
tmp = input()
nu = tmp.find(' ')
nunu = tmp.rfind(' ')

r = int(tmp[:nu:])
D = int(tmp[nu+1:nunu:])
Xtwo = int(tmp[nunu+1::])

if(r >=2 and r <= 5 and D >= 1 and D <= 100 and Xtwo >= D and Xtwo <= 200):
  xone = r * (Xtwo) - D
  for i in range(10):
    print(xone)
    xone = r * (xone) - D

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef std::vector<ll> vi;
typedef pair < ll , ll > pll;
 
ll MOD = 1e9+7;
 
#define pb push_back
#define mp make_pair
 
ll mx(ll a , ll b){if (a > b) return a;return b;}
ll mx(ll a , ll b , ll c){if (mx(a,c) > b) return mx(a,c);return b;}
ll mn(ll a , ll b){return a + b - mx(a , b);}
ll mod (ll x ){if (x % MOD < 0) return(mod (x + MOD));return x % MOD;}
 
ll gcd (ll x , ll y){
	if (y == 0)return x;
	return gcd( y , x%y );
}
 
ll lcm(ll x, ll y, ll z){
 	
 	if (x <= 0 or y <= 0 or z <= 0) return 0 ;

	ll l = x * y / gcd(x , y);
	return l * z / gcd( l , z); 
}
 
bool ip(ll x){
 
	for (ll i = 2; i <= sqrt(x) ; i ++){
		if (x % i == 0 )return false;
	}
	return true;
}
 

ll n;
vi arr;

int main(){
	
	ios::sync_with_stdio(0);
	cin.tie(0);
 	
 	cin >> n;

 	ll d =  1e18;
 	ll l = 1e9;
 	ll a , b;
 	ll my = 1e9;
 	ll mx = n/l+1;
 	//cout << mx * my;
 	while (mx*my-n >= l){
 		mx --;	
 	}

 	b = mx*my - n;
 	a = 1;

 	cout << 0 << " " << 0 << " " << a << " " << my << " " << mx << " " << b ;


	return 0;
 
}

Measured memory_bytes: 256