akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0, count = 0;
	char uc[100000];
	cin >> a>>b;
	cout << a * a - b << endl;
		return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,n;
double ans;
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%d",&a);
		ans+=1.0/a;
	}
	ans=1.0/ans;
	printf("%.6lf",ans);
	return 0;
}

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

int main() {
    int n, t;
    std::cin >> n >> t;
    
    std::vector<int> vec(n);
    
    int nowMin, maxDiff = 0;
    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            std::cin >> nowMin;
            continue;
        }
        
        int a;
        std::cin >> a;
        nowMin = std::min(nowMin, a);
        
        vec[i] = a - nowMin;
        maxDiff = std::max(maxDiff, vec[i]);
    }
    
    std::cout << std::count(vec.begin(), vec.end(), maxDiff) << std::endl;
}

Measured memory_bytes: 640
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		String n = sc.next();
		sc.close();
		boolean f=true;
		for (int i = 1; i < n.length(); i++) {
			if(n.charAt(i)!='9') {
				f = false;
				break;
			}
		}
		char c = f?'0':'1';
		int ans = (int)(n.charAt(0)-c) + (n.length() - 1) * 9;
		out.println(ans);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>

using namespace std;

int main(){
  int n, max = 0,sum = 0;
  int p[10];

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> p[i];
    if(p[i] > max)
      max = p[i];
    sum += p[i];
  }
  sum -=max;
  sum+=max/2;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool flag(string s)
{
    string a;
    a=s;
    reverse(a.begin(),a.end());
    return(s==a);
}
int main()
{
    string s;
    cin>>s;
    int l=s.size();
    if(flag(s) && flag(s.substr(0,(l-1)/2)) && flag(s.substr(((l+1)/2),(l-1)/2)))
    {
        cout<<"Yes"<<endl;

    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
    #include<vector>
    #include<cmath>
    using namespace std;
    int vacation(vector<int>&a,vector<int>&b,vector<int>&c, int n){
     vector<vector<int>> dp(n,vector<int>(3));
      dp[0][0] = a[0];
      dp[0][1] = b[0];
      dp[0][2] = c[0];
      for(int i=1; i<n; i++){
      	dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
      }
      return max(max(dp[n-1][0],dp[n-1][1]), dp[n-1][2]);
    }
    int main(){
      int n;
      cin>>n;
      vector<int>a(n);
      vector<int>b(n);
      vector<int>c(n);
      for(int i=0;i<n;i++){
      	cin>>a[i]>>b[i]>>c[i];
      }
      cout<<vacation(a,b,c,n);
      return 0;
    }

Measured memory_bytes: 9824
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from collections import defaultdict

N = int(input())
V = list(map(int, input().split()))

dic1 = defaultdict(int)
dic2 = defaultdict(int)

for v in V[::2]:
    dic1[v] += 1
for v in V[1::2]:
    dic2[v] += 1

lst1 = [[dic1[i], i] for i in dic1]
lst2 = [[dic2[i], i] for i in dic2]

lst1.sort(key = lambda x: x[0], reverse = True)
lst2.sort(key = lambda x: x[0], reverse = True)

ans = N
if lst1[0][1] != lst2[0][1]:
    ans = N - lst1[0][0] - lst2[0][0]
else:
    if len(lst1) == 1:
        if len(lst2) == 1:
            ans = N // 2
        else:
            ans = N - lst1[0][0] - lst2[1][0]
    elif len(lst2) == 0:
        ans = N - lst1[1][0] - lst2[0][0]
    else:
        ans = N - max(lst1[0][0] + lst2[1][0], lst1[1][0] + lst2[0][0])

print (ans)


Measured memory_bytes: 24064
#include<bits/stdc++.h>
typedef long long i64;
const int N=2e6+7;
char s[N];
int f[N],n,n1,n2,n3;
i64 l,r;
void ext(){
	for(int i=2,j=0;i<=n;++i){
		while(j&&s[i]!=s[j+1])j=f[j];
		if(s[i]==s[j+1])++j;
		f[i]=j;
	}
	int p=f[n];
	while(p*2>=n)p=f[p];
	memcpy(s+n-p+1,s+1,n-p);
	n+=n-p*2;
}
int t[333],ts[2][333];
i64 ans[333];
void cal1(i64 x,int sgn){
	memset(t,0,sizeof(t));
	for(int i=1;i<=x%n;++i)++t[s[i]];
	for(int i='a';i<='z';++i)ans[i]+=t[i]*sgn;
	for(int i=x%n+1;i<=n;++i)++t[s[i]];
	for(int i='a';i<='z';++i)ans[i]+=t[i]*sgn*(x/n);
}
void cal1(){
	n=n2-n1;
	cal1(r,1),cal1(l-1,-1);
}
i64 fs[207][2],len[207];
int mx;
void cal2(i64 x,int sgn){
	for(int i=mx;i>=2;--i)if(len[i]<=x){
		x-=len[i];
		for(int j='a';j<='z';++j)ans[j]+=sgn*(fs[i][0]*ts[0][j]+fs[i][1]*ts[1][j]);
	}
	cal1(x,sgn);
}
void cal2(){
	n1/=2,n2/=2,n3/=2,n/=2;
	for(int i=1;i<=n1;++i)++ts[0][s[i]];
	for(int i=n1+1;i<=n2;++i)++ts[1][s[i]];
	len[0]=n1,len[1]=n2;
	fs[0][0]=fs[1][0]=fs[1][1]=1;
	mx=1;
	do{
		++mx;
		len[mx]=len[mx-1]+len[mx-2];
		fs[mx][0]=fs[mx-1][0]+fs[mx-2][0];
		fs[mx][1]=fs[mx-1][1]+fs[mx-2][1];
	}while(len[mx]<r);
	cal2(r,1),cal2(l-1,-1);
}
int main(){
	scanf("%s%lld%lld",s+1,&l,&r);
	n=strlen(s+1);
	ext();
	n1=n;
	ext();
	n2=n;
	ext();
	n3=n;
	if(n2-n1==n3-n2)cal1();
	else cal2();
	for(int i='a';i<='z';++i)printf("%lld ",ans[i]);
	return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,a[100010],q,sum=0;
    cin>>n;
    map<int,int>mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
        sum+=a[i];
    }
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        sum+=(c-b)*mp[b];
        mp[c]+=mp[b];
        mp[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 10312
def main():
    S = input()
    n = len(S)
    if S[0] != "A": return "WA"

    j = None
    for i in range(2, n-1):
        if S[i] == "C":
            if j == None:
                j = i
            else:
                return "WA"
    if j == None: return "WA"
    for i in range(1, n):
        if i != j and not S[i].islower():
            return "WA"
    return "AC"



if __name__ == '__main__':
    print(main())

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

using namespace std;

int main(){

  int d,w,h;

  while(cin>>d>>w>>h,d||w||h){
	int n,r;
	cin>>n;

	for(int i=0;i<n;++i){
	  cin>>r;

	  if(2*r > sqrt(d*d + h*h) || 2*r > sqrt(h*h + w*w) || sqrt(2*r > d*d + w*w))
		cout<<"OK"<<endl;
	  else
		cout<<"NA"<<endl;
		
	}
	
  }
  
}



Measured memory_bytes: 3036
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long i,j,minn,maxn,t,k,a[262144],r=0,l;
    double d;
    char s[262144];
    scanf("%lld",&k);
    //l=strlen(s);
    for(i=1;i<=k;i++){scanf("%lld",&a[i]);}
    if(a[k]!=2){printf("-1\n");return 0;}
    minn=2;maxn=3;
    for(i=k-1;i>=1;i--){
        minn=a[i]*llceil(minn,a[i]);
        maxn=a[i]*(1+maxn/a[i])-1;
        if(maxn<minn){printf("-1\n");return 0;}
    }
    printf("%lld %lld\n",minn,maxn);
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M           1000011
#define N           14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}



int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    p=0;
    cin>>s1;
    for(i=0;i+1<s1.size();++i)p+=(s1[i]!=s1[i+1]);
      cout<<p<<"\n";








}



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

int main() {
    ll N;
    cin >> N;
    vector<vector<ll>> AB(2, vector<ll>(3));

    for (auto &r : AB) {
        for (auto &c : r)
            cin >> c;
    }

    for (int i = 0; i < 2; i++) {
        vector<ll> from = AB[i], to = AB[(i + 1) % 2];
        vector<ll> dp(N + 1);
        iota(dp.begin(), dp.end(), 0LL);

        for (int D = 0; D <= N; D++) {
            if (D + from[0] <= N)
                dp[D + from[0]] = max(dp[D + from[0]], dp[D] + to[0]);
            if (D + from[1] <= N)
                dp[D + from[1]] = max(dp[D + from[1]], dp[D] + to[1]);
            if (D + from[2] <= N)
                dp[D + from[2]] = max(dp[D + from[2]], dp[D] + to[2]);
        }
        N = dp[N];
    }
    cout << N << endl;
}

Measured memory_bytes: 195584
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(long i=1; i<=(long)(n); i++)
int main(){
long N, ans=0; cin >> N;
REP(A, N){ REP(B, N){
if(A*B<N){ ans++; }else{ break; }
} }
cout << ans << "\n";
}

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

int main(){
	double x1, x2, y1, y2;
	double tmp,d;

	cin>>x1>>y1>>x2>>y2;
	tmp = pow((x1 - x2), 2) + pow((y1 - y2), 2);
	d = sqrt(tmp);

	printf("%7lf\n",d );

	return 0;
}

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

using ll = long long;

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

ll lcm(ll a, ll b) {
    int g = gcd(a, b);
    a /= g;
    b /= g;
    return a * b * g;
}

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> d(n), v(n);
        for(int i=0; i<n; ++i) {
            cin >> d[i] >> v[i];
            int g = gcd(d[i], v[i]);
            d[i] /= g;
            v[i] /= g;
        }
        ll l = d[0], g = v[0];
        for(int i=1; i<n; ++i) {
            l = lcm(l, d[i]);
            g = gcd(g, v[i]);
        }
        for(int i=0; i<n; ++i) {
            cout << l * v[i] / d[i] / g << endl;
        }
    }
}


