akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
    int a1,b1;cin >> a1 >> b1;
    int a2,b2;cin >> a2 >> b2;
    if(a1!=a2) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int n,k,a[1010],ans=0;

int main(){
	ios::sync_with_stdio(false);
	int i;
	cin>>n>>k;
	for(i=1;i<=n;++i)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(i=1;i<=k;++i)
		ans+=a[i];
	cout<<ans;
	
	
	return 0;
}

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

typedef long long ll;
int n, k, a[200000];
string s;

map<string, int> m = {{"SUN", 7},
                      {"MON", 6},
                      {"TUE", 5},
                      {"WED", 4},
                      {"THU", 3},
                      {"FRI", 2},
                      {"SAT", 1}};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> s;
    cout << m[s] << endl;
    return 0;
}

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

int main(void)
{
    char str[100000];
    int i, count;

    cin >> str;

    i=0;
    count= 0;
    while (str[i] != '\0') {
        if (i % 2 == 0) {
            if (str[i] != '0') {
                count += 1;
            }
        } else {
            if (str[i] != '1') {
                count += 1;
            }
        }
        i++;
    }

    cout << min(count, i - count) << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main() {
int n;
cin >> n;int che = 0;
vector<int>a(n);
for(int i=0;i<n;i++){
cin >> a.at(i);
che+=a.at(i);
}
che/=n;
ll ans = 0;
for(int i=0;i<n;i++){
  ans+=pow(che-a.at(i),2);
}
che++;
ll z=0;
for(int i=0;i<n;i++){
  z+=pow(che-a.at(i),2);
}
chmin(ans,z);
cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//
int 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;
    }
}

// 二項係数計算
int 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;
}

     signed main(){
     COMinit();
     int n,m;
     cin>>n>>m;
     int ans=0,ans2=fac[m]*finv[m-n]%MOD,t=1;
     for(int i=0;i<=n;i++){
         ans=(ans+MOD+t*(COM(n,i)*fac[m-i]%MOD*finv[m-n]%MOD))%MOD;
         t*=-1;
       //  cerr<<ans<<endl;
         }
     cout<<ans*ans2%MOD<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 15584
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(input.readLine());
			
			int taro = 0;
			int hanako = 0;
			for (int i = 0; i < n; i++) {
				final String[] cards = input.readLine().split(" ");
				if (0 < cards[0].compareTo(cards[1])) {
					taro += 3;
				} else if (cards[0].compareTo(cards[1]) < 0) {
					hanako += 3;
				} else {
					taro++;
					hanako++;
				}
			}
			
			System.out.println(taro + " " + hanako);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}

Measured memory_bytes: 20260
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
//
//		  _____       _           _        _
//		 / ____|     | |         (_)      | |
//		| (___   __ _| |__  _   _ _       | | __ _ _ __   __ _
//		 \___ \ / _` | '_ \| | | | |  _   | |/ _` | '_ \ / _` |
//		 ____) | (_| | |_) | |_| | | | |__| | (_| | | | | (_| |
//		|_____/ \__,_|_.__/ \__,_| |  \____/ \__,_|_| |_|\__,_|
//		                        _/ |
//		                       |__/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define int long long int
#define double long double
#define PI acos(-1)

void print1d(const vector<int>& vec) {for (auto val : vec) {cout << val << " ";} cout << endl;}

void print2d(const vector<vector<int>>& vec) {for (auto row : vec) {for (auto val : row) {cout << val << " ";} cout << endl;}}

signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("error.txt", "w", stderr);
// #endif
	crap;

	int n;
	cin >> n;

	int ans = (n / 500) * 1000 + ((n % 500)/5) * 5;
	cout << ans << endl;



	return 0;
}






Measured memory_bytes: 256
#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 rep2(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 tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m;
    cin >> n >> m;
    int l = 1,r = 1+m;
    while(l < r) {
        cout << l << " " << r << endl;
        l++;
        r--;
    }
    l = m+2,r = l+m-1;
    while(l < r) {
        cout << l << " " << r << endl;
        l++;
        r--;
    }
}


Measured memory_bytes: 3656
import fractions
lcm = lambda a, b: a * b // fractions.gcd(a, b)
A, B, C, D = map(int, input().split(' '))
div_A = A - 1 - (A - 1) // C - (A - 1) // D + (A - 1) // lcm(C, D)
div_B = B - B // C - B // D + B // lcm(C, D)
print(div_B - div_A)

Measured memory_bytes: 5984
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

//コスト最小化
const long long INF = 1LL << 60;
long long dp[100010];

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

