akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n";
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define clt(x) 63-__builtin_clzll(x)
#define bct(x) __builtin_popcountll(x)
#define all(v) (v).begin(),(v).end()
#define pi pair<ll,ll>
#define vi vector<ll>
#define vpi vector<pair<ll,ll>>
#define maxq priority_queue<ll>
#define minq priority_queue<ll,vector<ll>, greater<ll>>
#define cont continue;
#define reto return 0;
#define sz size()
#define spmod 1116295198451
#define mod 1000000007
#define md 998244353 
#define N 3009
//typedef tree<int,null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> //pbds;

ll dp[N][N][4],a[N][N];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n,m,k,i,j,v;
  cin>>n>>m>>k;
  while(k--)
  {
  	cin>>i>>j>>v;
  	a[i][j]=v;
  }
  i=n;
  while(i)
  {
  	j=m;
  	while(j)
  	{
  			dp[i][j][1]=max({dp[i][j+1][1],a[i][j],a[i][j]+max({dp[i+1][j][1],dp[i+1][j][2],dp[i+1][j][3]})});
  			dp[i][j][2]=max(dp[i][j+1][2],a[i][j]+dp[i][j+1][1]);
  			dp[i][j][3]=max(dp[i][j+1][3],a[i][j]+dp[i][j+1][2]);
  			/*
  			deB(i,j)
  			deb(dp[i][j][1])
  			deb(dp[i][j][2])
  			deb(dp[i][j][3])
  			*/
  		j--;
  	}
  	i--;
  }
  deb(max({dp[1][1][1],dp[1][1][2],dp[1][1][3]}));
}

Measured memory_bytes: 356184
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int K = sc.nextInt();
        char[][] c = new char[H][W];

        for (int i = 0; i < H; i++) {
            c[i] = sc.next().toCharArray();
        }

        int ans = 0;
        for(int h = 0;h< Math.pow(2,H);h++){
            for(int w = 0;w<Math.pow(2,W);w++){
                int count = 0;
                for(int j=0;j<H;j++){
                    for(int k=0;k<W;k++){
                        if((((int)Math.pow(2,j) & h) == 0) && (((int)Math.pow(2,k) & w) == 0) && c[j][k] == '#'){
                            count++;
                        }
                    }
                }
                if(count == K){
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }

}




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

int main() {
    int x, i;
    i = 1;
    cin >> x ;
    while(x !=0){
        cout << "Case" << " " << i << ": " << x << endl;
        i = i + 1;
        cin  >> x ;
    }
}
    


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

vector<ll> zalgorithm(string s) {
  ll N=s.size();
  vector<ll> res(N);
  res[0]=N;
  ll i=1, j=0;
  while(i<N) {
    while(i+j<N && s[j]==s[i+j]) j++;
    res[i]=j;
    if(j==0) {i++; continue;}
    ll k=1;
    while(i+k<N && k+res[k]<j) {res[i+k]=res[k]; k++;}
    i+=k; j-=k;
  }
  
  return res;
}


int main(){
  ll i, j, k;
  
  ll N;
  cin >> N;
  string s;
  cin >> s;
  
  ll ans=0;
  for(i=0; i<N; i++) {
    string t=s.substr(i);
    vector<ll> lcp=zalgorithm(t);
    
    for(j=0; j<t.size(); j++) chmax(ans, min(lcp[j], j));
  }
  
  pt(ans);
}




Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main () {
    long long h;
    std::cin >> h;

    int r = 0;
    while (h > 0) {
        h /= 2;
        r++;
    }

    long long ans = 1;
    for (int i = 0; i < r; i++) {
        ans *= 2;
    }

    std::cout << ans - 1 << "\n";
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	std::ios_base::sync_with_stdio();

	int n;
	int dp[51];
	bool f;

	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0;i<51;i++) dp[i]=-1;
		dp[n/100]=0;
		f=true;
		while(f){
			f=false;
			for(int i=n/100;i>=0;i--){
				if(dp[i]!=-1){
					/*A5*/
					if(i>=10){
						if(dp[i-10]==-1||dp[i-10]>dp[i]+(380*5)*0.8){
							f=true;
							dp[i-10]=dp[i]+(380*5)*0.8;
						}
					}
					/*B5*/
					if(i>=12){
						if(dp[i-12]==-1||dp[i-12]>dp[i]+(550*4)*0.85){
							f=true;
							dp[i-12]=dp[i]+(550*4)*0.85;
						}
					}
					/*C5*/
					if(i>=15){
						if(dp[i-15]==-1||dp[i-15]>dp[i]+(850*3)*0.88){
							f=true;
							dp[i-15]=dp[i]+(850*3)*0.88;
						}
					}
					/*A1*/
					if(i>=2){
						if(dp[i-2]==-1||dp[i-2]>dp[i]+380){
							f=true;
							dp[i-2]=dp[i]+380;
						}
					}
					/*B1*/
					if(i>=3){
						if(dp[i-3]==-1||dp[i-3]>dp[i]+550){
							f=true;
							dp[i-3]=dp[i]+550;
						}
					}
					/*C1*/
					if(i>=5){
						if(dp[i-5]==-1||dp[i-5]>dp[i]+850){
							f=true;
							dp[i-5]=dp[i]+850;
						}
					}
				}
			}
		}
		cout<<dp[0]<<endl;
	}
	return 0;
}

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


