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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i = (n); i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(1e5+5);

void pre() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  #endif
}

void solve() {
  int k;  cin>>k;
  int a = 7;
  rep(i,k) {
    a %= k;
    if(a == 0) {cout<<(i+1);return;}
    a = (a*10 + 7);
  }
  cout<<-1;
}

int main() {
  pre();
  int t = 1;
  //cin>>t;
  rep(i,t)  {
    //cout<<"Case #"<<(i+1)<<"\n";
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n = II()
    a = LI()
    a.sort()
    r = 1
    t = a[0]
    for ai in a[1:]:
        if t*2 < ai:
            r = 1
        else:
            r += 1
        t += ai

    return r

print(main())


Measured memory_bytes: 17916
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        int ans = 0;
        float lim = sqrt((float)2/3*i);
        int max = (int)(sqrt((float)2*i));
        int lim_up = (int)lim +1;
        if( lim == (float)((int)lim) ) lim_up--; 
        for(int x=lim_up;x<=max+1;x++){
            for(int z=1;z<=(int)lim;z++){
                for(int y=z;y<=x;y++){

                    int det = x*x + y*y + z*z;
                    if(x+y>z && y+z>x && z+x>y && det == 2*i){
                        if(x==y && y==z) ans++;
                        else if(x==y || y==z) ans += 3;
                        else ans += 6;
                    }

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

Measured memory_bytes: 2112
/*  (: ///////|||||| BEGINS |||||||\\\\ :) */
/* REMEMBER
Deletes all characters except first one     Deletes 4 characters from index number 1
    str.erase(1);                               str.erase(1,4);
Deletes character at position 4
 str.erase(str.begin() + 4);
bool compare(const pair<int, int>&a, const pair<int, int>&b)
{
   return a.second<b.second;
}
maxn = max_element(mp.begin(), mp.end(), compare)->second;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}
priority_queue <int, vector<int>, greater<int>> gquiz; // to create min heap
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
const int inf=0x3f3f3f3f;
#define mod  1000000007
#define fo(i,n) for(int i=1;i<=n;i++)
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define three_max(n1,n2,n3) (n1 > n2)?(n1>n3?n1:n3):(n2>n3?n2:n3)
#define lb lower_bound
#define ub upper_bound
#define tr(it, a) for(auto it = a.begin();it!=a.end();it++)
#define gcd(a,b) __gcd(a,b)
#define pq priority_queue 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long isprime(long long n)
{
    for(long long i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)return 0;
    }
    return 1;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

int n;
cin>>n;
string s;
cin>>s;
ll cn=0;
ll i=0,j=n-1;
while(i<j)
{
if(s[i]=='W' && s[j]=='R')
{
    swap(s[i],s[j]);
    cn++;
    i++;
    j--;
}
else if(s[j]=='W')
{
    j--;
}
else if(s[i]=='R')
i++;
}
cout<<cn<<endl;
return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  string S;
  cin >> S;
  vector<ll> change_to_l;
  vector<ll> ret(S.size(), 0);
  for (int i = 1; i < S.size(); ++i) {
    if (S[i - 1] == 'R' && S[i] == 'L')
      change_to_l.push_back(i);
  }
  ll k = 0;
  int j = change_to_l[k];
  for (int i = 0; i < S.size(); ++i) {
    if(i>j&&S[i]=='R'){
     k++;
     j=change_to_l[k];
    }
    if (abs(i-j)%2==0) {
      ret[j]++;
    }else{
      ret[j-1]++;
    }
  }
  for (int i = 0; i < ret.size(); ++i) {
    cout << ret[i] << " ";
  }
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll a,b; cin >> a >> b;
    ll c,d; cin >> c >> d;
    ll lcm = c/__gcd(c,d)*d;
    ll b_mod = b/c + b/d - b /lcm;
    ll a_mod = (a-1)/c + (a-1)/d - (a-1)/lcm;
    cout << (b-(a-1)) - (b_mod - a_mod) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

bool ok[15];
int c[]{0,2,5,5,4,5,6,3,7,6};

int dp[15][20000];

int main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		int a;scanf("%d",&a);
		ok[a]=true;
	}
	memset(dp,-1,sizeof(dp));
	dp[1][0]=0;
	for(int i=1;i<10;i++){
		rep(j,12000){
			if(dp[i][j]==-1)continue;
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
			if(ok[i])dp[i][j+c[i]]=max(dp[i][j+c[i]],dp[i][j]+1);
		}
	}
	string ans;
	for(int i=9;i>=1;i--){
		if(!ok[i])continue;
		while(n>=c[i]&&dp[i][n-c[i]]==dp[i][n]-1){
			n-=c[i];
			char c='0'+i;
			ans+=c;
		}
	}
	cout<<ans<<endl;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

const ll mod = 1000000007;
//const ll mod = 998244353;

const int MAX_N = 1000010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void create_table(int n) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= n;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[n] = pow_mod(fact[n],-1);
    for (int i = n;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= n;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    int n;
    cin >> n;
    create_table(1000000);
    ll ans = 0,s = 0;
    for (int i = (n+1)/2;i < n;++i) {
        ll x = combi(i-1,n-i-1)*fact[i]%mod;
        (ans += (x-s)*fact[n-i-1]%mod*i%mod) %= mod;
        s = x*(n-i-1)%mod;
    }
    cout << (ans+mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 23680
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


#define SUB_SIZE 19
#define	SIZE	pow(2, SUB_SIZE)	// 2^19 = 524,288


int main()
{
	int n, c;
	char *one_count;
	int count, tmp;
	int bk;
	int i, j, k;

	scanf("%d %d", &n, &c);

	// 信号の配列を用意
	one_count = (char *)malloc(sizeof(char) * SIZE);

	// 初期化
	for(i = 0; i < SIZE; i++)
		one_count[i] = 0;

	// 信号二次元配列の作成
	for(i = 0; i < SUB_SIZE; i++){
		tmp = pow(2, i);
		for(j = tmp; j < SIZE; j += 2 * tmp){
			count = 0;
			k = j;
			while(count < tmp){
				one_count[k]++;
				count++;
				k++;
			}
		}
	}


	// 全組み合わせの表示
	tmp = pow(2, n);
	for(i = 0; i < tmp; i++){
		if(one_count[i] == c){
			printf("%d:", i);
			bk = i;
			for(j = 0; j < n; j++, bk >>= 1)
				if(bk & 0x1)
					printf(" %d", j);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 2500
S = gets.chomp
combi = 2 ** (S.size-1)
formulas = Array.new(combi)
(0...combi).each do |n|
  count = 0
  copy_S = S.clone
  ("%0#{S.size-1}b" % n).split('').each.with_index(1) do |bit, i|
    if bit == '1'
      copy_S.insert(i+count, '+')
      count += 1
    end
  end
  formulas[n] = copy_S
end
sum = 0
formulas.each do |formula|
  sum += formula.split('+').map(&:to_i).inject(:+)
end
puts sum


Measured memory_bytes: 1916
n,m,k = map(int,input().split())
mod = 998244353
ans = 0
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = mod
N = 10**6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
for i in range(0,k+1):
  ans += m*pow(m-1,n-1-i,mod)*cmb(n-1,i,p)
  ans %= mod
print(ans)

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

int main(){
  int n, m, l;
  cin >> n >> m >> l;
  int A[n][m], B[m][l];
  for (int i=0; i<n; ++i){
    for (int j=0; j<m; ++j){
      cin >> A[i][j];
    }
  }
  for (int i=0; i<m; ++i){
    for (int j=0; j<l; ++j){
      cin >> B[i][j];
    }
  }
  long long C[n][l];
  for (int i=0; i<n; ++i){
    for (int j=0; j<l; ++j){
      C[i][j] = 0;
      for (int k=0; k<m; ++k){
	C[i][j] += A[i][k] * B[k][j];
      }
      if (j==l-1) cout << C[i][j] << endl;
      else cout << C[i][j] << " ";
    }
  }
  return 0;
}

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

int main(){
  
 string s; cin>>s;
  set<char> st;
  for(char c : s ) st.insert(c);
  
  if(st.size()>1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  
  return 0;
}

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

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;

  double deg_per_min_a = 0.5;
  int deg_per_min_b = 6;

  double deg_a = ((h * 60) + m) * deg_per_min_a;
  int deg_b = m * deg_per_min_b;

  if (deg_a == deg_b) {
    cout << abs(a - b) << endl;
    return 0;
  }

  double angle = abs(deg_a - deg_b);
  ld radians = 2 * M_PI * (angle / 360);
  ld answer_squared = pow(a, 2) + pow(b, 2) - (2 * a * b * cos(radians));
  printf("%.10Lf", sqrt(answer_squared));
}


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

int main(){
    int N = 3;
    int tmp; cin >> tmp;
    int a[4];
    for(int i = 3; i >= 0; i--){
        a[i] = tmp % 10;
        tmp /= 10;
    }   
    // for(int i = 0; i < 4; i++) cout << a[i];
    for(int bit = 0; bit< (1<<N); bit++){
        vector<char> S;
        for(int i=0;i<N;i++){
            if(bit & (1<<i)){
                S.push_back('+');
            }
            else{
                S.push_back('-');
            }
        }
        // for(int i=0;i<S.size();i++){
        //     cout<<S[i];
        // }
        // cout<<endl;
        int ans = a[0];
        // cout << ans << endl;
        for(int i = 1; i < 4; i++){
            if(S[i-1] == '+') ans += a[i];
            else ans -= a[i];
        }
        if(ans == 7){
            for(int i = 0; i < 4; i++){
                cout << a[i];
                if(i < 3) cout << S[i];
            }
            cout << "=7" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int a,b,m;
    cin >> a >> b >> m;
    vector<int> A(a),B(b);
    int x,y,c;
    int amin=INF,bmin=INF,ans=INF;
    for(int i=0; i<a; i++){
        cin >> A[i];
        amin=min(amin,A[i]);
    }
    for(int i=0; i<b; i++){
        cin >> B[i];
        bmin=min(bmin,B[i]);
    }
    ans=amin+bmin;
    for(int i=0; i<m; i++){
        cin >> x >> y >> c;
        ans=min(A[x-1]+B[y-1]-c,ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

int main()
{
  int a, b;
  std::cin >> a >> b;
  if ( (a+b) % 2 == 0 ) std::cout << (a+b) / 2 << std::endl;
  else std::cout << (a+b) / 2 + 1 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,m,n,p;

int main()
{
    cin>>a>>b>>c;
    m=a+b;
    n=a+c;
    p=b+c;
    if(m==n && m==p && n==p) {cout<<m;}
    if(m<n && m<p) {cout<<m;}
    if(n<m && n<p) {cout<<n;}
    if(p<n && p<m) {cout<<p;}
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll N;
ll memo[109][100010];
vector<pair<ll,ll> >v;
ll sol(ll pos,ll val){
  if(val<0)return 2e12;
  if(pos>=N && val==0)return 0;
  if(pos>=N)return 2e12;
  if(memo[pos][val])return memo[pos][val];
  return memo[pos][val]=min(sol(pos+1,val),sol(pos+1,val-v[pos].second)+v[pos].first);
}
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
		ll W;
    cin>>N>>W;
    for(ll i=0;i<N;i++){
      ll a,b;
      cin>>a>>b;
      v.push_back({a,b});
    }
    for(int i=100000;i>=0;i--){
      if(sol(0,i)<=W){
        cout<<i;
        return 0;
      }
    }
    return 0;
}

Measured memory_bytes: 80000
#include <stdio.h>

int main(void)
{
   int a[3],max,min,i;

   for(i=0;i<3;i++)
      scanf("%d",&a[i]);

   max = a[0];
   min = a[0];
   for(i=0;i<3;i++){
      if(a[i]>max) max = a[i];
      if(a[i]<min) min = a[i];
      }
   printf("%d\n",max-min);

   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(register int i=(a);i<(b);i++)
#define per(i,a,b) for(register int i=(b);i>=(a);i--)
#define For(i,a,b) for(register int i=(a);i<=(b);i++)
#define Forenska(it,c) for(register __typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
using namespace std;
typedef long long LL;
typedef pair<int,int> Pair;
typedef vector<int> vec;
const long double PI=3.14159265358979323846264338327950288;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const int MAX_N=60;
LL dp[MAX_N][MAX_N][MAX_N*MAX_N];
LL N,A,x[MAX_N];
int main()
{
	LL sum=0;
	cin>>N>>A;
	For(i,1,N)
	{
		cin>>x[i];
		sum+=x[i];
	}
	For(i,0,N)dp[i][0][0]=1;
	For(i,1,N)
	{
		For(j,1,i)
		{
			For(k,0,sum)
			{
				if(k>=x[i])dp[i][j][k]+=dp[i-1][j-1][k-x[i]]+dp[i-1][j][k];
				else dp[i][j][k]+=dp[i-1][j][k];
			}
		}
	}
	LL ans=0;
	For(j,1,N)
	{
		ans+=dp[N][j][A*j];
	//	cout<<j<<" "<<dp[N][j][A*j]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 84224
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const ll INF = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = (int)S.size();
    vector<vector<ll>> dp(N + 1, vector<ll>(2, INF));  // dp[i][j]: 上位i桁目まででS[i]よりj大きい時の最小値
    dp[0][0] = 0;
    dp[0][1] = 1;
    rep(i, 1, N + 1) {
        chmin(dp[i][0], dp[i - 1][0] + (ll)(S[i - 1] - '0'));
        chmin(dp[i][0], dp[i - 1][1] + 10 - (ll)(S[i - 1] - '0'));
        chmin(dp[i][1], dp[i - 1][0] + (ll)(S[i - 1] - '0') + 1);
        chmin(dp[i][1], dp[i - 1][1] + 10 - (ll)(S[i - 1] - '0') - 1);
    }
    cout << dp[N][0] << endl;
    return 0;
}

Measured memory_bytes: 55964
#include<bits/stdc++.h>
using namespace std;
 int  main()
{ long long int  n,w;
cin>>n>>w;
long long int  val[n],wt[n];
for(long long int  i=0;i<n;i++)
    cin>>wt[i]>>val[i];
    int x=100000;
long long int  dp[n+1][x+1]={0};

for(long long int  i=0;i<=n;i++)
    for(long long int  j=0;j<=x;j++)
    dp[i][j]=1000000001;
for(int i=0;i<=n;i++)
    dp[i][0]=0;
for(long long int  i=val[0];i<val[0]+1;i++)
    dp[1][i]=wt[0];
//cout<<dp[1][val[0]]<<endl;
for(long long int  i=2;i<=n;i++)
{ for(long long int  j=1;j<=x;j++)
    { if(val[i-1]<=j)
        { dp[i][j]=min(dp[i-1][j-val[i-1]]+wt[i-1],dp[i-1][j]);
            //cout<<i<<" "<<j<<" "<<dp[i-1][j-wt[i-1]]+val[i-1]<<endl;
        }
        else
            dp[i][j]=dp[i-1][j];
    }
}

int ans=0;
for(int i=0;i<=n;i++)
{ for(int j=0;j<=x;j++)
    { if(dp[i][j]<=w)
        ans=max(ans,j);
        if(dp[i][j]==1000000001)
            dp[i][j]=-1;
        //cout<<dp[i][j]<<"  ";
//
    }
   //cout<<i<<endl;
}

cout<<ans<<endl;
}


Measured memory_bytes: 79104
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] s = new int[N+1];
		int total = 0;
		for( int i=1; i<=N; i++ ){
			s[i] = sc.nextInt();
			total += s[i];
		}
		Arrays.sort(s);
		int ans = 0;
		int dis = 0;
		int a = 1;
		int b = 0;
		for( int i=1; i<=N; i++ ){
			if( s[i]%10!=0 ){
				break;
			}
			if( i==N ){
				ans = 0;
				b = 1;
			}
		}
		if( total%10!=0 ){
			ans = total;
		}else if(b==0){
			for( int i=1; i<=N; i++ ){
				if( s[i]%10!=0 ){
					ans = total - s[i];
					break;
				}
			}			
		}
		System.out.println(ans);
	}
}


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

int main() {
 string s;
 cin >> s;
 string ret = "No";

 int n = s.length();
 char first = s[0];
 for (int i = 1; i < n; i++) {
     if(s[i] != first) {
         ret = "Yes";
     }
 }
 
 cout << ret << endl;
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const long long mod=1e9+7;
long long qpow(long long base,long long n){
	long long ans=1;
	while(n){
		if(n%2==1){
			ans=(ans*base)%mod;
		}
		base=(base*base)%mod;
		n/=2;
	}
	return ans%mod;
}
int main(){
	long long n;
	cin>>n;
	cout<<(qpow(10,n)%mod-2*qpow(9,n)%mod+qpow(8,n)%mod+10*mod)%mod;
} 

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

int main()
{
  int N,ans,j;
  int max=0,max2=0;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if(max<A[i]) {
      j=i;
      max=A[i];
    }
  }
  sort(A.begin(), A.end());
  max2=A[N-2];
  for (int i = 0; i < N; i++) {
    if(i==j)
      cout << max2 << endl;
    else
      cout << max << endl;
  }
  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vi a(n), b(n);
  rep(i, n){
    cin >> a[i];
    if(i != 0){
      a[i] += a[i - 1];
    }
  }
  rep(i, n) cin >> b[i];
  for(int i = n - 1; i > 0; i--) b[i - 1] += b[i];
  int ans = 0;
  rep(i, n){
    int point = a[i] + b[i];
    ans = ans < point ? point : ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string.h>
#include<functional>
//aoj 0118
using namespace std;
int n,m,ans;
int cun[103][103];
int dh[5]={0,0,0,1,-1};
int dl[5]={0,1,-1,0,0};
void dfs(int h,int l)
{
	int ls=cun[h][l];
	cun[h][l]=0;
	for(int i=1;i<=4;i++)
	{
		if(h+dh[i]>0&&h+dh[i]<=n&&l+dl[i]>0&&l+dl[i]<=m&&cun[h+dh[i]][l+dl[i]]==ls)
		{
			dfs(h+dh[i],l+dl[i]);
		}
	}
}
int main()
{
	while(1)
	{
		scanf("%d%d",&n,&m);
		if(n==0&&m==0)
		{
			break;
		}
		memset(cun,0,sizeof(cun));
		ans=0;
		while(getchar()!='\n');
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				char aaa;
				scanf("%c",&aaa);
				if(aaa=='*')
				{
					cun[i][j]=1;
				}else if(aaa=='#')
				{
					cun[i][j]=2;
				}else if(aaa=='@')
				{
					cun[i][j]=3;
				}
			}
			while(getchar()!='\n');
		}
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				if(cun[i][j]!=0)
				{
					ans++;
					dfs(i,j);
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}













Measured memory_bytes: 3260
#include <stdio.h>

int main(void)
{
  int n;
  int a[100001];
  int b[100000];
  long cnt = 0;
  
  scanf("%d", &n);
  for (int i = 0; i < n+1; i++)
    scanf("%d", &a[i]);
  for (int i = 0; i < n; i++)
    scanf("%d", &b[i]);
  
  for (int i = 0; i < n; i++)
    if (a[i] >= b[i])
      cnt += b[i];
    else {
      cnt += a[i];
      b[i] -= a[i];
      if (a[i+1] > b[i]) {
        cnt += b[i];
        a[i+1] -= b[i];
      } else {
        cnt += a[i+1];
        a[i+1] = 0;
      }
    }
  
  printf("%ld", cnt);
  
  return 0;
}

Measured memory_bytes: 896
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(a);
    cini(b);

    cout<<max(a+b, max(a-b, a*b))<<endl;
}



Measured memory_bytes: 892
import sys
a,b,c,k = map(int,input().split())

ans = 0

if a <= k:
    ans += a
    k -= a
else:
    print(k)
    sys.exit()
if b <= k:
    k -= b
else:
    print(ans)
    sys.exit()
if c <= k:
    ans -= c
    print(ans)
else:
    print(ans - k)


Measured memory_bytes: 9188
import sys
H, W = [int(x) for x in input().split()]

A = [[0] * (W + 2) for _ in range(H + 2)]

for h in range(H):
    s = input()
    for w in range(W):
        A[h + 1][w + 1] = 1 if s[w] == "#" else 0

for h in range(1, H + 1):
    for w in range(1, W + 1):
        a = A[h][w] + A[h][w + 1] + A[h][w - 1] + A[h + 1][w] + A[h - 1][w]
        if A[h][w] == 1 and a == 1:
            print("No")
            sys.exit(0)

print("Yes")


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

using namespace std;

int main(){
        int mx=-1, mn=100000000;
        int N;
        cin>>N;
        for(int i=0;i<N;i++){
                int a;
                cin>>a;
                mx=max(a, mx);
                mn=min(a, mn);
        }
        cout<<mx-mn<<endl;
        return 0;
}


Measured memory_bytes: 256
import sys

def f(n):
  X6 = []
  X9 = []
  for i in range(1, 10):
    if n >= 6**i:
      X6.append(6**i)
    if n >= 9**i:
      X9.append(9**i)
  return X6, X9


def main():
  input = sys.stdin.readline
  N = int(input())
  dp = [0 for _ in range(N+1)]
  for i in range(1, N+1):
    can = []
    X6, X9 = f(i)
    X = [1] + X6 + X9
    for x in X:
      can.append(dp[i-x] + 1)
    dp[i] = min(can)
  print(dp[N])

if __name__ == '__main__':
  main()

Measured memory_bytes: 3888
S = input()

ans = 0
ACGT = ("A", "C", "G", "T")

count = 0
count_list = [0]
for s in S:
    if s not in ACGT:
        count_list.append(count)
        count = 0
        continue
    else:
        count += 1
count_list.append(count)
print(max(count_list))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()

void solve(){
  int n; cin >> n;
  vector<ll> h(n);
  RPT(i,0,n) cin >> h[i];
  vector<int> ds(1,0); int  d=0;
  for(;d<n-1;){
    int cnt=0;
    while(d<n-1){
      ++d;
      if(h[d-1]<h[d]) break;
      cnt++;
    }
    ds.push_back(cnt);
    cnt = 0;
  }
  cout << *max_element(ALL(ds)) << endl;
}

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

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

using namespace std;

int main()
{
    int n, ans = 0;
    cin >> n;

    vector<int> as(n);
    for (int i = 0; i < n; ++i)
        cin >> as[i];
    sort(as.begin(), as.end());

    vector<int> ps(as[n - 1] + 1, 0);

    for (int i = 0; i < n; ++i)
    {
        if (ps[as[i]] > 1)
            continue;

        for (int j = as[i]; j <= as[n - 1] + 1; j += as[i])
        {
            ps[j]++;
        }
    }

    for (int i = 0; i < n; ++i)
    {
        if (ps[as[i]] == 1)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8008
def main():
    n = int(input())
    a = list(map(int, input().split()))
    all_v = sum(a)
    ans = 0
    if n == 0:
        if a[0] == 1:
            ans = 1
        else:
            ans = -1
    elif a[0] != 0:
        ans = -1
    else:
        ans = 1
        max_vertex = 1
        for i in range(1, n + 1):
            max_vertex *= 2
            if max_vertex < a[i]:
                ans = -1
                break
            ans += min(max_vertex, all_v)
            max_vertex = min(max_vertex, all_v) - a[i]
            all_v -= a[i]
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int Euler(int n)
{
    int res=n;
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            res-=res/i;
            while(n%i==0) n/=i;
        }
    }
    if(n>1) res-=res/n;
    return res;
}

int main()
{
    int n;
    while(cin>>n)
    {
        cout<<Euler(n)<<endl;
    }

    return 0;
}



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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

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

    string ans="";
    ll digit=0;
    
    for(; digit<=11; digit++){
        ll ldiv, lmod;

        n-=1;

        ldiv = n/26;
        lmod = n%26;

        ans += (char)('a'+lmod);

        n = ldiv;

        if(n==0) break;
    }

    reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
const long double PI=acos(-1);
using namespace std;
void fast() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
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;
}
bool p(int a,int b)
{
    return a>b;
}
int modpow(int a,int b,int c)
{
    if(b==0)
        return 1%c;
    int u = modpow(a,b/2,c);
    u=(u*u)%c;
    if(b&1)
        u=(u*a)%c;
    return u;
}
bool cmp(const pair<ll,ll>&q,const pair<ll,ll>&f)
{
    return q.second>f.second;
}
ll prime(ll x)
{
    if(x<2)
    {
        return false;
    }
    else
    {
        for(int i=2;i*i<=x;i++)
        {
            if(x%i==0)
            {
                return false;
            }
        }
        return true;
    }
}

int main() {
    fast();
    ll x,z=0;
    cin>>x;
    while(x--)
    {
        bool f=false;
        ll a,b;
        cin>>a>>b;
        if(a==b)
        {
            z++;
            f=true;
        }
        else
        {
            z=0;
        }
        if(z==3)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
        cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 100010;
int q,n,len[N],val[N],ans[N],m;
void doit(int x,int v) {
  if (!x) return;
  int t = upper_bound(len+1,len+m+1,x) - len - 1;
  if (t == 0) ans[1] += v, ans[x+1] -= v;
  else {
    val[t] += (x / len[t]) * v;
    doit(x % len[t],v);
  }
}
signed main() {
  int x;
  scanf("%lld%lld",&n,&q);
  len[++m] = n;
  for (int i = 1 ; i <= q ; ++ i) {
    scanf("%lld",&x);
    while (m && len[m] >= x) -- m;
    len[++m] = x;
  }
  val[m] = 1;
  for (int i = m ; i >= 2 ; -- i) {
    val[i-1] += val[i] * (len[i] / len[i-1]);
    doit(len[i] % len[i-1],val[i]);
  }
  ans[1] += val[1];
  ans[len[1]+1] -= val[1];
  for (int i = 2 ; i <= n ; ++ i)
    ans[i] += ans[i-1];
  for (int i = 1 ; i <= n ; ++ i)
    printf("%lld\n",ans[i]);
  return 0;
}


Measured memory_bytes: 4096
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v < w:
    print('NO')
    exit()
if abs(a-b) <= t*(v-w):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 72948
#include <stdio.h>
int main(void){
  int N,K,X,Y;
  scanf("%d%d%d%d", &N,&K,&X,&Y);
  int sum = 0;
  for(int i = 1;i <= N;i++){
    if(i <= K){
     sum = sum + X;
    }else{
	 sum = sum + Y;
  }
  }printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str = {sc.next(), sc.next(), sc.next()};
		int[] len = new int[3];
		int turn = 0;

		while(true){
			len[turn]++;
			if(len[turn]>str[turn].length()) break;
			turn = str[turn].charAt(len[turn]-1) - 'a';
		}
		String c = ""+ (char)('a'+turn-32);
		System.out.println(c);
	}
}

Measured memory_bytes: 9428
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out
vector<bool> eratosmake(int n,vector<bool> num){
    //整数を列挙して素数の候補とする
    for(int i = 0; i < n; i++) num[i] = true;
    //0と1を消す
    num[0] = num[1] = false;
    //iを残してiの倍数を消していく
    for(int i = 2; i < n; i++){
        if(num[i]){
            for(int j = i + i; j < n; j += i){
                num[j] = false;
            }
        }
    }
    return num;
}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n,q;
    vector<bool> prime(200000,false);
    prime=eratosmake(200000,prime);
    while(1){
        cin>>n>>q;
        if(n==-1&&q==-1)break;
        int co=110,p=n+1;
        vector<int> primelist;
        while(co>0){
            if(prime[p]){
                primelist.push_back(p);
                co--;
            }
            p++;
        }
        // rep(i,primelist.size())cout<<primelist[i]<<" ";
        // cout<<endl;
        vector<int> m;
        for(int i=0;i<primelist.size();i++){
            for(int j=i;j<primelist.size();j++){
                m.push_back(primelist[i]+primelist[j]);
                // if(primelist[i]+primelist[j]==5) cout<<primelist[i]<<" "<<primelist[j]<<endl;
            }
        }
        sort(m.begin(),m.end());

        // rep(i,10)cout<<m[i]<<" ";
        // cout<<endl;

        cout<<m[q-1]<<endl;
    }
//////////////////////////////////////////////////////
return 0;}



Measured memory_bytes: 3200
//
//  main.cpp
//  AOJ-1160
//
//  Created by Kenta Kodera on 2017/06/18.
//  Copyright ?? 2017??´ Kenta Kodera. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
#include <ctype.h> // isdigit
#include <cassert>
using namespace std;

int W, H;

void dfs(vector<vector<int>> &field, int h, int w){
  int dhw[3] = {1, -1, 0};
  field[h][w] = 0;
  
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      int nh = h+dhw[i];
      int nw = w+dhw[j];
      for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
          if(0<=nh && nh<H && 0<=nw && nw<W && field[nh][nw]==1){
            dfs(field, nh, nw);
          }
        }
      }
    }
  }
  
}


int main(){
  
  while(cin >> W >> H, W|H){
    vector<vector<int>> field(H);
    for(int h=0; h<H; h++){
      field[h].resize(W);
    }
    
    for(int h=0; h<H; h++){
      for(int w=0; w<W; w++){
        cin >> field[h][w];
      }
    }
    
    int n=0;
    for(int h=0; h<H; h++){
      for(int w=0; w<W; w++){
        if(field[h][w] == 1){
          dfs(field, h, w);
          n++;
        }
      }
    }
    cout << n << endl;
    
  }
  

  return 0;
}

Measured memory_bytes: 3320
import math
A,B,H,M=map(int,input().split())
M_rad = math.radians(M*6)
H_rad = math.radians(H*30+M*0.5)
rad = M_rad - H_rad
ans = math.sqrt(A**2+B**2-2*A*B*math.cos(rad))
print(ans)

Measured memory_bytes: 9372
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000000
vector< bool > prime( MAX+1, true);
 
void get_prime(int n){
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
   
  for(int i = 2; i * i <= n; i++){
    if(prime[i]){
      for(int j = i + i; j <= n; j += i) prime[j] = false;
    }
  }
}

int main(){
  get_prime(MAX);
  int a,d,n;
  while(cin >> a >> d >> n , a){
    int cnt = 0;
    int idx = 0;
    while(cnt != n){
      if(prime[a+idx*d]) cnt++;
      idx++;
    }
    cout << a+(idx-1)*d << endl;
  }
}

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

int main(){
  int n, y;
  cin >> n >> y;
  int ans10000 = -1, ans5000 = -1, ans1000 = -1;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j + i <= n; j++){
      int k = n - i - j;
      int total = 10000 * i + 5000 * j + 1000 * k;
      if(total == y){
        ans10000 = i;
        ans5000 = j;
        ans1000 = k;
      }
    }
  }
  
  cout << ans10000 << " " << ans5000 << " " << ans1000 << endl;
  return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, m;
	while (true) {
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		vector<int> s1(n), s2(m);
		int ans1 = 0, ans2 = 0;
		int s;
		for (int i = 0; i < n;i++) {
			cin >> s1[i];
			ans1 += s1[i];
		}
		for (int i = 0; i < m;i++) {
			cin >> s2[i];
			ans2 += s2[i];
		}
		
		int dif = abs(ans2 - ans1);

		if (dif % 2 == 1) {
			cout << -1 << endl;
			continue;
		}

		dif /= 2;
		pair<int, int> ans;
		int Min = 1000;
		for (int i = 0; i < n;i++) {
			for (int j = 0; j < m;j++) {
				if (ans1 <= ans2) {
					if (s2[j] - s1[i] == dif) {
						if (s1[i] + s2[j] < Min) {
							ans = { s1[i],s2[j] };
							Min = s1[i] + s2[j];
						}
					}
				}
				else {
					if (s1[i] - s2[j] == dif) {
						if (s1[i] + s2[j] < Min) {
							ans = { s1[i],s2[j] };
							Min = s1[i] + s2[j];
						}
					}
				}
			}
		}
		if (Min == 1000) {
			cout << -1 << endl;
		}
		else {
			cout << ans.first << " " << ans.second << endl;
		}
	}
}

Measured memory_bytes: 3096
//Started 2 mins late

#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	string s;
	cin >> s;
	map<char, int> m;
	for(auto &it:s)
		m[it]++;
	if(m.size() == 2 && m.begin() -> second == 2)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        while (true) {
            int n = input.nextInt();
            if (n == 0) break;
            List<Integer> list = new ArrayList<Integer>();
            int sum = 0;
            for (int i = 0; i < n; i++) {
                int s = input.nextInt();
                list.add(s);
                sum += s;
            }
            double avg = (double)sum / list.size();
            double a = 0;
            for (int s : list) {
                a += Math.pow(s - avg, 2);
            }
            System.out.println(Math.sqrt(a / list.size()));
        }
    }
}

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

int main() {
 
  string S;
  cin >> S;
 
  int a = S.at(0) - '0';
  int b = S.at(1) - '0';
  int c = S.at(2) - '0';
  int d = S.at(3) - '0';
  
if(10 * a + b >= 1 && 10 * a + b <= 12) {
  if(10 * c + d  >= 1 && 10 * c + d <= 12) {
    cout << "AMBIGUOUS" << endl;
    return 0;
  }
  else {
    cout << "MMYY" << endl;
  }
}
  else {
    if(10 * a + b == 0 && 10 * c + d > 12) {
      cout << "NA" << endl;
      return 0;
    }
    else if(10 * c + d == 0 && 10 * a + b> 12) {
      cout << "NA" << endl;
      return 0;
    }
    else if(10 * c + d == 0 && 10 * a + b == 0) {
      cout << "NA" << endl;
      return 0;
    }
     else if(10 * a + b > 12 && 10 * c + d > 12) {
       cout << "NA" << endl;
       return 0;
     }
    else if(10 * c + d >= 1 && 10 * c + d <= 12) {
      cout << "YYMM" << endl;
      return 0;
    }
  }


 }
   
  

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

namespace io {
char buf[1<<21], *p1 = buf, *p2 = buf;
inline char gc() {
    if(p1 != p2) return *p1++;
    p1 = buf;
    p2 = p1 + fread(buf, 1, 1 << 21, stdin);
    return p1 == p2 ? EOF : *p1++;
}
#define G gc

#ifndef ONLINE_JUDGE
#undef G
#define G getchar
#endif

template<class I>
inline void read(I &x) {
    x = 0; I f = 1; char c = G();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = G(); }
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = G(); }
    x *= f;
}
template<class I>
inline void write(I x) {
    if(x == 0) {putchar('0'); return;}
    I tmp = x > 0 ? x : -x;
    if(x < 0) putchar('-');
    int cnt = 0;
    while(tmp > 0) {
        buf[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while(cnt > 0) putchar(buf[--cnt]);
}

#define in(x) read(x)
#define outn(x) write(x), putchar('\n')
#define out(x) write(x), putchar(' ')

} using namespace io;

#define ull unsigned long long
#define ll long long
const int N = 100010;
const ull base = 13131;

int ans[N];
map<ull,int>mp;

int main() { int n;
	scanf("%d", &n);
	ll ans = 0;
	for(int i = 1; i <= n; ++i) {
		char ch[20]; scanf("%s",ch+1);
		int len = strlen(ch + 1); ull h = 0;
		sort(ch+1,ch+len+1);
		for(int j = 1; j <= len; ++j) {
			h = h * base + ch[j];
		}
		ans += mp[h]; 
		mp[h]++;
	}
	outn(ans);
}

Measured memory_bytes: 6528
import sys
sys.setrecursionlimit(100000) 

n = int(input())
high = list(map(int,input().split()))
lists = []

def func(i,t):
    if i == n - 1:
        lists.append(t)
        return
    if high[i] < high[i+1]:
        lists.append(t)
        func(i+1,0)
    else:
        t += 1
        func(i+1,t)

func(0,0)
print(max(lists))


Measured memory_bytes: 121572
#include <iostream>
#include <queue>
#include <cstring>
 
using namespace std;
 
#define MAX 151
#define INF 1e9
 
struct P{
    int x, y, d;
    P(int x, int y, int d){
	this->x = x;
	this->y = y;
	this->d = d;
    }
};
 
int t, sx, sy;
bool impossible[MAX][MAX];
int dist[MAX][MAX];
const int dx[] = {-1,0,0,-1,1,1};
const int dy[] = {-1,-1,1,0,0,1};
 
int bfs(int x, int y){
    bool visited[MAX][MAX];
    memset(visited,false,sizeof(visited));
    fill(dist[0],dist[MAX],INF);
 
    queue<P> que;
    que.push(P(x,y,0));
    dist[x][y] = 0;
 
    while(!que.empty()){
	P p = que.front(); que.pop();
 
	if(impossible[p.x][p.y] || p.d > t || 
	   visited[p.x][p.y]){
	    continue;
	}
	visited[p.x][p.y] = true;
 
	for(int i = 0 ; i < 6 ; i++){
	    int nx = p.x + dx[i];
	    int ny = p.y + dy[i];
       
	    if(impossible[nx][ny] || dist[nx][ny] != INF){
		continue;
	    }
 
	    dist[nx][ny] = dist[p.x][p.y] + 1;
	    que.push(P(nx,ny,dist[nx][ny]));
	}
    }
 
    int res = 0;
    for(int i = 0 ; i < MAX ; i++){
	for(int j = 0 ; j < MAX ; j++){
	    if(dist[i][j] <= t){
		res++;
	    }
	}
    }
    return res;
}
 
int main(){
    int n, x, y;
 
    while(cin >> t >> n , (t | n)){
	memset(impossible,false,sizeof(impossible));
	for(int i = 0 ; i < n ; i++){
	    cin >> x >> y;
	    x += 75, y += 75;
	    impossible[x][y] = true;
	}
	cin >> sx >> sy;
	cout << bfs(sx+75, sy+75) << endl;
    }
    return 0;
}

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

int main() {
  int N; cin >> N;
  int exor = 0;
  for(int i = 0; i < N; i++) {
    int a; cin >> a;
    exor ^= a;
  }
  if(exor==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int loop;
	int	j,k;
	scanf("%d",&loop);
		int inpball[loop][10];
	for(j=0;j<loop;j++){
		for(k=0;k<10;k++){
			scanf("%d",&inpball[j][k]);
		}
	}

	for(j=0;j<loop;j++){
		docheck(inpball[j]);
	}

	return 0;
}


int docheck(int ball[10]){
	int i;
	int flg = 1;
	int maxB = 0;
	int maxA = 0;
	for(i=0;i<10;i++){
		if(maxA < ball[i]){
			maxA = ball[i];
		}else if(maxB < ball[i]){
			maxB = ball[i];
		}else{
			flg = 0;
			break;
		}
	}
	if(flg){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 576
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int n,m,c;cin>>n>>m>>c;
    VEC(int,b,m);
    vector<vector<int>>a(n,vector<int>(m));
    rep(i,n)rep(j,m)cin>>a[i][j];
    int res = 0;
    rep(i,n){
        int r = c;
        rep(j,m){
            r += (a[i][j]*b[j]);
        }
        if(r>0)res++;
    }
    cout<<res;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,W;
  int v,w;
  cin >> n >> W;
  int g[n][W+1];
  for(int i=0;i<n;i++){
    cin >> v >> w;
    for(int j=0;j<W+1;j++){
      if(i==0){
	if(j-w>=0)g[i][j]=v;
	else g[i][j]=0;
      }
      else{
	if(j-w<0)g[i][j]=g[i-1][j];
	else g[i][j]=max(g[i-1][j],g[i-1][j-w]+v);
      }
    }
  }
  cout << g[n-1][W] << endl;
  return 0;
}

Measured memory_bytes: 5064
# 解説

def solve() -> None:
    from collections import namedtuple
    from heapq import heappush, heappop
    from operator import attrgetter
    pt = namedtuple('pt', 'x y idx')

    n = int(input())
    cities = []
    for idx in range(n):
        x, y = map(int, input().split())
        cities.append(pt(x=x, y=y, idx=idx))

    g = tuple(set() for _ in range(n))

    xs = sorted(cities, key=attrgetter('x'))
    for a, b in zip(xs, xs[1:]):
        g[a.idx].add((b.x - a.x, b.idx))
        g[b.idx].add((b.x - a.x, a.idx))

    ys = sorted(cities, key=attrgetter('y'))
    for a, b in zip(ys, ys[1:]):
        g[a.idx].add((b.y - a.y, b.idx))
        g[b.idx].add((b.y - a.y, a.idx))

    ret = 0
    h = [(0, 0)]
    used = [False] * n
    count = 0

    while True:
        c, v = heappop(h)
        if used[v]:
            continue
        used[v] = True
        count += 1
        ret += c
        if count == n:
            break
        for c_, u in g[v]:
            if used[u]:
                continue
            heappush(h, (c_, u))

    return ret


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

# 最小全域木


Measured memory_bytes: 125528