akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll n;
  cin >> n;
  ll a[n];
  REP(i, n) cin >> a[i];
  SORT(a, n);

  ll s1 = 0, s2 = 0;

  if(n % 2){
    REP(i, n / 2){
      s1 -= 2 * a[i];
      s2 += 2 * a[n - 1 - i];
    }
    REP(i, n / 2 - 1){
      s1 += 2 * a[n - 1 - i];
      s2 -= 2 * a[i];
    }
    s1 += (a[n / 2] + a[n / 2 + 1]);
    s2 -= (a[n / 2 - 1] + a[n / 2]);
  }
  else{
    REP(i, n / 2 - 1){
      s1 += 2 * a[n - 1 - i];
      s1 -= 2 * a[i];
    }
    s1 += (- a[n / 2 - 1] + a[n / 2]);
  }
  ll ans = max(s1, s2);
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int n;

ll modpow(ll x, ll y) {
  ll v = 1;
  REP(i,y) {
    v *= x; v %= MOD;
  }
  return v;
}

// 包除原理解法
void solve1() {
  ll p1 = modpow(10, n);
  ll p2 = (modpow(9, n) * 2) % MOD;
  ll p3 = modpow(8, n);
  ll ans = p1 - (p2 - p3);
  ans %= MOD;
  ans = (ans + MOD) % MOD;
  COUT(ans);
}

// DP解法
// dp[桁数][0,9使用状況]
int dp[1000000][1<<2];
void solve2() {
  dp[0][0] = 1;
  REP(i,n) {
    REP(j,1<<2) {
      REP(d,10) {
        int nj = j | ( d == 0 ? 1 : 0 ) | ( d == 9 ? 2 : 0 );
        dp[i+1][nj] += dp[i][j];
        dp[i+1][nj] %= MOD;
      }
    }
  }
  COUT(dp[n][3]);
}

int main() {
  IOS;
  cin >> n;
  // solve1();
  solve2();
  return 0;
}

Measured memory_bytes: 19128
// util
let scanInts () = stdin.ReadLine().Split() |> Array.map int
let scanIntsML n = [ for i in 1..n -> scanInts () ]
let frceil a b = a/b + (if a % b = 0 then 0 else 1)
let rec powerset = function
  | [] -> [[]]
  | x::xs -> let ps = powerset xs in ps @ List.map (List.append [x]) ps
 
// main
let [|D;G|] = scanInts ()
 
let alltup = // (point, num, bonus) ボーナス抜きのコスパで並べる
  scanIntsML D
  |> List.mapi (fun i a -> ((i+1)*100, a.[0], a.[1])) 
  |> List.rev // 
 
// 完全回答組が与えられたとき 中途を（必要があれば）一つ選んで総回数を返す
let tryAnswer atups ctups =
  let cnt = List.sumBy (fun (_,n,_) -> n) ctups
  let scr = List.sumBy (fun (p,n,b) -> b+p*n) ctups
  match G - scr with
    | tgt when tgt <= 0 -> Some(cnt) // 中途を選ぶ必要がない
    | tgt ->
        atups // 完全組でなく, 単独で目標を達成しうるものの 先頭
        |> List.filter (fun t -> not (List.contains t ctups))
        |> List.filter (fun (p,n,_) -> tgt <= p*(n-1))
        |> List.tryHead // コスパソート済みなので先頭でよい
        |> Option.map (fun (p,n,_) -> cnt + (frceil tgt p))

alltup
|> powerset
|> List.choose (tryAnswer alltup)
|> List.min
|> printfn "%d"


Measured memory_bytes: 17244
#include <iostream>

using namespace std;
int main() {
	char input[100];
	int i = 0;
	cin >> input;
	if (input[0] == input[1] || input[1] == input[2] || input[2] == input[3]) {
		i++;
	}
	 if (i == 0) {
		cout << "Good" << endl;
	}
	else if (i != 0) {
		cout << "Bad" << endl;
	}
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool flag = true;

    for(int i=0; i<n; i++){
        if(i%2){
            if(s[i]=='R'){
                flag = false;
                break;
            }
        }else{
            if(s[i]=='L'){
                flag = false;
                break;
            }
        }
    }

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


    return 0;
}

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

#define ASC(a) a.begin(), a.end()		// 昇順ソート 例：sort(ASC(a));
#define DESC(a) a.rbegin(), a.rend()	// 降順ソート 例:sort(DESC(a));
//#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep(i, a, n) for(int i = a; i < n; ++i)
#define Rep(i, n) for(int i = 1; i < n; ++i)
#define In(a) rep(i, n) cin>>a[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;
#define only_unique(vec) vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
#define souwa(vec) accumulate(ASC(vec), 0)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };


