akhauriyash/Code-Regression huggingface dataset:
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    cin>>n;
    int x = (n+1000-1)/1000;
    int z = x*1000;
    cout<<z-n<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

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

int main()
{
	string s,t;
	cin >> s >> t;
	for(int i=0;i<s.length();++i)
	{
		char c=s[s.length()-1];
		string tmp=s;
		s.pop_back();
		s.insert(s.begin(),c);
//		cout << s << endl;
		if(s==t)
		{
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
using namespace std;
int main()
{
    int a,b;
    cin>>a;
    cin>>b;
    stringstream ss;
    if(a<=b)
    {
        ss<<a;
        string str1=ss.str();
        //cout<<str1;
        string temp=str1;
        //cout<<temp;
        for(int i=1;i<b;i++){
                str1+=temp;
        }

    cout<<str1;
    }
    else
    {
        ss<<b;
        string str1=ss.str();
        cout<<str1;
        string temp=str1;
        for(int i=2;i<a;i++){
                str1+=temp;
        }

    cout<<str1;

    }

}




Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		execute14_1();
	}

	private static void execute14_2() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int [] a = new int[n];
			
			for(int i=0; i<n; i++) {
				a[i] = sc.nextInt();
			}
			
			int ans =0;
			for(int i=0; i<n-1; i++) {
				for(int j=i+1; j<n; j++) {
					if(j-i==a[i]+a[j]) ans++;
				}
			}
			System.out.println(ans);
		}

	}

	private static void execute14_1() {
		try (Scanner sc = new Scanner(System.in)) {
			long x = sc.nextInt();

			int ans_a = 9999;
			int ans_b = 9999;
			if(x==1) {
				ans_a=1;
				ans_b=0;
			}
			for(int i=2; i <= x; i++) {
				long tmp = x;
				int wr = (int) ((int) tmp/Math.pow(i, 5));
				if(wr>1) continue;
				tmp%=Math.pow(i, 5);
		
				for(int n=0; n < i; n++) {
					if(tmp==Math.pow(n, 5)) {
						ans_a = i;
						ans_b = n*-1;
					} else if(Math.abs(tmp-Math.pow(i, 5))==Math.pow(n, 5)) {
						ans_a = i;
						ans_b = n;
					}
				}
				if(ans_a!=9999) break;
				
				
				
			}
			System.out.println(ans_a + " " + ans_b);
		}

	}
}

Measured memory_bytes: 27076
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {

	int N, R, G, B;

	cin >> R >> G >> B >> N;

	int count = 0;

	for (int x = 0; x <= N; x++) {
		for (int y = 0; y <= N; y++) {
			int t = N - R * x - G * y;
			if (t >= 0 && t%B == 0) {
				count++;
			}
		}
	}

	cout << count << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }

const ll INF=99999999999999;
const ll MOD=1000000007;

 
int main() {
  ll h,w,a,b;
  cin >> h >> w >> a >> b;
  rep(i,h){
    rep(j,w){
      if(j < a){
        if(i < b){
          cout << 1;
        } else {
          cout << 0;
        }
      } else {
        if(i>=b){
          cout << 1;
        } else {
          cout << 0;
        }
      }
    }
    cout << endl;
  }
  
  
  
  

 return 0;
}

