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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

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

    string s;
    cin >> s;
    int ans1 = 0, ans2 = 0;
    REP(i, s.size()) {
        if (s[i] == (i % 2 ? '0' : '1')) ans1++;
        if (s[i] == (i % 2 ? '1' : '0')) ans2++;
    }
    cout << min(ans1, ans2) << ln;

    return 0;
}


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

int main(){
  int N,t,x,y;
  int x_tmp=0,y_tmp=0,t_tmp=0,flag=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>t>>x>>y;
    int dis=(t-t_tmp)-(x-x_tmp)-(y-y_tmp);
    if(dis<0 | (dis)%2!=0){
      flag=1;
    }
    t_tmp=t;
    x_tmp=x;
    y_tmp=y;
  }

  if(flag==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll x;
    cin >> x;
    ll ans = 1000 * (x/500);
    x %= 500;
    ans += 5 * (x/5);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back
#define SZ(x) ll(x.size())

using namespace std;
const int maxn = 1000*100+5 ;
int n , a[maxn] , last[maxn] , dp[maxn] ; 
int main()
{
	migmig ;
	
	cin>>n ; 
	for(int i = 1 ; i <= n ; i ++)
	{
		cin>>a[i] ; 
	}
	int ans = 0 ; 
	fill(last , last + maxn , -1) ; 
	for(int i = 1 ; i <= n ; i++)
	{
		int l = 1 , r = 100004 ; 
		while(r - l > 1)
		{
			int mid = (l + r) / 2 ; 
			if(last[mid] >= a[i]) l = mid ; 
			else r = mid ; 
			 
		}
		ans = max(ans , l+1) ; 
		
		last[l+1] = max(last[l+1] , a[i]) ; 
	}
	cout<<ans-1; 
//	cout<<endl ; 
//	for(int i = 0 ; i <= n ; i++) cout<<last[i]<<" " ; 

}
//////
////////
///////////



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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> osero (H,vector<char>(W));
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> osero.at(i).at(j);
    }
  }
  
  int K=0;
  vector<int> t(W), y(H);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(osero.at(i).at(j)=='#'){
        K=1;
      }
    }
    if(K==1){
      y.at(i)=1;
    }
    else{
      y.at(i)=2;
    }
    K=0;
  }
  for(int j=0;j<W;j++){
    for(int i=0;i<H;i++){
      if(osero.at(i).at(j)=='#'){
        K=1;
      }
    }
    if(K==1){
      t.at(j)=1;
    }
    else{
      t.at(j)=2;
    }
    K=0;
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(y.at(i)==1&&t.at(j)==1){
        cout << osero.at(i).at(j);
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	string s;
	cin >> s;
	int m;
	cin >> m;
	int n = s.size();
	VVV dp(n + 1, VV(m + 5, V(2, 0)));
	int i, j, k;
	dp[0][0][0] = 1; // 初期状態はちゃんと設定しよう!
	for (i = 0; i < n; i++) {
		for (j = 0; j < 4; j++) {
			for (k = 0; k <= 1; k++) {
				int digit = s[i] - '0';
				for (int num = 0; num <= 9; num++) {
					int nj = (num) ? j + 1 : j;
					int nk = k;
					if (nk == 0) {
						if (num > digit) continue;
						if (num == digit) nk = 0;
						if (num < digit) nk = 1;
					}
					dp[i + 1][nj][nk] += dp[i][j][k];
				}
			}
		}
	}
	cout << dp[n][m][0] + dp[n][m][1];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(void) {
  int m,n;
  std::cin >> m >> n;
  int c[10][10];
  for(int i = 0; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
      std::cin >> c[i][j];
    }
  }

  int a[m][n];
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < n; j++) {
      std::cin >> a[i][j];
    }
  }

  //ある数xを1にする最小コストを計算する。
  //変換経路は最長9のパスを通る
  //つまりこれはネットワークの最短経路問題とおんなじだ。

  //コストのMAXは1000なので、10000よりコストは小さい
  const int MAX = 10000;

  //ダイクストラ法を用いる。
  //経路は必要ないので求めない。

  bool visited[10] = {};
  int cost[11]; //1つMAXのコストを持つだけのcostを作った。
  for(auto &x : cost) x = MAX;

  for(int node_cnt = 0; node_cnt < 10; node_cnt++) {
    if(node_cnt == 0) {
      visited[1] = true;
      cost[1] = 0;
    } else {
      //最小コストのノードをカウントする。
      int min_id = 11;
      for(int i = 0; i < 10; i++) {
        if(!visited[i] && cost[i] < cost[min_id]) {
          min_id = i;
        }
      }
      if(min_id == 11) std::cout << "Err! min_id = 11" << std::endl;
      visited[min_id] = true;
    }

    //コスト情報の更新
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
        if(i == j) continue;
        cost[i] = std::min(cost[i], cost[j] + c[i][j]);
      }
    }
  }

  int output = 0;
  for(int i = 0; i < m; i++) {
    for(int j = 0; j < n; j++) {
      if(a[i][j] < 0) continue;
      output += cost[a[i][j]];
    }
  }

  std::cout << output << std::endl;

 }