int main(){
    int n; cin >> n;
    int h[n];
    for(int i = 0; i < n; i++) cin >> h[i];
    for(int i = 0; i < 100010; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 1; i < n; i++){
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if(i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1408
#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 n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i,n)  cin >> p[i];
    rep(i,n)  cin >> q[i];
    vector<int> a(n);
    rep(i,n) a[i] = i + 1;

    map<vector<int>, int> mp;
    do{
        mp[a] = mp.size();
    }while(next_permutation(a.begin(), a.end()));

    int ans = abs(mp[p] - mp[q]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
const int P=998244353;
string S;
unordered_map<string,int> f,g;
int Mod(int x){return x>=P?x-P:x;}
int F(string S);
int G(string S){
	if(g.find(S)!=g.end())return g[S];
	if(S.size()==1)return g[S]=S[0]-'0'+1;
	for(int i=1;i<S.size();i++)
	if(S.size()%i==0){
		string T;
		for(int j=0;j<i;j++){
			int r=1;
			for(int k=0;k<S.size()/i;k++)r&=(S[i*k+j]=='1');
			T+=(char)(r+'0');
		}g[S]=Mod(g[S]+F(T));
 	}
	return g[S];
}
int F(string S){
	if(f.find(S)!=f.end())return f[S];
	for(int i=1;i<=S.size();i++)
	f[S]=Mod(f[S]+1ll*G(S.substr(0,i))*F(S.substr(i,S.size()-i))%P);
	return f[S];
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>S,f[""]=1;
	printf("%d",F(S));
	return 0;
}

Measured memory_bytes: 13036
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_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 all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

const int maxn = 3000;
double dp[maxn][maxn];

void solve(){
	//write here
    int n;
    cin>>n;
    vector<double> p(n);
    rep(i,0,n)cin>>p[i];
    for (int j = 0 ; j<=n ; j++)dp[0][j] = 0;
    dp[0][0] = 1;
    for (int i = 1 ; i<=n ; i++)dp[i][0] = dp[i-1][0] *(1- p[i-1]);
    for (int i = 1 ; i<=n ; i++){
        for (int j = 1 ; j<=i ; j++){
            dp[i][j] = dp[i-1][j-1] * p[i-1] + dp[i-1][j]*(1 - p[i-1]);
        }
    }
    double ans = 0;
    for (int i = (n+1)/2 ; i<=n ; i++)ans+=dp[n][i];
    cout<<setprecision(10)<<ans<<endl;
    
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

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

#define MAX 16777216

using namespace std;

bool dic[16777216];

int getStrNum(string str){
	int sum = 0, p=1;
	for(int i=0;i<str.size();++i){
		if(str[i] == 'A')sum += 1*p;
		else if(str[i] == 'C')sum += 2*p;
		else if(str[i] == 'G')sum += 3*p;
		else if(str[i] == 'T')sum += 4*p;
		p*=4;
	}
	return sum;
}

int main(){
	int n, i;
	cin >> n;
	
	string siji, _str;
	for(i=0;i<n;++i){
		cin >> siji >> _str;
		if(siji[0] == 'i'){
			dic[getStrNum(_str)]=true;
		}else{
			if(dic[getStrNum(_str)])cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,Q,a;cin>>N>>K>>Q;
  vector<int>A(N,K);
  for(int i=0;i<Q;i++){
    cin>>a;A.at(a-1)++;
  }
  for(int i=0;i<N;i++){
    if(A.at(i)>Q)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int dfs(std::vector<int> v, int n, int a) {
	if (v.size() == n) {
		return 1 - a;
	}

	if (v[n] % 2 == 1) {
		return dfs(v, n + 1, 0) * 2 + dfs(v, n + 1, a);
	}
	else {
		return dfs(v, n + 1, 0) + dfs(v, n + 1, a) * 2;
	}
}

int main()
{
	long long n;

	std::cin >> n;

	std::vector<int> v(n);

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v[i];
	}

	std::cout << dfs(v, 1, (v[0] - 1) % 2) + dfs(v, 1, v[0] % 2) + dfs(v, 1, (v[0] + 1) % 2) << std::endl;
	
	return 0;
}


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

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

  double ans = 0;
  for (int i = 1; i <= N; i++) {
    int score = i;
    double tot = 1;
    while (score < K) {
      tot /= 2;
      score *= 2;
    }
    ans += tot / N;
  }

  cout << fixed << setprecision(9);
  cout << ans << endl;
}

Measured memory_bytes: 256
def check(x, y)
  2.times do |z|
    4.times do
      return true if x == y
      a, b, c, d, e, f  = x
      x = z.zero? ? [e, a, c, d, f, b] : [d, b, a, f, e, c]
      c = x
      4.times do
        i, j, k, l, m, n = c
        c = [i, k, m, j, l, n]
        return true if c == y
      end
    end
  end
  false
end

ar = $<.map(&:chomp).map(&:split).drop(1)
ar.size.times do |x|
  (x+1).upto(ar.size - 1) do |y|
    (puts 'No')^exit if check(ar[x], ar[y])
  end
end
puts 'Yes'

Measured memory_bytes: 10000
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
LL ans[10050]={0};
int main()
{
        LL n;
        cin>>n;
        fr(i,1,105){
            fr(j,1,105){
                fr(k,1,105){
              LL v= i*i+j*j+k*k+i*j+j*k+k*i;
              if (v<10050) ans[v]+=1; 
        }
        }
        }
        fr(i,1,n+1) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 3580
N, A, B = input().split(' ')
N = int(N)
A = int(A)
B = int(B)
S = []
S = list(input())
JS = 0
AS = 0
OT = 0

for i in range(N):
  if S[i] == 'a' and A+B > JS+AS:
    print('Yes')
    JS += 1
  elif S[i] == 'b' and A+B > JS+AS and AS < B:
    print('Yes')
    AS += 1
  else:
    print('No') 

Measured memory_bytes: 4712
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

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


int i,j;

int main(void){
    
    string a,b,c;
    cin>>a>>b>>c;
    string ans;
    char A=a[0]-32,B=b[0]-32,C=c[0]-32;
    //ans = (a[0]-32)+(b[0]-32)+(c[0]-32);
    //transform( ans.begin(), ans.end(), ans.begin(), toupper );
    cout<<A<<B<<C;
    
    
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int range = 10000002;
int spf[10000002];

void smallest_prime_factor(){
    for (int i = 0; i < range; ++i)
    {
        spf[i]=i;
    }
    spf[0]=0;
    spf[0]=0;
    for (int i = 4; i < range; i+=2)
    {
        spf[i]=2;
    }

    for (int i = 3; i*i<range; i+=2)
    {
        if(spf[i]==i){
            for (int j = i*i; j<range; j+=i)
            {
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }    
    }
}

int tot_factors(int n){
    map<int, int> m1;
    int ans=1;
    while(n!=1){
        m1[spf[n]]++;
        n=n/spf[n];
    }
    for (auto i = m1.begin(); i != m1.end(); ++i)
    {
        ans = ans * (i->S+1);
    }
    return ans;
}


int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    smallest_prime_factor();
    int n;
    cin>>n;
    ll ans=1;
    for (ll i = 2; i<=n; ++i)
    {
        int tot = tot_factors(i);
        ans = ans + (long(tot)*i);
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 42676
#include<iostream>
using namespace std;
using ll = long long;

int main() {
	ll a, b, c, x, y, ans;
	cin >> a >> b >> c >> x >> y;
	ans = min(x, y) * min(a + b, 2 * c);
	if (x < y) {
		ll n = y - x;
		ans += n * min(b, 2 * c);
	} else {
		ll n = x - y;
		ans += n * min(a, 2 * c);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        1000005
#define LOG         20
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a,b,x,mi,y,ans,ans1=0,ans2=0;
    cin>>n>>a>>b;
    x=b-a;
    if(x%2==0){
        x=x/2;
        cout<<x;
    }
    else{
        x=a;
        y=b;
        ans1+=x-1;
        y=y-(x-1);
        ans1++;
        y--;
        ans1+=y/2;
        ans2+=n-b;
        //cout<<ans2<<endl;
        a=a+(n-b);
        ans2++;
        a++;
        ans2+=(n-a)/2;
        //cout<<ans1<<" "<<ans2<<endl;
        cout<<min(ans1,ans2);
    }
}

Measured memory_bytes: 256
import fractions

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

gcd_ab=fractions.gcd(a,b)

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

soinnsuu=factorization(gcd_ab)

if gcd_ab == 1:
    ans=1
else:
    ans=len(soinnsuu)+1

print(ans)

Measured memory_bytes: 5048
a, b, c, d  = map(int, input().split())

tairyoku_a = a # 高橋君の体力
tairyoku_b = c # 青木君の体力

count = 0

while tairyoku_a > 0 and tairyoku_b > 0:
    if count%2 ==0: #高橋くんのターン
        tairyoku_b = tairyoku_b - b
    else: # 青木くんのターン
        tairyoku_a = tairyoku_a - d
    count += 1
    

if tairyoku_a > 0:
    print("Yes")
else:
    print("No")

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

using ll = long long;

int C[100];
int A[100][100];

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

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

	for(int i=1; i<=n; i++)
	{
		cin>>C[i];
		for(int j=1; j<=m; j++) cin>>A[i][j];
	}

	int ans=1e9;

	for(int b=0; b<(1<<n); b++)
	{
		vector<int> U(m+1);
		int cost=0;

		for(int i=0; i<n; i++)
		{
			if(!((1<<i) & b)) continue;

			//cout << b << " " << i << endl;

			cost += C[i+1];
			for(int j=1; j<=m; j++) U[j]+=A[i+1][j];
		}
		//cout << endl;

		bool w=1;
		for(int i=1; i<=m; i++)
		{
			//cout << b << " " << U[i] << endl;
			if(U[i]<x) w=0;
		}
		//cout << endl;
		if(w) ans=min(ans,cost);
	}

	if(ans==1e9) cout<<-1<<endl;
	else cout << ans<<endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };

int main() {
	ll n, a, b;
	std::cin >> n >> a >> b;
	if (a > b) {
		std::cout << 0 << std::endl;
	}
	else if (n == 1 && a != b) {
		std::cout << 0 << std::endl;
	}
	else {
		ll max = b*(n - 1) + a, min = a*(n - 1) + b;
		std::cout << max - min + 1 << std::endl;
	}
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l.sort()
count=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i]+l[j]>l[k] and l[i]!=l[j] and l[j]!=l[k] and l[i]!=l[k]:
        count+=1
print(count)


Measured memory_bytes: 9124
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

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

using namespace std;

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

int h, w, k;

int func(vvi field)
{
    int score = 0;
    int base = 1;
    
    for(;;){
        // fall stones
        rep(j, w){
            int np = h-1;
            for(int i=h-1; i>=0; --i){
                int t = field[i][j];
                if(t != -1){
                    field[i][j] = -1;
                    field[np][j] = t;
                    --np;
                }
            }
        }
        
        // erase stones
        int add_score = 0;
        
        rep(i, h){
            int cnt = 1;
            reps(j, 1, w+1){
                if(j < w && field[i][j] != -1 && field[i][j] == field[i][j-1]){
                    ++cnt;
                }
                else{
                    if(cnt >= k){
                        add_score += cnt * field[i][j-1] * base;
                        rep(l, cnt){
                            field[i][j-l-1] = -1;
                        }
                    }
                    cnt = 1;
                }
            }
        }
        
        if(add_score == 0) break;
        score += add_score;
        
        base *= 2;
    }
    
    return score;
}


signed main()
{
    cin >> h >> w >> k;
    
    vvi field(h, vi(w));
    
    rep(i, h){
        string str;
        cin >> str;
        rep(j, w) field[i][j] = str[j] - '0';
    }
    
    int ans = 0;
    rep(i, h) rep(j, w){
        vvi cp = field;
        cp[i][j] = -1;
        ans = max(ans, func(cp));
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define dracarys ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
 
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define dbg(x) cout << " Here => " << x 

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

bool ptime;
void inline fileIO(){ 
    ptime=false;
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        ptime=true;
    #endif
        srand((unsigned)time(0));
}

void inline solve(int tc){
    string s;
    cin >> s;
    int sum = 0;
    for (int i=0;i<s.size();i++){
        sum = (sum + (s[i]-'0'))%9;
    }
    cout << (sum==0 ? "Yes\n":"No\n");
}

int main(){
    fileIO();

    dracarys

    int tt=0,t=1;
    //cin >> t;

    while(t--){solve(++tt);}

    if (ptime)
        cerr << "processor time: " << clock() / (double) CLOCKS_PER_SEC << "s    ";


    return 0;
}

Measured memory_bytes: 3680
# D - We Like AGC
# https://atcoder.jp/contests/abc122/tasks/abc122_d

N = int(input())
memo = [{} for i in range(N+1)]

MODULO = 10**9 + 7

def legal(prev4):
    for i in range(len(prev4)):
        check = list(prev4)
        if i >= 1:
            check[i], check[i-1] = check[i-1], check[i]
        if ''.join(check).count('AGC') >= 1:
            return False
    return True

def dfs(cur, prev3):

    if prev3 in memo[cur]:
        return memo[cur][prev3]
    if cur == N:
        return 1

    cnt = 0
    for c in 'ACGT':
        prev4 = prev3 + c
        if legal(prev4):
            cnt = (cnt + dfs(cur + 1, prev4[1:])) % MODULO

    memo[cur][prev3] = cnt
    return cnt

print '{}'.format(dfs(0, '___'))


Measured memory_bytes: 3332
a_cards = list(input())
b_cards = list(input())
c_cards = list(input())

cards_dict = {'a': a_cards,
        'b': b_cards,
        'c': c_cards}

turn = 'a'
while(True):
    if (cards_dict[turn] == []):
        print(turn.upper())
        break;
    trush = cards_dict[turn][0]
    cards_dict[turn] = cards_dict[turn][1:]
    turn = trush

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int N;
    cin>>N;
    int a[100010];
    int b[100010];
    int c[100010];
    int fp[100010][3];
    int dp[100010];
    for(int i=0;i<N;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    fp[0][0]=a[0];
    fp[0][1]=b[0];
    fp[0][2]=c[0];
    dp[0]=max(a[0],b[0]);
    dp[0]=max(dp[0],c[0]);
    for(int n=1;n<N;n++){
        fp[n][0]=max(fp[n-1][1]+a[n],fp[n-1][2]+a[n]);
        fp[n][1]=max(fp[n-1][0]+b[n],fp[n-1][2]+b[n]);
        fp[n][2]=max(fp[n-1][0]+c[n],fp[n-1][1]+c[n]);
        dp[n]=max(fp[n][0],fp[n][1]);
        dp[n]=max(dp[n],fp[n][2]);
    }
    cout<<dp[N-1]<<endl;


    return 0;
}

Measured memory_bytes: 2944
import scala.io.StdIn._
object Main extends App {
  println(
    readLine.trim.split(' ').foldLeft(Nil: List[Int]){
      case (stack, d) if d.forall(_.isDigit) ⇒ d.toInt::stack
      case (a::b::rest, "+") ⇒ b + a :: rest
      case (a::b::rest, "-") ⇒ b - a :: rest
      case (a::b::rest, "*") ⇒ b * a :: rest
    }.head
  )
}



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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

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

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

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

    int n = s.size();
    vector<vector<mint>> dp(n + 1, vector<mint>(4, -1));

    for (int i = n; i >= 0; i--) {
        for (int j = 3; j >= 0; j--) {
            if (i == n) {
                dp[i][j] = (j == 3 ? 1 : 0);
            } else {
                dp[i][j] = dp[i + 1][j] * (s[i] == '?' ? 3 : 1);
                if (j < 3 && (s[i] == '?' || s[i] == "ABC"[j])) {
                    dp[i][j] += dp[i + 1][j + 1];
                }
            }
        }
    }
    cout << dp.front().front() << endl;
}


Measured memory_bytes: 10388
//In the name of Allah

#include <bits/stdc++.h>

#define int long long

using namespace std;

const int N = 123456;

int a[N];

typedef long long ll;
int m = 1e9+7;

/*
 * power function
 * @return a^b % mod
 * more details in https://telegram.me/dore_com/174
 */
int power(ll a, int b, ll mod = m)
{
	if (b == 0)
		return 1%mod;
	ll p = power(a%mod, b>>1);
	p *= p;
	p %= mod;
	if (b & 1) {
		p *= a;
		p %= mod;
	}
	return p;
}

ll f[N];

int C(ll n, int r)
{
	if(r < 0 || r > n)
		return 0;
	if(r == 0 || r == n)
		return 1;
	return f[n]*power(f[r]*f[n-r]%m, m-2)%m;
}

int cnt[N];

int32_t main() {
  int n;
  scanf("%lld", &n);
  for (int i = 0; i < n + 1; i++) {
    scanf("%lld", &a[i]);
    cnt[a[i]]++;
  }
	f[0] = 1;
	for (int i = 1; i < N; i++)
		f[i] = (f[i-1]*i)%m;
  int rep;
  for (int i = 0; i < n + 1; i++) {
    if (cnt[i] > 1) {
      rep = i;
      break;
    }
  }
  int per = 0, suf = 0, flg = 0;
  for (int i = 0; i < n + 1; i++) {
    if (a[i] == rep) {
      flg++;
    } else {
      per += !flg;
      suf += flg == 2;
    }
  }
  for (int k = 1; k < n + 2; k++) {
    cout << (C(n + 1, k) - C(suf + per, k - 1) + m) % m << endl;
  }
  return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cmath>

inline int read(void){
	int res = 0;
	char ch = std::getchar();
	while(ch < '0' || ch > '9')
		ch = std::getchar();
	while(ch >= '0' && ch <= '9')
		res = res * 10 + ch - 48, ch = std::getchar();
	return res;
}

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

int f(int n){
	int s = std::sqrt(n), res = 0;
	for(int i = 1; i <= s; ++i)
		for(int j = 1; j <= s; ++j)
			if(clac(i, j, 1) <= n)
				for(int k = 1; k <= s; ++k)
					if(clac(i, j, k) == n){
						++res;
						break;
					}
					else if(clac(i, j, k) > n)
						break;
	return res;
}

int n;

int main(){
	n = read();
	for(int i = 1; i <= n; ++i)
		std::printf("%d\n", f(i));
	return 0;
}

Measured memory_bytes: 3092
s = gets.chomp.chars

q = gets.to_i
n = 0

q.times do
    t, *fc = gets.chomp.split

    if t.to_i == 1
        n += 1
    else
        (n + fc[0].to_i).odd? ? s.unshift(fc[1]) : s << fc[1]
    end
end

puts n.odd? ? s.reverse.join : s.join

Measured memory_bytes: 30204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main(){
  int N; ll m; cin >> N >> m;
  vector<ll> A(N); 
  for(int i = 0; i < N; i++){ cin >> A[i];}
  
  vector<ll> sum(N+1); 
  
  for(int i = 0; i < N; i++){ sum[i+1] = (sum[i]+A[i])%m;}
  
  map<ll,ll> mp;
  ll ans = 0 ;
  
  for(int i = 0; i <= N; i++){
    
    ans += mp[sum[i]];
    mp[sum[i]]++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#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 all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];

    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll ans = 0;
    rep(j, n){
        ll bj = b[j];
        auto itri = lower_bound(all(a), bj);
        auto itrk = upper_bound(all(c), bj);
        ll idxi = itri - a.begin();
        ll idxk = itrk - c.begin();
        ans += idxi*(n-idxk);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll k, a, b;
	cin >> k >> a >> b;
	for (ll i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}


Measured memory_bytes: 3640
#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 n;
    cin >> n;
    vector<int> a(3*n);
    rep(i, 3*n) cin >> a.at(i);
    ll ans = 0;
    sort(a.rbegin(), a.rend());
    rep(i,n) {
        ans += a.at(1 + 2*i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4576
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

s=S()
ans=0
n=len(s)
for i in range(n):
    for j in range(i,n):
        if all('AGCT'.count(c)==1 for c in s[i:j+1]):
            ans=max(ans,j-i+1)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

void solve()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int flag = -1;
	while(a>0 || c>0)
	{
		c -= b;
		if(c <= 0)
		{
			flag = 1;
			break;
		}
		a -= d;
		if(a <= 0)
		{
			flag = 0;
			break;
		}
	}
	
    if (flag ==1)
    {
        cout << "Yes" << "\n";
    }
    else
    {
        cout << "No" << "\n";
    }
}

int main()
{
   solve();
   return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);
		
		// ?????????????????????
		Dise2 dise = new Dise2();
		// ?????¢?????°??????????????????
		for(int i = 0; i < 6; i++) {
			dise._values[i] = scan.nextInt();
		}
		//??????????????°???????????????
		int q = scan.nextInt();
		// ???????????°????????°?????????
		for(int i = 0; i < q; i++) {
			// ?????? ???????????????
			int top = scan.nextInt();
			int front = scan.nextInt();
			// ??????????????????????????????????´????????????°
			boolean result = false;
			
			// ?¢????
			for(int i2 = 0; i2 <= 6; i2++) {
				// ?????¢????¢????
				if (dise._values[1] == front) {
					// ?????¢????¢????
					result = topVarueCheck(dise, top, result);
				}
				else {
					dise.MoveSouth();
				}
				if (result == true) break;
				if (i2 == 3) {
					dise.MoveEast();
					dise.MoveSouth();
				}
			}
		}
		
	}

	private static boolean topVarueCheck(Dise2 dise, int top, boolean result) {
		// ?????¢????????£????????????????????¢??????????????§??????
		for(int i3 = 0; i3 < 4; i3++) {
			if (dise._values[0] == top) {
				// ?????¢?????????
				System.out.println(dise._values[2]);
				result = true;
				break;
			}
			else dise.MoveEast();
		}
		return result;
	}
}

// ??????????????????
class Dise2 {

	public int _values[] = new int[6];
	
	public void Dice(int values[]) {
    	for (int i = 0; i < values.length; i++)
    	this._values[i] = values[i];
	}
    
    public enum ValueType
    {
        Top,
        Front,
        Right,
        Left,
        Back,
        Bottom
    }
    
    public void MoveWest()
    {
        int tmp = this._values[0];
        this._values[0] = this._values[2];
        this._values[2] = this._values[5];
        this._values[5] = this._values[3];
        this._values[3] = tmp;
    }
    public void MoveEast()
    {
        int tmp = this._values[0];
        this._values[0] = this._values[3];
        this._values[3] = this._values[5];
        this._values[5] = this._values[2];
        this._values[2] = tmp;
    }
    public void MoveNorth()
    {
        int tmp = this._values[0];
        this._values[0] = this._values[1];
        this._values[1] = this._values[5];
        this._values[5] = this._values[4];
        this._values[4] = tmp;
    }
    public void MoveSouth()
    {
        int tmp = this._values[0];
        this._values[0] = this._values[4];
        this._values[4] = this._values[5];
        this._values[5] = this._values[1];
        this._values[1] = tmp;
    }


}

Measured memory_bytes: 26252
#include <iostream>

int main () {
    int n;
    std::cin >> n;
    int h[n];
    for (int i = 0; i < n; ++i) {
        std::cin >> h[i];
    }
    int c = h[0];
    for (int i = 0; i < n-1; ++i) {
        if (h[i+1] > h[i]) {
            c = c + h[i+1] - h[i];
        }
    }
    std::cout << c << std::endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

class Main{
		public static void hit_and_blow(ArrayList<String> list){
			int hit,blow;
			String str_a,str_b;
			ArrayList <Integer> list_a = new ArrayList<Integer>();
			ArrayList <Integer> list_b = new ArrayList<Integer>();
			
			for(int i=0;i<list.size()/2;i++){
				str_a = list.get(i*2);
				str_b = list.get(i*2+1);
				
				list_a.clear();
				list_b.clear();
				
				String [] strAry_a = new String[str_a.length()];
				strAry_a = str_a.split(" ");
				for(int j=0;j<strAry_a.length;j++){
					Pattern p = Pattern.compile("[0-9]*");
					Matcher m = p.matcher(strAry_a[j]);
					if(m.find()){
					int x = Integer.valueOf(m.group(0)).intValue();
					list_a.add(x);
					}
				}
				
				String [] strAry_b = new String[str_b.length()];
				strAry_b = str_b.split(" ");
				for(int j=0;j<strAry_b.length;j++){
					Pattern p = Pattern.compile("[0-9]*");
					Matcher m = p.matcher(strAry_b[j]);
					if(m.find()){
					int x = Integer.valueOf(m.group(0)).intValue();
					list_b.add(x);
					}
				}
				
				hit = 0;
				blow = 0;
				for(int j=0;j<list_a.size();j++){
					if(list_a.get(j) == list_b.get(j))
						hit++;
				}
				for(int j=0;j<list_a.size();j++){
					for(int k=0;k<list_b.size();k++){
						if(j != k && list_a.get(j) == list_b.get(k))
							blow++;
					}
				}
				System.out.println(hit + " " + blow);
			}
		}
		
		public static void main(String args[]) throws IOException{
			String str;
			ArrayList <String> inp = new ArrayList<String>();

			Scanner scan = new Scanner(System.in);
			scan.useDelimiter("\n");
			
			while(scan.hasNext()){
				str = scan.next();
				inp.add(str);
			}
			hit_and_blow(inp);
		}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const ll MAX = 2e5;

vector<ll> bit;

void bit_init(ll n) {
  bit.resize(n + 1, 0);
}

ll sum(ll i) {
  ll s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(ll i, ll x) {
  while (i <= bit.size() - 1) {
    bit[i] += x;
    i += i & -i;
  }
}

vector<ll> fact2(MAX + 1, 0);

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, ll>> p(n);
  rep(i, n) cin >> p[i].second >> p[i].first;

  sort(p.begin(), p.end());
  rep(i, n) {
    p[i].first = i + 1;
    swap(p[i].first, p[i].second);
  }
  sort(p.begin(), p.end());
  rep(i, n) {
    p[i].first = i + 1;
  }
  vector<vector<ll>> cnt(n, vector<ll>(4, 0));
  bit_init(n);
  rep(i, n) {
    cnt[i][0] = sum(p[i].second);
    cnt[i][1] = i - cnt[i][0];
    add(p[i].second, 1);
  }
  rep(i, bit.size()) bit[i] = 0;
  repr(i, n - 1) {
    cnt[i][2] = sum(p[i].second);
    cnt[i][3] = n - 1 - i - cnt[i][2];
    add(p[i].second, 1);
  }
  fact2[0] = 1;
  rep(i, MAX) {
    fact2[i + 1] = fact2[i] * 2 % mod2;
  }
  ll ans = 0;
  rep(i, n) {
    ans = (ans + fact2[n - 1]) % mod2;
    rep(j, 16) {
      vector<bool> used(4, false);
      rep(k, 4) {
        if (j >> k & 1) used[k] = true;
      }
      if ((used[0] && used[3]) || (used[1] && used[2])) {
        ll res = 1;
        rep(k, 4) {
          if (used[k]) {
            res = res * (fact2[cnt[i][k]] - 1) % mod2;
          }
        }
        ans = (ans + res) % mod2;
      }
    }
  }
  cout << ans << endl;

  






  
  return 0;
}

Measured memory_bytes: 20608
s = input()
nums = [int(s)]

for i in range(1, 2**(len(s)-1)):
    binary = "{0:0>{1}b}".format(i, len(s)-1)
    idxes = [p for p, x in enumerate(binary) if x == '1']
    for j in range(len(idxes)):
        if j == 0:
            nums.append(int(s[:idxes[j]+1]))
        else:
            nums.append(int(s[idxes[j-1]+1:idxes[j]+1]))

    nums.append(int(s[idxes[j]+1:]))
            
    
print(sum(nums))

Measured memory_bytes: 3064
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  int a[10],i,n,x,y;
  double b,c,d,e;
  double sum=0;
  pair<int,int> p[10];
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    a[i]=i;
    scanf("%d %d\n",&x,&y);
    p[i].first=x,p[i].second=y;
  }
  do{
    for(i=1;i<n;i++){
      b=p[a[i-1]].first,c=p[a[i-1]].second,d=p[a[i]].first,e=p[a[i]].second;
      sum=sum+sqrt((b-d)*(b-d)+(c-e)*(c-e));
    }
    }while(next_permutation(a,a+n));
  x=1;
  for(i=0;i<n;i++){
    x=x*(i+1);
  }
  b=x;
  printf("%.9lf\n",sum/b);
  return 0;
}

Measured memory_bytes: 256
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)




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

int main() {
	int st = -1, ed = -1;
	string str;
	cin >> str;
	for (int i = 0; str[i] != NULL; i++) {
		if (str[i] == 'A' && st == -1) {
			st = i;
		}
		if (str[i] == 'Z') {
			ed = i;
		}
	}


	cout << ed - st+1 <<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <numeric>
using namespace std;
int main(void){
    //1~n, 3つ選び、合計がX
    int l, r, i, k;
    
    scanf("%d %d", &l, &r);
    
    int sum[l+1][r+1];
    
    // 入力された値を配列に格納
    for(i=0; i<l; i++){
        for(k=0; k<r; k++){
            scanf("%d", &sum[i][k]);
        }
    }
    
    // 格納された配列の行/列の和を配列に格納
    for(int m=0;m<l;m++){
        sum[m][r] = 0;
        for(int n=0;n<r;n++){
            sum[m][r] = sum[m][r] + sum[m][n];
        }
    }
    
    // 各行の最終列の配列に入力値の合計値を格納
    for(int m=0;m<=r;m++){
        sum[l][m] = 0;
        for(int n=0;n<l;n++){
            sum[l][m] = sum[l][m] + sum[n][m];
        }
    }
    
    for(int m=0;m<=l;m++){
        for(int n=0;n<=r;n++){
            if(n!=r){
                printf("%d ", sum[m][n]);    
            }else{
                printf("%d", sum[m][n]);
            }
            
        }
        printf("\n");
    }
}



Measured memory_bytes: 3240
from typing import List
N, M = map(int, input().split())
graph:List[List[int]] = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(lambda x : int(x) -1 , input().split())
    graph[a].append(b)
    graph[b].append(a)
prev = [-1]*N
prev[0] = 0
import queue
qu = queue.Queue()
qu.put(0)
while not qu.empty():
    top = qu.get()
    for nxt in graph[top]:
        if prev[nxt] == -1:
            prev[nxt] = top
            qu.put(nxt)
if all(x != -1 for x in prev[1:]):
    print("Yes")
    print("\n".join(map(lambda x : str(x+1), prev[1:])))
else :
    print("No")

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

int main(){
	int H, W;
	for(int i=0 ; ; i++){
		cin >> H >> W;
		if(H==0 && W==0){
			break;
		}else{
			for(int ii=1 ;ii<=H; ii++){
				for(int iii=1 ;iii<=W; iii++){
					if((ii+iii)%2==0){
						cout << "#";
					}else{
						cout << ".";
					}
				}
				cout << endl;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main(){
    ll T;
    cin >> T;
    vector<ll> beki3(32,1),sum3(32,1);
    for(int i=1;i<32;i++){
        beki3[i] = 3*beki3[i-1];
        sum3[i] = beki3[i]+sum3[i-1];
    }
    T++;
    ll x = 0,t = 1,cnt = 0;
    while(t<T){
        cnt++;
        if(t+sum3[x+1]<=T){
            x++;
            t += beki3[x];
        }else if(t+sum3[x]<=T){
            t += beki3[x];
        }else{
            x--;
            t += beki3[x];
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3108