Measured memory_bytes: 3060
#include<stdio.h>
  int main(){
   int n,a,b,c,i;
    scanf("%d",&n);
      for(i=0;i<n;i++){
       scanf("%d%d%d",&a,&b,&c);
        if(a*a==b*b+c*c || b*b == a*a+c*c|| c*c == a*a+b*b){
         printf("YES\n");
          }else{
            printf("NO\n");
             }
              }
return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  ll N;cin>>N;vl a(N);ll tot; rep(i,N){cin>>a[i];tot+=a[i];}
  vl ara(N);ara[0]=a[0];for(int i=1;i<N;i++){ara[i]=ara[i-1]+a[i];}
  ll ans=100000000000000;
  for(int i=0;i<N-1;i++){
    ans =min(ans,abs(tot-2LL*ara[i]));
  }
  cout<<ans<<endl;
}





Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD (long long)(1e9+7)
int main(){
	ll n;
	cin>>n;
	vector<ll>L(n);
	for(int i=0;i<n;i++)cin>>L[i];
	sort(L.begin(),L.end());
	ll ans=0;
	for(int i=0;i<n-1;i++){
		ans+=L[i];
	}
	if(ans>L[n-1]){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

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

int main() {
	string s;
	cin>>s;
	int n,ans=0;
	n=s.size();
	rep(i,n){
		if(s[i]!=s[n-i-1]){
			s[n-i-1]=s[i];
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 127348
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define int long long


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;

const int maxn = 3e5;

std::vector<int> v[maxn];

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	static int a[maxn];
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		v[a[i]].eb(i);
	}
	int t = 0, c = 0;
	int len = 0;
	while(1) {
		int &x = a[t];
		t = lower_bound(all(v[x]), t) - v[x].begin() + 1;
		if(t == (int)v[x].size()) {
			++c;
			t = v[x][0] + 1;
		} else {
			t = v[x][t] + 1;
		}
		if(t >= n) {
			t -= n;
			++c;
		}
		if(t == 0) {
			len = c * n;
			break;
		}
	}
	int tot = k * n % len;
	t = 0, c = 0;
	while(1) {
		int &x = a[t % n], lst = t;
		int p = lower_bound(all(v[x]), t % n) - v[x].begin() + 1;
		if(p == (int)v[x].size()) {
			++c;
			t = c * n + v[x][0] + 1;
		} else {
			t = c * n + v[x][p] + 1;
		}
		// cout << t << endl;
		c = t / n;
		if(t > tot) {
			static int b[maxn], q[maxn];
			int r = -1;
			for(int i = lst % n; i < n; ++i) {
				if(!b[a[i]]) {
					b[a[i]] = 1;
					q[++r] = a[i];
				} else {
					while(1) {
						b[q[r]] = 0;
						if(q[r--] == a[i]) break;
					}
				}
			}
			for(int i = 0; i <= r; ++i) {
				cout << q[i] << ' ';
			}
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 20992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

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

  int ans = 0;
  ans += (n * (n-1)) / 2;
  ans += (m * (m-1)) / 2;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(void)
{
    string S;
    cin >> S;

    string s = "abcdefghijklmnopqrstuvwxyz";
    for(const auto& e : S)
    {
        s[e - 'a'] = 0;
    }
    for(const auto& e : s)
    {
        if(e)
        {
            cout << e << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#1_7_C
a = 0
r , c = map(int,input().split())
l = [list(map(int,input().split())) for i in range(r)]

for j in range(r):
    s = 0
    print(*l[j],end=" ")
    print(sum(l[j]))
    s = sum(l[j])
    a += s
    

for n in range(c):
    c = 0
    for m in range(r):
        c += l[m][n]
    print(c,end=" ")
print(a)


Measured memory_bytes: 6248
#include<iostream>
#include<stdio.h>
int main()
{
	int a, b;
	char op = 0;
	int ans;
	while (op != '?'){
		std::cin >> a;
		std::cin >> op;
		std::cin >> b;
		switch(op){
		case '+':
			ans = a + b;
			std::cout << ans << "\n";
			break;
		case '-':
			ans = a - b;
			std::cout << ans << "\n";
			break;
		case '*':
			ans = a*b;
			std::cout << ans << "\n";
			break;
		case '/':
			ans = a / b;
			std::cout << ans << "\n";
		default:
			break;
		}
	}
	return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

/////////////////////////////////////////////////////////////
map<ll, ll> prime_factorization(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      res[i] += 1;
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}
/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
class CombinationModulo {
 public:
  static const int MAX_N_LIB = (int)(2e5 + 100);
  static const ll MOD_LIB = (ll)(1e9 + 7);

  ll fact[MAX_N_LIB];
  ll inv[MAX_N_LIB];
  ll fact_inv[MAX_N_LIB];

  CombinationModulo(int n) { init(n); }

  void init(int n) {
    inv[1] = fact[0] = fact_inv[0] = 1;
    for (int i = 2; i <= n; i++) {
      inv[i] = (MOD_LIB - (MOD_LIB / i) * inv[MOD_LIB % i] % MOD_LIB) % MOD_LIB;
    }
    for (int i = 1; i <= n; i++) {
      fact[i] = fact[i - 1] * i % MOD_LIB;
    }
    for (int i = 1; i <= n; i++) {
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD_LIB;
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0;
    return fact[n] * fact_inv[r] % MOD_LIB * fact_inv[n - r] % MOD_LIB;
  }
};
/////////////////////////////////////////////////////////////

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

int n;
ll m;

ll ans;

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &m);

  auto prime_map = prime_factorization(m);

  int max_sholder = -1;

  for (auto &e: prime_map) {
    max_sholder = max(max_sholder, (int)(e.second));
  }

  CombinationModulo cm(n + max_sholder + 3);

  ans = 1LL;

  for (auto &e: prime_map) {
    ll cur = cm.comb(n + (int)(e.second) - 1, (int)(e.second));
    ans *= cur;
    ans %= MOD;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 4864
n,m=map(int,input().split())
a=[0]*(n+3)
mod=10**9+7
for _ in range(m):
    aa=int(input())
    a[aa]=1
dp=[0]*(n+3)
dp[0]=1
for i in range(1,n+1):
    if a[i]==1:
        dp[i]=0
    else:
        if i>=2:
            dp[i]=(dp[i-1]+dp[i-2])%mod
        elif i>=1:
            dp[i]=dp[i-1]
print(dp[n])


Measured memory_bytes: 7668
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

elems = defaultdict(int)
for elem_i in A:
    elems[elem_i] += 1

# print(elems)

# solve
ans = 0
for num_a, freq in elems.items():
    diff = freq - num_a
    if diff >= 0:
        ans += diff
    else:
        ans += freq

print(ans)

Measured memory_bytes: 18672
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int t = sc.nextInt();
		int c = (x - t);


		if (c < 0) {

			System.out.println("0");

		} else {

			System.out.println(x-t);

		}
	}
}


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

struct edge{long long i, u, v, cost;};
bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

int N, M;
long long X;
vector<edge> es;
vector<pair<long long, long long>> tree[1000];
long long pathmax[1000][1000];
const long long MOD = 1e9+7;
bool use[2000];


struct UnionFind {
    vector<int> par;
    vector<int> rank;

    void initialize(int n){
        par.resize(n);
        rank.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

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

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
};

long long kruskal(){
    sort(es.begin(), es.end(), comp);
    UnionFind uf;
    uf.initialize(N);
    long long res = 0;
    for(int i=0; i<es.size(); i++){
        edge e = es[i];
        if(!uf.same(e.u, e.v)){
            uf.unite(e.u, e.v);
            res += e.cost;
            use[e.i] = true;
            tree[e.u].push_back({e.v, e.cost});
            tree[e.v].push_back({e.u, e.cost});
        }
    }
    return res;
}

long long power_mod(long long num, long long power){
    long long prod = 1;
    num %= MOD;
    while(power > 0){
        if((power&1) == 1){
            prod = prod * num % MOD;
        }
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

void dfs(int s, int i, int prev){
    for(auto p : tree[i]){
        if(p.first == prev) continue;
        pathmax[s][p.first] = max(pathmax[s][i], p.second);
        dfs(s, p.first, i);
    }
}


int main(){
    long long i, j, k;
    cin >> N >> M >> X;
    for(i=0; i<M; i++){
        long long u, v, w;
        cin >> u >> v >> w;
        es.push_back({i, u-1, v-1, w});
    }

    long long S = kruskal();
    long long D = X - S;

    for(i=0; i<N; i++){
        pathmax[i][i] = 0;
        dfs(i, i, -1);
    }

    int equal = 0, upper = 0;
    for(auto e : es){
        if(use[e.i]) continue;
        long long diff = e.cost - pathmax[e.u][e.v];
        if(diff > D){
            upper += 1;
        }else if(diff == D){
            equal += 1;
        }
    }

    long long ans = 0;
    if(D == 0){
        long long result1 = (power_mod(2, N-1)-2+MOD) * power_mod(2, M-N+1) % MOD;
        long long result2 = (power_mod(2, equal)-1) * power_mod(2, upper+1) % MOD;
        ans = (result1 + result2) % MOD;
    }else if(D > 0){
        ans = (power_mod(2, equal)-1) * power_mod(2, upper+1) % MOD;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8320
def btc2jpy(price):
    return 380000. * price

N = int(input())
sum_ = 0
for i in range(N):
    elms = input().split(" ")
    if elms[1] == "BTC":
        x = btc2jpy(float(elms[0]))
    else:
        x = int(elms[0])
    sum_ += x

print(sum_)

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

int main() 
{
    int N;
    cin >> N;
    pair<int, int> A[N];
    for(int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        A[i].first = tmp;
        A[i].second = i;
    }
    //sort(A, A + N);
    sort(A, A + N,
        [](const pair<int, int> &x, const pair<int, int> &y) {
            return x.first < y.first;
        }
    );
    /*
    for(int i = 0; i < N; ++i) {
        cout << A[i].first << " " << A[i].second << endl;
    }
    */
    
    int ans[N];
    for(int i = 0; i < N; ++i) {
        if(i < N-1) {
            ans[A[i].second] = A[N-1].first;
        }
        else {
            ans[A[i].second] = A[N-2].first;
        }
    }
    for(int i = 0; i < N; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);    
    
     ll int   x,y,k;
       cin>>x>>y>>k;
     
       ll int c=max(x-k,(ll)0);
        cout<<c<<" "<<max(y-max(k-x,(ll)0),(ll)0);
       
    }


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<string> ans;
    while (true) {
        if (N % 2) {
            ans.emplace_back("1");
            N--;
        } else {
            ans.emplace_back("0");
        }
        N /= -2;
        if (N == 0) break;
    }
    reverse(ans.begin(), ans.end());
    rep(i, ans.size()) cout << ans[i];
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] p = new int[n];
    for(int i=0;i<n;i++)p[i]=sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    int[] r = new int[n];
    for(int i=0;i<n;i++)r[p[i]-1]=i;
    for(int i=0;i<n;i++){
      a[i]=30000*(i+1);
      b[i]=30000*(n-i)+r[i];
    }
    System.out.print(a[0]);
    for(int i=1;i<n;i++)System.out.print(" "+a[i]);
    System.out.println("");
    System.out.print(b[0]);
    for(int i=1;i<n;i++)System.out.print(" "+b[i]);
    System.out.println("");
  }
}

Measured memory_bytes: 42068
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    string s;
    cin >> s;
    int w;
    cin >> w;
    rep(i,s.size()){
        if(i%w==0) cout << s[i];
    }
    cout << endl;
}

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

int main() {
  int N;
  int A;
  cin >> N;
  cin >> A;
  int a;
  a = N % 500;
  if (A >= a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
# ABC103D - Islands War
from operator import itemgetter as gt


def main():
    N, M, *AB = map(int, open(0).read().split())
    Q = [(a, b) for a, b in zip(*[iter(AB)] * 2)]
    Q.sort(key=gt(1))
    ans, cur = 0, -1
    for a, b in Q:
        if a >= cur:  # need to break another bridge
            ans += 1
            cur = b
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25644
n=int(input())
a=list(map(int,input().split()))
d=[0]*n
for i in range(n):
  c=n-i
  t=0
  sum_d=sum(d[x] for x in range(c-1,n,c))
  if sum_d%2 != a[c-1]:
    d[c-1]=1

print(sum(d))
b=[]
if sum(d):
  for i in range(n):
    if d[i]>0:
      b.append(i+1)
  print(*b)

Measured memory_bytes: 14136
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666,mo=1e9+7;
int n,k,p[N],a[N],len,b[N],res;
ll power(ll a, ll n){
	ll res=1;
	while(n){
		if(n&1)res=res*a%mo;a=a*a%mo;n>>=1;
	}
	return res;
}
void facfac(int n){
	for(int x=2;x*x<=n;x++)if(n%x==0){
		p[++len]=x;while(n%x==0)n/=x,a[len]++;
	}
	if(n>1)p[++len]=n,a[len]=1;
}
inline int calc(){
	int res=1;
	rep(i,1,len)if(a[i]-b[i])res=1LL*res*(1-p[i]+mo)%mo;
	return res;
}
void dfs(int dep, int y){
	if(dep>len){
		int ans=0;
		if(y%2==0)ans=1LL*y/2*calc()%mo;
		else if(n/y&1)ans=1LL*y*calc()%mo;
	//	cerr<<y<<' '<<ans<<endl;
		res=(res+1LL*ans*power(k,(y+1)/2))%mo;
		return;
	}
	rep(i,0,a[dep])b[dep]=i,dfs(dep+1,y),y*=p[dep];
}
int main() {
	read(n);read(k);facfac(n);
	dfs(1,1);cout<<res;
	return 0;
}


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

using namespace std;

typedef long long ll;

const int MAX_N = 19, MAX_M = 1 << MAX_N;
const ll MOD = 998244353, INV2 = (MOD + 1) / 2;

ll sq(ll x) { return x * x % MOD; }
ll qpow(ll x, ll y) { return y ? sq(qpow(x, y / 2)) * (y & 1 ? x : 1) % MOD : 1; }
ll inv(ll x) { return qpow(x, MOD - 2); }

int N;
ll A[MAX_M];

vector<ll> solve(const vector<ll> &a, const vector<ll> &b) {
    if (a.size() == 1) {
        return {a[0] ? b[0] * inv(a[0]) % MOD : 0};
    } else {
        vector<ll> al, ar, bl, br;
        for (int i = 0; i < a.size(); i += 2) {
            al.push_back((a[i] + a[i + 1]) % MOD);
            bl.push_back((b[i] + b[i + 1]) % MOD);
            ar.push_back((a[i] - a[i + 1] + MOD) % MOD);
            br.push_back((b[i] - b[i + 1] + MOD) % MOD);
        }
        vector<ll> resl = solve(al, bl), resr = solve(ar, br), res;
        for (int i = 0; i < al.size(); i++) {
            res.push_back((resl[i] + resr[i]) * INV2 % MOD);
            res.push_back((resl[i] - resr[i] + MOD) * INV2 % MOD);
        }
        return res;
    }
}

int main() {
    scanf("%d", &N);
    ll s = 0;
    for (int i = 0; i < 1 << N; i++) scanf("%lld", &A[i]), s += A[i];
    s = inv(s);
    vector<ll> a, b;
    for (int i = 0; i < 1 << N; i++) a.push_back(A[i] * s % MOD - (i == 0));
    for (int i = 0; i < 1 << N; i++) b.push_back((MOD - 1 + (i == 0 ? 1 << N : 0)) % MOD);
    vector<ll> res = solve(a, b);
    ll t = res[0];
    for (ll &i : res) (i += MOD - t) %= MOD;
    for (ll i : res) printf("%lld\n", i);
}


Measured memory_bytes: 21360
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
 
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");
 
T lread(T = long)()
{
    return readln.chomp.to!T();
}
 
T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}
 
void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

long disit_sum(long a)
{
    long sum,disit_num;
    foreach(disit;0 .. 10)
    {
        disit_num = a / pow(10, disit);
        sum += disit_num % 10;
    }
    return sum;
}


void main()
{
    long s = lread();
    long sum = disit_sum(s);
    (s % sum?"No":"Yes").writeln();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

int main(){
	int h, w;
	char *c, *c_org;
	bool *bh, *bw;
	scanf("%d %d\n", &h, &w);
	c = (char*)malloc(sizeof(char)*h*w);
	c_org = c;
	bh = (bool*)malloc(sizeof(bool)*h);
	bw = (bool*)malloc(sizeof(bool)*w);
	for(int i=0; i<h; i++){
		scanf("%s\n", c);
		c+=w;
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			bh[i] = false;
			bw[j] = false;
		}
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(*(c_org + i*w +j) == '#') {
				bh[i] = true;
				bw[j] = true;
			}
		}
	}
	for(int i=0; i<h; i++){
		if(bh[i]){
			for(int j=0; j<w; j++){
				if(bw[j]) {
					printf("%c", *(c_org + i*w +j));
				}
			}
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

#define min(a, b) ((a) < (b) ? a : b)

int main(void) {
	int n, m, x;
	int is_price[101] = {0};

	scanf("%d %d %d", &n, &m, &x);
	for (int i = 0; i < m; i++) {
		int a;
		scanf("%d", &a);
		is_price[a] = 1;
	}

	int sum[101] = {0};

	for (int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + is_price[i];

	printf("%d\n", min(sum[x], sum[n] - sum[x]));

	return 0;
}


Measured memory_bytes: 128
import copy

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

m_1 = sorted(a)[-1]
m_2 = sorted(a)[-2]

for i in range(n):
    if a[i] == m_1:
        print(m_2)
    else:
        print(m_1)

Measured memory_bytes: 15132
N = int(input())
MOD = 10 ** 9 + 7
A = [1] * 64
A[6] = A[9] = A[33] = 0
for _ in range(N-3):
    B = [0] * 64
    for p in range(256):
        i = p >> 2
        j = p & 63
        b = ((i == 6) or (i == 9) or (i == 33)
            or (j == 6) or (j == 9) or (j == 33)
            or (p & 207 == 9) or (p & 243 == 33))
        if not b:
            B[j] = (B[j] + A[i]) % MOD
    A[:] = B[:]
res = 0
for a in A:
    res = (res + a) % MOD
print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
using namespace std;



int main(){
  bool is_prime[50001];
  is_prime[0]=false;is_prime[1]=false;
  for(int i=2;i<50001;i++)is_prime[i]=true;
  for(int i=2;i<=sqrt(50001);i++){
    if(is_prime[i]){
      for(int j=2;i*j<=50001;j++)is_prime[i*j]=false;
    }
  }
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int cnt=0;

    for(int i=2;i<=n/2;i++){
      if(is_prime[i]){
        if(is_prime[n-i])cnt++;
      }
    }
    cout<<cnt<<endl;
  }
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Bit[40];

ll Solve(ll num){
  ll ans = 0;
  for (int i = 0; i < 40; i++){
    ll now = (num / Bit[i]) * (Bit[i] / 2);
    now += max(num % Bit[i] - (Bit[i]/2 - 1), 0ll);
    if (now % 2 != 0) ans += Bit[i] / 2;
  }
  return ans;
}


int main(){
  Bit[0] = 2;
  for (int i = 1; i < 40; i++) Bit[i] = Bit[i-1] * 2;

  ll A, B; cin >> A >> B;
  ll ans = Solve(A - 1) ^ Solve(B);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 200000
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n,m;
    cin>>n>>m;
    vector<P>a(n);
    REP(i,n){
        int x,y;
        cin>>x>>y;
        a[i]={x,y};
    }
    sort(ALL(a));
    int k=0;
    ll ans=0;
    priority_queue<int> q;
    for(int i=1;i<=m;i++){
        while(k<n&&a[k].first<=i){
            q.push(a[k].second);
            k++;
        }
        if(SZ(q)==0)continue;
    ans+=q.top();
    q.pop();
    }
    OUT(ans);
	return 0;
}

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

struct kv {
    int k;
    int v;
};
bool operator<(const kv &kv1, const kv &kv2) {
    return kv1.v < kv2.v;
}

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

    int ai, A[N+1];
    fill(A, A+N+1, 0);
    rep(i, N) {
        cin >> ai;
        A[ai]++;
    }

    vector<kv> vec;
    rep(i, N+1) {
        if (A[i] > 0) vec.push_back({i, A[i]});
    }
    sort(vec.begin(), vec.end());

    int ans = 0;
    if (K < vec.size()) rep(i, vec.size() - K) ans += vec[i].v;

    cout << ans << endl;

   return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    ll n,a,b;
    while(sf("%lld %lld %lld",&n,&a,&b)==3)
    {
        ll ara[n+5];
        for(int i=0;i<n;i++)sf("%lld",&ara[i]);

        ll ans=0;
        for(int i=0;i<n-1;i++)
        {
            ll dis=ara[i+1]-ara[i];
            if(dis*a<=b)ans+=(dis*a);
            else ans+=b;
        }
        pf("%lld\n",ans);
    }
    return 0;
}
 









 




























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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++) {
    if(n > (int)('Z' - s.at(i))) s.at(i) = (char)('A' + n - 'Z' + s.at(i) - 1);
    else s.at(i) = (char)(s.at(i) + n);
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int a, b, c, N;
int p[301];
vector<int> va, vb, vc, vu;

int main(void) {
  while(cin >> a >> b >> c, !(a == 0 && b == 0 && c == 0)) {
    cin >> N;

    REP(i, 1, a + b + c + 1) p[i] = 2;

    REP(n, 0, N) {
      int i, j, k, r; cin >> i >> j >> k >> r;
      if(r == 0) {
        va.push_back(i);
        vb.push_back(j);
        vc.push_back(k);
        vu.push_back(0);
      }
      else {
        p[i] = 1;
        p[j] = 1;
        p[k] = 1;
      }
    }

    int cont = 1;
    while(cont == 1) {
      cont = 0;
      REP(n, 0, va.size()) {
        if(vu[n] == 0) {
          int i = va[n];
          int j = vb[n];
          int k = vc[n];

          if(p[i] == 2 && p[j] == 1 && p[k] == 1) p[i] = 0, cont = 1, vu[n] = 1;
          if(p[i] == 1 && p[j] == 2 && p[k] == 1) p[j] = 0, cont = 1, vu[n] = 1;
          if(p[i] == 1 && p[j] == 1 && p[k] == 2) p[k] = 0, cont = 1, vu[n] = 1;
        }
      }
    }

    REP(i, 1, a + b + c + 1) {
      cout << p[i] << endl;
    }

    va.clear();
    vb.clear();
    vc.clear();
    vu.clear();
  }

  return 0;
}

Measured memory_bytes: 1240
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let gcd x y =
    let rec aux x y = if y = 0 then x else aux y (x % y)
    aux (abs x) (abs y)

[<EntryPoint>]
let main _ =
    let n = read int
    let xs = reads int
    List.reduce (fun s x -> gcd x s) xs
    |> printfn "%i"
    0

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


using namespace std;
int total=0,n,a[105];

void cheak(int i,int p)
{
    //cout<<total<<" "<<i<<endl;
    if(i==n)
        return;
    if(p==a[i])
    {
        total+=1;
        p=0;
    }
    else
    {
        p=a[i];
    }
    cheak(i+1,p);
}

int main()
{
    int i,j;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];

    }
    cheak(0,0);
    cout<<total<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>


int main()
{
	long h,w,n,i,k,ck,cy;
	long s = 0;
	long j = 0;
	long a[10000];
	long m[10000];
	scanf("%ld %ld", &h,&w);
	scanf("%ld", &n);
	for (i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
	}
	ck = a[0];
	cy = 1;
	for (i = 0; i < h; i++) {
		printf("\n");
		if (i % 2 == 0) {
			for (k = 0; k < w; k++) {
				if (ck == 0) {
					ck = a[cy];
					cy++;
				}
				printf("%ld ", cy);
				ck--;
			}
		}
		else {
			for (k = 0; k < w; k++) {
				if (ck == 0) {
					ck = a[cy];
					cy++;
				}
				m[s] = cy;
				s++;
				ck--;
				if (s == w) {
					for (s = w; s >0; s--) {
						printf("%ld ", m[s-1]);
						m[s] = 0;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
d = {}
for i in range(m):
    s, c = map(int, input().split())
    if n >= 2 and s == 1 and c == 0:
        print(-1)
        exit()
    if s in d:
        if d[s] != c:
            print(-1)
            exit()
    else:
        d[s] = c

ans = [0]*n
if n >= 2:
    ans[0] = 1
for i in range(n):
    if i+1 in d:
        ans[i] = d[i+1]
print(''.join(map(str, ans)))

Measured memory_bytes: 38384
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n;
    cin >> n;

    bool ans = false;
    for (int i = 1; i < 10; ++i)
        for (int j = 1; j < 10; ++j)
            if (i * j == n)
                ans = true;

    if (ans) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256