Measured memory_bytes: 384
N=int(input())
H=[int(i) for i in input().split()]
X=[-1 for i in range(N)]
X[0]=0
for i in range(1,N):
    if H[i-1]>=H[i]:
        X[i]=X[i-1]+1
    else:
        X[i]=0
print(max(X))


Measured memory_bytes: 64228
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
int main(){
  ll h,w;cin>>h>>w;
  vector<string> s(h);
  rep(i,h)cin>>s[i];
  vvl ans(h,vl(w,0));
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#')cout<<'#';
      else {
        ll part=0;
        rep(k,8){
          if(0<=i+dx[k]&&i+dx[k]<h&&0<=j+dy[k]&&j+dy[k]<w&&s[i+dx[k]][j+dy[k]]=='#')part++;
        }
        cout<<part;
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  vector<P> Ans(0);
  int mx = 0, id = -1;
  REP(i, N) {
    if (mx < abs(A[i])) {
      mx = abs(A[i]);
      id = i;
    }
  }
  if (mx == 0) {
    cout << 0 << endl;
    return 0;
  }
  REP(i, N) {
    if (i == id) continue;
    A[i] += A[id];
    Ans.push_back(P(id, i));
  }
  if (A[id] > 0) {
    REP(i, N - 1) { Ans.push_back(P(i, i + 1)); }
  } else {
    for (int i = N - 1; i > 0; i--) {
      Ans.push_back(P(i, i - 1));
    }
  }
  cout << Ans.size() << endl;
  for (auto s : Ans) {
    cout << s.first + 1 << " " << s.second + 1 << endl;
  }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
long long n;
int main() {
    cin >> n;
    long long mid = 1;
    while(1) {
        long long cm = mid*mid;
        if(n < cm) break;
        mid++;
    }

    int coi = 0;

    for(int i = mid; i >= 1; --i) {
        if(n % i == 0) {
            coi = i;
            break;
        }
    }

    long long a = coi;
    long long b = n / a;

    string ai = to_string(a);
    string bi = to_string(b);

    cout << max(ai.size(), bi.size()) << endl;

}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;

template<class T>
inline bool asMn(T &a, const T &b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T &a, const T &b) { return a < b ? a = b, true : false; }

mt19937 rng( (int)chrono::steady_clock::now().time_since_epoch().count() );

struct Bit {
  vector<int> cnt;
  Bit(int nNode) { cnt.assign(nNode, 0); }

  void upd(int pos, int val) {
    for (int i = pos; i < sz(cnt); i |= i + 1) cnt[i] += val;
  }
  int get(int pos) {
    int ret = 0;
    for (int i = pos; ~i; i = (i & (i + 1) ) - 1) ret += cnt[i];
    return ret;
  }
  int get(int l, int r) { return get(r) - get(l - 1); }
};

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

  #ifdef FourLeafClover
  freopen("input", "r", stdin);
  #endif // FourLeafClover

  int n, m; cin >> n >> m;

  vector<vector<int> > souvenir(m + 1);
  while (n--) {
    int l, r; cin >> l >> r;
    souvenir[l].emplace_back(r);
  }

  vector<int> ans(m + 1);
  vector<vector<int> > pos(m + 1);
  for (int i = 1; i <= m; ++i) {
    for (int j = i; j <= m; j += i) pos[j].emplace_back(i);
  }

  Bit bit(m + 1);
  for (int i = 1; i <= m; ++i) {
    for (int r : souvenir[i]) bit.upd(r, 1);
    for (int j : pos[i]) ans[j] += bit.get(i, min(m, i + j - 1) );
  }

  for (int i = 1; i <= m; ++i) cout << ans[i] << '\n';

  return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sz size()
#define S second
#define F first
#define all(x) x.begin(), x.end()
#define int ll

typedef pair < int, int > pii;
typedef vector < int >  vi;
typedef vector < vector < int > >  vvi;

void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi suff(n + 3, 0);
    vi pos;
    for(int i = s.sz - 1; i >= 0; i--){
        if(s[i] == 'R'){
            pos.pb(i);
            suff[i] = 1;
        }
        suff[i] += suff[i + 1];
    }

    /*for(int i = 0; i < n; i++){
        cout << suff[i] << " ";
    }
    cout << "\n";*/
    int cnt = 0, ans = 0;
    //cout << cnt << " ";
    for(int i = 0; i < s.sz; i++){
        if(s[i] == 'W' && ans < suff[i]){
            ans++;
            swap(s[pos[cnt]], s[i]);
            //cout << pos[cnt] << " ";
            cnt++;
        }
    }
    cout << ans;
}

signed main() {
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
/*
10
WRWRWRWRWR
*/



Measured memory_bytes: 7060
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		long A = scan.nextLong();
		long B = scan.nextLong();
		long C = scan.nextLong();
		long D = scan.nextLong();

		long max = Math.max(A * B, C * D);

		System.out.println(max);
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

int INF = 1000001;
int dist[10][10];
int cost[10];
char used[10];

void dijkstra(int g)
{
 int x, y, min;
 for(x = 0; x < 10; x++){
  cost[x] = INF;
  used[x] = 0;
 }
 cost[g] = 0;
 while(1){
  min = INF;
  for(x = 0; x < 10; x++){
   if(!used[x] && min > cost[x])
    min = cost[x];
  }
  if(min == INF) break;
  for(y = 0; y < 10; y++){
   if(cost[y] == min){
    used[y] = 1;
    for(x = 0; x < 10; x++){
     if(cost[x] > dist[x][y] + cost[y])
      cost[x] = dist[x][y] + cost[y];
    }
   }
  }
 }
}


int main() {
  int h,w;
  cin >> h >> w;
  for(int i = 0;i < 10;i++) for(int j = 0;j < 10;j++) cin >> dist[i][j];
  dijkstra(1);
  long ans = 0;
  for(int i = 0;i < h*w;i++){
    int a;
    cin >> a;
    if(a == -1) continue;
    else ans += cost[a];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n,x,y,t;
    cin >> n >> x >> y;
    map<int, int> map_k;
    for(int i = 1; i<n; i++){
        for(int j = i+1; j<n+1; j++){
            if((i<=x) && (y<=j)){
                map_k[j-i-(y-x)+1]++;
            }else if((x<=i) && (j<=y)){
                map_k[min(j-i, y-x+1-(j-i))]++;
            }else if((x<j)&&(j<y)){
                map_k[min(x-i+j-x, x-i+y-j+1)]++;
            }else if((x<i) && (i<y)){
                map_k[min(j-y+y-i, j-y+i-x+1)]++;
            }else{
                map_k[j-i]++;
            }
            // cout << i <<  j << endl;
        }
    }
    for(int i=1; i<n; i++){
        cout << map_k[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>


int solve(int n) {
    if (n <= 81) {
        for (int i = 1; i < 10; ++i) {
            if (n % i == 0 && n / i < 10) {
                return 0;
            }
        }
        return -1;
    } else {
        return -1;
    }
}


int main () {
    int n;

    scanf("%d", &n);
    if (solve(n) == 0) {
        printf("%s\n", "Yes");
    } else {
        printf("%s\n", "No");
    }
}

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

using namespace std;
using ll = long long int;

int main(){
    int N,K;
    cin>>N>>K;
    
    int count=1;
    
    while(N>=K){
        N/=K;
        count++;
    }
    
    cout<<count<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    if(__builtin_popcount(n)==1)return cout<<"No" , 0;
    cout<<"Yes\n"<<"2 "<<n+1<<"\n";
    for(ll x=2;x<n;x+=2){
        cout<<x<<" "<<x+1<<"\n";
        cout<<"1 "<<x+1<<"\n";
        cout<<"1 "<<x+n<<"\n";
        cout<<x+n<<" "<<x+n+1<<"\n";
    }

    ll k=0;while((1ll<<k)<n)k++;
    k--;

    if(n%2==0){
        cout<<n<<" "<<n+(1ll<<k)<<"\n";
        cout<<2*n<<" "<<(n-(1ll<<k))+1<<"\n";
    }
}

Measured memory_bytes: 2304
N = int(input())
A = list(map(int,input().split()))

temp = sum(A)
for i in range(1, N, 2):
  temp -= A[i] * 2

R = [0] * N
R[0] = temp

for i in range(1, len(R)):
  R[i] = A[i - 1] * 2 - R[i - 1]

print(*R)

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

int main() {
	int a[3][3];
	bool appear[3][3];
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	int b[n];
	for (int k = 0; k < n; k++) cin >> b[k];
	for(int i = 0; i < n; i++) {
 		for(int j = 0; j < n; j++) {
 			appear[i][j] = false;
 			for(int k = 0; k < n; k++) {
 				if(a[i][j] == b[k]) appear[i][j] = true;
 			}
 		}
 	}
 	string ANS = "No";
	for(int i = 0; i < 3; i++) {
		if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
	}
	for(int i = 0; i < 3; i++) {
		if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
	}
	if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
	if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
	cout << ANS << endl;
}


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

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

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
   int n;
   cin>>n;
   int ans=1000-n%1000;
   if(ans==1000) ans=0;
   cout<<ans;

  

return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    long long a,b,c,i,k,ans=0;
    cin>>a>>b>>c>>k;

    if(k>=a)
    {
        ans+=a;
        k-=a;
    }
    else
    {
        cout<<k<<'\n';
        return 0;
    }
    if(k>0)
    {
        if(k>=b)
            ans+=0,k-=b;
        else
        {
            cout<<ans<<'\n';
            return 0;
        }
    }
    if(k>0)
    {
        if(k>=c)
        {
            ans-=c;
            k-=c;
        }
        else
        {
            ans-=k;
        }

    }
    cout<<ans<<'\n';

}




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

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if (S == U)
    A = A - 1;
  else
    B = B - 1;
  cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define WHITE 1
#define GRAY 2
#define BLACK 3
int t=0;
typedef struct{
  int id;
  int *child; //子供のIDを保存
  int count; //子供の数
  int color;
  int d;
  int f;
}Vertex;
int visit(Vertex *A,int u){
  int i;
  A[u].color=GRAY;
  A[u].d=++t;
  for(i=0;i<A[u].count;i++){
    if(A[A[u].child[i]].color==WHITE){
      visit(A,A[u].child[i]);
    }
  }
  A[u].color=BLACK;
  A[u].f=++t;
}
void dfs(Vertex *A,int n){
  int i;
  for(i=0;i<=n;i++){
    A[i].color=WHITE;//1
  }
  for(i=1;i<n;i++){
    if(A[i].color==WHITE){
      visit(A,A[i].id);
    }
  }
}
int main(){
  int n,i,j;
  int id,num,col,x;
  Vertex *A;
  
  scanf("%d",&n);//入力(ノードの数)
  A=(Vertex *)malloc(sizeof(Vertex)*(n+1));
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&num);//入力(ノードのIDと子供の数)
    A[id].id=id;//ノードのID
    A[id].count=num;//ノードの子供の数
    A[id].child=(int*)malloc(sizeof(int)*num);//子供の数だけ動的確保
    for(j=0;j<num;j++){//子供のIDを格納
      scanf("%d",&x);
      A[id].child[j]=x;
    }
  }
  dfs(A,n);
  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,A[i].d,A[i].f);
  }
  return 0;
}



Measured memory_bytes: 2088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long ans = 1;
		for(int i=0;i<n;i++){
			long l = scanner.nextLong();
			ans = lcm(ans,l);
		}
		System.out.println(ans);

	}
	private static long gcd(long m, long n) {
		if( n == 0 ){
			return m;
		}
		return gcd(n, m % n);
	}

	private  static long lcm(long m, long n) {
		return m * (n / gcd(m, n));
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	int x = 'A' - 'a';
	s[k - 1] -= x;
	cout << s << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(void) {
  int q;
  cin >> q;

  ll sum = 0;
  for (int i = 0; i < q; i++) {
    ll p, n;
    char c;
    cin >> p >> c >> n;
    sum += (c == '(') * n;
    sum -= (c == ')') * n;

    cout << (sum == 0 ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;
#define MOD 1000000007
#define rint register int
#define gc() getchar()
inline int read(rint ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
#define BUF_SIZE 1000000
#define _END fwrite(_Ob,1,_O-_Ob,stdout), _O = _Ob
#define Outc(a) (*_O++ = a)
char _Ob[BUF_SIZE+5], *_O = _Ob, _Os[25], *_Ot;
template <typename T> inline void Out(T x)
{
	if(!x){Outc('0'); return;} if(x < 0) Outc('-'), x = -x;
	for(_Ot = _Os; x; *_Ot++ = x%10+'0', x /= 10);
	for(; _Ot != _Os; Outc(*--_Ot)); if(_O-_Ob >= BUF_SIZE-50) _END;
}
int C[4005][4005], f[4005][4005], g[4005][4005], F[4005], G, A, B, N;
int main()
{
	A = read(), B = read(), N = A+B;
	for(rint i = 0, j; i <= N; i++) for(C[i][0] = 1, j = 1; j <= i; C[i][j] = C[i-1][j]+C[i-1][j-1], C[i][j]<MOD?:C[i][j]-=MOD, j++);
	for(rint a = 0; a <= A; f[a][0] = g[a][0] = 1, a++); for(rint b = 0; b <= B; f[0][b] = g[0][b] = 1, b++); F[0] = G = 1;
	for(rint a = 1, b; a <= A; a++)
		for(b = 1; b <= B; f[a][b] = f[a-1][b]+C[b][a], f[a][b]<MOD?:f[a][b]-=MOD, b++);
	for(rint a = 1, b; a <= A; a++)
		for(b = 1; b <= B; g[a][b] = g[a-1][b]+f[a][b-1], g[a][b]<MOD?:g[a][b]-=MOD, b++);
	for(rint a = 1, j; a <= A; a++)
		for(j = 0; j <= a; F[a] = (F[a]+1ll*C[B-1][j]*g[a-j][j])%MOD, j++);
	for(rint a = 1; a <= A; G = G+F[a], G<MOD?:G-=MOD, a++); printf("%d\n",G); return 0;
}

Measured memory_bytes: 128768
A, B, N = list(map(int,input().split()))
MAX = float('inf')*(-1)
a = int(A/B)
b = B
if N < B:
    MAX = (A * N // B) - A * (N // B)
else:
    MAX = (A * (B-1) // B) - A * ((B-1) // B)
print(MAX)

Measured memory_bytes: 9196
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
   
   Scanner sc = new Scanner(System.in);  
   
   while (true) {
   int H = sc.nextInt();
   int W = sc.nextInt();

    if (H == 0 && W == 0) {
      break;
    }
       
       for(int y=0; y<H; y++){
          for(int x=0; x<W; x++){
             System.out.print((x+y)% 2 == 0 ? '#' : '.');
          }
          System.out.println();
       }
       System.out.println();
   }
   sc.close();
  }
}


Measured memory_bytes: 39152
#include <math.h>
#include <stdio.h>
#include <string.h>
int main()
{   char s[11];
    scanf("%s",s);
    long long ans=0,cnt=0;
    int l=strlen(s);
    if(l==1){
        printf("%c",s[0]);
        return 0;
    }
    int a[9]={0};
    for(a[8]=0;a[8]<2;a[8]++){
        for(a[7]=0;a[7]<2;a[7]++){
            for(a[6]=0;a[6]<2;a[6]++){
                for(a[5]=0;a[5]<2;a[5]++){
                    for(a[4]=0;a[4]<2;a[4]++){
                        for(a[3]=0;a[3]<2;a[3]++){
                            for(a[2]=0;a[2]<2;a[2]++){
                                for(a[1]=0;a[1]<2;a[1]++){
                                    for(a[0]=0;a[0]<2;a[0]++){
                                        if(cnt==pow(2,l-1))break;
        long long tmp=s[0]-'0';
        for(int i=0;i<l-1;i++){
            if(a[i]==0){
                tmp*=10;
                tmp+=s[i+1]-'0';
            }else{
                ans+=tmp;
                tmp=s[i+1]-'0';
            }
            if(i==l-2){
                ans+=tmp;
            }
        }
        cnt++;
        
        //printf("preans=%lld\n",ans);
    }
    }   
    }
    }
    }              
    }
    }
    }
    }
    
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 128
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input! {
        n: i64,
        v: [i64; 5],
    }

    let min = *v.iter().min().unwrap() as f64;
    let ans = n as f64 / min;
    println!("{}", ans.ceil() as i64 + 4);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int change(int h,int m,int s){
	return h*3600+m*60+s;
}

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		int sh,sm,ss,th,tm,ts,ans=0;
		vi d(86410);
		rep(i,0,n){
			scanf("%d:%d:%d %d:%d:%d",&sh,&sm,&ss,&th,&tm,&ts);
			d[change(sh,sm,ss)]++; d[change(th,tm,ts)]--;
		}
		rer(i,1,86400){
			d[i]+=d[i-1]; ans=max(ans,d[i]);
		}
		o(ans);
	}
}

Measured memory_bytes: 1576
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0

    flag = True
    while flag:
        flag = False
        for i in range(1, n):
            if a[i] < a[i-1]:
                a[i], a[i-1] = a[i-1], a[i]
                flag = True
                ans += 1
    print(*a)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
template<class T>  //多次元ベクトルの生成
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main(){
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n)std::cin >> a[i];
	int counter=0;
	rep(i,n){
		for (;;) {
			/* code */
			if(a[i]%2==0){a[i]/=2;
			counter++;}
			else break;
		}
	}
	std::cout << counter << std::endl;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double sum=0;
  int n=0; cin>>n;
  rep(i,n){
    double A=0; cin>>A;
    sum+=1/A;
  }
  cout<<1/sum<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from itertools import accumulate
from bisect import bisect, bisect_left
from collections import Counter, deque
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor
from string import ascii_lowercase as abc

from sys import setrecursionlimit
setrecursionlimit(10**9)
 
import sys
#input = sys.stdin.readline
from collections import Counter
def inpl(): return list(map(int, input().split()))

K, X = inpl()
minimum = max(-1000000, X-K+1)
maximum = min(1000000, X+K-1)
size = maximum-minimum+1 
print(*[minimum + x for x in range(size)])

Measured memory_bytes: 38640
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
vector<string>v;
ll n,m ;
ll dp[3001][3001];
ll mod = 1e9+7 ;
ll func(ll i , ll j)
{
    if(i>=n || j>=m)
    {
        return(0);
    }
    if(i==n-1 && j==m-1)
    {
        return(1);
    }
    if(v[i][j]=='#')
    {
        return(0);
    }
    if(dp[i][j]!=-1)
    {
        return(dp[i][j]);
    }
    ll ans = (func(i+1,j)%mod + func(i,j+1)%mod)%mod;
    dp[i][j] = ans;
    return(ans);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,t,k,y,w;
    double p,q,r,u,s ;
    string str = "",str1 = "" ;
    char ch,chr ;
    ll a1=0,a2=0,b1=0,b2=0 ;
    cin>>n>>m ;
    memset(dp,-1,sizeof(dp));
    for(i=0 ; i<n ; i=i+1)
    {
        cin>>str;
        v.pb(str);
    }
    a = func(0,0);
    cout<<a;
}

Measured memory_bytes: 71808
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int front = sc.nextInt();
    int current;
    int count = 0;
    int count_max = 0;
    
   	for(int i = 1; i < n; i++){
      current = sc.nextInt();
      if(current <= front) count++;
      else count = 0;
      if(count_max < count) count_max = count;
      front = current;
    }
    
    System.out.println(count_max);
  }
}


Measured memory_bytes: 58868
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 0x3fffffff;


int main(){
	//ios_base::sync_with_stdio(0);
	ll N, M, ans=0;

	cin >> N >> M;
	ans = min( M/2, N );
	N -= ans;
	M -= ans*2;
	ans += M / 4;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;cin>>n;
    vector<vector<int>> in(n,vector<int>(3));
    rep(i,n) rep(j,3) cin >> in[i][j];
    vector<vector<int>> dp(n+10,vector<int>(3,-INF));
    rep(i,3){
        dp[0][i] = 0;
    }

    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(j==k) continue;
                dp[i+1][j] = max(dp[i+1][j],dp[i][k] + in[i][j]);
            }
        }
    }
    int ans=-INF;
    rep(i,3) ans = max(ans,dp[n][i]);
    cout << ans << endl;
}