Measured memory_bytes: 1280
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int[] a = new int[3];
		int Max = 0;
		int res = 0;
		for(int i=0;i<3;i++) {
			int t = nextInt();
			res += t;
			Max = Math.max(t,Max);
		}
		out.println(res-Max);
	}


	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}

}

Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	ll x, k, d; cin >> x >> k >> d;
	x=abs(x);
	ll p=x%d, n=x/d;
	ll q=abs(p-d);
	if(k-n<0){
		cout << x-(d*k) << endl;
	}
	else{
		if((k-n)%2)
			cout << q << endl;
		else
			cout << p << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
// ABC072_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    string S;
    cin >> S;
    
    // calculation
    REP(i, S.length()) {
        if (i%2 == 0) cout << S[i];
    }
    cout << "\n";
    
    return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <complex>

using namespace std;
using ll = long long;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    auto l = a + b, r = c + d;
    if (l > r) {
        cout << "Left" << endl;
    } else if (l < r) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
}



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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i){
    	cin >> v[i];
    }
    sort(v.begin(), v.end());
    int o = 0;
    for(int i = 1; i < n; i++){
    	if(v[i-1] < v[i]){
    		if(n-i == i)
    			o += v[i]-v[i-1];
    	}
    }

    cout << o << endl;
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  vector<int> data = {a, b, c};
  sort(data.begin(), data.end());
  if (data.at(0) + data.at(1) == data.at(2)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
str1 = list(input())
str2 = list(input())

answer = len(str2)
for i in range(len(str1)-len(str2)+1):
    count = 0

    for j in range(len(str2)):
        if not str1[i+j] == str2[j]:
            count += 1

    if count < answer:
        answer = count

print(answer)


Measured memory_bytes: 81100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int H, W;
    cin >> H >> W;
    string S[H];
    rep(i, H) cin >> S[i];
    int n = H+(H&1);
    vector<vector<int>> v[n/2+1];
    vector<int> emp;
    v[0].pb(emp);
    rep(i, n/2){
        for(auto &e: v[i]){
            vector<bool> used(n, false);
            for(auto &u: e) used[u] = true;
            int now = 0;
            rep(j, i+1){
                while(used[now]) now++;
                used[now] = true;
            }
            rep(j, n){
                if(!used[j]){
                    vector<int> memo = e;
                    memo.pb(j);
                    v[i+1].pb(memo);
                }
            }
        }
    }
    bool able = false;
    for(auto &b: v[n/2]){
        string res[H];
        vector<int> a;
        vector<bool> used(n, false);
        for(auto &e: b) used[e] = true;
        rep(i, n) if(!used[i]) a.pb(i);
        vector<pii> p;
        rep(i, n/2) p.pb(pii(b[i], a[i]));
        sort(all(p));
        rep(i, n/2){
            int j = p[i].first, k = p[i].second;
            if(j < H) res[i] = S[j];
            res[H-1-i] = S[k];
        }
        vector<bool> rem(W, true);
        //上から、下から
        string u[W], d[W];
        rep(j, W){
            rep(i, H) u[j] += res[i][j];
            rep3(i, H-1, 0) d[j] += res[i][j];
        }
        int cnt = 0;
        for(int now = 0; now < W; now++){
            if(!rem[now]) continue;
            rem[now] = false;
            cnt++;
            rep(j, W){
                if(rem[j] && u[now] == d[j]){
                    rem[j] = false;
                    break;
                }
            }
        }
        if(cnt == (W+1)/2) able = true;
    }
    if(able) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 1724
n,a,b = tuple(map(int,input().split()))
s = list(input())

count = 0
foreign = 0
for s_i in s:
  if s_i=='a':
    if count<a+b:
      count+=1
      print("Yes")
    else:
      print("No")
  elif s_i=='b':
    if count<a+b and foreign < b:
      count+=1
      foreign+=1
      print("Yes")
    else:
      print("No")
  else:
    print("No")


Measured memory_bytes: 4708
program main
  implicit none
  character(3) :: sss
  integer :: i, counts
  read(*,*) sss
  
  counts = 0
  do i = 1, 3
    if ( sss(i:i) == 'S' ) then
      counts = counts
    else
      if (sss(i-1:i-1) == 'S' ) then
        counts = 1
      else
        counts = counts + 1
      endif   
    endif
  enddo
  write(*,*) counts
end program main

Measured memory_bytes: 2844
#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>;
#define INF 100000000

int main()
{
    /*ABC144 B
    int x;
    cin>>x;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(x==i*j)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    */
    /*ABC150 B
    int n;
    string s;
    cin>>n>>s;
    int count = 0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A')
        {
           if(s[i+1]=='B')
           {
               if(s[i+2]=='C')
               {
                   count++;
               }
           }
        }
    }
    cout<<count<<endl;
    */

    int n;
    cin>>n;
    int count = 0;
    for(int i=1;i<=n;i++)
    {
        int even=0;
        int num = i;
        while(num)
        {
            num/=10;
            even++;
        }
        if(even%2!=0)
        {
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define b_e(a) a.begin(),a.end() //sort(b_e(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define p_b push_back
#define SZ(x) ((ll)(x).size()) //size()がunsignedなのでエラー避けに
#define endk '\n'


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによる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"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //



int main(){

  ll N, M;
  cin >> N >> M;

  vector<ll> as(N);
  rep(i, N) as[i] = il();

  // mod M の cumsum
  vector<ll> cumsum(N+1, 0);
  rep(i, N) cumsum[i+1] = (cumsum[i] + as[i]) % M;

  // cumsum が等しいものを同じグループに入れる
  map<ll, ll> groups;
  rep(i, N+1) groups[cumsum[i]]++;

  // 全てのグループについて、メンバ数 C 2 を加算
  ll ans = 0;
  for (pll p : groups){
    ans += (p.second * (p.second - 1)) / 2;
  }

  cout << ans << endk;


}



Measured memory_bytes: 8820
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(b%a==0)
	{
	    cout<<a+b;
	}
	else
	{
	    cout<<b-a;
	}
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)

int main() {
	int n;
	cin >> n;
	cout << (n < 1200 ? "ABC" : "ARC") << endl;
}


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;




    int main(){
        int k, x;
        std::cin >> k >> x;
        for (int i = 1; i < k; ++i)
        {
            x--;
        }
        for (int i = 0; i < (2*k)-1; ++i)
        {
            std::cout << x << " " << "\n";
            x++;
        }
        return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,ans;
char s[N];
int main()
{
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;i++)
        if(s[i]!=s[i-1])
            ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int n,i,j,k,t,d[100];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  for(i=0;i<n;i++){
    for(j=i;j<n;j++){
      t=d[i];
      d[i]=d[j];
      d[j]=t;
      for(k=1;k<n;k++){
	if(d[k-1]>d[k])break;
      }
      if(k==n){
	printf("YES\n");
	return 0;
      }
      t=d[i];
      d[i]=d[j];
      d[j]=t;
    }
  }
  printf("NO\n");
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

ll howManyDivisers(ll a, ll b, ll m)
{
    ll foo = a + (m - a % m) % m;
    ll bar = b - (b % m);
    if (foo > bar)return 0;
    else return (bar - foo) / m + 1;
}
ll gcd(ll x, ll y)
{
    return y == 0 ? x : gcd(y, x % y);
}
int main()
{
    ll a = in(), b = in(), c = in(), d = in();
    cout <<
        b - a + 1
        - howManyDivisers(a, b, c)
        - howManyDivisers(a, b, d)
        + howManyDivisers(a, b, c / gcd(c, d) * d)
        << endl;
}

Measured memory_bytes: 256
N,M,Q = list(map(int,input().split()))

D = [list(map(int,input().split())) for i in range(Q)]

l = []

def perm(l1,i,depth):
    if depth == N:
        l.append(l1)
    else:
        for j in range(i,M+1):
            l2 = list(l1)
            l2.append(j)
            perm(l2,j,depth+1)

perm([],1,0)

ans = 0

def smax(a,b):
    if a>b:
        return a
    else:
        return b

for ll in l:
    score = 0
    for i in range(Q):
        if ll[D[i][1]-1]-ll[D[i][0]-1]==D[i][2]:
            score += D[i][3]
    ans =  smax(score,ans)


print(ans)

Measured memory_bytes: 94540
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n,k;
    cin>>n>>k; 
    bool a[n];
    memset(a,false,sizeof(a));
    while(k--){
      ll d; 
      cin>>d; 
      while(d--){
        ll kk; 
        cin>>kk; 
        //cout<<kk<<"@$";
        a[kk-1]=true; 
      }
    }
    ll cnt=0;
    for(ll i=0;i<n;i++){
      a[i]==false?(cnt++):(1);
    }
    cout<<cnt<<endl; 
    //printclock;
    return 0;
}
    

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
string s;
cin >> s;
int che =0;
for(int i=0;i<s.size();i++){
    if(s.at(i)=='2')che++;
}
cout << che<<endl;
 }


Measured memory_bytes: 256
#include <stdio.h>

#define N 100000

int cnt, n, q;
int s[N], t[N];

void scanData() {
	int i;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &s[i]);
	}

	scanf("%d", &q);

	for (i = 0; i < q; i++) {
		scanf("%d", &t[i]);
	}
}