// ────────────────────────────────────────────────────
int N, K, X[3010], Y[3010];
//---------------------------------------------------------------------------------------------------
int  main() {
	cin >> N >> K;
	rep(i, 0, N) cin >> X[i] >> Y[i];

	vector<pair<double, double>> cnt;
	rep(a, 0, N) rep(b, a, N) if (X[a] != X[b]) {
		int a_up = Y[a] - Y[b];
		int a_dn = X[a] - X[b];

		int b_up = (X[a] * Y[b] - X[b] * Y[a]);
		int b_dn = X[a] - X[b];

		double aa = 1.0 * a_up / a_dn;
		double bb = 1.0 * b_up / b_dn;

		cnt.push_back({ aa, bb });
	}
	sort(ASC(cnt));

	int ma = 0;
	rep(i, 0, cnt.size()) {
		int found = 0;
		rep(j, i + 1, cnt.size()) if (cnt[i] != cnt[j]) {
			chmax(ma, j - i);
			i = j - 1;
			found = 1;
			break;
		}
		if (!found) {
			chmax(ma, (int)cnt.size() - i);
			break;
		}
	}

	int Kma = K * (K - 1) / 2;
	if (Kma <= ma) {
		printf("1\n");
		return 0;
	}

	map<int, int> cnt2;
	rep(i, 0, N) cnt2[X[i]]++;
	for(auto p : cnt2) if (K <= p.second) {
		printf("1\n");
		return 0;
	}

	printf("0\n");
}



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

int main()
{
    int N, K;
    int p[200005];
    double sum[200005];
    double ans;
    cin >> N >> K;
    REP(i, N)
        cin >> p[i];
    sum[0] = 0.0;
    REP(i, N)
        sum[i+1] = sum[i] + ((double)p[i] + 1.0)/2.0;
    
    ans = 0.0;
    REP(i, N-K+1){
        if(ans < (sum[K+i]-sum[i]))
            ans = sum[K+i] - sum[i];
    }
    cout << fixed;
    cout << setprecision(8) << ans << endl;
    
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  string S, T; cin >> S >> T;
  ll SZ = S.size();
  REP(d, SZ) {
    bool ok = true;
    REP(i, SZ) {
      ok = ok && S[i] == T[(i+d)%SZ];
    }
    if (ok) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#define r(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#include <cmath>
#include <fstream>
#define f first
#define endl "\n"
#define s second
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a))
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
char _;
int l,r,d;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int ans=0;
	cin>>l>>r>>d;
	for(int i=l;i<=r;i++){
		if(i%d==0) ans++;
	}
	cout << ans << endl;
			
	return 0;
}



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

