akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double d = sc.nextDouble();
        double t = sc.nextDouble();
        double s = sc.nextDouble();
        if(s >= Math.ceil((d/t))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

int main(){
  
  int N,A;
  cin >> N >> A;
  
  if( N % 500 == 0) cout << "Yes" << endl; // 500 の倍数だったら問答無用で YES
  else if ( N > 500 ){	//500 の倍数ではなくて、500 より大きい場合
    int amari = N % 500; //N を 500 で割った数のあまりを出す
    if( A >= amari)	cout << "Yes" << endl;
    else	cout << "No" << endl;
  }else{
    if ( A >= N )	cout << "Yes" << endl;
    else	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <string.h>

int main(void){
  int n;
  float sum;
  scanf("%d", &n);
  //sum = a*b;
  if(n%2 == 0){
    //sum = 1/2;
  	printf("%f",(n/2)/(float)n);
  }
  else{
    //sum = 1/n +1/2;
    printf("%f", (n/2+1)/(float)n);
  }
  return 0;
}

  


Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  string s;
  cin>>s;
  for(char &c:s) if(c=='?') c='D';
  cout<<s<<newl;
  return 0;
}


Measured memory_bytes: 3784
import scala.collection.mutable
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    val in = StdIn.readLine().split(" ").map(_.toInt)
    val sheet = readCells(in(0),0,List.empty[List[Int]])

    for(row <- sheet){
      println(row.mkString(" ") + " " + row.sum)
    }
    val columnSummary = getColumnSummary(sheet,List.fill(in(1))(0))
    println(columnSummary.mkString(" ") + " " + columnSummary.sum)
  }

  def readCells(r:Int,i:Int,sheet:Seq[List[Int]]):Seq[List[Int]] = {
    if(r == i){
      sheet
    } else {
      readCells(r,i + 1,sheet :+ StdIn.readLine().split(" ").map(_.toInt).toList)
    }
  }

  def getColumnSummary(sheet:Seq[List[Int]],sum:List[Int]):List[Int] = {
    if(sheet.size == 0){
      sum
    } else {
      getColumnSummary(sheet.tail,(sum,sheet.head).zipped.map(_ + _))
    }
  }
}

Measured memory_bytes: 49152
#include <stdio.h>
int main(void)
{
  int n;
  //printf("N,A1,A2...Anを入力してください");
  scanf("%d",&n);
  int a[n],i,k=0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if((a[i] % 2 == 1) || (a[i] % 3 == 0) || (a[i] % 5 == 0))
      k++;
  }
  if(k==n)
    printf("APPROVED\n");
  else
    printf("DENIED\n");
  
  return 0;
}

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

