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

int calc(const vector<vector<int>> &s, const vector<int> &c, const vector<int> &last, int day, int t) {
  int v = 0;
  v += s.at(day - 1).at(t);
  for (int i = 0; i < 26; i++) {
    if (i == t) continue;
    v -= c.at(i) * (day - last.at(i));
  }
  return v;
}

int main() {
  int d;
  cin >> d;
  vector<int> c(26), last(26);
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  vector s(d, vector(26, 0));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  int v = 0;
  for (int i = 0; i < d; i++) {
    int t;
    cin >> t;
    t--;
    v += calc(s, c, last, i + 1, t);
    cout << v << endl;
    last.at(t) = i + 1;
  }
}


Measured memory_bytes: 3672
//============================================================================
// Name        : e.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
	string ss;cin>>ss;
	vector<int> n;
	for(int i=0;i<ss.size();i++){
		n.push_back(ss[i]-'0');
	}
	int k;cin>>k;
	vector<int> v1(101),v2(101),v3(101);
	long long ans=0;
	v1[1]=9;
	for(int i=2;i<=100;i++){
		v1[i]=9;
		v2[i]=9*(i-1)*9;
		v3[i]=9*9*9*(i-2)*(i-1)/2;
	}
	int dig=n.size();
	int s,t;
	s=t=0;
	for(int i=1;i<dig;i++){
		if(n[i]){
			s=i;
			break;
		}
	}
	for(int i=s+1;i<dig;i++){
		if(n[i]){
			t=i;
			break;
		}
	}