void linearSearch(int a, int n) {
	int i;

	for (i = 0; i < n; i++) {
		if (s[i] == a) {
			cnt++;
			break;
		}
	}
}

int main() {
	int i;

	scanData();

	for (i = 0; i < q; i++) {
		linearSearch(t[i], n);
	}

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

	return 0;
}

Measured memory_bytes: 644
module Int = struct
  type t = int
  let compare = compare
end
module IntMap = Map.Make (Int)

let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  Array.fold_left (fun m a ->
    IntMap.add a (1 + try IntMap.find a m with Not_found -> 0) m) IntMap.empty as_
  |> IntMap.bindings
  |> (fun l ->
      List.length @@ List.filter (fun (_, n) -> n mod 2 = 0) l,
      List.length @@ List.filter (fun (_, n) -> n mod 2 = 1) l)
  |> (fun (evens, odds) -> evens + odds - evens mod 2)
  |> Printf.printf "%d\n"

Measured memory_bytes: 15360
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<cstdlib>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
 
inline ll quick(ll a,ll b,ll p)	//(a^b) mod p 
{
	ll ans=1;
	for( ;b;b>>=1)
	{
		if(b&1) ans=ans*a%p;
		a=a*a%p;
	}
	return ans%p;	//如果b=0,p=1,不加%p会错 
}
 