int main() {

  int n,m;
  vector <int> dp;

  cin >> n >> m;
  int a[21];
  
  for(int i=0;i<m;i++) cin >> a[i];
  
  dp.resize(n+1);
  for(int i=0;i<=n;i++) dp[i] = i;
  
  for(int j=0;j<m;j++){
    for(int i=1;i<=n;i++) {
      // cout << dp[i] <<" "<< dp[i-a[j]]+1<<endl;
      if(i / a[j] != 0)
      dp[i] = min(dp[i],dp[i-a[j]]+1);
    }
  }
  
  cout << dp[n] << endl;
  
  return 0;
  
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void){
	int A, B, C; cin >> A >> B >> C;
	ll sum = A;
	bool flag = false;
	for (int i = 0; i < 10000; ++i){
		if(sum % B == C) flag = true;
		sum += A;
		// sum %= C;
	}
	if(flag) printf("YES\n");
	else printf("NO\n");
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    int dx[] = {1,0,-1,0};
    int dy[] = {0,1,0,-1};
    vector<string> f(h);
    rep(i,h) cin>>f[i];
    rep(i,h)rep(j,w)if(f[i][j]=='#'){
        bool ok=false;
        rep(k,4){
            int ti = i+dy[k];
            int tj = j+dx[k];
            if (!(0<=ti&&ti<h&&0<=tj&&tj<w)) continue;
            if (f[ti][tj]=='#'){
                ok = true;
                break;
            }
        }
        if (!ok){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
X,K,D = map(int,input().split())
if X > 0:
  if X // D >= K:
    ans = X - D*K
  else:
    K -= X//D
    X = X%D
    if K%2 == 0:
      ans = X
    else:
      ans = abs(X -D)
if X < 0:
  if -1*X // D >= K:
    ans = abs(X + D*K)
  else:
    K -= (-1*X)//D
    X = (-1*X)%D
    if K%2 == 0:
      ans = X
    else:
      ans = abs(X -D)
if X == 0:
  if K%2==0:
    ans = 0
  else:
    ans = D
print(ans)


Measured memory_bytes: 9128
#include <stdio.h>
int main(){
    int a,b,c,i;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+'){
            printf("%d\n",a+b);
        }
        else if(op=='-'){
            printf("%d\n",a-b);
        }
        else if(op=='*'){
            printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }
        else if(op=='?'){
            break;
        }
        else{}
    }
    return 0;
    
}


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

int main()
{
  int64_t N, A, B, ans = 0;
  cin >> N >> A >> B;
  vector<int64_t> X(N), D(N, 0);
  for (int i = 0; i < N; i++)
  {
    cin >> X.at(i);
    if (i)
    {
      D.at(i) = A * (X.at(i) - X.at(i - 1));
    }
  }
  for (int i = 1; i < N; i++)
  {
    if (D.at(i) < B)
      ans += D.at(i);
    else
      ans += B;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,l[200],c=0;
    cin>>n;
    for(int i=0;i<n*2;i++){
        cin>>l[i];
    }
    sort(l, l+n*2);
    for(int i=0;i<n;i++){
        c+=l[i*2];
    }
    cout<<c<<endl;
}


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

typedef long long LL;
const int MAX_N = 200100;
const LL INF = 1 << 30;
LL nmin[MAX_N];

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

	int n;
	cin >> n;

	LL ans = -INF;
	for(int i = 0; i < n; ++i){
		LL r;
		cin >> r;
		if(i == 0){
			nmin[0] = r;
		}
		else {
			ans = max(ans, r - nmin[i - 1]);
			nmin[i] = min(nmin[i - 1], r);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2764
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 i=1;i<=H;i++){
                for(int j=1;j<=W;j++){
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    sc.close();
    }
}


Measured memory_bytes: 38436
#include <bits/stdc++.h>
#define nmax 100005

using namespace std;

typedef long long ll;

int n;
ll a[nmax], b[nmax];

ll solve(int sgn){
	ll cur=0, ans=0;
	memcpy(b,a,n*sizeof(ll));
	
	for(int i=0;i<n;i++){
		b[i]+=cur;
		
		if(sgn==-1){
			if(b[i]>=0){
				ans+=b[i]+1;
				cur-=b[i]+1;
			}
		}
		else{
			if(b[i]<=0){
				ans+=-b[i]+1;
				cur+=-b[i]+1;
			}
			
		}
		sgn*=-1;
	}
	
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
		a[i]+=a[i-1];
	}
	
	
	ll ans = solve(1);
	ans=min(ans,solve(-1));
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2048
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int d[32][32], c[510][510];
int color[3][32];
int main(void) {
	int n,C;
	int ans = INF;
	cin >> n >> C;
	for (int i = 1;i <= C;i++) {
		for (int j = 1;j <= C;j++) {
			cin >> d[i][j];
		}
	}
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= n;j++) {
			cin >> c[i][j];
			color[(i + j) % 3][c[i][j]]++;
		}
	}
	int x1 = 0, x2 = 0, x3 = 0;
	for (int i = 1;i <= C;i++) {
		for (int j = 1;j <= C;j++) {
			if (j == i)continue;
			for (int k = 1;k <= C;k++) {
				if ((k == i) || (k == j))continue;
				x1 = 0, x2 = 0, x3 = 0;
				for (int l = 1;l <= C;l++) {
					x1 += color[0][l] * d[l][i];
					x2 += color[1][l] * d[l][j];
					x3 += color[2][l] * d[l][k];
				}
				ans = min(ans, x1 + x2 + x3);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int64_t X, Y;
  cin >> X >> Y;
  int ans = 0;
  while(X <= Y){
    ans++;
    X *= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def start_coord(a)
  a.each_with_index{|hh, h|
    if w = hh.index("S")
      return [h, w]
    end
  }
end

def goal?(coord)
  coord[0] <= 0 || coord[0] >= H-1 || coord[1] <= 0 || coord[1] >= W-1
end

def f(a, k)
  start = start_coord(a)
  return 0 if goal?(start)

  visited = H.times.map{ [false]*W }

  queue = [start]
  visited[start[0]][start[1]] = true
  min = 1.0/0
  dirs = [[1,0], [-1,0], [0,1], [0,-1]]

  while !queue.empty?
    curr = queue.shift
    curr.tap{|h, w| min = [min, h, w, H-h-1, W-w-1].min }
    dirs.each{|d|
      h = curr[0] + d[0]
      next if !h.between?(0, H-1)
      w = curr[1] + d[1]
      next if !w.between?(0, W-1)
      next if a[h][w] == "#"
      next if (h-start[0]).abs + (w-start[1]).abs > k
      next if visited[h][w]
      return 1 if goal?([h,w])
      queue << [h,w]
      visited[h][w] = true
    }
  end

  1 + min.fdiv(k).ceil
end

H, W, K = gets.split.take(3).map(&:to_i)
A = H.times.map{ gets.chars.take(W) }
p f(A, K)


Measured memory_bytes: 53244
num = gets.to_i
while num > 0
	num1 = gets.to_i
	num2 = gets.to_i
	ans = num2+num1
	if ans >= 100000000000000000000000000000000000000000000000000000000000000000000000000000000 then
		puts "overflow"
	else
		puts ans
	end
	num = num - 1
end

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

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

  int r=0, g=0, b=0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'G') g++;
    if(s[i] == 'B') b++;
  }
  
  ll ans = (ll)r * (ll)g * (ll)b;
  for(int j = 1; j < n; j++){
    for(int i = 0; i < j; i++){
      int k = j+j-i;
      if(k < n){
        if(s.at(i) != s.at(j) && s.at(j) != s.at(k) && s.at(k) != s.at(i)) ans--;
      }
    }
  }
  
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
long long gcd(long long, long long);
long long lcm(long long, long long);
int main()
{
	long long A,B,C,D,num;
	long long CA,CB,DA,DB,lcmv,CDA,CDB;
	cin >> A >> B >> C >> D;
    if ((B-A)<1) { cout << 0 << endl;}
    else{
	  if (A%C == 0) { CA=A/C;	}
	  else {		CA = A/C + 1; }
	  CB = B/C;
	  num = CB-CA+1;	
	  if (A%D == 0) { DA=A/D;	}
	  else  { DA = A/D+1;}
	  DB = B/D;
	  num += DB-DA+1;

	  lcmv = lcm(C,D);
			
	  if (A%lcmv==0) { CDA = A/lcmv;}
	  else { CDA = A/lcmv +1;	}	
	  CDB = B/lcmv;
	  num -= (CDB-CDA+1);	
	
	  num = B-A+1 - num;
	  cout << num << endl;	
    }
	return 0;
}
long long gcd(long long m, long long n)
{
	if (n==0) return m;
	else gcd((m>n)?n:m, (m>n)?m%n:n%m);
}

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

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a<=c && b>=c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


    }

}


Measured memory_bytes: 21716
#include<stdio.h>

int main(void){
  int n, k, i, j, a;

  scanf("%d%d", &n, &k);

  int d[k], flag[n], cnt = n;

  for(i = 0; i < n; i++){
    flag[i] = 0;
  }

  for(i = 0; i < k ; i++){
    scanf("%d", &d[i]);
    for(j = 0; j < d[i] ; j++){
      scanf("%d", &a);
      if(flag[a-1] == 0){
        flag[a-1] = 1;
        cnt -= 1;
      }
    }
  }

  printf("%d", cnt);

  return 0;
}


Measured memory_bytes: 1732
//----------------------------------------------------------------
//L


#include <iostream>
#include <vector>
using namespace std;

// DP テーブル
long long dp[3100][3100];

int main() {
    // 入力受け取り
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // 初期条件
    for (int i = 0; i < N; ++i) dp[i][i] = 0;

    // DP
    for (int len = 1; len <= N; ++len) {
        for (int i = 0; i + len <= N; ++i) {
            int j = i + len;

            // 先手番
            if ((N - len) % 2 == 0)
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);

            // 後手番
            else
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
        }
    }

    // 答え
    cout << dp[0][N] << endl;
}



Measured memory_bytes: 50180
import Control.Applicative
import Control.Monad
main = do
  n <- readLn
  xs <- replicateM n getLine
  mapM_ putStrLn $ map solve (map (map read . words) xs)

solve :: [Int] -> String
solve xs = if a == b-a then "YES" else "NO"
  where a = (maximum xs) ^ 2; b = sum $ map (^2) xs


Measured memory_bytes: 4532
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    if(a%b == 0) return b;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}