Measured memory_bytes: 11136
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll A, B, K;
    cin >> A >> B >> K;
    A-=K;
    if(A<0){
        K=-A;
        A=0;
    }else{
        K=0;
    }
    B-=K;
    chmax(B, 0ll);
    cout << A << " " << B << el;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

int main(){
    string S; cin>>S;
    rep(i,S.size()) if(S[i]=='?') S[i]='D';
    cout<<S<<endl;
}

Measured memory_bytes: 3764
from bisect import bisect_left
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())
a = list(map(int, input().split()))

result = [-1 for _ in range(n)]
tree = [[] for _ in range(n)]
for _i in range(n-1):
    u, v = map(int, input().split())
    u, v = u-1, v-1
    tree[u].append(v)
    tree[v].append(u)
INF = float('inf')
dp = [INF for _i in range(n+1)]


def dfs(p, x):
    i = bisect_left(dp, a[p])
    old = dp[i]
    dp[i] = a[p]
    result[p] = bisect_left(dp, INF)
    for j in tree[p]:
        if j != x:
            dfs(j, p)
    dp[i] = old
    

dfs(0, -1)

for i in result:
    print(i)

Measured memory_bytes: 225024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, K;
  cin >> N >> K;
  
  int Ans = 1;
  int b = K;
  while (N/b!=0){
  b*= K;
  Ans++;
  }

  cout << Ans << endl;
}

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