int main()
{
    ll n;
    cin>>n;
    ll t=(quick(10,n,mod)+quick(8,n,mod)-2*quick(9,n,mod)+2*mod)%mod;
    cout<<t<<endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 3700
import fractions
n, k =map(int, input().split())
dat = list(map(int, input().split()))
x = dat[0]
for i in range(n):
    x = fractions.gcd(x, dat[i])
#print(x)
if k % x == 0 and k <= max(dat):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 16240
// AC or WA
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main ()
{
    int N,M;
    cin >> N >> M;
    if (N == M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N, p[20005];
long long int a[20005], b[20005];

int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> p[i];
	}

	for (int i = 1; i <= N; i++) {
		a[i] = i; b[i] = N - i+1;
	}

	for (int i = 1; i <= N; i++) {
		for (int j = p[i]; j <= N; j++) { a[j] += i; }
		for (int j = 1; j <= p[i]; j++) { b[j] += i; }
	}

	for (int i = 1; i <= N; i++) {
		if (i != 1) { cout << " "; }
		cout << a[i];
	}
	cout << endl;

	for (int i = 1; i <= N; i++) {
		if (i != 1) { cout << " "; }
		cout << b[i];
	}cout << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int C[N + 1][N + 1];

int lcs(string X, string Y)
{
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = ' ' + X;
    Y = ' ' + Y;
    for (int i = 1; i <= m; i++) {
        C[i][0] = 0;
    }
    for (int j = 1; j <= n; j++) {
        C[0][j] = 0;
    }

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (X[i] == Y[j]) {
                C[i][j] = C[i-1][j-1] + 1;
            } else {
                C[i][j] = max(C[i-1][j], C[i][j-1]);
            }
            maxl = max(maxl, C[i][j]);
        }
    }

    return maxl;
}

int main(int argc, char const *argv[])
{
    string s1, s2;
    int n; 
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s1 >> s2;
        int ans = lcs(s1, s2);
        cout << ans << endl;
    }    

    return 0;
}



Measured memory_bytes: 7076
import heapq

X,Y,A,B,C = map(int, input().split())
p_list = sorted([(-v, 'p') for v in map(int, input().split())])
q_list = sorted([(-v, 'q') for v in map(int, input().split())])
r_list = sorted([(-v, 'r') for v in map(int, input().split())])