int main(){
    cin >> H >> W >> K;
    int h = H;
    vector<vector<int>> v(W, vector<int> (H, 0));
    string str;

    REP(i, H){
        cin >> str;
        REP(j, W){
            v[j][i] = str[j] - '0';
        }
    }
    ll ans = 1e6;
    for (int bit = 0; bit < (1<<h-1); ++bit) {
        ll can = 0;
        vector<int> part;
        for (int i = 0; i < h-1; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                part.push_back(i+1);
            }
        }
        part.push_back(0);
        part.push_back(h);
        sort(ALL(part));
        can += part.size()-2;
        //for(auto u : part) cout << u << endl;

        vector<int> p(part.size()-1, 0);
        bool f = true;
        bool t  = true;
        for(int i = 0; i < W; ++i){
            for(int j = 0; j < part.size()-1; ++j){
                auto itl = v[i].begin();
                auto itr = v[i].begin();
                itl += part[j];
                itr += part[j + 1]; 
                p[j] += accumulate(itl, itr, 0);
                if(p[j] <= K) continue;
                 f = false;
            }
            //for(auto s: p) cout << s << " ";
            if(f == true) continue;
            ++can;
            for(int j = 0; j < part.size() -1; ++j){
                auto itl = v[i].begin();
                auto itr = v[i].begin();
                itl += part[j];
                itr += part[j + 1] ; 
                p[j] = accumulate(itl, itr,0);
                f = true;
            }
            for(auto u : p){if(u > K) t = false;}
        }
        if(t) ans = min(ans, can);
        //cout << can << " ";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

const int V = 101010;
vector<int> to[V * 2];
bool visited[V * 2];
vector<int> cnt;
void dfs(int v)
{
  if (visited[v])
    return;
  visited[v] = true;
  cnt[v / V]++;
  for (auto &&u : to[v])
  {
    dfs(u);
  }
}
void solve(void)
{
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    int x, y;
    cin >> x >> y;
    y += V;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  int res = 0;

  for (int i = 0; i < V * 2; i++)
  {
    if (visited[i])
      continue;
    cnt = vector<int>(2);
    dfs(i);
    res += cnt[0] * cnt[1];
  }
  res -= n;
  cout << res << endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main(){
  int N,M;
  cin>>N>>M;
  
  vector<int> a(M),b(M);
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
  }
  
  vector<int> r(N);
  for(int i=0;i<M;i++){
    r[a[i]-1]++;
    r[b[i]-1]++;
  }
  
  for(int i=0;i<N;i++){
    cout<<r[i]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

x = ni()

base = 2*(x//11)

if x%11 == 0:
    print(base)
elif 0 < x%11 <= 6:
    print(base + 1)
else:
    print(base + 2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a[3][3][2];
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> a[i][j][0];
            a[i][j][1] = 0;
        }
    }

    int N;
    cin >> N;
    int num[15];
    for (int k=0; k<N; k++) {
        cin >> num[k];
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            if (a[i][j][0] == num[k]) a[i][j][1] = 1;
        }
    }
    }
    int tate, yoko;
    for (int i=0; i<3; i++) {
        tate = a[i][0][1]+a[i][1][1]+a[i][2][1];
        yoko = a[0][i][1]+a[1][i][1]+a[2][i][1];
        if (tate == 3 || yoko == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }

    int naname,naname2;
    naname = a[0][0][1]+a[1][1][1]+a[2][2][1];
    naname2 = a[0][2][1]+a[1][1][1]+a[2][0][1];
    if (naname == 3 || naname2 == 3){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)
K = int(input())

A = set()
for i in range(N):
    for j in range(i + 1, N + 1):
        if j > i + K:
            break
        A.add(S[i:j])

A = list(A)
A.sort()
print(A[K - 1])


Measured memory_bytes: 4464
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; string s; cin >> n >> k >> s;
	s[k-1] = tolower(s[k-1]);
	println(s);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, k, ans = 0;  cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++)  cin >> h[i];
 
    for (int i = 0; i < n; i++) {
        if (h[i] >= k)  ans++;
    }
 
    cout << ans << endl;
}

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

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