int main(void){
    // Your code here!
   int a, b;
   cin >> a >> b;
   if(a == 2 && b ==2){
       cout << "Yes" << endl;
   } else if((a == 4 || a == 6 || a == 9 || a == 11) && (b == 4 || b == 6 || b == 9 || b == 11)){
       cout << "Yes" << endl;
   } else if((a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12) &&(b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12)){
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int calc(int x, int y, int z) {
  return x*x+y*y+z*z+x*y+y*z+z*x;
}

const int MAX = 10010;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> res(MAX);
  rep(i, 100) rep(j, 100) rep(k, 100) {
    if (!i || !j || !k)
      continue;
    int num = calc(i, j, k);
    if (num < MAX)
      res[num]++;
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cout << res[i] << '\n';
  return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int a = Integer.parseInt(br.readLine());

		String result = "AGC";
		if(a < 1200){
			result = "ABC";
		}
		else if (a < 2800){
			result = "ARC";
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 21332
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,ans=0; cin>>n;
    vector<vector<ll>> d(n,vector<ll>(n,0));
    rep(i,n)rep(j,n){
        cin>>d[i][j];
        ans+=d[i][j];
    }
    rep(i,n)rep(j,n){
        if(i==j) continue;
        rep(k,n){
            if(i==k || j==k) continue;
            if(d[i][j]>d[i][k]+d[k][j]){
                cout<<-1<<endl;
                return 0;
            }
            if(d[i][j]==d[i][k]+d[k][j]){
                ans-=d[i][j];
                break;
            }
        }
    }
    cout<<ans/2<<endl;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from collections import deque

def rec(n, k, ans):
    print(ans)
    ans.append(int(k))
    if len(k) >= n:
        return
    d = int(k[-1])
    if d > 0:
        rec(n, k + str(d-1), ans)
    rec(n, k + str(d), ans)
    if d < 9:
        rec(n, k + str(d+1), ans)

def main():
    n = int(input().strip())
    # v = list(map(int, input().strip().split()))
    # ans = []
    # for j in range(13):
    #     for i in range(1, 10):
    #         rec(j, str(i), ans)
    # print(ans)
    c = 0
    q = deque()
    for i in range(1, 10):
        q.append(str(i))
    while len(q) > 0:
        d = q.popleft()
        c += 1
        if c == n:
            print(d)
            return
        if int(d[-1]) > 0:
            q.append(d + str(int(d[-1])-1))
        q.append(d + d[-1])
        if int(d[-1]) < 9:
            q.append(d + str(int(d[-1])+1))
    # for i in range(1, 7):
    #     ans = []


if __name__ == '__main__':
    main()


Measured memory_bytes: 70108
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#include <map>
#define rep(i, n) for (int i=0; i<n; ++i)
#define FOR(i, a, b) for (int i=a; i<b; ++i)
#define pb(x) push_back(x)
#define ll long long
#define ul unsigned long long
#define dbg(x) cout  << #x << " : " << (x) << endl
#define out(x) cout << (x)
#define outl(x) cout << (x) << endl
#define int(n); int n; cin >> n;
#define long(n); long long n; cin >> n;
#define dbl(f); double f; cin >> f;
#define s(s); string s; cin >> s;
#define into(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
using namespace std;

const int inf =1000000000;

int h,w,n;
char f[1000][1000];
int d[1000][1000];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int gx[10],gy[10];
typedef pair<int, int> P;

int bfs(int sx, int sy, int l) {
  queue<P> q; 
  rep(i, h) rep(j, w) d[j][i]=inf;
  q.push(P(sx, sy));
  d[sx][sy]=0;
  while(q.size()) {
    P p=q.front(); q.pop();
    if (p.first==gx[l]&&p.second==gy[l]) break;
    rep(i, 4) {
      int nx=p.first+dx[i], ny=p.second+dy[i];
      if (nx>=0&&n<w&&ny>=0&&ny<h&&f[nx][ny]!='X'&&d[nx][ny]==inf) {
        q.push(P(nx,ny));
        d[nx][ny]=d[p.first][p.second]+1;
      }
     }
  }
  return d[gx[l]][gy[l]];
} 

int main () {
  cin>>h>>w>>n;
  ll cnt=0;
  rep(i,h) {
    rep(j,w) {
      cin>>f[j][i];
      if (f[j][i]=='S') {gx[0]=j;gy[0]=i;f[j][i]='.';}
      if (f[j][i]!='.'&&f[j][i]!='X') {
        gx[(int)(f[j][i]-'0')]=j;
        gy[(int)(f[j][i]-'0')]=i;
        f[j][i]='.';
      }
    }
  }
  rep(i, n) {
    cnt+=bfs(gx[i], gy[i], i+1);
  }
  outl(cnt);
  return 0;
}

Measured memory_bytes: 6096
N = gets.to_i
A = gets.split.map(&:to_i)

ans = {}
A.each_with_index do |a, i|
  # puts "#{N-a}: #{i+1}"
  ans[a-1] = i + 1
end

N.times do |i|
  if i == N-1
    puts "#{ans[i]}"
  else
    print "#{ans[i]} "
  end
end


Measured memory_bytes: 17796
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;
int x[10][10];

int main(){
    int n,d;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++)cin>>x[i][j];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j){
                int sum=0;
                for(int k=0;k<d;k++){
                    sum+=pow(abs(x[i][k]-x[j][k]),2);
                }
                bool flag=false;
                for(int l=1;l*l<=sum;l++){
                    if(l*l==sum)flag=true;
                }
                if(flag)ans++;
            }
        }
    }
    cout<<ans/2<<endl;
}
 
   

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;



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

    string s, t; cin>>s>>t;
    int cnt = 0;
    for (int i=0; i<s.size(); ++i)
        if (s[i] != t[i]) cnt++;
    cout<<cnt;
}


Measured memory_bytes: 3804
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main(){
  string s;
  cin>>s;
  int c=0;
  string a;
  rep(i,(int)s.size()){
    if(s[i]=='Z' || s[i]=='A')a+=s[i];
  }
  string ans;
  rep(i,(int)a.size()-1){
    if(a[i]=='A' && a[i+1]=='Z'){
      ans+="AZ";
      c++;
    }
  }
      
  if(c==0)cout<<"-1"<<endl;
  else cout<<ans<<endl;
  
  return 0;
}

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

using namespace std;