int N;
vector<int> A;


void input() {
    cin >> N;
    A = vector<int>(N);
    rep(i, N) cin >> A[i];
}


int main() {
    input();
    rep(i, N) {
        if (A[i] % 2 == 0) {
            if (A[i] % 3 != 0 && A[i] % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n; string s;
int main() {
	cin >> n >> s;
	int p = 0, q = 0;
	while(p < n && s[p] == '<') p++;
	while(q < n && s[n - q - 1] == '>') q++;
	cout << n - min(p, q) << endl;
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans = n/(a+b)*a;
    ll res = n%(a+b);
    cout<<ans+((res>a)?a:res)<<endl;

}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;



int main() {
	string s;
	cin >> s;
	int ans = INF;
	for (int i = 0; i < s.size() - 2; i++) {
		int a, b, c;
		a = (s[i] - '0') * 100;
		b = (s[i + 1] - '0') * 10;
		c = s[i + 2] - '0';
		int sum = a + b + c;
		ans = min(ans, abs(sum - 753));
	}
	cout << ans << en;
}

Measured memory_bytes: 256
//xenowi`tz -- Jai Shree Ram
#include<bits/stdc++.h>
using namespace std;

#define fori(i,a,b) for (long long int i = a; i <= b ; ++i)
#define ford(i,a,b) for(long long int i = a;i >= b ; --i)
#define mk make_pair
#define mod 1000000007
#define MAXN 200005
#define pb push_back
#define vec vector<long long int>
#define ll long long
#define rnd mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count())
#define pi pair<long long int,long long int>
#define sc second
#define fs first


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, k;
	cin >> n >> k;
	
	ll ans = 0;

	fori(i,k,n+1) {
		ll l = i*(i-1)/2;
		ll r = i*(2*n-i+1)/2;
		if (l <= r) {
			ans = (ans + r-l+1)%mod;		
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,m; cin>>n>>m;
  vector<pll> v(m);
  rep(i,m){
    int a,b; cin>>a>>b;
    a--, b--;
    v[i]={b,a};
  }
  sort(v.begin(),v.end());
  
  int ans=0;
  int now=-1;
  rep(i,m){
    if(now<=v[i].second){
      ans++;
      now=v[i].first;
    }
  }
  cout<<ans<<endl;
}

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

int MOD=1000000007;
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  string s;
  cin>>s;
  int n=s.size();
  int dp[100001][13];
  rep(i,100001)rep(j,13)dp[i][j]=0;
  dp[0][0]=1;
  int m=1;
  rep(i,s.size()){
    if(s[n-1-i]=='?'){
      rep(j,13)rep(k,10){
        dp[i+1][(j+(k*m))%13]=(dp[i+1][(j+(k*m))%13]+dp[i][j])%MOD;
      }
    }
    else{
      int t=s[n-1-i]-'0';
      rep(j,13)dp[i+1][(j+t*m)%13]=dp[i][j];
    }
    m=10*m%13;
  }
  cout<<dp[s.size()][5]<<endl;
}


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

int main(){
  int x,y;

  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    else if(x < y) cout << x << " " << y << endl;
    else           cout << y << " " << x << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>
#include <cstring>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	string str[101];
	int r,c;
	bool col[101],row[101];
	memset(col , 1 , sizeof(col));
	memset(row , 1 , sizeof(row));
	cin >> r >> c;

	for(int i=0 ; i<r ; i++)
		cin >> str[i];


	for(int i=0 ; i<r ; i++)
	{
		for(int j=0 ; j<c ; j++)
		{
			if(str[i][j] == '#')
			{
				col[j] = false;
				row[i] = false;
			}
		}
	}

	for(int i=0 ; i<r ; i++)
	{
		if(!row[i])
		{
			for(int j=0 ; j<c ; j++)
			{
				if(!col[j])
					cout << str[i][j];

			}
			cout << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 256
import bisect

a, b, q = list(map(int, input().split(' ')))
inf = float('inf')

sa = [None] * a
for i in range(a):
    sa[i] = (int(input()))

tb = [None] * b
for i in range(b):
    tb[i] = (int(input()))

xq = [None] * q
for i in range(q):
    xq[i] = (int(input()))

sa = [-inf] + sa + [inf]
tb = [-inf] + tb + [inf]

for x in xq:
    result = float('inf')

    l = bisect.bisect_left(sa, x)
    m = bisect.bisect_left(tb, x)

    for v in [sa[l - 1], sa[l]]:
        for w in [tb[m - 1], tb[m]]:
            o = abs(x - v) + abs(v - w)
            p = abs(x - w) + abs(w - v)
            result = min(result, o, p)

    print(result)



Measured memory_bytes: 95960
#include <stack>
#include <iostream>

using namespace std;

int main(){
    int num;
    stack <int> s;
    while(1){
        cin >> num;
        if(!num){
            if (s.empty()) break;
            cout << s.top() <<endl;
            s.pop();
        }
        else s.push(num);
    }
    return 0;
}

Measured memory_bytes: 1200
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream> 
#include <cmath>
 
using namespace std;
typedef long long ll;
typedef long double ld;

const ll MOD=ll(1e9+7);

//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)

ll P_POW(ll i, ll n) {
  if(n==0) return 1;

  n--;
  ll rep = i;

  while(n) {
    rep = rep * i;
    n--;
  }
  return rep;
} 

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}

ll n;


long long solve2(long long N) {
    if (N % 2 == 1) return 0;

    long long res = 0;
    N /= 2;
    while (N) {
        res += N / 5;
        cout << "N/5: " << N/5 <<  endl;
        cout << "res1: " << res <<  endl;
        N /= 5;
    }
    return res;
}


ll solve(ll n) {
    if (n % 2 == 1) return 0;

    ll res = 0;
    n /= 2;
    int c = 1;

    while ((ll) n/((ll)pow(5,c))) {
      res += n/P_POW(5,c);
      c++;
    }
    return res;
}

void f(int rest, string s) {
  char abc[] = "abc";
  if(rest == 0) {
    cout << s << endl;
  } else {
    for(int i=0; i < 3; i++) {
      f(rest - 1, s+abc[i]);
    }
  }
}

int main() {
  ll n, q;
  cin >> n >> q;
  // 2次元vector
  //vector<vector<ll>> a(n ,vector<ll>{2,0});
  vector<ll> s(n,0);

  bool isA = false;

  REP(i, n) {
    char c;
    cin >> c;

    if(i == 0) {
      s[i] = 0;
      if(c=='A') isA = true;
      else isA = false;
    } else {
      if(c == 'C') {
        if (isA) s[i] = s[i-1] + 1;
        else s[i] = s[i-1];
        isA = false;
      }else if(c == 'A') {
        s[i] = s[i-1];
        isA = true;
      }else {
        s[i] = s[i-1];
        isA = false;
      }
    }
  }

  
  REP(i, q) {
    ll l,r;
    cin >> l >> r;

    if (l == 1) {
      cout << s[r-1] << endl;
    } else {
      cout << s[r-1] - s[l-1] << endl;
    }
  }

}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>

using ll = long long;
ll h, w, m;

int main(){
    std::cin >> h >> w >> m;
    std::set<std::pair<ll, ll>> monster;
    std::vector<ll> H(m), W(m), Hcnt(h, 0), Wcnt(w, 0);
    ll hmax = 0, wmax = 0;
    for(int i = 0; i < m; i++){
        std::cin >> H[i] >> W[i];
        H[i]--; W[i]--;
        monster.emplace(H[i], W[i]);
        Hcnt[H[i]]++;
        Wcnt[W[i]]++;
        hmax = std::max(hmax, Hcnt[H[i]]);
        wmax = std::max(wmax, Wcnt[W[i]]);
    }

    std::set<ll> hh, ww;
    for(int i = 0; i < h; i++){
        if(Hcnt[i] == hmax) hh.insert(i);
    }
    for(int i = 0; i < w; i++){
        if(Wcnt[i] == wmax) ww.insert(i);
    }

  	ll ans = hmax + wmax - 1;
    for(auto a : hh){
    	for(auto b : ww){
        	if(monster.find(std::make_pair(a, b)) == monster.end()){
            	std::cout << ans + 1 << std::endl;
                return 0;
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 59488
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 * 
 * https://atcoder.jp/contests/abc173/submissions/15525302 にも参考
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			long answer = IntStream.rangeClosed(1, n).mapToLong(i -> i * (long) (n - i + 1)).sum();
			answer -= IntStream.range(1, n).mapToLong(i -> {
				int u = scanner.nextInt(), v = scanner.nextInt();
				int l = Math.min(u, v), r = Math.max(u, v);
				return l * (long) (n - r + 1);
			}).sum();
			System.out.println(answer);
		}
	}
}


Measured memory_bytes: 60108
import java.util.Scanner;
import java.util.HashMap;

class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    //HashMap.putは置き換え<文字列→数値>
    HashMap<String, Integer> hashmap = new HashMap<>();

    hashmap.put("A" , 10);
    hashmap.put("B" , 11);
    hashmap.put("C" , 12);
    hashmap.put("D" , 13);
    hashmap.put("E" , 14);
    hashmap.put("F" , 15);


    String X = sc.next();
    String Y = sc.next();


//HashMap.getで.putで書き換えた数値を取得
    if  (hashmap.get(X) > hashmap.get(Y)){
      System.out.println(">");
    }
    else if (hashmap.get(X) < hashmap.get(Y)) {
      System.out.println("<");
    }
    else {
      System.out.println("=");
    }
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i,t,n) for(int i=t;i<n;i++)
#define nd "\n"
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>




/*ll power(ll x,ll t){
if(t<=0){
    return 1;
}
ll y=(power(x,t/2));
y=(y*y)%ma;
if(t%2)
    y=(y*x)%ma;
return y;

}*/
/*ll ph[100001];
void E_phi(int n){

ph[0]=0;
ph[1]=1;
for(int i=2;i<=n;i++){
    ph[i]=i;
}
for(int i=2;i<=n;i++){
    if(ph[i]==i){
        for(int j=i;j<=n;j+=){
            ph[j]-=ph[j]/i;
        }
    }
}


}*/
/*string s,t;
vector<int>  z_fun(string s){

int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}*/

/*struct st{
ll sum,pre,suf,ans;
st(){}
st(ll k){
ans=k,pre=k,suf=k,sum=0;
}

};
ll t[4*200001+4];
ll a[200001];
ll lazy[4*200001+4];
ll mx=1e14;



void push(int ind){
int l=2*ind+1,r=2*ind+2;
t[l]+=lazy[ind];
t[r]+=lazy[ind];
lazy[l]+=lazy[ind];
lazy[r]+=lazy[ind];
lazy[ind]=0;

}

void build(int ind,int l,int r){
if(l==r){
    t[ind]=a[l];
return;
}
int mid=(l+r)/2;
build(2*ind+1,l,mid);
build(2*ind+2,mid+1,r);

  t[ind] =min(t[ind*2+1] , t[ind*2+2]);



}
ll query(int ind,int l,int r,int p,int q){

if(l>q || r<p )
    return mx;
    int mid=(l+r)/2;

if(l>=p && r<=q )
    {
      return t[ind];
    }
    push(ind);
ll x=query(2*ind+1,l,mid,p,q);
ll y=query(2*ind+2,mid+1,r,p,q);


return min(x,y);
}

void update(int ind,int l,int r,int p,int q,int val){
if(l>q || r<p )
    return;

if(l>=p && r<=q )
    {
      t[ind]+=val;
      lazy[ind]+=val;
      return;
    }
push(ind);
int mid=(l+r)/2;
    update(2*ind+1,l,mid,p,q,val);
     update(2*ind+2,mid+1,r,p,q,val);
    t[ind]=min(t[2*ind+1],t[2*ind+2]);



}


ll mod(ll a){
if(a>=0)
    return a;
else return -a;
}
*/



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

ll ma=1e9+7;
ll ans=0;
ll x=0;
int n;
cin>>n;
ll a[n];
rep(i,0,n)
cin>>a[i];
for(int i=n-1;i>=0;i--){
    ans=(ans+(a[i]*x)%ma)%ma;
    x=(x+a[i])%ma;
}
cout<<ans<<nd;

    }



Measured memory_bytes: 5216
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	string S;
	cin >> S;
	i64 ans = 0;
	i64 cur_len = 0;
	REP(i, SIZE(S))
	{
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
		{
			++cur_len;
			if (ans < cur_len)
				ans = cur_len;
		}
		else
		{
			cur_len = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
    #define _CRT_SECURE_NO_WARNINGS
    #pragma warning(disable:4996)
#endif

#define ll long long
#define vi vector<ll>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;



int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vi h(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];
    vi dp(n);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; i++)
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    cout << dp[n - 1];
}

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

using ll=int64_t;

int main() {
  int N; cin >>N;
  vector<ll> check;
  rep(i,0,N) {
    ll A; cin >>A;
    check.push_back(A);
  }
  sort(check.rbegin(),check.rend());
  ll temp=0;
  rep(i,1,N) {
    if (check[i-1]==check[i]) {
      if (!temp) {
        temp=check[i];
        i++;
      } else {
        cout <<check[i]*temp <<endl;
        return 0;
      }
    }
  }
  cout <<0 <<endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

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

  vector<int> v[2];
  rep (i, 2) {
    rep (j, n) {
      int tmp;
      cin >> tmp;
      v[i].push_back(tmp);
    }
  }


  int count;
  int maxNum = 0;
  rep (i, n) {
    count = 0;
    for (int j = 0; j <= i; j++) {
      count += v[0][j];
    }
    for (int j = i; j < n; j++) {
      count += v[1][j];
    }
    maxNum = max(count, maxNum);
  }
  P(maxNum);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
const int MAX = 510000;
const int MOD = 1000000007;
long long 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;
    }
}
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    int a, b;
    cin >> a >> b;
    string s1, s2;
    rep(i, b)
    {
        s1 += to_string(a);
    }
    rep(i, a)
    {
        s2 += to_string(b);
    }
    if (s1 > s2)
    {
        cout << s2;
    }
    else
    {
        cout << s1;
    }

    return 0;
}

Measured memory_bytes: 256
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

h, w = inintm()

pixel = []
f = ""
l = ""

for i in range(w+2):
    f += "#"

pixel.append(f)

for i in range(h):
    pixel.append("#" + input() + "#")

for i in range(w+2):
    l += "#"

pixel.append(l)

for x in pixel:
    print(x)


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

using namespace std;

const int N=1e5+10;

int n,a[N],dep[N],t[N];

void Init()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]),t[a[i]]++;
}