using namespace std;

int main(){
	string s; cin>>s;
	int n=s.length();
	for(int l=n;;l--) rep(i,n-l+1) {
		if(regex_match(s.substr(i,l),regex("[AGTC]*"))) { cout<<l<<endl; return 0; }
	}
	return 0;
}


Measured memory_bytes: 256
using System;

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string s=Console.ReadLine();
    string t=Console.ReadLine();
      int ans=0;
      for(int i=0;i<s.Length;i++){
        if(s.Substring(i,1)!=t.Substring(i,1)){
          ans++;
        }
      }
      Console.WriteLine(ans);
    }
    
  }

}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

bool ins(int x1,int x2, int y1, int y2, int x, int y) {
	return (x >= x1 && x <= x2 && y >= y1 && y <= y2);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	vector<int> xs(n);
	vector<int> ys(n);
	vector<int> oxs(n);
	vector<int> oys(n);
	for(int i = 0; i < n; i++) {
		cin >> xs[i] >> ys[i];
		oxs[i] = xs[i];
		oys[i] = ys[i];
	}
	sort(xs.begin(),xs.end());
	sort(ys.begin(),ys.end());
	ll minarea = INF;
	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			for(int l = 0; l < n; l++) {
					for(int m = l+1; m < n; m++) {
						ll x1 = xs[i];
						ll x2 = xs[j];
						ll y1 = ys[l];
						ll y2 = ys[m];
						int inside = 0;
						for(int o = 0; o < n; o++) {
							if((oxs[o] >= x1 && oxs[o] <= x2 && oys[o] >= y1 && oys[o] <= y2)) {
								inside++;
								if(inside >= k) {
									break;
								}
							}
						}
						if(inside >= k) {
							minarea = min(minarea,(x2-x1)*(y2-y1));
						}
					}
			}
		}
	}
	cout << minarea;
	return 0;
}




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