res = 0
r_cnt = 0
for v, k in heapq.merge(p_list, q_list, r_list):
    v = -v
    if X+Y-r_cnt == 0:
        break
    if k == 'p':
        if X != 0:
            X -= 1
            res += v
        continue
    
    if k == 'q':
        if Y != 0:
            Y -= 1
            res += v
        continue

    res += v
    r_cnt += 1

print(res)


Measured memory_bytes: 43368
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;
   
int sum(int l, int r) {

	return (l + r)*(r - l + 1) / 2;

}

int gcd(int a, int b) {

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

}
int arr[200001];
int32_t  main() {

	IOS;

	int K, N;

	cin >> K >> N;
	 
	int maxi = 0;
	int mini = INT_MAX;

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

		cin >> arr[i];	 
 
	}

	arr[N] = arr[0] + K;

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

		
		l = max(l, arr[i] - arr[i - 1]);

	}

	

	cout << K-l << endl;


}


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

#define ll long long
#define dd double
#define scl(n)    scanf("%lld",&n)
#define scd(n)    scanf("%lf",&n)
#define ptl(n)    printf("%lld",n)
#define ptd(n)    printf("%lf",n)
#define nline     printf("\n")
#define vld       vector<ll>
#define vbd       vector<bool>
#define eb        emplace_back
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define pi        2*acos(0.0)

using namespace std;

int main()
{
    ll n,a,cnt=0;
    scl(n);
    FOR1(i,n)
    {
        scl(a);
        if(i%2!=0&&a%2!=0)
            cnt++;
    }
    ptl(cnt);
    return 0;
}


Measured memory_bytes: 3720
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    A[] -= 1;
    long ans;
    foreach (i; 0 .. N)
    {
        if (i < A[i] && A[A[i]] == i)
            ans++;
    }
    writeln(ans);
}


Measured memory_bytes: 4284
#include <stdio.h>

#define N 100000
#define Q 50000

int main(){

  int i;
  int s[N], t[Q];
  int n, q;
  int count = 0;
  int l, mid, r;

  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
    scanf("%d", &s[i]);
    
  }
  
  scanf("%d", &q);
  
  for(i = 0; i < q; i++){
    scanf("%d", &t[i]);
    
  }

  for(i = 0; i < q; i++){

    l = 0;
    r = n;

    while(l < r){

      mid = (l + r) / 2;

      if(s[mid] == t[i]){
	count++;
	break;
      }

      if(s[mid] < t[i]) l = mid + 1;	
      else r = mid; 

    }

  }

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

  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)

int main(){
    int A,B;
    string S,T,U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(S==U){
        A--;
    }else{
        B--;
    }
    cout << A << " " << B << "\n"; 
    return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n = int(input())
memo = [dict() for i in range(n + 1)]


def ok(last4):
    for i in range(4):
        t = list(last4)

        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]

        if "".join(t).count("AGC") >= 1:
            return False

    return True


def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == n:
        return 1
    ret = 0
    for c in "ACGT":
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret


print(dfs(0, "TTT"))

Measured memory_bytes: 3812
let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let xs = Array.init m @@ fun _ -> Scanf.scanf "%d " @@ fun x -> x in
  Array.sort compare xs;
  let ds = Array.init (m - 1) @@ fun i -> xs.(i + 1) - xs.(i) in
  Array.sort compare ds;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@
  Array.sub ds 0 @@ max 0 @@ m - n


Measured memory_bytes: 6272
#include <bits/stdc++.h>
    #include <iostream>
    #include <unordered_map>
    #include <unordered_set>
    #define pb push_back
    #define mpr make_pair
    #define pii pair<int, int>
    #define pll pair<ll, ll>
    #define ll long long
    #define ld long double
    #define fi first
    #define se second
    #define all(arr) arr.begin(), arr.end()
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
    #define fo(i, l, r) for (int i = l; i <= r; i++)
    #define INF 1000000001
    #define inf1 1000000000000000001
    #define MOD 1000000007
    #define mod 1000000007
    #define pie 3.14159265358979323846264338327950L
    #define N 200009
    #define M 1e6 + 9
    #define mid(l, r) l + (r - l) / 2
    #define vec vector<int>
    #define vecl vector<ll>
    #define umap unordered_map<ll, ll>
    #define yes cout << "Yes" << endl;
    #define no cout << "No" << endl;
    #define endl "\n"
    #define int long long
    using namespace std;
    
    int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
    int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
    ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
    ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}
    

    
    void test_case()
    {
        
        
        int n ;
        cin>>n;
        string s,t;
        cin>>s>>t;

        string ans = "";
        for(int i=0; i<n; i++) {
            ans+= s[i];
            ans+= t[i];
        }

        cout<<ans<<endl;


        



    
        
    }
    
    signed main()
    {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout << fixed << setprecision(20);
    
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    
        int t = 1;
        // cin >> t;
        while (t--)
        {
            test_case();
        }
    }