void Solve()
{	
	sort(a+1,a+n+1); reverse(a+1,a+n+1);
	
	int Mx=0,Mx2=0,fl=1,cnt=0;
	
	for (int i=a[n]+1;i<a[1];++i) if (t[i]<2) fl=0;
	
	if (t[a[n]]>2 || (t[a[n]]==2 && !(a[1]%2))) fl=0;
	
//	Mx=(a[1]+1)/2; Mx2=a[1]-Mx;
	
	if (a[1]!=a[2]) fl=0;
	
	if (a[n]!=(a[1]+1)/2) fl=0;
	
//	
//	for (int i=2;i<=n;++i)
//	{
//		if (a[i]-Mx || !cnt) dep[i]=a[i]-Mx;
//		else dep[i]=a[i]-Mx2;
//		if (dep[i]<0) fl=0;
//		else if (dep[i]==0) cnt++;
//	}
//	if (cnt>1 || !cnt) fl=0;
	if (fl) printf("Possible\n");
	else printf("Impossible\n");
}

int main()
{
	Init();
	Solve();
	return 0;
}


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

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef vector<int> vi;

const int nunach = 2500, N = 1e5 + 5;
bool vis[nunach];
vi prime;
int ans, n;
long long a[N];
map<long long, int> mp;

void sieve() {
    for (int i = 2; i < nunach; ++i) {
        if(!vis[i]) {
            prime.pb(i);
            for (int j = 2 * i; j < nunach; j += i) vis[j] = 1;
        }
    }
}