#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair


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

    ll n,i,a;
    cin>>n;
    vector<ll> arr(n);
    for(i=0;i<n;i++)cin>>arr[i];
    sort(arr.begin(),arr.end());
    ld t=arr[0];
    for(i=1;i<n;i++){
        t=(t+arr[i])/2;
    }
    cout<<t;


    return 0;  
}

Measured memory_bytes: 256
N,M=map(int, input().split())
p=[]
for x in range(M):
    p.append(input())
A=[]
B=[]
for x in range(M):
    a,b=map(int,p[x].split())
    A.append(a)
    B.append(b)
    
isl=[]
for x in range(N):
    isl.append(0)
for x in range(M):
    if A[x]==1:
        isl[B[x]]=1
for x in range(M):
    if B[x]==N:
        isl[A[x]]=isl[A[x]]+1

if 2 in isl:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")



Measured memory_bytes: 34796
import sys
input = sys.stdin.readline
# ユニオンファインド
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,k,l=map(int, input().split())
p= [list(map(int, input().split())) for i in range(k)]
r = [list(map(int, input().split())) for i in range(l)]
uf1=UnionFind(n)
uf2=UnionFind(n)
for i in range(k):
    uf1.union(p[i][0]-1,p[i][1]-1)

for i in range(l):
    uf2.union(r[i][0]-1,r[i][1]-1)

from collections import defaultdict
p=defaultdict(int)
for i in range(n):
    a=uf1.find(i)
    b=uf2.find(i)
    p[(a,b)]+=1
ans=[]
for i in range(n):
    ans.append(p[uf1.find(i),uf2.find(i)])
print(*ans)

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

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

    auto count = 0;
    for (auto i = min(A, B); i > 0; --i)
    {
        if (A % i == 0 && B % i == 0)
        {
            if (++count == K)
            {
                cout << i << endl;
                break;
            }
        }
    }

    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)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) {
    cin >> A.at(i);
  }
  vector<bool>b(N,false);
  int m=0;
  for(int i=N-1;i>=0;i--){
    if(i>N/2-1){
      if(A.at(i)){
        b.at(i)=true;
        m++;
      }
    }
    else{
      int co=0;
      int ci=(i+1)*2;
      while(ci<=N){
        if(b.at(ci-1)){
          co++;
        }
        ci+=i+1;
      }
      if(A.at(i)&&co%2==0){
        b.at(i)=true;
        m++;
      }
      else if((!A.at(i))&&co%2==1){
        b.at(i)=true;
        m++;
      }
    }
  }
  cout<<m<<endl;
  rep(i,N){
    if(b.at(i)){
      cout<<i+1<<" ";
    }
  }
}

Measured memory_bytes: 1792
#include <vector>
#include <queue>
#include <stdio.h>
#include <iostream>

using namespace std;
const int MAXV = 10000;
const int MAXE = 100000;

int indeg[MAXV];
bool used[MAXV];
vector<int> G[MAXV];
vector<int> out;

void bfs(int start) {
  queue<int> q;
  q.push(start);
  used[start] = true;
  while (!q.empty()) {
    int cur = q.front(); q.pop();
    out.push_back(cur);
    for (int i = 0; i < G[cur].size(); ++i) {
      int v = G[cur][i];
      indeg[v]--;
      if (indeg[v] == 0 && !used[v]) {
	used[v] = true;
	q.push(v);
      }
    }
  }  
}