int main()
{
	int a;
	int b;
	int res = 0;
	cin >> a >> b;
		if (a >= 0 && b >= 0)
	{
		if (a > b)
		{
			res += 2;
			res += abs(a - b);
			if (b == 0)
			{
				res -= 1;
			}
		}
		else
		{
			res += abs(a - b);
		}
	}
	if (a < 0 && b >= 0)
	{
			res += 1;
			res += abs(a + b);
				if (b == 0)
			{
				res -= 1;
			}
	}
	if (a >= 0 && b < 0)
	{
		res += 1;
		res += abs(a + b);
	}
	if (a < 0 && b < 0)
	{
		if (abs(a) < abs(b))
		{
			res += 2;
			res += abs(a - b);
		}
		else
		{
			res += abs(a - b);
		}
	}
	cout << res;
	return 0;
}
//s.earase(s.beigin()+makan)

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


struct UnionFind {
    vector<int> par;
    vector<size_t> siz;

    UnionFind(int N) : par(N), siz(N, 1)
    {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x)
    {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;

        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    size_t size(int x)
    {
        return siz[root(x)];
    }
};

///////////////////////////////////////////////////

int main()
{
    int N, M;
    io >> N >> M;
    
    UnionFind uft(N);
    for (int i = 0; i < M; i++)
    {
        int a, b;
        io >> a >> b;
        uft.unite(a-1, b-1);
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans = max<int>(ans, uft.size(i));
    }
    cout << ans << BR;
}

Measured memory_bytes: 5644
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    int result = 0;
    for (int i = 0; i < 2; ++i) {
        if (a > b) {
            result += a;
            --a;
        } else {
            result += b;
            --b;
        }
    }
    cout << result << '\n';
}


Measured memory_bytes: 256
def main():
    roads = [[] for _ in range(4)]
    for _ in range(3):
        a, b = map(lambda x: int(x) - 1, input().split())
        roads[a].append(b)
        roads[b].append(a)
    length = [0, 0, 0, 0]
    for r in roads:
        length[len(r)] += 1
    print("YES" if length == [0, 2, 2, 0] else "NO")


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
signed main(){
    double ans = 0;
    int n;
    cin >> n;
    rep(i,n){
        double x;
        string s;
        cin >> x >> s;
        if(s=="JPY"){
            ans += x;
        }else{
            ans += 380000.0 * x;
        }
    }
    printf("%.6lf\n", ans);
    return 0;
}

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

typedef long long ll;