void upd(long long &num) {
    for(int i : prime) {
        long long cube = 1LL * i * i * i;
        while(num % cube == 0) num /= cube;
    }
}

long long get(long long num) {
    long long res = 1;
    for (int i : prime) {
        if(num % i == 0) {
            res *= i;
            if(num % (1LL * i * i) != 0) res *= i;
            while(num % i == 0) num /= i;
        }
    }
    long long rem = sqrt(num);
    if(rem * rem == num) res *= rem;
    else res *= num * num;
    return res;
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    sieve();
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        upd(a[i]);
        mp[ a[i] ] ++;
    }

    for(auto i : mp) {
        if(i.fi == 1) ans ++;
        else {
            long long rem = get(i.fi);
            if(mp.count(rem) ) {
                ans += max(i.se, mp[rem]);
                mp.erase(rem);
            }
            else ans += i.se;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 7424
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
typedef pair<LL, LL> P;
typedef pair<P, P> PP;


int main() {
	string s;
	cin >> s;
	int a, b, c, d;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
	//cin >> a >> b >> c >> d;
	for (int i = 0; i <= 1; i++) {
		for (int j = 0; j <= 1; j++) {
			for (int k = 0; k <= 1; k++) {
				int num = a;
				if (i)num += b;
				else num -= b;
				if (j)num += c;
				else num -= c;
				if (k)num += d;
				else num -= d;
				if (num == 7) {
					cout << a << (i ? "+" : "-") << b << (j ? "+" : "-") << c << (k ? "+" : "-") << d << "=7" << endl;
					return 0;
				}
			}
		}
	}
}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  ll ans(0);
  for(int i(0);i<=N;i++){
    if(i%3 != 0 && i%5 != 0) ans+=i;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3636
// ABC147-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

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

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

    ll mod=pow(10,9)+7;
    ll ans=0;
    ll twofact=1;
    for(int i=0;i<60;i++){
        ll one=0,zero=0;
        for(int j=0;j<n;j++){
            if((a[j]>>i)&1) one+=1;
            else zero+=1;
        }
        ans+=one*zero%mod*twofact%mod;
        ans%=mod;
        twofact=twofact*2%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;

 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    cout<<fixed<<setprecision(15);
    int n;
    cin>>n;
double ans;
    if(n%2==1)
    ans=n/2+1;
else ans=n/2;

    ans=ans/n;

    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a, b;
	int n, h, w;
	int i;
	int count=0;
	
	scanf("%d %d %d", &n,&h,&w);
	
	for(i=0; i<n; i++){
		scanf("%d %d", &a,&b);
		if(a>=h && b>=w)count++;
	}
	
	printf("%d",count);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
  #include <algorithm>
  #include <vector>
  #include <cmath>
#include <string>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <iomanip>
  #include <stack>
  #include <queue>
  #include <deque>
  using namespace std;
   
  int main(){
    long long N,K,M;
    cin>>N>>K;
    M=(N-2)*(N-1)/2;
    if(M<K){
        cout<<-1;
      return 0;
    }
    M=N+M-K-1;
    cout<<M<<'\n';
    for(long long i=1;i<=N;i++){
      for(long long j=i+1;j<=N;j++){
          cout<<i<<' '<<j<<'\n';
          if(--M==0)
            return 0;
      }
    }
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int main()
{
    cin.sync_with_stdio(false);
    vi A(3);
    int a, b, c;
    cin >> a >> b >> c;
    A[0] = a; A[1] = b; A[2] = c;
    sort(A.begin(), A.end());
    cout << A[0]+A[1];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int a[200][200];
signed main(){
  int n, m;cin >> n >> m;
  rep(i,n)rep(j,m)cin >> a[i][j];
  int ans = 0;
  rep(i,n)rep(j,n){
    if(i >= j)continue;
    int d = 0;
    rep(k,m){
      d += (a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
    }
    int dd = sqrt(d);
    if(dd*dd == d)ans++;
  }
  cout << ans << endl;
  return 0;
}






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

typedef long long ll;

int main () {
	int N;
	cin >> N;
	int max;
	ll ans = 0;
	cin >> max;
	for (int i=1; i<N; i++) {
		int a;
		cin >> a;
		int diff = max - a;
		if (diff > 0) {
			ans += diff;
		} else {
			max = a;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int H, W; cin >> H >> W;
    vector<string> A;
    rep (i, 0, H) {
        string in; cin >> in;
        A.push_back(in);
    }

    vector<bool> row(H, false);
    vector<bool> col(W, false);
    rep (i, 0, H) {
        rep (j, 0, W) {
            if (A[i][j] == '#') {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    rep (i, 0, H) {
        if (row[i]) {
            rep (j, 0, W) {
                if (col[j]) cout << A[i][j];
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define vll         vector<pll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323



void solve()
{
    ll n,x,y,c1=0,c2=0,c3=0;
    cin>>n>>x>>y;
    ll a[n];
    rep(i,0,n) cin>>a[i];
    rep(i,0,n){
        if(a[i]<=x) c1++;
        else if(a[i]>x && a[i]<=y) c2++;
        else c3++;
    }
    cout<<min(c1,min(c2,c3));

}

int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define c(s) cout<< (s) << endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define cyn(c) cout<<(c?"Yes":"No")<<endl;
#define cYN(c) cout<<(c?"YES":"NO")<<endl;
#define pyn(c) printf("%s\n",c?"Yes":"No");
#define pYN(c) printf("%s\n",c?"YES":"NO");
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int n,a,b; cin>>n>>a>>b;
    cout<<(a>=b?b:a)<<" ";
    c(a+b-n>0?a+b-n:0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
const double EPS = 1e-10;
int main(){
	double d;
	while(cin >> d) {
		if(d == -1) break;
		int ret[13] = {};
		for(int i = 7; i >= -4; --i) {
			if(d>=pow(2,i)) {
				d-=pow(2,i);
				ret[7-i] = 1;
			}
			if(d<EPS) break;
		}
		if(d>=EPS) cout << "NA" << endl;
		else {
			rep(i,8) cout << ret[i];
			cout << ".";
			rep2(i,8,12) cout << ret[i];
			cout << endl;
		}
	}
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, x;
    cin >> n >> x;
    vi a(n);
    rep(i, n) cin >> a[i];
    ll cnt = 0;
    if (a[0] > x) {
        cnt += a[0] - x;
        a[0] -= a[0] - x;
    }
    for (int i = 1; i < n; ++i) {
        if (a[i-1] +  a[i] > x) {
            cnt += a[i-1] + a[i] - x;
            a[i] -= a[i-1] + a[i] - x;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int N, M;
int a[51] = {};
int b[51] = {};
int ans[51] = {};

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> a[i] >> b[i];
		ans[a[i]]++;
		ans[b[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		cout << ans[i] << endl;
	}
}

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

int main() {
    int n,i,l,r,ans=0,sum=0,cnt=0;
    scanf("%d",&n);
    int a[n+1];
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(i&1&&a[i]&1) ans++;
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3824
#include<stdio.h>
#include<string.h>

int main() {
  char input[11];
  scanf("%s", &input);

  char ans[11] = {};
  int count = 0;
  for(int i=0; i<strlen(input); i++){
    if(input[i] == '0'){
      ans[count] = '0';
      count++;
    }else if(input[i] == '1'){
      ans[count] = '1';
      count++;
    }else if(count > 0){
      if(input[i] == 'B'){
        ans[count-1] = '\0';
        count-=2;
      }
      count++;
    }
  }

  ans[count] = '\0';

  printf("%s\n", ans);
  return 0;
}


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

const int MAX = 3000000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res % mod;
}
void init_ncr() {
    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 ncr(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(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  init_ncr();
  int k;cin>>k;
  string s;cin>>s;
  int n = s.size();

    ll ans=0;
  for(int i=0;i<=k;i++){
      ans += modpow(26,i,MOD) * modpow(25,k-i,MOD) % MOD * ncr(n + k - i - 1, k - i) % MOD;
      ans %= MOD;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 74576
//Feet don't fail me now
//Take me to the finish line
//Oh, my heart, it breaks every step that I take
//But I'm hoping at the gates, they'll tell me
//that IOI gold is mine
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer {cout << "NO"; exit(0);}
#define vectors vector<vector<llong> >
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)

const long long MXN = 2e5 + 10;
const long long MNN = 1e4 + 520;
const long long MOD = 10007;
const long long INF = 1e18;
const long long OO = 1e9;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, m, v, p, b[MXN], ans;

bool check(llong pos){
    llong left = (v - (p - 1)) * m;
    if(b[p] > b[pos] + m) return false;
    for(llong i = 1; i <= n; i++){
        if(b[i] <= b[pos]){
            left -= m;
        }
    }
    for(llong i = pos; i >= p; i--){
        if(b[pos] == b[i]) continue;
        left -= b[pos] + m - b[i];
    }
    if(left <= 0) return true;
    else return false;
}

int main(){
    ios;
    cin >> n >> m >> v >> p;
    for(llong i = 1; i <= n; i++){
        cin >> b[i];
    }
    sort(b + 1, b + n + 1);
    reverse(b + 1, b + n + 1);
    llong l = 1, r = n;
    while(r - l > 1){
        llong m = (r + l) / 2;
        if(check(m)){
            l = m;
        }else{
            r = m - 1;
        }
    }
    cout << (check(r) ? r : l);
}


/*
 010110
 101001
 010100
 101000
 100000
 010000
 1 2
 1 4
 1 5
 2 3
 2 6
 3 4
 */


Measured memory_bytes: 1024
package main

import(
	"bufio"
	"strconv"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


func main() {
	sc.Split(bufio.ScanWords)

	n, k := nextInt(), nextInt()

	ans := k

	for i := 1; i < n; i++ {
		ans *= k-1
	}

	fmt.Println(ans)
}

Measured memory_bytes: 640
s = input()
for i in range(2 ** 3):
    formula = s[0]
    for j in range(3):
        if (i >> j) & 1:
            formula += "+"
        else:
            formula += "-"
        formula += s[j + 1]
    if eval(formula) == 7:
        print(formula + "=7")
        exit()

Measured memory_bytes: 3060