void topological_sort(int n) {
  for (int i = 0; i < n; ++i) indeg[i] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < G[i].size(); ++j) {
      int v = G[i][j];
      indeg[v]++;
    }
  }

  for (int i = 0; i < n; ++i) {
    if (indeg[i] == 0 && !used[i]) bfs(i);
  }
}

int main() {
  int v, e;
  scanf("%d %d", &v, &e);
  for (int i = 0; i < e; ++i) {
    int s, t;
    scanf("%d %d", &s, &t);
    G[s].push_back(t);
  }

  for (int i = 0; i < v; ++i) used[i] = false;
  topological_sort(v);
  for (size_t i = 0; i < out.size(); ++i) {
    printf("%d\n", out[i]);
  }
  return 0;
}



Measured memory_bytes: 4012
h,w = map(int,input().split())
lst1 = [list(list(input())) for i in range(h)]

def grid(i,j):
    direc = [(-1,-1),(0,-1),(1,-1),(-1,0),(1,0),(-1,1),(0,1),(1,1)] #8近傍
    res = 0
    for xy in direc:
        if 0 <= i+xy[1] < h and 0 <= j+xy[0] < w \
            and lst1[i+xy[1]][j+xy[0]] == "#":
            res += 1
    lst1[i][j] = str(res)

for i in range(h):
    for j in range(w):
        if lst1[i][j] ==".":
            grid(i,j)

for i in lst1:
    print("".join(i))

Measured memory_bytes: 42644
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

typedef long double ld;


int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> a(n);
  map <int, int> cnt;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  ll ans = 0;
  for (auto to : cnt) {
    ans += (to.second) * (ll) (to.second - 1) / 2;
  }
  ll tmp = ans;
  for (int i = 0; i < n; i++) {
    ans -= (cnt[a[i]]) * (ll) (cnt[a[i]] - 1) / 2;
    cnt[a[i]]--;
    ans += (cnt[a[i]]) * (ll) (cnt[a[i]] - 1) / 2;
    cout << ans << '\n';
    cnt[a[i]]++;
    ans = tmp;
  }
  return 0;
}

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

int main() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  if (A > K) {
    cout << K << endl;
  }
  else if (A <= K && K < A+B) {
    cout << A << endl;
  }
  else {
    cout << A - (K - (A+B)) << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"
#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"

int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

int main(){
  int N; scanf("%d",&N);
  int a[N];
  int m1 = 0;
  int m2 = 0;
  REP(i,N){
    int t;
    scanf("%d",&t);
    if(m1<=t){
      m2 = m1;
      m1 = t;
    }else if(m2<t){
      m2 = t;
    }
    a[i] = t;
  }
  REP(i,N){
    if(a[i]==m1) printf("%Ld\n",m2);
    else printf("%Ld\n",m1);
  }
}

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

int main()
{
    string s; cin >> s;
    cout << s[0]+to_string(s.size()-2)+s[s.size()-1] << endl;
}

/*
Ctrl+@
g++ a.cpp
./a.out
*/

Measured memory_bytes: 256
#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);
    const ll mod = 1e9 + 7;
    string s;
    cin >> s;

    ll ans = 1;
    ll pow = 2;
    for (char c : s)
    {
        if (c == '1')
            ans *= 3, ans %= mod, pow *= 2, pow %= mod;
        else
            ans = (ans * 3 + mod - pow) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main (void){
  int n,k,d[100],a,i,j,ans[100],aans=0;
  
  for(i=0;i<100;i++){for(j=0;j<100;j++){a=0;}ans[i]=0;}
  
  scanf("%d%d",&n,&k);
  for(i=0;i<k;i++){
    scanf("%d",&d[i]);
    for(j=0;j<d[i];j++){
      scanf("%d",&a);
      ans[a-1]=1;
    }  
  }  
  for(i=0;i<n;i++){
    if(ans[i]==0){aans++;}}
  printf("%d\n",aans);
}

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

int main() {
	int N, d;
	cin >> N;
	vector<int> vec;
	int total = 1;
	for (int i = 0; i < N; i++) {
		cin >> d;
		vec.push_back(d);
	}
	sort(vec.begin(), vec.end());
	for (int j = 0; j < N - 1; j++) {
		if (vec.at(j) < vec.at(j + 1)) {
			total++;
		}
	}
	cout << total << endl;
}


Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	rep(i, sx, tx) cout << 'R';
	rep(i, sy, ty) cout << 'U';
	rep(i, sx, tx) cout << 'L';
	rep(i, sy, ty) cout << 'D';
	cout << 'D';
	rep(i, sx, tx + 1) cout << 'R';
	rep(i, sy, ty + 1) cout << 'U';
	cout << 'L' << 'U';
	rep(i, sx, tx + 1) cout << 'L';
	rep(i, sy, ty + 1) cout << 'D';
	cout << 'R' << endl;
	system("pause");
}

Measured memory_bytes: 504
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		char[] a = new char[s.length+1];
		int p=0;
		for (i = 0; i < s.length; i++) {
			if(s[i]=='B') {
				if(p>0) {
					p--;
					a[p]='\u0000';
				}
			} else {
				a[p]=s[i];
				p++;
			}
		}
		for (i = 0; a[i] != '\u0000'; i++) {
			out.print(a[i]);
		}
		out.println();
	}
}


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

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

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif

int main(void)
{
	ll n, k, q; cin >> n >> k >> q;

	vector<ll> a(q);
	rep(i, 0, size(a))
	{
		cin >> a[i];
		a[i]--;
	}

	vector<ll> ok(n);
	rep(i, 0, q)
		ok[a[i]]++;


	rep(i, 0, size(ok))
	{
		if (k -(q - ok[i]) <= 0)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 2176
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	var s string
	list := make([]string, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&s)
		list[i] = s
	}

	m := make(map[string]struct{})

    newList := make([]string, 0)

    for _, element := range list {
        if _, ok := m[element]; !ok {
            m[element] = struct{}{}
            newList = append(newList, element)
        }
	}
	
	fmt.Println(len(newList))
}


Measured memory_bytes: 35628
//#i#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

bool in_table(int x){
	return 0<=x && x<8;
}

void put_q(vector<vector<bool>> &ju, int x, int y){
	rip(i,8,0){
		ju[x][i] = true;
		ju[i][y] = true;
		if(in_table(x+y-i)) ju[x+y-i][i] = true;
		if(in_table(x+i-y)) ju[x+i-y][i] = true;
	}
}

bool dfs(vector<string> &da, vector<vector<bool>> &ju, vector<int>&ans, int now){
	//cout << now << endl;
	if(now == 8) return true;
	if(ans[now] != -1){
		if(ju[now][ans[now]]){
			return false;
		}
		put_q(ju, now, ans[now]);
		return dfs(da, ju, ans, now+1);
	}
	rip(i,8,0){
		if(!ju[now][i]){
			auto next = ju;
			put_q(next, now, i);
			if(dfs(da, next, ans, now+1)){
				ans[now] = i;
				return true;
			}
		}
	}
	return false;
}