ll MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> A(N), p, m;
    rep(i, N) {
        cin >> A[i];
        if (A[i] > 0) p.push_back(A[i]);
        else m.push_back(A[i]);
    }
    if (K == N) {
        ll ans = 1;
        rep(i, N) {
            ans = (ans * (A[i] + MOD)) % MOD;
        }
        cout << ans << "\n";
        return 0;
    }
    sort(p.begin(), p.end());
    sort(m.begin(), m.end());
    if (K % 2) {
        if (p.size() == 0) {
            ll ans = 1;
            rep(i, K) {
                ans = (ans * (m[m.size() - 1 - i] + MOD)) % MOD;
            }
            cout << ans << "\n";
            return 0;
        }
        ll ans = p[p.size() - 1];
        vector<ll> v;
        rep(i, (p.size() - 1) / 2) {
            v.push_back(p[p.size() - 2 - i * 2] * p[p.size() - 3 - i * 2]);
        }
        rep(i, m.size() / 2) {
            v.push_back(m[i * 2] * m[i * 2 + 1]);
        }
        sort(v.begin(), v.end());
        rep(i, K / 2) {
            ans = (ans * (v[v.size() - 1 - i] % MOD)) % MOD;
        }
        cout << ans << "\n";
    } else {
        ll ans = 1;
        vector<ll> v;
        rep(i, p.size() / 2) {
            v.push_back(p[p.size() - 1 - i * 2] * p[p.size() - 2 - i * 2]);
        }
        rep(i, m.size() / 2) {
            v.push_back(m[i * 2] * m[i * 2 + 1]);
        }
        sort(v.begin(), v.end());
        rep(i, K / 2) {
            ans = (ans * (v[v.size() - 1 - i] % MOD)) % MOD;
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 8048
#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() {
  string s;
  cin >> s;
  int a=s.at(0)-'0';
  int l=s.size();
  bool ch=true;
  rep2(i,1,l){
    if(s.at(i)!='9'){
      ch=false;
      break;
    }
  }
  if(ch){
    int ans=a+9*(l-1);
    cout<<ans<<endl;
  }
  else{
    int ans=a-1+9*(l-1);
    cout<<ans<<endl;
  }
 
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int a, b, i, n;
  char s[12];
  scanf("%d %d", &a, &b);
  scanf("%s", &s);
  
  if (strlen(s) != a + b + 1) {
    printf("No\n");
    return 0;
  }
  
  if (s[a] != '-') {
    printf("No\n");
    return 0;
  }
  
  for (i = 0; i < a; ++ i) {
    n = s[i] - '0';
    if (n < 0 || n > 9)  {
      printf("No\n");
      return 0;
    }
  }
  
  for (i = a + 1; i < a + b + 1; ++ i) {
    n = s[i] - '0';
    if (n < 0 || n > 9)  {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 1656
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
       break

    for h in range(H):
        for w in range(W):
            if (h + w) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')

        print()
    print()
        

Measured memory_bytes: 8964
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int **ar = new int*[n];
    for(int i = 0;i < n;i++)
    {
        ar[i] = new int[3];
        for(int j = 0;j< 3;j++)
        cin>>ar[i][j];
    }
    int **dp = new int*[n];
    for(int i = 0;i < n;i++)
    {
        dp[i] = new int[3];
        for(int j = 0;j < 3;j++)
        dp[i][j] = 0;
    }
    dp[n-1][0] = ar[n-1][0];
    dp[n-1][2] = ar[n-1][2];
    dp[n-1][1] = ar[n-1][1];
    for(int i = n-2;i >= 0;i--)
    {
        for(int j = 0;j < 3;j++)
        {
            dp[i][j] = max(dp[i+1][(j+1)%3],dp[i+1][(j+2)%3]) + ar[i][j];
        }
    }
    cout<<max(dp[0][0],max(dp[0][1],dp[0][2]));
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n, k; cin >> n >> k;
	double ans = 0;
	for (int i = 1; i <= n; ++i) {
		double p = 1. / n;
		int score = i;
		while (score != 0 and score <= k - 1) {
			p *= 1. / 2;
			score *= 2;
		}
		ans += p;
	}
	printf("%.12f\n", ans);
	return 0;
}


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

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

    long long N;
    cin >> N;

    long long ans = 0;
    for (long long i=1; i*i<=N; ++i) {
        if (N % i == 0) {
            long long t = (N-i)/i;
            if (t > 0 && N / t == (N % t)) {
                ans += t;
            }

            if (i*i == N && (N/i) <= 0) continue;
            long long u = (N - N / i) / (N / i);
            if (u > 0 && N / u == (N % u)) {
                ans += u;
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int H,W,a,b,c=0;
	while(1){
		scanf("%d %d",&H,&W);
		if(c==1){printf("\n");}
		else{c=1;}
		for(a=0;a<H;a++){
			for(b=0;b<W;b++){
				printf("#");
			}
			printf("\n");
		}
		if(H==0&&W==0){
			break;}
	}
	return 0;

}

Measured memory_bytes: 2604
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int n, m;

int main() {
	cin >> n >> m;
	vector<pair<int, int>> ba;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		ba.push_back({ b, a });
	}
	sort(ba.begin(), ba.end());
	int ans = 1, x = ba[0].first - 1;
	for (int i = 0; i < m; i++) {
		if (x < ba[i].second) {
			ans++;
			x = ba[i].first - 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;
typedef  long long LL;
const int maxn=50+5;

int max(int a,int b)
{
    if(a<b)
        return b;
    return a;
}

/*LL gcd(LL a,LL b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
LL lcm(LL a,LL b)
{
    return a/gcd(a,b)*b;
}*/
int cmp(int a,int b)
{
    return a<b;
}
int main()
{
    LL n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    if(a>b)cout<<"0"<<endl;
    else
    {
        if(n==1){
            if(a==b)cout<<"1"<<endl;
            else cout<<"0"<<endl;
        }
            else
            {
                LL sum1=a*(n-1)+b;
                LL  sum2=a+(n-1)*b;
                cout<<sum2-sum1+1<<endl;
            }
        }
    return 0;
}


Measured memory_bytes: 256
N ,Y = map(int, input().split())

flg = True

for x in range(N+1):
    for y in range(N-x+1):
        z = N - (x + y)
        if 10000 * x + 5000 * y + 1000 * z == Y:
            ans = [x, y, z]
            flg = False
            break

if flg:
    ans = [-1, -1, -1]

print(' '.join(map(str, ans)))

Measured memory_bytes: 40812
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll n,m,i,j,k,l,t,a,b,c,d;
stack<ll>q;
int main()
{
    string cc;
    cin >> cc;
   if(cc[1]=='R')
    printf("ABC\n");
   else
    printf("ARC\n");
}


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

int INF=1e9;


int main(){
    while(true){
        vector<vector<int>> T(1000,vector<int>(1000,INF)); 
        vector<vector<int>> C(1000,vector<int>(1000,INF));
        int n,m;
        cin>>n>>m;
        if(n==0&&m==0) break;
        
        for(int i=0;i<n;i++){
            int a,b,Cost,Time;
            cin>>a>>b>>Cost>>Time;
            T[a][b]=Time;
            C[a][b]=Cost;
            T[b][a]=Time;
            C[b][a]=Cost;
        }

        
        int k;
        cin>>k;
        for(int i=0;i<k;i++){
            vector<int> d(1000,INF);
            vector<bool>  u(1000,false);
            int p,q,r;
            cin>>p>>q>>r;
            d[p]=0;
            
            if(r){
                while(true){
                    int v=-1;
                    for(int j=1;j<=m;j++){
                        if(u[j]) continue;
                        if(v==-1||d[j]<d[v]) v=j;
                    }

                    if(v==-1) break;
                    u[v]=true;

                    for(int l=1;l<=m;l++){
                        if(d[l]>d[v]+T[v][l]){
                            d[l]=d[v]+T[v][l];
                        }
                    }
                }
                cout<<d[q]<<endl;   
            }else{
                while(true){
                    int v=-1;
                    for(int j=1;j<=m;j++){
                        if(u[j]) continue;
                        if(v==-1||d[j]<d[v]) v=j;
                    }

                    if(v==-1) break;
                    u[v]=true;

                    for(int l=1;l<=m;l++){
                        if(d[l]>d[v]+C[v][l]){
                            d[l]=d[v]+C[v][l];
                        }
                    }
                }
                cout<<d[q]<<endl;      
            }
            
        }
    }

    return 0;
}


Measured memory_bytes: 10716
lst = [int(input()) for i in range(5)]
i1,i2 = 0,0
for i,x in enumerate(lst):
    i3 = 10 - (x % 10)
    if i3 >= i1 and not(i3 == 10):

        i1 = i3
        i2 = i


lst.append(lst.pop(i2))

ans = 0
for i in range(4):

    if lst[i] % 10 == 0:
        ans = ans + lst[i]

    else:
        ans = ans + ((lst[i] // 10 + 1)*10)


print(ans+lst[-1])

Measured memory_bytes: 3064
#include <stdio.h>

int main( void )
{
	int n, i, j, p, a=0, b=0, c;
	scanf("%d", &n);
	for( i=1; i<=n; i++ ){
		scanf("%d", &p);
		a = a + p;
		if( b < p )
			b = p;
	}
	c = b / 2;
	a = a - c;
	printf("%d\n", a);
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;


ull E = 1000000007;

int main() {
    ull a, b, x;
    cin >> a >> b >> x;
    ull ans = (b / x) - (a / x) + 1 - (a % x != 0);
    cout << ans << endl;
}


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

main(){
    int long long N,K;
    cin>>N;
    cin>>K;
    int long long b=0;
    int long long ans=0;
    for(b=(K+1);b<=N;b++){
        ans+=(N/b)*(b-K);
        if(N%b>=K&&K!=0) ans+=((N%b)-K+1);
        else if(K==0) ans+=(N%b);
    }
    cout<<ans;
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
a = Array.new(h) { gets.chomp.chars }
count = 0

h.times do |i|
  w.times do |j|
    count += 1 if a[i][j] == '#'
  end
end

puts (count == h + w - 1) ? :Possible : :Impossible

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string sa,sb,sc; cin >> sa >> sb >> sc;

  const int a = 'a';
  const int b = 'b';
  const int c = 'c';

  int next = sa[0];
  sa.erase(sa.begin(),sa.begin()+1);
  int num = 1;
  
  //while(sa.size()>0 && sb.size()>0 && sc.size()>0){
  while(1){
    switch(next){
    case a:
      if(sa.size()==0){
	cout << "A" << endl;
	return 0;
      }
      next = sa[0];
      sa.erase(sa.begin(),sa.begin()+1);
      break;
    case b:
      if(sb.size()==0){
	cout << "B" << endl;
	return 0;
      }
      next = sb[0];
      sb.erase(sb.begin(),sb.begin()+1);
      break;
    case c:
      if(sc.size()==0){
	cout << "C" << endl;
	return 0;
      }
      next = sc[0];
      sc.erase(sc.begin(),sc.begin()+1);
    }
  }
  
  return 0;
}


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

const int m = 1000005;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  a[0]=n;
  for(int i=1;i<m;i++){
    if(a[i-1]%2==0) a[i]=a[i-1]/2;
    else a[i]=3*a[i-1]+1;
    for(int j=0;j<i;j++){
      if(a[i]==a[j]){
        cout << i+1;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str;
    string res("");
    cin >> str;
    bool a = true;
    for(auto c : str)
    {
    	if (a) res += c;
    	a = !a;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
  public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int H = Integer.parseInt(s[0]);
    int W = Integer.parseInt(s[1]);
    int[] sx = {-1, -1, -1, 0, +1, +1, +1, 0};
    int[] sy = {-1, 0, +1, +1, +1, 0, -1, -1};
    
    char[][] field = new char[H][W];
    for(int i = 0; i < H; i++){
      field[i] = sc.nextLine().toCharArray();
    }
    
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        int count = 0;
        if(field[i][j] == '.'){
          for(int k = 0; k < 8; k++){
            if(i + sx[k] >= 0 && i + sx[k] < H && j + sy[k] >= 0 && j + sy[k] < W){
              if(field[i + sx[k]][j + sy[k]] == '#'){
                count++;
              }
            }
          }
          field[i][j] = (char)(count + '0');
        }
            System.out.print(field[i][j]);
      }
      System.out.println("");
    }
  }
}


Measured memory_bytes: 23252
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val A, B = sc.nextInt()

    if (A == B)
      println(A + B)
    else {
      val max = Math.max(A, B)
      println(max + max - 1)
    }

  }

}

Measured memory_bytes: 25420
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
	_typer init = 0;
	char ch = getchar(), k = 0;
	for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
	for ( ; isdigit(ch); ch = getchar())
		init = (init << 3) + (init << 1) + (ch ^ 48);
	return k ? -init : init;
}
const ll N = 0, INF = 1e9;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

int L, R;

int main() {
	cin >> L >> R;
	if (R - L >= 2019) cout << 0 << endl;
	else if (L == 0) cout << 0 << endl;
	else {
		int res = INF;
		rep (i, L, R) rep (j, i + 1, R) {
			res = min(res, i % 2019 * (j % 2019) % 2019);
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int k, x;
    cin >> k >> x;
    if(500 * k >= x) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
int main(void) {
  int n, m, i, s, c, digit[3] = {-2, -2, -2};
  scanf("%d %d", &n, &m);    // n桁,条件m個
  for (i = m; i > 0; i--) {  // m個の条件を確認
    scanf("%d %d", &s, &c);
    if (digit[2 - n + s] == -2) {  //初の条件は採用
      digit[2 - n + s] = c;
    } else if (digit[2 - n + s] != c) {  //同じ行に別条件がある場合は死ぬ
      printf("-1\n");
      exit(0);
    }
  }
  //一桁目が0だと死ぬ,条件なければ1,あればそれ
  if (n == 1 && (digit[2] == 0 || digit[2] == -2)) {
    printf("0\n");
    exit(0);
  }
  if (digit[3 - n] == 0) {
    printf("-1\n");
    exit(0);
  } else if (digit[3 - n] == -2)
    printf("1");
  else
    printf("%d", digit[3 - n]);
  //条件の無い行は0
  for (i = 4 - n; i < 3; i++) {
    if (digit[i] == -2)
      printf("0");
    else
      printf("%d", digit[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int N, T;
	cin >> N >> T;

	vector<int> cst;
	cst.clear();
	int cv, tv;
	for (int i = 0; i < N; i++) {
		cin >> cv >> tv;
		if (tv <= T) {
			cst.push_back(cv);
		}
	}

	if (cst.size() == 0) {
		cout << "TLE" << endl;
	}
	else {
		cout << *min_element(cst.begin(), cst.end()) << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
using namespace std;
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 T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, K, Q;
  cin >> N >> K >> Q;
  vec< int > p(N, 0);
  REP(i, Q) {
    int q;
    cin >> q;
    q--;
    p[q]++;
  }

  REP(i, N) {
    // DEBUG(K - (Q - p[i]));
    if (K - (Q - p[i]) > 0) {
      print("Yes");
    } else {
      print("No");
    }
  }
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    if(s.size() % 2 == 1)
    {
        cout << "No\n";
        return 0;
    }
    for(int i = 0;i < s.size();i++)
    {
        if(!(i % 2 == 0 && s[i] == 'h' || i % 2 == 1 && s[i] == 'i'))
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  string S;
  cin >> S;
  if(S == "Sunny")
    cout << "Cloudy" << endl;
  else if(S == "Cloudy")
    cout << "Rainy" << endl;
  else
    cout << "Sunny" << endl;
  return 0;
}


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

int main() {
  long long N; cin >> N;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  long long cnt = 0;
  priority_queue<long long> q;
  for (long long i = 0; i < N; i++) {
    if (A[N-1] == A[N-1-i]) {
      cnt++;
      q.push(A[N-1]);
    } else {
      break;
    }
  }
  long long result = A[N-1]*(cnt-1);
  for (long long i = 0; i < N - cnt; i++) {
    long long p = q.top();
    long long next = A[N-cnt-1-i];
    result += p;
    q.pop();
    q.push(next);
    q.push(next);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 6908
n=int(input())
l=list(map(int,input().split()))
c=l[-1]
for i in range(n-1):
  c=l[-i-2]-c
l1=[]
l1.append(str(c))
c1=c//2
for i in range(n-1):
  c1=l[i]-c1
  l1.append(str(c1*2))
print(" ".join(l1))

Measured memory_bytes: 17228
from collections import deque

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

q = deque()
q.append(a[0])
ans = 0
for i in range(1, n):
    b = q.popleft()
    ans += b
    b = min(b, a[i])
    for _ in range(2):
        q.append(b)
print(ans)


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

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

    int N = scanner.nextInt();
    Dish[] dishes = new Dish[N];
    for (int i = 0; i < N; i++) dishes[i] = new Dish(scanner.nextInt(), scanner.nextInt());
    Arrays.sort(dishes, (d1, d2) -> -d1.a - d1.b + d2.a + d2.b);

    long res = 0;
    for (int i = 0; i < N; i++) {
      if (i % 2 != 0) res -= dishes[i].b;
      else res += dishes[i].a;
    }
    System.out.println(res);
  }

  private static class Dish {
    private final int a;
    private final int b;

    private Dish(int a, int b) {
      this.a = a;
      this.b = b;
    }
  }
}


Measured memory_bytes: 93184
#include<stdio.h>
int main()
{
    char s[15];
    scanf("%s", s);
    int i;
    for (i = 0; i < 4; i++)
        printf("%c", s[i]);
    printf(" ");
    for (i = 4; i < 12; i++)
        printf("%c", s[i]);
        printf("\n");
    return 0;
}

Measured memory_bytes: 128
const main = (input) => {
  input = input.split(' ');
  const a = parseInt(input[0], 10);
  const b = parseInt(input[1], 10);
  const c = parseInt(input[2], 10);
  const result = [a,b,c];
  
  console.log(a+b+c-Math.max.apply(null, result));
 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int a, b;
    cin >> a >> b;
    int cur = 1;
    int ans = 0;
    while (cur < b) {
        cur += a-1;
        ++ans;
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3624
# ABC054 B - Template Matching
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,m=nl()
a=[]
b=[]

for i in range(n):
    a.append(input())

for i in range(m):
    b.append(input())

for i in range(n-m+1):
    for j in range(n-m+1):
        cnt=0
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l]==b[k][l]:
                    cnt+=1
        if cnt==m**2:
            print('Yes')
            exit()
print('No')

        

Measured memory_bytes: 3444
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
#dp = [[0] * 4 for i in range(3)] #2次元配列初期化
#dp = [[[0] * 2 for i in range(3)] for j in range(5)]
#(ord('A'))でASCII出力 Aは65
import math
import statistics
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

n = intinput()
x = listintinput()

av = int(statistics.mean(x))
avone = av+1
ans = 0
ansone = 0
for i in x:
    ans += (i-av) ** 2
    ansone += (i-avone) ** 2

print(min(ans,ansone))



Measured memory_bytes: 5884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int main() {
    int N;
    cin >> N;
    map<int,int> m;
    rep(i,0,N) {
        int x;
        cin >> x;
        m[x]++;
    }
    ll ans=0LL;
    vector<int> a;
    for (auto p : m) {
        if (p.second>=4) ans=1LL*p.first*p.first;
        if (p.second>=2) a.push_back(p.first);
    }
    if (a.size()>=2) ans=max(ans,1LL*a[a.size()-1]*a[a.size()-2]);
    cout << ans << endl;
}


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


signed main() {
  int N, M, Q; cin >> N >> M >> Q;
  vector<vector<int>> q(Q, vector<int>(4));
  rep(i, Q) rep(j, 4) cin >> q[i][j];

  
  vector<int> vec(N+1, 1);
  vec[N] = -1;

  int ans = 0;
  
  int i = N-2;
  
  while(true) {
    int a = 0;
    rep(i, Q) {
      if(vec[q[i][1]-1]-vec[q[i][0]-1] == q[i][2]) a += q[i][3];
    }
    ans = max(ans, a);
    if(vec[i] == vec[i+1]) {
      while(vec[i] == vec[i+1]) i++;
      if(i == N-1) {
        if(vec[i] == M) {
          cout << ans << endl;
          return 0;
        } else {
          vec[i]++;
          rep(j, i) vec[j] = 1;
          i = 0;
        }
      } else {
        vec[i]++;
        rep(j, i) vec[j] = 1;
        i = 0;
      }
    } else vec[i]++;
  }

  cout << ans << endl;

}

Measured memory_bytes: 3636