Measured memory_bytes: 3612
{-# LANGUAGE TypeApplications #-}
module Main where
import qualified Data.ByteString.Char8         as BS
import qualified Data.ByteString.Lazy.Char8    as BSL
import qualified Data.ByteString.Builder       as BSB
import           Data.Char                      ( isSpace )
import           Data.List
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM
-- see: https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Map-Strict.html
import           Data.Map.Strict                ( Map )
import qualified Data.Map.Strict               as Map
import           Data.IntMap                    ( IntMap )
import qualified Data.IntMap                   as IntMap


main :: IO ()
main = do
  n  <- readLn @Int
  as <- VU.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let xs = hist $ VU.toList $ VU.zipWith (-) (VU.enumFromN 1 n) as
  let ys = hist $ VU.toList $ VU.zipWith (+) (VU.enumFromN 1 n) as
  print $ sum $ IntMap.elems $ IntMap.intersectionWith (*) xs ys
-- create histogram from list
hist :: [Int] -> IntMap Int
hist xs = IntMap.fromListWith (+) $ zip xs $ repeat 1


Measured memory_bytes: 61772
#include <stdio.h>

int main(void){
int a,b,c,x;
scanf("%d %d %d",&a,&b,&c);
if (a > b){
x = a;
a = b;
b = x;
}
if (b > c){
x = b;
b = c;
c = x;
}
if (a > b){
x = a;
a = b;
b = x;
}
printf("%d %d %d\n",a,b,c);

return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> vec(N-1);
  rep(i,N-1)
  {
    cin >> vec[i];
  }
  int sum = vec[0]+vec[N-2];
  for(int i=0;i<N-2;i++)
  {
    sum += min(vec[i],vec[i+1]);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt()+1;
    int k=sc.nextInt();
    int m=k;
    int po=1;
    while(m<n){
      m*=k;
      po++;
    }
    System.out.print(po);
  }
}


Measured memory_bytes: 21716
#T=(0,0,...,0)
#に変換するためのコストの2^N倍
N=int(input())
c=sorted([int(i) for i in input().split()])
mod=10**9+7
if N==1:
    print((2*c[0])%mod)
    exit()
ans=0
for k in range(N):
    a1=pow(2,N-2,mod)
    a2=(N-k+1)
    tmp=(a1*a2)%mod
    ans+=(c[k]*tmp)%mod
    ans%=mod
    #print(k,tmp)
ans=ans*pow(2,N,mod)
ans%=mod
print(ans)


Measured memory_bytes: 89164
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

typedef vector<vvi> vvvi;
int main(){
	int n,k;
	cin>>n>>k;
	vi given(n+1);
	REP(i,k){
		int day,kind;
		cin>>day>>kind;
		given[day]=kind;
	}
	vvvi dp(n+1,vvi(3,vi(3)));
	REP(i,3){
		if(!given[1]||given[1]-1==i){
			dp[1][0][i]=1;
		}
	}
	FOR(day,2,n+1){
		REP(prev,3){
			FOR(cur,given[day]?given[day]-1:0,given[day]?given[day]:3){
				REP(pp,3){
					if(prev==cur&&cur==pp&&day!=2)continue;
					dp[day][prev][cur]+=dp[day-1][pp][prev];
					dp[day][prev][cur]%=10000;
				}
			}
		}
	}
	int ans=0;
	REP(i,3){
		REP(j,3){
			ans+=dp[n][i][j];
			ans%=10000;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1232
import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Main {
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        public long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int b  = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(a+b+c>=22?"bust":"win");


    }

}


Measured memory_bytes: 32564
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    int n, m; cin >> n >> m;
    // from1 : 1から到達できる場合true
    // toN : Nに到達できる場合true
    bool from1[n]; rep(i,0,n) from1[i] = false;
    bool toN[n]; rep(i,0,n) toN[i] = false;
    rep(i,0,m){
        int a, b; cin >> a >> b;
        a--; b--;
        if( a == 0 ){
            from1[b] = true; 
        }else if( b == n-1 ){
            toN[a] = true;
        }
    }
    bool res = false;
    rep(i,0,n) res |= (from1[i] & toN[i]);
    cout << (res ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    

}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << ((a + b) * h) / 2 << endl;
}


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

int main(){
    int r;
    cin >> r;
    cout << 2.0*M_PI*r << endl;
    return 0;
}


Measured memory_bytes: 3788
N,D,A=map(int,input().split())
from heapq import heappop,heappush,heapify
B=[]
for _ in range(N):
    x,h=map(int,input().split())
    B.append((x,h))
heapify(B)

dic={}

ans=0
atk_cnt=0
while B:
    x,h=heappop(B)
    if h==-1:
        atk_cnt-=dic[x-1]
        continue
    if h<=A*atk_cnt:
        continue
    h-=A*atk_cnt
    sup=x+2*D
    bomb=(h-1)//A+1
    ans+=bomb
    dic[sup]=bomb
    atk_cnt+=bomb
    heappush(B,(sup+1,-1))
    
    
print(ans)


Measured memory_bytes: 47384
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		sc.next();
		char c = sc.next().toCharArray()[0];
		sc.next();

		System.out.println("A" + c + "C");
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 8916
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll k,n;
    cin>>k>>n;
    ll a[2*n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        a[i+n]=a[i]+k;
    }
    ll ans=k;
    for(ll i=0;i<n;i++){
        ans=min(ans,a[i+n-1]-a[i]);
    }
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

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

int main(){
	int n, m;
	while(cin >> n){
		double a[1005], b[1005], c = 0;
		for(int i = 1; i <= n; i++){
			scanf("%lf %lf",&a[i],&b[i]);
		}
		for(int i = 1; i <= n-1; i++){
			for(int j = i+1; j <= n; j++){
				c += sqrt((a[i] - a[j]) * (a[i] - a[j]) +(b[i] - b[j]) * (b[i] - b[j]));
			}
		}
		printf("%.10lf\n",c * 2 / n);
	}	
	return 0;
} 

/*
4
1 2
2 3
3 4
4 5
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int s, w; cin >> s >> w;
    if (s <= w)cout << "unsafe\n";
    else cout << "safe\n";
}

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

def func(l,r):
    if l==r:
        return l
    mid = (l+r)//2
    count = 0
    for i in A:
        count += (i-0.1)//mid
    if count <= K:
        return func(l,mid)
    else:
        return func(mid+1,r)

print(func(1,max(A)))

Measured memory_bytes: 30848
from collections import Counter
def main():
    n=int(input())
    a=Counter(map(int,input().split()))
    d=0
    for k,v in a.items():
        if k > v:
            d += v
        elif k < v:
            d += v-k
    print(d)

if __name__ == "__main__":
    main()

Measured memory_bytes: 27312
import math
S = input()



kzero = 0
kone = 0
gzero = 0
gone = 0


buff1 = [0 for i in range(2)]
buff2 = [0 for i in range(2)]

_len = len(S)
gu_kazu = math.ceil(_len/2)
ki_kazu = _len//2

for i in range(_len):
    if i % 2 == 0:
        if S[i] == '0':
            buff1[0] += 1
        else:
            buff1[1] += 1

    else:
        if S[i] == '0':
            buff2[0] += 1
        else:
            buff2[1] += 1

print(min(gu_kazu-buff1[0]+ki_kazu-buff2[1],gu_kazu-buff1[1]+ki_kazu-buff2[0]))


Measured memory_bytes: 3188