//	cout<<s<<' '<<t<<endl;
	if(k==1){
		ans=(n[0]);
		for(int i=1;i<dig;i++){
			ans+=v1[i];
		}
	}else if(k==2){
		if(s==0){
			ans=(n[0]-1)*(dig-1)*9;
			ans+=(dig-1)*(dig-2)/2*9*9;
			cout<<ans<<endl;
			return 0;
		}
//		ans=n[s];
//		ans+=(n[0]-1)*9;
//		ans+=n[0]*(dig-1-s)*9;
//		ans+=9*(dig-1-s)*9;
		ans=n[s];
		ans+=(dig-1-s)*9;
		ans+=(n[0]-1)*(dig-1)*9;
		ans+=(dig-1)*(dig-2)/2*9*9;
//		cout<<n[s]<<' '<<(dig-1-s)*9<<' '<<(n[0]-1)*(dig-1)*9<<endl;
	}else{
		if(s==0){
			ans=(n[0]-1)*(dig-1)*(dig-2)/2*9*9;
			ans+=(dig-1)*(dig-2)*(dig-3)/6*9*9*9;
		}
		if(t==0){
			ans=(n[s]-1)*(dig-1-s)*9;
			ans+=(dig-1-s)*(dig-2-s)/2*9*9;
			ans+=(n[0]-1)*9*9*(dig-1)*(dig-2)/2;
			ans+=(dig-1)*(dig-2)*(dig-3)/6*9*9*9;
			cout<<ans<<endl;
			return 0;
		}

//		ans=n[t];
//		ans+=(n[s]-1)*9;
//		ans+=(n[0]-1)*9*9;
//		ans+=n[s]*(dig-1-t)*9;
//		ans+=(n[0]-1)*9*(dig-1-t)*9;
//		ans+=n[0]*
		ans+=n[t];
		ans+=(dig-1-t)*9;
		ans+=(n[s]-1)*(dig-1-s)*9;
		ans+=(dig-1-s)*(dig-2-s)/2*9*9;
		ans+=(n[0]-1)*9*9*(dig-1)*(dig-2)/2;
		ans+=(dig-1)*(dig-2)*(dig-3)/6*9*9*9;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	char b;
	cin >> b;
	
	switch(b) {
		case 'A': cout << 'T' << endl; break;
		case 'C': cout << 'G' << endl; break;
		case 'G': cout << 'C' << endl; break;
		case 'T': cout << 'A' << endl; break;
	}
	
	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

//ほげほげ
void solve() {
	map<int, int> go;
	REP(i, 3) {
		int a;
		cin >> a;
		go[a]++;
	}
	for (auto x : go) {
		if (x.second == 2) {
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
	return;
}

#undef int
int main() {
	init();
	solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  char c;
  while((c=getchar())!='.'){
    if(c=='.')break;
    int cnthi=0;
    int cnthika=0;
    vector<int>hkf;
    bool ans=true;
    if(c=='('){cnthi++;hkf.pb(1);}
    else if(c=='['){cnthika++;hkf.pb(2);}
    else if(c==')')ans=false;
    else if(c==']')ans=false;
    char c2;
    while((c2=getchar())!='\n'){
      if(c2=='('){cnthi++;hkf.pb(1);}
      else if(c2=='['){cnthika++;hkf.pb(2);}
      else if(c2==')'){cnthi--;if(hkf.empty()){ans=false;}
	else if(hkf[hkf.size()-1]==1){hkf.pop_back();}
	else if(hkf[hkf.size()-1]!=1){ans=false;}}
      else if(c2==']'){cnthika--;if(hkf.empty()){ans=false;}
	else if(hkf[hkf.size()-1]==2){hkf.pop_back();}
	else if(hkf[hkf.size()-1]!=2){ans=false;}
      }
      if(cnthi<0||cnthika<0)
	ans=false;
    }
    if(cnthi!=0||cnthika!=0)
      ans=false;
    if(ans)
      cout<<"yes"<<endl;
    else
      cout<<"no"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3144
while True:
    n, m = map(int, input().split())
    dpList = []
    if (n,m) == (0,0):
        break
    for i in range(n):
        row = list(map(int,input().split()))
        dpList.append(row)
    dpList = sorted(dpList, key = lambda x:x[1], reverse = True)
    num = 0
    for i in range(n):
        if m >= dpList[i][0]:
            m -= dpList[i][0]
        else:
            num += (dpList[i][0] - m) * dpList[i][1]
            m = 0
    print(num)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main(){
	
	int n;cin >> n;
	
	ll sumA = 0;
	ll sumB = 0;
	
	vector<ll> A(n);
	vector<ll> B(n);
	REP(i,n)cin >> A[i],sumA += A[i];
	REP(i,n)cin >> B[i],sumB += B[i];
	
	if(sumA < sumB){
		cout << -1 << endl;
		return 0;
	}
	
	ll sum = 0;
	ll ans = 0;
	vector<ll> mp;
	REP(i,n){
		if(A[i] < B[i]) {
			ans++;
			sum+= B[i] - A[i];
		}
		else if(A[i] > B[i]){
			mp.PB(A[i] - B[i]);
		}
	}

	sort(ALL(mp),greater<ll>());
	REP(i,mp.size()){
		if(sum <= 0)break;
		ans++;
		sum -= mp[i];
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    auto f = [](int a) {
                 int res = 0;
                 while (a > 0) {
                     res += a % 10;
                     a /= 10;
                 }
                 return res;
             };
    int k = f(n);
    if (n % k == 0) puts("Yes");
    else puts("No");
        
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
const int MAX = 1000000000;

long long find_min(function<bool(long long)> solve, long long low, long long high) {
	long long ng = low, ok = high;
	while (ok - ng > 1) {
		long long mid = (ok + ng) / 2;
		if (solve(mid)) {
			ok = mid;
		} else {
			ng = mid;
		}
	}
	return ok;
}

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	long long c = a - b;
	vector<long long> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	function<bool(long long)> f = [&](long long x) {
		vector<long long> v(h);
		long long cnt = 0;
		for (int i = 0; i < v.size(); i++) {
			v[i] -= b * x;
			if (v[i] > 0) {
				cnt += (v[i] + c - 1) / c;
			}
		}
		return cnt <= x;
	};
	long long ans = find_min(f, 0, MAX);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4440
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int MAX = 1000000;
ll fac[MAX], finv[MAX], inv[MAX];

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

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


int main(){
        COMinit();
        int x, y;
        cin >> x >> y;
        if((x + y) % 3 != 0) {
                cout << 0 << endl;
                return 0;
        }
        int q;
        int l = (x + y) / 3;
        for(int i = 0; i <= l; i++) { //iは上移動、l-iは横移動の回数
                int a = i + ((l - i) * 2);
                int b = (l - i) + (i * 2);
                if(x ==a && y == b) {
                        q = i;
                        break;
                }
        }
        int ans = COM(l,q) % MOD;
        cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    ll maxLen = K - A[N - 1] + A[0];
    ll total = maxLen;
    rep(i, N - 1) {
        ll len = A[i + 1] - A[i];
        chmax(maxLen, len);
        total += len;
    }
    cout << total - maxLen << endl;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	int n,m,p=0;
	double sum=0.0;
	cin>>n>>m;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	for(int j=0;j<n;j++){
		if(arr[j]>=sum/(4*m)){
			p++;
		}
	}
	if(p>=m){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

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

parent = [i for i in range(N + M)]
rank = [0] * (N + M)


def find(i):
    if parent[i] == i:
        return i
    else:
        parent[i] = find(parent[i])
        return parent[i]


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


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return

    if rank[x] > rank[y]:
        parent[y] = x
    else:
        parent[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1


for i in range(N):
    P = list(map(int, input().split()))
    n = P[0]
    for j in range(1, n + 1):
        unite(i, P[j] - 1 + N)


k = find(0)
for i in range(N):
    if k != find(i):
        print('NO')
        exit()

print('YES')

Measured memory_bytes: 13460
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  int d = abs(n-m);
  mint ans;
  if(d > 1){
    ans = 0;
  }else if(d == 1){
    mint p = 1;
    rep(i, min(n, m)){
      p *= (i+1);
    }
    mint pp = p * (min(n, m)+1);
    cerr << p.x << " " << pp.x << endl;
    ans = p * pp;
  }else{
    mint p = 1;
    rep(i, n){
      p *= (i+1);
    }
    p *= p;
    ans = p * 2;
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 3652
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
prime_factors = factorization(N)
if prime_factors[0][0] == 1:
    print(0)
else:
    ans = 0
    for pf in prime_factors:
        n = pf[1]
        i = 0
        while n >= i:
            n -= i
            i += 1
        ans += i-1
    print(ans)

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

  
int main() {

  string a;
  cin >> a;
  
  int count = a.size();
  vector<int> s(count);
  vector<int> s0(count);
  vector<int> s1(count);
  
  vector<char> b;
  b.push_back('0');
  b.push_back('1');
  
  int d0 = 0;
  int d1 = 0;
  
  for(int i=0; i<count; i++)
  {
    s[i] = a[i];
    int id0 = i%2;
    int id1 = (i+1)%2;
//  cout << id1 << ", " << id0 << endl;
//    s0[i] = b[id0];
//    s1[i] = b[id1];
    
    if(a[i] != b[id1])
    {
      d0++;
    }
    if(a[i] != b[id0])
    {
      d1++;
    }
  }
  
//  cout << d1 << ", " << d0 << endl;
  cout << min(d1,d0) << endl;
  
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define _IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll N=1e5+9,mod=1e9+7,inf=1e18;


int main()
{
    _IO;
    int k;cin>>k;
    while(k--)cout<<"ACL";
    cout<<"\n";


}


Measured memory_bytes: 3648
# include "cstdio"
# include "iostream"

using namespace std;

const int maxm=1e2+10;

int D[maxm],Cnt[maxm];

int main(){
	register int i;
	int X,Y;
	for(i=1;i<=3;i++) scanf("%d%d",&X,&Y),D[X]++,D[Y]++;
	for(i=1;i<=4;i++) Cnt[D[i]]++;
	puts((Cnt[1]==2 && Cnt[2]==2)?"YES":"NO");
	return 0;
}

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

int main()
{
    string S,T;
    cin >> S >> T;
    int ans = 1; 
    for(int i=0;i<S.size();i++)
    {
        if(S[i]!=T[i])
        {
            ans = 0;
        }
    }
    if(ans)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}

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

int
main ()
{
  string S;
  cin >> S;
  if (S == "ABC")
    {
      std::cout << "ARC" << std::endl;
    }
  if (S == "ARC")
    {
      std::cout << "ABC" << std::endl;
    }
  return 0;
}

Measured memory_bytes: 3624
def solve():
    N = int(input())
    S = input()
    attention = sum(s != 'W' for s in S[1:])
    min_val = attention
    # print(min_val)
    for i in range(1,N):
        if S[i] == 'E': attention -= 1
        if S[i-1] != 'E':
            attention += 1
        # print(attention)
        min_val = min(min_val, attention)
    
    # print('---')
    print(min_val)
    
solve()

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

int dirx[]={1,-1,0,0};
int diry[]={0,0,1,-1};

int32_t main()
{
	int n,m;
	cin>>n>>m;

	char arr[n][m];
	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++) cin>>arr[i][j];

	int ans=0;
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++){
			if (arr[i][j]=='#') continue;

			//Choose Start Node
			queue<pair<int,pair<int,int>>>q;
			q.push({0,{i,j}});

			bool vis[n][m];
			for (int i=0;i<n;i++)
			for (int j=0;j<m;j++) vis[i][j]=0;
			vis[i][j]=1;

			while (!q.empty()){
				auto y = q.front();
				q.pop();

				ans=max(ans,y.first);

				for (int dir=0;dir<4;dir++){
					int newx = y.second.first + dirx[dir];
					int newy = y.second.second + diry[dir];

					if (newx>=0 && newy>=0 && newx<n && newy<m && arr[newx][newy]!='#' && !vis[newx][newy])
					{
						vis[newx][newy] = 1;
						q.push({y.first+1,{newx,newy}});
					}
				}

			}
			
		}
	}

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


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

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

const int nax = 3005;

ll dp[nax][nax];

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

   int n;
   cin>>n;
   vector<ll>a(n);
   ll sum = 0;

   for(auto& x : a)cin>>x, sum += x;

   for(int gap = 0; gap < n; gap++){
       for(int i = 0, j = gap; j < n; ++i,++j){
           ll x,y,z;
            x = ((i+2)<=j)?dp[i+2][j] : 0;
            y = ((i+1)<=(j-1))?dp[i+1][j-1] : 0;
            z = ((i <= (j-2)) ? dp[i][j-2] : 0);
           dp[i][j] = max(a[i] + min(x,y), a[j] + min(y,z));
       }
   }

   cout<<2*dp[0][n-1]-sum;




}

Measured memory_bytes: 70016
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
#define int long long
	int n;
	cin >> n;
	vector<pair<int, int>> inputs;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		inputs.push_back(make_pair(b, a));
	}
	sort(inputs.begin(), inputs.end());
	int now = 0;
	REP(i, inputs.size()) {
		now += inputs[i].second;
		if (now > inputs[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 6384
#include <iostream>
using namespace std;
 
int main(){
    int a,b,c,d; cin >>a>>b>>c>>d;
    if ((a+b)>(c+d)) cout<<"Left"<<endl;
    else if ((a+b)<(c+d)) cout <<"Right"<<endl;
    else cout <<"Balanced"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
const int N = 1e6 + 500;
const long long mod = 998244353;
const long long INF = 1LL << 57;
const int LN = 22;

long long n, m, u, v, k, t, q, x, d, p, a, b, c, s;

typedef long long ll;
map <int, int> mx, my;
int tree[2][N];
int X[N], Y[N];


vector <pair <int, int> > res;

void add(int bit, int x, int val) {
   while (x < N) {
      tree[bit][x] += val;
      x += (x &-x);
   }
}

int get(int bit, int x) {
   int ret = 0;
   while (x > 0) {
      ret += tree[bit][x];
      x -= (x &-x);
   }
   
   return ret;
}

long long two[N];

ll mul(ll A, ll B) {
   return (A*B)%mod;
}

ll Add(ll A, ll B) {
   return (A+B)%mod;
}
ll sub(ll A, ll B) {
   return (A-B+mod)%mod;
}

int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> n;
   for (int i = 1; i <= n; ++i) {
      cin >> X[i] >> Y[i];
      mx[X[i]];
      my[Y[i]];
   }
   two[0] = 1;
   for (int i = 1; i <= n; ++i) {
      two[i] = (two[i - 1] * 2) % mod;
   }
   int i = 0;
   
   for (auto &it: mx) {
      it.second = ++i;
   }
   
   i = 0;
   for (auto &it: my) {
      it.second = ++i;
   }
   
   for (int i = 1; i <= n; ++i) {
      X[i] = mx[X[i]];
      Y[i] = my[Y[i]];
      //cout << X[i] << " " << Y[i] << endl;
      res.push_back(make_pair(X[i], Y[i]));
   }
   res.push_back({-1, -1});
   sort(res.begin(), res.end());
   for (int i = n; i >= 1; --i) {
      add(1, res[i].second, 1);
   }
   
   long long sol = 0;
   
   for (int i = 1; i <= n; ++i) {
      add(1, res[i].second, -1);
      int right = n - i;
      int left = i - 1;
      int left_down = get(0, res[i].second);
      int left_up = i - 1 - left_down;
      int right_down = get(1, res[i].second);
      int right_up = right - right_down;
      int up = right_up + left_up;
      int down = right_down + left_down;
      
      
      sol = Add(sol, two[n]);
      sol = sub(sol, two[up]);
      sol = sub(sol, two[down]);
      sol = sub(sol, two[right]);
      sol = sub(sol, two[left]);
      sol = Add(sol, two[left_up]);
      sol = Add(sol, two[right_up]);
      sol = Add(sol, two[left_down]);
      sol = Add(sol, two[right_down]);
      sol = sub(sol, 1);
      add(0, res[i].second, 1);
   }
   cout << sol << endl;
}


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
using ll=unsigned long long int;
int const m=1000000007;
int main(){

ll n,x,t;
cin>>n>>x>>t;
if(n<=x){
	cout<<t;
}
else if(n%x==0){
	ll a=n/x;
	cout<<a*t;
}
else if(n%x != 0){
	ll a=n/x;
	a+=1;
	cout<<a*t;
}

return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int d,s,t;
cin>>d>>s>>t;
if(d>s*t)
{
	cout<<"No"<<endl;
}
else{
	cout<<"Yes"<<endl;
}
}

 
 

 


Measured memory_bytes: 3644
/**
 *　　　　　　　　┏┓　　 　┏┓
 * 　　　　　　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　　　┃　　　　　　　┃ 　
 * 　　　　　　　┃　　　━　　 　┃
 * 　　　　　　　┃　＞　　　＜　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃...　⌒　... 　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┗━┓　　　┏━┛
 * 　　　　　　　　　┃　　　┃　Code is far away from bug with the animal protecting　　　　　　　　　　
 * 　　　　　　　　　┃　　　┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃　　　┃　　　　　　　　　　　
 * 　　　　　　　　　┃　　　┃  　　　　　　
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃　　　　　　　　　　　
 * 　　　　　　　　　┃　　　┗━━━┓
 * 　　　　　　　　　┃　　　　　　　┣┓
 * 　　　　　　　　　┃　　　　　　　┏┛
 * 　　　　　　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　　　　　　┃┫┫　┃┫┫
 * 　　　　　　　　　　┗┻┛　┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<assert.h>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1LL<<(x))
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid ((x+y)>>1)
#define NM 505
#define nm 11
#define pi 3.1415926535897931
const ll inf=998244353;
using namespace std;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}




ll s,x,y,_x,_y;

int main(){
    //x*_y-_x*y
    x=1e9;
    s=read();
    if(s==1000000000000000000){
	x=1e9;_y=1e9;_x=0;y=0;
	return 0*printf("0 0 %lld %lld %lld %lld\n",x,y,_x,_y);
    }
    _y=s/x+1;
    s=x*_y-s;
    _x=s;y=1;
    printf("0 0 %lld %lld %lld %lld\n",x,y,_x,_y);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  ll x, y;
  cin >> x >> y;
  ll ans = 2e9;

  if (x <= y)
    ans = min(ans, y - x);
  if (-x <= y)
    ans = min(ans, y + x + 1);
  if (x <= -y)
    ans = min(ans, -y - x + 1);
  if (-x <= -y)
    ans = min(ans, -y + x + 2);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 764
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

#[derive(Debug)]
struct Dice {
    top: u32,
    south: u32,
    east: u32,
    west: u32,
    north: u32,
    bottom: u32,
}

impl Dice {
    fn go_north(&mut self) {
        let tmp = self.top;
        self.top = self.south;
        self.south = self.bottom;
        self.bottom = self.north;
        self.north = tmp;
    }

    fn go_south(&mut self) {
        let tmp = self.top;
        self.top = self.north;
        self.north = self.bottom;
        self.bottom = self.south;
        self.south = tmp;
    }

    fn go_east(&mut self) {
        let tmp = self.top;
        self.top = self.west;
        self.west = self.bottom;
        self.bottom = self.east;
        self.east = tmp;
    }

    fn go_west(&mut self) {
        let tmp = self.top;
        self.top = self.east;
        self.east = self.bottom;
        self.bottom = self.west;
        self.west = tmp;
    }
}

fn main() {
    let v = read_vec::<u32>();
    let mut dice = Dice {
        top: v[0],
        south: v[1],
        east: v[2],
        west: v[3],
        north: v[4],
        bottom: v[5],
    };

    let n = read::<usize>();
    for _ in 0..n {
        let v2 = read_vec::<u32>();
        let top = v2[0];
        let south = v2[1];

        let mut f = 0;
        while dice.south != south {
            match f {
                4 => {
                    dice.go_west();
                    dice.go_south();
                }
                5 => {
                    dice.go_north();
                    dice.go_north();
                }
                _ => dice.go_north(),
            }
            f += 1;
        }
        while dice.top != top {
            dice.go_east();
        }
        println!("{}", dice.east);
    }
}



Measured memory_bytes: 5032
class imosOneDimension:
    def __init__(self, size):
        self.table = [0 for i in range(size)]

    def setTable(self):
        for i in range(len(self.table)-1):
            if is_prime(i) and is_prime(int((i + 1) / 2)):
                self.table[i] = 1
                # self.table[i] += self.table[i - 1]

    def cumulativeSum(self):
        for i in range(1, len(self.table)):
            self.table[i] += self.table[i - 1]


def is_prime(n):
    if (n == 1):
        return False
    if (n == 2):
        return True
    if (n % 2 == 0):
        return False
    i = 3
    while (i ** 2 <= n):
        if (n % i == 0):
            return False
        i += 2
    return True

imos = imosOneDimension(size=10 ** 5 + 1)
imos.setTable()
tableOneHot = []
for i in range(len(imos.table)):
    if imos.table[i] == 1:
        tableOneHot.append(i)
#print(tableOneHot)
#print(imos.table)

imos.cumulativeSum()
#print(imos.table)
q = int(input())
for i in range(q):
    l, r = [int(i) for i in input().split()]
    print(imos.table[r] - imos.table[l - 1])


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

def main():

    N, K = map(int, input().split())
    p = list(map(int, input().split()))

    ans = 0

    p.sort()
    

    for i in range(K):
        ans += p[i]

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9236
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define in(e,l) (std::find(l.begin(), l.end(), e) != l.end())
#define asort(l) (std::sort(l.begin(), l.end()))
#define dsort(l) (std::sort(l.rbegin(), l.rend()))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;

int main() {
  ll N;
  cin >> N;
  vl a(N);
  double ans = 0;
  rep(i, N){
    cin >> a[i];
    ans += (1.0) / a[i];
  }
  cout << 1 / ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,d,a[110];
int main(){
	int i,j,l;
	cin>>n>>k;
	for(i=1;i<=k;i++){
		cin>>d;
		for(j=1;j<=d;j++){
			cin>>l;
			a[l]=1;
		}
	}
	int cnt=0;
	for(i=1;i<=n;i++){
		if(a[i])cnt++;
	}
	cout<<n-cnt;
	getchar();getchar();
}

Measured memory_bytes: 3636
import java.util.Scanner;

// implement the linear search
public class Main {
	
	public static int linear_search(int[] q, int x) {
		int i = 0;
		while(i < q.length) {
			if(q[i] == x) {
				return i;
			}
			i++;
		}
		
		
		return -1;
	}
	
	public static void main(String [] args) {
		Scanner cin = new Scanner(System.in);
		
		int len = cin.nextInt();
		int [] q = new int[len];
		for(int i = 0; i < len; i++) {
			q[i] = cin.nextInt();
		}
		
		
		int count = 0;
		len = cin.nextInt();
		int x = 0;
		while(len > 0) {
			x = cin.nextInt();
			count += (linear_search(q, x) >= 0)? 1:0;
			len --;
		}
		
		
		System.out.println(count);
	}
	

}

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

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 3; ++i) if (i != a && i != b) cout << i << endl;
	return 0;
}


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

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

    if(n>=b-1)cout<<(a*(b-1))/b<<endl;
    else cout<<(a*n)/b-a*(n/b)<<endl;
  
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)

typedef pair<int, int> P;

ll modnum = 998244353;

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

int main() {
    int n; ll k;
    cin >> n >> k;
    rep(i, n) {
        cin >> to[0][i];
        to[0][i]--;
    }

    // ダブリングのテーブルを埋める
    rep(i, D-1) rep(j, n) to[i+1][j] = to[i][to[i][j]];

    int v = 0;
    for( int i = D-1; i >= 0; i--) {
        // bitでi番目の数値
        ll l = 1ll<<i;
        // kがl以上なら、その数を使っているので、その遷移を実行後に引いておく
        if(l <= k) {
            v = to[i][v];
            k -= l;
        }
    }

    cout << v + 1 << endl;

    return 0;

}



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

const long long INF = 1LL << 60;



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

int main() {
    ll X;
    cin>>X;
    bool a=true;
    ll cnt=0;
    ll k=0;
    ll ans=0;
    while(a==true){
        k+=cnt+1;
        if(X<=k){
            cout<<cnt+1<<endl;
            a=false;
        }
        cnt++;
    }
}

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main() {
	ll a, b, c;
    cin >> a >> b >> c;
  	ll d = c-a-b;
    if(d > 0 && 4*a*b < d*d) cout << "Yes" << endl;
  	else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        long k = sc.nextInt();
        long a[] = new long[n + 1];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        long b[] = new long[n + 1];
        TreeMap<Long, Integer> map = new TreeMap<>();
        long sum = 0;
        for (int i = 0; i <= n; i++) {
            b[i] = sum - k * i;
            map.putIfAbsent(b[i], null);
            sum += a[i];
        }
        int value = 0;
        for (Map.Entry<Long, Integer> entry : map.entrySet()) {
            entry.setValue(value++);
        }

        int bn = Integer.highestOneBit((n + 1) * 2 - 1);
        long bit[] = new long[2 * bn];
        long ans = 0;
        for (int i = 0; i <= n; i++) {
            int c = map.get(b[i]);
            ans += query(c, bn, bit) + bit[c + bn];
            add(c, bn, bit);
        }

        System.out.println(ans);
    }

    private void add(int n, int off, long bit[]) {
        if (off == 0) {
            return;
        }

        bit[n + off]++;
        add(n / 2, off / 2, bit);
    }

    private long query(int n, int off, long bit[]) {
        if (off == 0) {
            return 0;
        }

        return (n % 2) * bit[n + off - 1] + query(n / 2, off / 2, bit);
    }

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


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

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

  int a, b, c, d, e;
  int cnt = 0;
  for(int i = A; i <= B; i++){
    a = i / 10000;
    b = i % 10000 / 1000;
    d = i % 100 / 10;
    e = i % 10;
    if(a == e && b ==d)cnt++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        String S = scanner.next();
        int ans = 1;
        char prev = S.charAt(0);
        for (int i = 1; i < N; i++) {
            if (S.charAt(i) != prev) {
                prev = S.charAt(i);
                ans++;
            }
        }

        System.out.println(ans);
    }
}


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

int main(){
    int n,d,x;
    cin >> n;
    cin >> d >> x;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans = x;
    for(int i=0;i<n;i++){
        int j = 0;
        while(1+a[i]*j <= d){
            ans++;
            j++;
        }
    }
    cout << ans << endl;

}

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

using namespace std;

int main() {
  string s; cin >> s;
  string ans="";
  for(int i=0; i<s.size(); ++i) {
    if(s[i]=='B' && ans.size()>0) {
      ans.pop_back();
    } else if(s[i]!='B') {
      ans+=s[i];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3560
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int i;
    for(i=0;a<=b;a++)
        if(c%a == 0 ){
        i++;
    }
    printf("%d\n",i);
    
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>

int main() {

    int A;
    int B;
    int charge = 0;

    std::cin >> A >> B;

    if(A >= 13) charge += B;
    else if(A >= 6)charge += (B/2);

    std::cout << charge << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

int main()
{
    for(;;){
        int w, h, n;
        cin >> w >> h >> n;
        if(w == 0)
            return 0;

        vector<vector<bool> > wall(2*h+1, vector<bool>(2*w+1, true));
        for(int i=1; i<2*h; ++i){
            for(int j=1; j<2*w; ++j){
                wall[i][j] = false;
            }
        }

        for(int i=0; i<n; ++i){
            int x1, y1, x2, y2;
            cin >> x1 >> y1 >> x2 >> y2;

            if(x1 == x2){
                for(int y=min(y1,y2); y<max(y1,y2); ++y)
                    wall[y*2+1][x1*2] = true;
            }else{
                for(int x=min(x1,x2); x<max(x1,x2); ++x)
                    wall[y1*2][x*2+1] = true;
            }
        }

        int sx1, sy1, sx2, sy2;
        cin >> sx1 >> sy1 >> sx2 >> sy2;
        int y, x, d;
        if(sy1 == 0 && sy2 == 0){
            y = 1;
            x = min(sx1, sx2) * 2 + 1;
            d = 0;
        }else if(sy1 == h && sy2 == h){
            y = 2 * h - 1;
            x = min(sx1, sx2) * 2 + 1;
            d = 2;
        }else if(sx1 == 0 && sx2 == 0){
            y = min(sy1, sy2) * 2 + 1;
            x = 1;
            d = 1;
        }else{
            y = min(sy1, sy2) * 2 + 1;
            x = 2 * w - 1;
            d = 3;
        }

        int gx, gy;
        cin >> gx >> gy;
        gy = gy * 2 + 1;
        gx = gx * 2 + 1;
        
        int move = 1;
        vector<vector<vector<bool> > > check(2*h+1, vector<vector<bool> >(2*w+1, vector<bool>(4, false)));
        for(;;){
            if(y == gy && x == gx){
                cout << move << endl;
                break;
            }else if(check[y][x][d]){
                cout << "Impossible" << endl;
                break;
            }
            check[y][x][d] = true;

            if(!wall[y+dy[(d+3)%4]][x+dx[(d+3)%4]]){
                d = (d + 3) % 4;
                y += dy[d] * 2;
                x += dx[d] * 2;
                ++ move;
            }else if(!wall[y+dy[d]][x+dx[d]]){
                y += dy[d] * 2;
                x += dx[d] * 2;
                ++ move;
            }else{
                d = (d + 1) % 4;
            }
        }
    }
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
long long P = 998244353; 
long long inv[1000010]; 
int N; 
long long A[200010]; 
long long cnt[1000010]; 
long long sum[1000010]; // sum[i] := iの倍数の総和
long long keisuu[1000010]; 
bool isprime(int num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	for(int i = 3; i * i <= num; i++){
		if(num % i == 0) return false; 
	}
	return true; 
}
void init() {
	inv[1] = 1;
	for(int i = 2; i < 1000005; i++) {
		inv[i] = P - inv[P % i] * (P / i) % P;
	}
}
int main(){
	cin >> N; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; cnt[A[i]] ++; 
	}
	for(int i = 1; i <= 1000000; i++){
		for(int j = 1; i * j <= 1000000; j++){
			sum[i] += (cnt[i*j] * i * j) % P; 
			if(sum[i] >= P) sum[i] -= P; 
		}
	}
	init(); 
	fill(keisuu, keisuu+1000005, 1); 
	for(long long i = 2; i <= 1000000; i++){
		if(!isprime((int) i)) continue; 
		long long mul = (P + 1 - i) % P; 
		for(int j = 1; i * j <= 1000000; j++){
			keisuu[i*j] *= mul; 
			keisuu[i*j] %= P; 
		}
	}
	long long ans = P; 
	ans -= sum[1] % P; 
	for(int i = 1; i <= 1000000; i++){
		if(!sum[i]) continue; 
		ans += (((sum[i] * sum[i] % P) * keisuu[i] % P) * inv[i]) % P; 
		if(ans >= P) ans -= P; 
	}
	ans *= inv[2]; ans %= P; 
	cout << ans << endl; 
}

Measured memory_bytes: 33152
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int A,B,C;
	cin>>A>>B>>C;
	if(A*C<=B)
	{
		cout<<C<<endl;
	}
	else
	{
		cout<<(B/A)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1e18;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define all(x) (x).begin(), (x).end()

// 10進数 n の桁数を求める
ll num_digit(ll n) {
    ll res = 0;
    while (n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

ll N;

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

    cin >> N;
    ll cnt = 0;
    reps(i, N) {
        if (num_digit(i)%2 == 1) {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n; long long a[100100], x;

int main()
{
  scanf ("%d",&n);
  for (int i=0;i<n;i++){
	scanf ("%lld",&a[i]);
    x ^= a[i];
  }
  
  long long basis[64] = {0,};
  for (int k=0;k<n;k++){
    long long v = (a[k] | x) ^ x;
    for (int i=62;i>=0;i--) if (v & (1ll << i)){
      if (!basis[i]){basis[i] = v; break;}
      else v ^= basis[i];
    }
  }
  
  long long ans = 0;
  for (int i=62;i>=0;i--){
	if ((ans & (1ll << i)) == 0) ans ^= basis[i];
  }
  ans *= 2;
  ans += x;
  printf ("%lld\n",ans);
  

return 0;
}


Measured memory_bytes: 4004
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
  
  ll a,b,k;
cin >> a >> b >> k;
	long long i,cnt=0;
	for (i = min(a, b); i >= 1; i--) 
	{
		if (a % i == 0 && b % i == 0) 
		{
			cnt++;
			if (cnt == k)
				break;
		}
	}
	cout << i << endl;
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a > 12){
    cout << b << endl;
  }else if(a > 5){
    cout << b/2 << endl;
  }else{
    cout << "0" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())

def push(chara, dig):
  if ord(chara) + dig > 90: return chr(64 + dig + ord(chara) -90)
  else: return chr(dig + ord(chara))
  
string = input()
e = ""
for i in range(0, len(string)):
  e = e + push(string[i], n)
  
print(e)


Measured memory_bytes: 9112
#include<iostream>
#include<stdio.h>
#include<cmath>
#define EPS 0.00001
using namespace std;


bool eq(double x,double y){
  if(abs(x-y)<EPS*y)return true;
  else return false;
}

long long  n;
double t[1000000];
int main(){
  while(cin>>n){
    if(n==-1)break;
    t[1]=n/2.0;
    for(int i=1;i<1000000;i++){
      if(i==1)t[i]=n/2.0;
      else t[i]=t[i-1]-(t[i-1]*t[i-1]*t[i-1]-(double)n)/(3.0*t[i-1]*t[i-1]);

      if(eq(t[i]*t[i]*t[i],(double)n)){
	//cout<<t[i]<<endl;
	printf("%.6f\n",t[i]);
	break;
      }
    }
    
  }
}

Measured memory_bytes: 1196