int main(){
	vector<string> da(8,"");
	rip(i,8,0) rip(j,8,0) da[i] += ".";
	int n;
	cin >> n;
	rip(i,n,0){
		int x,y;
		cin >> x >> y;
		da[x][y] = 'Q';
	}
	vector<vector<bool>> ju(8, vector<bool>(8));
	vector<int> ans(8, -1);
	rip(i,8,0) rip(j,8,0) if(da[i][j] == 'Q') ans[i] = j;
	rip(i,8,0){
		int co = 0;
		rip(j,8,0) if(da[i][j] == 'Q') co++;
		if(co >= 2){
			cout << "No Answer\n";
			return 0;
		}
		co = 0;
		rip(j,8,0) if(da[j][i] == 'Q') co++;
		if(co >= 2){
			cout << "No Answer\n";
			return 0;
		}
	}
	if(dfs(da, ju, ans, 0)){
		//vdeb(ans);
		rip(i,8,0){
			rip(j,8,0){
				if(ans[i] == j) cout << 'Q';
				else cout << '.';
			}
			cout << endl;
		}
		return  0;
	}
	else{
		cout << "No Answer\n";
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
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 true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

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

vector<int> divisor(int n) {
  vector<int> ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

ll n, k;
vector<ll> la;
vector<ll> lf;

// index が条件を満たすかどうか
bool isOK(ll key) {
  ll cost = 0;
  for (int i = 0; i < n; ++i) {
    ll p = key/lf[i];
    // cout << key << " " << la[i] << " " << lf[i] << " " << p << endl;
    if (p < la[i]) cost += la[i]-p;
    if (cost > k) return false;
  }
  return true;
}

// 汎用的な二分探索のテンプレ
ll binary_search(ll ng, ll ok) {
    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        // cout << ng << " " << ok << " " << mid << " " << isOK(mid) << endl;

        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

typedef long long ll;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    la.push_back(a);
  }
  for (int i = 0; i < n; ++i) {
    ll f;
    cin >> f;
    lf.push_back(f);
  }
  sort(la.begin(), la.end());
  sort(lf.begin(), lf.end(), greater<ll>());
  ll m = 0;
  for (int i = 0; i < n; ++i) {
    m = max(m, la[i]*lf[i]);
  }
  // cout << m << endl;
  ll ans = binary_search(-1, m+1);
  cout << ans << endl;
}


Measured memory_bytes: 4848
#include <stdio.h>

int main(void)
{
	int n, m, c;
	int b[20];
	int cnt = 0;
	int i, j;
	
	scanf("%d %d %d", &n, &m, &c);
	for(i=0; i<m; i++)
		scanf("%d", &b[i]);
	
	for(i=0; i<n; i++){
		int sum  = 0;
		
		for(j=0; j<m; j++){
			int a;
			scanf("%d", &a);
			sum += b[j]*a;
		}
		
		if(sum+c > 0)
			cnt++;
	}

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


	return 0;
}

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

int main() {
    ll n;
    cin>>n;
    if(n>=100 && n<=111){
        cout<<111;
    }
    if(n>111 && n<=222){
        cout<<222;
    }
    if(n>222 && n<=333){
        cout<<333;
    }
    if(n>333 && n<=444){
        cout<<444;
    }
    if(n>444 && n<=555){
        cout<<555;
    }
    if(n>555 && n<=666){
        cout<<666;
    }
    if(n>666 && n<=777){
        cout<<777;
    }
    if(n>777 && n<=888){
        cout<<888;
    }
    if(n>888 && n<=999){
        cout<<999;
    }
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

map<char,int> mp = {{'R',0},{'G',1},{'B',2}};

ll cnt[3][4040];

int main(void)
{
  ll n;
  string s;
  ll ans = 0;
  cin >> n >> s;
  cnt[0][n] = cnt[1][n] = cnt[2][n] = 0;
  for(ll i = n - 1; i >= 0; i--) {
    REP(j, 3) cnt[j][i] = cnt[j][i+1];
    cnt[mp[s[i]]][i] ++;
  }

  REP(i, n - 2) {
    for(ll j = i + 1; j < n - 1; j++) {
      if(s[i] != s[j]) {
	ll c3 = 3 - mp[s[i]] - mp[s[j]];
	ans += cnt[c3][j+1];
	ll k = j + j - i;
	if(k < n && mp[s[k]] == c3) ans --;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int main(){
    long long  k; cin >> k;


    
    long long aprev = 0;
    long long a;
    set<int> res;
    long long cnt=1;
    for(int ix=1;ix<=k;ix++){
        a = aprev*10 + 7;
        if(a%k == 0){
            cout << ix << endl;
            return 0;
        }
        //res.insert(a%k);
        aprev = (a%k);
        //cnt++;
        //if(res.size() >= k) break;
    }
    cout << -1 << endl;
    
}

Measured memory_bytes: 3600
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair

signed main()
{

	fast;
	cout<<fixed<<setprecision(6);
////////////////////////////////////////////////////////////////////////////////////////////
	
	ld t, x;
	cin >> t >> x;
	cout<<t/x<<endl;






	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define MAX_N 100000

using namespace std;

int main(void){
	int n, ans;
	bool prime[MAX_N + 1];

	fill(prime,prime + MAX_N + 1,true);
	prime[0] = prime[1] = false;
	for(int i = 2;i * i <= MAX_N;i++){
		if(prime[i]){
			for(int j = i * 2;j <= MAX_N;j+=i){
				prime[j] = false;
			}
		}
	}

	while(1){
		cin >> n;
		if(cin.eof()){
			break;
		}
		ans = 0;
		for(int i = 1;i <= n;i++){
			if(prime[i] && prime[n + 1 - i]){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int a[210];
int n;
int main(){
  int res = 0;
  cin >> n;
  for(int i = 0 ; i < n ; ++i )  cin >> a[i] ;
  while(true){
    bool odd = false;
    for(int j = 0; j < n; ++j){
      if(a[j] % 2 != 0) odd = true;
    }
    if(odd) break; 
    for(int i = 0;i < n; ++i){
      a[i] /= 2;
    }
    ++res;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <locale>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
    vector<string> ans;
    while (1)
    {
        string cards;
        int n;
        cin >> cards;
        if (cards == "-")
            break;
        cin >> n;
        rep(i, n)
        {
            int h;
            cin >> h;
            string s = cards.substr(h);
            cards = s + cards.erase(h);
        }
        ans.push_back(cards);
    }

    for (vector<string>::iterator itr = ans.begin(); itr != ans.end(); ++itr)
    {
        cout << *itr << endl;
    }
}


Measured memory_bytes: 3172