int main(){
    int X, A, B;
    scanf("%d %d %d", &X, &A, &B);

    if(A>=B) printf("delicious\n");
    else if(X>=(B-A)) printf("safe\n");
    else if(X<(B-A)) printf("dangerous\n");
    return 0;
}

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

void solve(int n){
  string tm[10];
  vector< pair<int,int> > scr;    
  int a,b,c;

  scr.resize(n);
  for(int i=0;i<n;i++){
    cin>>tm[i]>>a>>b>>c;
    scr[i]=make_pair((-1)*(a*3+c),i);
  }
  sort(scr.begin(),scr.end());
  for(int i=0;i<n;i++)
    cout<<tm[scr[i].second]<<","<<(-1)*scr[i].first<<endl;
}

int main (){

  int n;
  cin>>n;
  while(n){
    solve(n);
    cin>>n;
    if(n>0) cout<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 1208
N=int(input())
a=input().split()
A=[int(b) for b in a]
B=[format(a,'b').zfill(60) for a in A]
mod=pow(10,9)+7
answer=0
for i in range(60):
    zero=0
    one=0
    kotae=1
    for j in B:
        if j[i]=='0':
            zero+=1
        elif j[i]=='1':
            one+=1
    kotae=zero*one
    for _ in range(60-i-1):
        kotae*=2
    answer+=kotae
print(answer%mod)


Measured memory_bytes: 153948
import bisect

N = int(input())
L = [int(l) for l in input().split()]
L.sort()
S = 0
n = 0
S = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        l = L[i] + L[j]
        s = bisect.bisect_left(L, l)
        S += bisect.bisect_left(L, L[i] + L[j]) - j - 1

print(S)

Measured memory_bytes: 44124
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

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

  if (k*500 >= x){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}

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

struct lines {
  int h;  //横線の高さ                                                            
  int p, q; //横線に繋がる縦線の番号                                              

  bool operator>(const lines &left) const {
    return h > left.h;
  }
};

int amida(int n, int m, int a, lines* line, int size) {
  for(unsigned int i = 0; i < size; i++) {
    if(line[i].p == a)
      a = line[i].q;
    else if(line[i].q == a)
      a = line[i].p;
  }
  return a;
}

int main() {
  int n; //縦線の本数                                                             
  int m; //横線の本数                                                             
  int a; //調べる縦線の番号                                                       
  vector<lines> line;

  while(1) {
    cin >> n >> m >> a;
    if(n == 0 && m == 0 && a == 0) break;

    for(int i = 0; i < m; i++) {
      lines l;
      cin >> l.h >> l.p >> l.q;
      line.push_back(l);
    }

    sort(line.begin(), line.end(), greater<lines>());
    cout << amida(n, m, a, &line.front(), line.size()) << endl;
    line.clear();
  }

  return 0;
}




Measured memory_bytes: 2988
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#define INF 10e9
using namespace std;


int N, A, B;
int h[100000];

bool enough(int t){
	int h_[N];
	int dist = A - B;
	int count = 0;
	bool flag = true;
	for(int i = 0; i < N; i++){
		h_[i] = h[i] - B * t;
		if(h_[i] > 0)
			count += ceil((float)h_[i] / (float)dist);
		if(count > t){
			flag = false;
			break;
		}
	}

	return flag;
}



int main(){
	cin >> N >> A >> B;
	int temp_max = 0;
	for(int i=0; i < N; i++){
		cin >> h[i];
		temp_max = max(temp_max, h[i]);
	}
	int right = temp_max/B + 1;
	int left = 0;
	while(1){
		long int mid =(left + right)/2;
		if(enough(mid))
			right = mid;
		else
			left = mid + 1;
		if(left == right)
			break;

	}
	cout << left << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  int minx = 101, maxx = 0;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    minx = min(x[i], minx);
    maxx = max(x[i], maxx);
  }

  int min_stam = 10000000;
  for (int p = minx; p <= maxx; ++p) {
    int s = 0;
    for (int i = 0; i < n; ++i) {
      s += (x[i] - p) * (x[i] - p);
    }
    min_stam = min(min_stam, s);
  }

  cout << min_stam << endl;

  return 0;
}


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

int l[9], ans=1e9, n,a,b,c;

void eval(int p, int x, int y, int z, int w) {
	if (p>n)
		return;
	if (x&&y&&z)
		ans=min(ans,abs(a-x)+abs(b-y)+abs(c-z)+10*(w-3));
	eval(p+1,x+l[p],y,z,w+1);
	eval(p+1,x,y+l[p],z,w+1);
	eval(p+1,x,y,z+l[p],w+1);
	eval(p+1,x,y,z,w);
}

int main() {
	cin>>n>>a>>b>>c;
	for (int i=0; i<n; i++)
		cin>>l[i];
	eval(0,0,0,0,0);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
import math
N, M = map(int, input().split())

# M = a x bの形に分解する
pair = []
for i in range(1, int(math.sqrt(M))+1):
    if M % i == 0:
        pair.append((i, M // i))

ans = 1
for a, b in pair:
    if b >= N:
        ans = max(ans, a)
    if a >= N:
        ans = max(ans, b)

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

#define INF 200000

void dijkstra();

int n;
int A[101][101],color[101] = {};

int main(){
  int i,j,u,k,a,b;

  scanf("%d",&n);
   for(i = 0;i < n; i++){
     for(j = 0;j < n; j++){
       A[i][j] = INF;
     }
   }
   
  for(i = 0;i < n; i++){
    scanf("%d %d",&u,&k);
    
    for(j = 0;j < k; j++){
     scanf("%d %d",&a,&b);
     A[u][a] = b;
  }
}
  dijkstra();
  return 0;
}

void dijkstra(){
  int i,j,mincost,u;
  int d[101] = {},pi[101];
  
  for(i = 0;i < n; i++){
    d[i] = INF;
  }

  d[0] = 0;
  pi[0] = -1;
  
  while(1){
    mincost = INF;
    
    for(i = 0; i< n; i++){
      if(color[i] != -2 && d[i] < mincost){
        mincost = d[i];
	u = i;
      }
    }
    if(mincost == INF)break;
    color[u] = -2;

    for(i = 0; i < n; i++){
      if(color[i] != -2 && A[u][i] + d[u] < d[i]){
         d[i] = A[u][i] + d[u];
	 pi[i] = u;
      }
    }
  }
  for(i = 0; i < n; i++){
    if(d[i] != INF)printf("%d %d\n",i,d[i]);
    else printf("%d -1\n",i);
  }
}




Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    char c;
    cin >> c;
    c+=1;
    cout << c << endl;





}


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


int main(){
 int n;
  
  cin >> n;
  int v[n];
  int c[n];
  for(int i = 0;i < n;i++){
    cin >> v[i];
  }
  for(int i = 0;i < n;i++){
    cin >> c[i];
  }
  int ans = 0;
  for(int i = 0; i < n;i++){
    if(v[i] > c[i]){
      ans += v[i] - c[i];
    }
  }
  cout << ans;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


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

    int ans = INF;
    FOR(a,1,N) {
        int b = N-a;

        int a_sum = 0;
        string a_str = to_string(a);
        REP(i, a_str.size()) a_sum += a_str[i]-'0';

        int b_sum = 0;
        string b_str = to_string(b);
        REP(i, b_str.size()) b_sum += b_str[i]-'0';

        chmin(ans,a_sum+b_sum);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split(' '))
mod = int(1e9 + 7)

l = [1] * (m+1)
for i in range(1, m+1):
	l[i] = (l[i-1] * i) % mod

l2 = [1] * (m+1)
l2[m] = pow(l[m], mod-2, mod)
for i in range(m-1, 0, -1):
	l2[i] = (l2[i+1] * (i+1)) % mod

s = 0
for k in range(n+1):
	n_choose_k = (l[n] * l2[k] * l2[n-k]) % mod
	m_perm_k = (l[m] * l2[m-k]) % mod
	mk_perm_nk = (l[m-k] * l2[m-n]) % mod
	s += ((-1) ** k * n_choose_k * m_perm_k * mk_perm_nk ** 2 ) % mod 

print(s % mod)

Measured memory_bytes: 48272
import queue
n = int(input())

tree = {i: [] for i in range(n)}

for _ in range(n-1):
  t = input().split()
  u, v = int(t[0]), int(t[1])
  tree[u-1].append(v-1)
  tree[v-1].append(u-1)

a = 0
q = queue.Queue()
q.put(a)
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a]:
        if (v[b] == 0 and len(tree[b]) > 1):
            q.put(b)
            v[b] = 1

s = a
q = queue.Queue()
q.put([a, 1])
v = [0 for _ in range(n)]
v[a] = 1

while (not q.empty()):
    a = q.get()
    for b in tree[a[0]]:
        if (v[b] == 0 and len(tree[b]) > 1):
            q.put([b, a[1] + 1])
            v[b] = 1

if n <= 3:
    l = n
else:
	l = a[1] + 2

if l%3 == 2:
    print("Second")
else:
    print("First")

Measured memory_bytes: 108124
#include <stdio.h>
#include <iostream>
#include <stack>
#include <map>
#include <queue>
#include <algorithm>

typedef long long int lli;
#define PI 3.1415926535897932
#define MAX(a,b) ((a>b)?(a):(b)) // ?????§????????????
#define MIN(a,b) ((a<b)?(a):(b)) // ????°?????????????
#define INRANGE(a,b,c) ((a<=b&&b<=c)?(1):(0)) // a<=b<=c??????????????????????????????

int zeller(int y,int m,int d){ // ?????§??????
	if(m<3){y--; m+=12;}
	return (y+y/4-y/100+y/400+(13*m+8)/5+d)%7;
}

lli gcd(lli a,lli b){	// ?????§??¬?´???°
	if(b==0) return a;
	return gcd(b,a%b);
}

lli lcm(lli a,lli b){	// ????°???¬?????°
	return a*b/gcd(a,b);
}

int main(void){
	lli a,b;
	while(scanf("%lld %lld",&a,&b)!=EOF){
		printf("%lld %lld\n",gcd(a,b),lcm(a,b));
	}
	return 0;
}

Measured memory_bytes: 1188
import math

a,b,c,d = map(int, input().split())

C, D = c, d
if C < D:
  C, D = D, C
r = C % D
while r > 0:
  C = D
  D = r
  r = C % D
lcm = c * d // D

cPower = b//c - math.ceil(a/c) + 1
dPower = b//d - math.ceil(a/d) + 1
cdPower = b//lcm - math.ceil(a/lcm) + 1

print(max((b-a+1) - cPower - dPower + cdPower, 0))

Measured memory_bytes: 3064