akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ii pair <int,int>
#define pl pair <ll,ll>
#define fr(i,x,y) for (int i=x;i<=y;i++)
#define ft(i,x,y) for (int i=y;i>=x;i--)
#define N 100005
using namespace std ;
int gt[10*N],n,out[10*N],in[10*N],d[10*N];
vector <int> a[10*N] ;
string s ;
ll ans ;
void inp(){
     ios_base::sync_with_stdio(false);
     cin.tie(0);
     //freopen("agc040.inp","r",stdin) ;
     //freopen("agc040.out","w",stdout);
     cin>>s ;
     n=s.size();
     s=" "+s;
}
void DFS(int u){
   d[u]=1;
   for (int v:a[u]){
      if (!d[v]){
          DFS(v);
          gt[u]=max(gt[u],gt[v]);
      }
   }
   if (out[u]!=0){
        gt[u]++ ;
   }
   else
        gt[u]=0;
}
void sub(){
     string k="<";
     string k1=">";
     fr(i,1,n){
         if (s[i]=='<') {
            a[i+1].pb(i) ;
            in[i]++;
            out[i+1]++;
         }
         else{
             a[i].pb(i+1);
             in[i+1]++;
             out[i]++ ;
         }
     }
     fr(i,1,n+1){
        if (in[i]==0){
            DFS(i) ;
        }
     }
     fr(i,1,n+1){
       //cout<<gt[i]<<" ";
       ans+=gt[i];
     }
     cout<<ans;
}
int main(){
    inp() ;
    sub() ;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

constexpr ll siz = 1e6 + 10;
vector<ll> make_primes() {
	vector<bool> can(siz, true);
	can[0] = can[1] = false;

	vector<ll> primes;
	REP(i, siz)if (can[i]) {
		primes.push_back(i);
		ll times = 2;
		while (times*i < siz) {
			can[times*i] = false;
			times++;
		}
	}
	return primes;
}

int main()
{
	//auto primes = make_primes();
	ll N;
	set<ll> st;
	cin >> N;
	FOR(i, 1, sqrt(N) + 10) {
		if (N%i == 0) {
			st.insert(i);
			st.insert(N / i);
		}
	}
	ll res = 0;
	for (auto num : st) {
		if (num-1 > sqrt(N))res += num - 1;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
import math
N, M = map(int,input().split())
N, M = max(N,M), min(N,M)
mod = 10**9 + 7
if N-M != 1 and N != M:
    ans = 0
elif N != M:
    factN = math.factorial(N)
    ans = (factN*factN//N)%mod
else:
    factN = math.factorial(N)
    ans = (factN*factN*2)%mod
print(ans)

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

using namespace std;

int main(){
    int n,sec;
    cin >> n;
    vector<long long int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    sort(a.begin(),a.end());

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

    if(abs(a[n-1]/2 - a[sec-1])<abs(a[n-1]/2 - a[sec])){
        sec--;
    }

    if(n-1 == sec){
        sec--;
    }

    cout << a[n-1] << " " << a[sec] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

ll gcd(ll a,ll b){if(a<b)swap(a,b);return b?gcd(b,a%b):a;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vecint cnt(1000001, 0);
  ll g = 0;
  REP(i,n) {
    ll a;
    cin>>a;
    g = gcd(g, a);
    ++cnt[a];
  }
  if (g != 1) {
    cout<<"not coprime\n";
    return 0;
  }
  FOR(i,2,1000000) {
    int num = 0;
    for(int j=i; j <= 1000000; j += i) {
      num += cnt[j];
    }
    if (num > 1) {
      cout<<"setwise coprime\n";
      return 0;
    }
  }
  cout<<"pairwise coprime\n";
  return 0;
}


Measured memory_bytes: 7116
n, m = map(int, input().split())
LR = [list(map(int, input().split())) for i in range(m)]
max = n
min = 1

for i in range(m):
  if min < LR[i][0]:
    min = LR[i][0]
  if max > LR[i][1]:
    max = LR[i][1]

ans = max - min + 1

if ans > 0:
  print(ans)
else:
  print(0)

Measured memory_bytes: 27240
module Main (main) where


main :: IO ()
main = do
    strs <- words <$> getLine
    let a = strs !! 0
    let b = strs !! 1
    let c = strs !! 2
    if last a == head b && last b == head c
        then putStrLn "YES"
        else putStrLn "NO"


Measured memory_bytes: 380
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define PI 3.141592653589793
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
#define pii pair < int , int >
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;

ld A, B;
ll H, M;

int main()
{
    optimiza_io
    cin >> A >> B >> H >> M;
    H %= 12;
    M %= 60;
    ld hd = 360.0 - H * 30 - ( 30.0 ) * ( (ld)M / 60.0 );
    ld md = 360.0 - M * 6;
    ld ang = ( md - hd );
    while( ang < 0 )
        ang += 360;
    while( ang >= 360.0 )
        ang -= 360;
    if( ang >= 180 )
        ang = 360 - ang;
    ang = ang * PI / 180; 
    ld ans = A * A + B * B - 2 * A * B * cos(ang);
    cout << fixed << setprecision( 20 ) << sqrt( ans ) << "\n";
    return 0;
}

// CHECAR LIMITES 

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

using namespace std;

int main() {
  int n; cin >> n;
  string s; cin >> s;
  int ans = 0;
  int i = 0;
  while (i < n) {
    char c = s[i];
    while (i < n && s[i] == c) i++;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
// SeeAlso: 

#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 pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < 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 debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
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 long long INF = 1LL<<60;

int main() {
    ll n, m, k; cin >> n >> m >> k;
    ll a[n+1],b[m+1];
    a[0] = 0;
    b[0] = 0; 
    ll b_limit = m;
    FOR(i,1, n+1) {
        cin >> a[i];
        a[i] = a[i] + a[i-1];
    }
    FOR(i,1, m+1) {
        cin >> b[i];
        b[i] = b[i] + b[i-1];
    }

    ll ans = 0;
    rep(i, n+1) {
        while(k<(a[i]+b[b_limit]) && b_limit>0) {
            b_limit--;
        }
        if (a[i]+b[b_limit]<=k) ans = max(ans, i+b_limit);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 6720
#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
void A()
{
    // 入力
    string N;
    cin >> N;
    
    // 出力
    if( N.find("7") != string::npos )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
 
void B()
{
    // 入力
    int N;
    cin >> N;
    
    long long int ans = 0;
    
    // "Fizz", "Buzz", "FizzBuzz"のいずれでもない場合を合算する
    for( int i = 1; i < N+1; ++i )
        if( (i % 3 != 0) && (i % 5 != 0) )
            ans += i;
    
    // 出力
    cout << ans << endl;
}
 
long long int gcd(long long int a, long long int b)
{
    long long int ret;
     
    if( a < b ){
        long long int tmp = a;
        a = b;
        b = tmp;
    }
     
    if( b == 0 ) return a;
     
    ret = a % b;
    ret = gcd(b, ret);
     
    return ret;
}
 
void C()
{
    // 入力
    int K;
    cin >> K;
    
    int ans = 0;
    
    // 2重GCDで解ける
    for( int a = 1; a < K+1; ++a )
        for( int b = 1; b < K+1; ++b )
            for( int c = 1; c < K+1; ++c )
                ans += gcd(gcd(a, b), c);
    
    // 出力
    cout << ans << endl;
}
 
void D()
{
    // 入力
    int N;
    string S;
    cin >> N >> S;
    
    // SをR, G, Bに分割する
    unsigned long long int R = 0, G = 0, B = 0;
    for( int i = 0; i < N; ++i )
        switch( S[i] ){
            case 'R': ++R; break;
            case 'G': ++G; break;
            case 'B': ++B; break;
        }
    
    // {R, G, B}の組合せの数
    // 必ずR, G, Bそれぞれひとつずつの組合せになるが、i < j < k順に並びかえればいいので、それぞれの個数をかけた値になる
    unsigned long long int ans = R * G * B;
    
    // (j − i) == (k − j)の組合せの数を引く
    // i, jが決まればkを求められる
    for( int i = 1; i < N+1; ++i )
        for( int j = i+1; j < N+1; ++j ){
            int k = 2*j - i;
            if( k < j || N < k ) continue;
            if( S[i-1] != S[j-1] && S[j-1] != S[k-1] && S[k-1] != S[i-1] )
                --ans;
        }
    
    // 出力
    cout << ans << endl;   
}
 
int main()
{
    //A();
    //B();
    //C();
    D();
    
    return 0;
}


Measured memory_bytes: 3628
import Foundation

var bingo_card: [String] = []
var numbers: [String] = []
var bingo_status: [Bool] = []

for i in 0...2 {
  let input_line = readLine()!
  let split: [String] = input_line.componentsSeparatedByString(" ")
  for j in 0...2 {
    bingo_card.append(split[j])
  }
}

let numOfNumbers = Int(readLine()!)!

for i in 0...numOfNumbers-1 {
  numbers.append(readLine()!)
}

for i in 0...bingo_card.count-1 {
  var status = false
  for j in 0...numbers.count-1 {
    if numbers[j] == bingo_card[i] {
      status = true
    }
  }
  
  bingo_status.append(status)
}

if bingo_status[0] && bingo_status[1] && bingo_status[2] {
  print("Yes")
} else if bingo_status[3] && bingo_status[4] && bingo_status[5] {
  print("Yes")
} else if bingo_status[6] && bingo_status[7] && bingo_status[8] {
  print("Yes")
} else if bingo_status[0] && bingo_status[3] && bingo_status[6] {
  print("Yes")
} else if bingo_status[1] && bingo_status[4] && bingo_status[7] {
  print("Yes")
} else if bingo_status[2] && bingo_status[5] && bingo_status[8] {
  print("Yes")
} else if bingo_status[0] && bingo_status[4] && bingo_status[8] {
  print("Yes")
} else if bingo_status[2] && bingo_status[4] && bingo_status[6] {
  print("Yes")
} else {
  print("No")
}

Measured memory_bytes: 7400
#include<bits/stdc++.h>
#include<vector>
#include<iterator>
#define rep(i,n) for(long i = 0;i < (n) ;i++)

using namespace std;

int main(){
  long long N;
  cin >>N;
  vector<long long> v{istream_iterator<int>(cin),istream_iterator<int>()};
  
  int count = 0;
  int comp = v[0];
  rep(i,N){
    if(v[i] <= comp){
      comp = v[i];
      ++count;
    }
  }
  cout << count <<endl;
  return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

const int M_MAX = 100000;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> l(m);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    l[m-a].push_back(b);
  }
  
  long long ans = 0;
  priority_queue<int> pq;
  for (int i = m-1; i >= 0; --i) {
    for(int x : l[i]) {
      pq.push(x);
    }
    if (!pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 5504
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    string s, t; cin >> s >> t;

    vector<vector<int>> place(26);
    rep(i, s.size()){
        place[s[i] - 'a'].push_back(i);
    }

    ll index = -1, lap = 0;
    bool ok = true;
    rep(i, t.size()){
        vector<int>& p = place[t[i] - 'a'];
        if(p.size() == 0){ ok = false; break; }

        int num = upper_bound(all(p), index) - p.begin();
        if(num == p.size()){
            index = -1; lap++;
            num = upper_bound(all(p), index) - p.begin();
        }
        index = p[num];
    }
    ll res;
    ok ? res = s.size() * lap + index + 1 : res = -1;
    cout << res << ln;
}




Measured memory_bytes: 1228
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a<b:
    if b+w*t<=a+v*t:
        print("YES")
    else:
        print("NO")
else:
    if b-w*t>=a-v*t:
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 9180
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

m = 10**9 + 7
s = int(input())
if s <= 2:
    print(0)
else:
    dp = [0 for _ in xrange(s+1)]
    for i in xrange(3,s+1):
        dp[i] = 1
        for j in xrange(3,i+1):
            dp[i] += dp[i-j]
            if dp[i] >= m:
                dp[i] = dp[i] % m 
    print(dp[s] %m)


Measured memory_bytes: 85800
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    string str;
    ll n;
    cin>>str;
    ll num=0; n=str.length();
    for(ll i=0; i<n/2; i++)
    	if(str[i]!=str[n-1-i])
    		num++;
    cout<<num<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3832
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int a,b,n,x;
    cin>>a>>b>>n;
    if(n>=(b-1))
    {
       x=b-1;
    }
    else
    {
       x=n;
    }
    int ses=((a*x)/b)-(a*(x/b));
    cout<<ses<<endl;
    return 0;

}













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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

typedef std::pair<int, int> P;

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

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main() {
    int N, K;
    cin >> N >> K;
    int ch = N % K;
    cout << min(abs(ch - K), ch) << endl;
}


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

signed main(){
	int N, P, Q, i;
	scanf("%lld%lld%lld", &N, &P, &Q);
	vector<int> C(N);
	int cons = 0, sum = 0;
	for(i = 0; i < N; i++){
		scanf("%lld", &C[i]);
		C[i] += i * P;
		cons += i * P;
		sum += C[i];
	}
	int ans = sum;
	sort(C.begin(), C.end());
	for(i = 0; i < N; i++){
		sum -= C[i];
		ans = max(ans, sum + (i + 1) * (Q + i) * P);
	}
	printf("%lld\n", ans - cons);
	return 0;
}


Measured memory_bytes: 6796
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}


void solve() {
    ll n;
    cin >> n;
    ll a[n],b[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a,a+n);
    for(int i = 0;i < n;i++){
        if(b[i] == a[n-1]){
            cout << a[n-2] << endl;
        }else{
            cout << a[n-1] << endl;
        }
    }
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;
    vec A(N); REP(i,N) cin>>A[i];
    Sort(A); Reverse(A);
    int count = 0;
    vec CON;
    REP(i,N){
        if(A[i]==A[i+1]){
            CON.push_back(A[i]);
            i ++;
            count ++;
        }
        if(count==2){
            Out(CON[0]*CON[1]);
            return(0);
        }
    }
    Out(0);
    return(0);
}


Measured memory_bytes: 1024
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            int count=0;

            for (int i = a; i <= b ; i++)
            {
                if (c % i == 0) count++;
            }
            Console.WriteLine(count);
        }
    }
}

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

using namespace std;

int main() {
  long long n;
  cin >> n;
  if (n % 2 == 1) {
    cout << "0\n";
  } else {
    long long res = 0;
    long long tmp = 10;
    while (tmp <= n) {
      res += n / tmp;
      tmp *= 5;
    }
    cout << res  << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
import math
from collections import deque

class UnionFind():
  def __init__(self, n):
    self.seg_tree = [-1 for i in range(n)]
  
  def root(self, i):
    if self.seg_tree[i] < 0:
      return i
    else:
      self.seg_tree[i] = self.root(self.seg_tree[i])
      return self.seg_tree[i]

  def size(self, i):
    return -self.seg_tree[self.root(i)]

  def unite(self, i, j):
    if self.same(i, j):
      return

    if self.size(i) == self.size(j):
      self.seg_tree[self.root(i)] -= self.size(j)
      self.seg_tree[self.root(j)] = self.root(i)
    elif self.size(i) > self.size(j):
      self.seg_tree[self.root(i)] -= self.size(j)
      self.seg_tree[self.root(j)] = self.root(i)
    else:
      self.seg_tree[self.root(j)] -= self.size(i)
      self.seg_tree[self.root(i)] = self.root(j)

  def same(self, i, j):
    return self.root(i) == self.root(j)

def nC2(n):
  return math.factorial(n) / math.factorial(2) / math.factorial(n - 2)

N, M = map(int, raw_input().split())
A = []
B = []
rev_res = []
uf = UnionFind(N)
for _ in range(M):
  a, b = map(long, raw_input().split())
  A.append(a - 1)
  B.append(b - 1)

ans = N * (N - 1) / 2
for a, b in reversed(zip(A, B)):
  rev_res.append(ans)
  if not uf.same(a, b):
    ans -= uf.size(a) * uf.size(b)
  uf.unite(a, b)

for r in reversed(rev_res):
  print r

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

bool f(int n, bool* array){
    for(; n > 0; n /= 10){
        if(array[n%10])
            return 1;
    }
    return 0;
}

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

    int n, k; cin >> n >> k;
    bool array[10] = {0};
    for(; k; k--){
        int x; cin >> x;
        array[x] = 1;
    }

    for(; f(n, array); n++);
    cout << n;
}


Measured memory_bytes: 256
def main():
	x, n = map(int, input().split())
	P = list(map(int, input().split()))
	if n == 0:
		print(x)
		return
	ans = 0
	min_dis = 1000
	for item in range(102):
		if item in P:
			continue
		dis = abs(item - x)
		if min_dis > dis:
			min_dis = dis
			ans = item
	print(ans)
	return

if __name__ == "__main__":
	main()

Measured memory_bytes: 9140
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String S;
        String[] T ={"SUN","MON","TUE","WED","THU","FRI","SAT"};
        S = sc.next();
        for(int i=0;i<7;i++)if(S.equals(T[i]))System.out.println(7-i);
    }
}


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

int main(void)
{
    long long n, m;

    while (scanf("%lld %lld", &n, &m), n){
        long long p[1024];

        for (int i = 0; i < n; i++) scanf("%lld", p + i);
        p[n++] = 0;

        vector<long long> score;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                if (!binary_search(score.begin(), score.end(), p[i] + p[j])) score.push_back(p[i] + p[j]);
            }
        }
        sort(score.begin(), score.end());
        score.erase(unique(score.begin(), score.end()), score.end());

        long long maxi = 0;
        for (auto i : score){
            if (i > m) continue;
            maxi = max(maxi, min(*(upper_bound(score.begin(), score.end(), m - i) - 1) + i, m));
        }

        printf("%lld\n", maxi);
    }

    return 0;
}

Measured memory_bytes: 17140
#include<bits/stdc++.h>
using namespace std;
int d[100000];
vector<int> v[100005];
bool used[100005];
int n,m,ans;
void dfs(int n)
{
	if(used[n])
	return;
	used[n]=true; 
	for(int i=0;i<v[n].size();i++)
	{
		dfs(v[n][i]);
	}
} 
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		d[a]++;
		d[b]++;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=1;i<=n;i++)
	{
		if(d[i]!=0 && !used[i])
		{
		  dfs(i),ans++;
	    }
		if(d[i]==0)
		  ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int dist_to_a(char c) {
  if (c == 'a')
    return 0;
  else
    return 26 - (c - 'a');
}

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

  string ans;
  rep(i, sz(s)) {
    if (K >= dist_to_a(s[i])) {
      K -= dist_to_a(s[i]);
      ans.pb('a');
    } else
      ans.pb(s[i]);
  }

  if (K > 0) {
    ans[sz(ans) - 1] += (K % 26);
    if (ans[sz(ans) - 1] > 'z')
      ans[sz(ans) - 1] ^= 26;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int n,taxi,train;
    cin>>n>>train>>taxi;
    cout<<min(n*train,taxi)<<endl;


}










































Measured memory_bytes: 3560
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,t = inpl()
a = inpl()
res = 0
for i in range(n-1):
    res += min(t, a[i+1] - a[i])
print(res + t)

Measured memory_bytes: 103244
#include <stdio.h>
 
int main(void) {
	int a,b,c,nr;
	scanf("%d %d %d",&a,&b,&c);
	if(a==c||c==a)
	{
		if(a==b||b==a)
		{
			nr=1;
		}
		else
		{
			nr=2;
		}
	}
	else if(a==b||b==a)
	{
		if(a==c||c==a)
		{
			nr=1;
		}
		else
		{
			nr=2;
		}
	}
	else if(b==c||c==b)
	{
		if(a==b||b==a)
		{
			nr=1;
		}
		else
		{
			nr=2;
		}
	}
	else
	{
		nr=3;
	}
	printf("%d\n",nr);
	return 0;
}

Measured memory_bytes: 128
import sys
import copy
from collections import deque
import collections
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m, k = na()

a = na()
b = na()

num_books = 0
sum_time = 0
for i in a:
    if sum_time+i > k:
        break
    num_books += 1
    sum_time += i
# print(num_books)


res = num_books
ia = num_books - 1
ib = 0
if num_books==0 and b[ib] > k:
    print(0)
    exit(0)
while ib < len(b):
    if sum_time < k:
        sum_time += b[ib]
        ib += 1
        num_books += 1
    else:
        if ia == -1:
            break
        sum_time -= a[ia]
        ia -= 1
        num_books -= 1
    if sum_time <= k:
        res = max(res, num_books)

print(res)


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

using ll=long long; 


void solve(){
	int n,m;
	cin>>n>>m;
	vector<string> fld1(n), fld2(m);
	for(auto& e:fld1)cin>>e;
	for(auto& e:fld2)cin>>e;
	for(int i=0; i<n-m+1; i++){
		for(int j=0; j<n-m+1; j++){
			//cout<<i<<" "<<j<<endl;
			bool flag=false;
			for(int ii=0; ii<m; ii++){
				for(int jj=0; jj<m; jj++){
					//cout<<i+ii<<" "<<j+jj<<endl;
					if(fld1[i+ii][j+jj]!=fld2[ii][jj]){
						flag=true;
						break;
					}
				}
			}
			if(!flag){
				cout<<"Yes"<<endl;
				return;
			}
		}
	}
	cout<<"No"<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;

int main(){
	
	char s[1002];
	gets(s);
	
	for(int i=0;s[i]!='\0';i++){
		if(s[i]=='a'&&s[i+1]=='p'&&s[i+2]=='p'&&s[i+3]=='l'&&s[i+4]=='e'){
			s[i]='p';
			s[i+1]='e';
			s[i+2]='a';
			s[i+3]='c';
			s[i+4]='h';
			i=i+4;
		}
		else if(s[i]=='p'&&s[i+1]=='e'&&s[i+2]=='a'&&s[i+3]=='c'&&s[i+4]=='h'){
			s[i]='a';
			s[i+1]='p';
			s[i+2]='p';
			s[i+3]='l';
			s[i+4]='e';
			i=i+4;
		}
	}
	puts(s);
	
}

Measured memory_bytes: 1088
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long double r;
	cin >> r;
	cout << fixed << setprecision(20) << 2 * PI * r << "\n";
	return 0;
}


Measured memory_bytes: 3784
/*
	Swamy Saranam

	Date	: 13/09/2016 14:57:03
	Author	: Krishna Mohan A M
	Problem	: E - Sequential operations on Sequence
	Status	:
*/
#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

typedef long long ll;
typedef pair<int,int>	pii;
typedef pair<ld,ld>	pdd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef pair<ll,ll> pl;

#define FASTIO          ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,a,b)		for(int i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)			memset(a,b,sizeof a)
#define pb				push_back
#define x               first
#define y               second
#define endl            "\n"
#define sendl           " \n"
#define all(x)          (x).begin(), (x).end()

const int mod = 1000000007;
ll a[100005];

int main()
{
    FASTIO
    int n, q;
    cin>>n>>q;
    vector<ll> stk;
    stk.pb(n);
    REP(i, q)
    {
      ll tmp;
      cin>>tmp;
      while(!stk.empty() && stk.back() > tmp)
        stk.pop_back();
      stk.pb(tmp);
    }
    int k = stk.size();
    vector<ll> t(k);
    t[k-1] = 1;
    for(int i=k-1; i>=0; i--)
    {
      if(!i){
        a[stk[i]] += t[i];
        break;
      }
      ll p = t[i];
      ll z = stk[i];
      stk[i] = 2e18; //setting it as max value
      while(z > stk[0]){
        int j = lower_bound(all(stk), z) - stk.begin()-1;
        t[j] += p*(z/stk[j]);
        z%=stk[j];
      }
      a[z] += p;
    }
    for(int i=n-1; i>=0; i--)
        a[i] += a[i+1];
    FOR(i, 1, n+1)
      cout<<a[i]<<endl;
    #ifdef LOCAL_DEFINE
      cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}


Measured memory_bytes: 4212
s = str(input())
t = str(input())

dp = [[-1]*3100 for _ in range(3100)]
# dp[i+1][j+1]: s[i], t[j]まで見たときのLCSの長さ

dp[0][0] = 0
for i in range(len(s)):
  for j in range(len(t)):
    if s[i] == t[j]:
      dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
    dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])
    
i = len(s)
j = len(t)
ans = ''
while i>0 and j>0:
  if dp[i][j] == dp[i-1][j]:
    i -= 1
  elif dp[i][j] == dp[i][j-1]:
    j -= 1
  else:
    ans = s[i-1] + ans
    i -= 1
    j -= 1
print(ans)

Measured memory_bytes: 119132
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#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 Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int n;
  cin>>n;
  vector<pair<int,int>>  range(n);
  rep(i,n){
    int x,l;
    cin>>x>>l;
    range.at(i).second = x-l;
    range.at(i).first = x+l;
  }
  sort(all(range));
  int ans=0;
  int inf,sup;
  rep(i,n){
    if(i==0){
      ans++;
      inf=range.at(i).second;
      sup=range.at(i).first;
    }
    else{
      if(range.at(i).second < sup) continue;
      ans++;
      inf=range.at(i).second;
      sup=range.at(i).first;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n,k,ans=0;
    cin >>n >>k;
    vector<int> l(n);
    for (int i=0;i<n;i++){
        cin >> l[i] ;
    }
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    for(int i=0;i<k;i++){
        ans += l[i];
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    int ans[4]={0};
    ans[A]=1;
    ans[B]=1;
    for(int i=1;i<=3;i++){
        if(ans[i]==0)cout<<i<<endl;
    }

    return 0;
}


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

int S,mod = 1e9 + 7,memo[2020],dp[2020];

long long f(int S){
	if(S == 0) return 1;
	if(memo[S] != -1) return memo[S];
	for(int i = 3;i <= S;i++){
		dp[S] += f(S - i);
		dp[S] %= mod;
	}
	return memo[S] = dp[S];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>S;
	memset(memo, -1, sizeof(memo));
	cout<<f(S)<<endl;
}


Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, h[110];

    cin >> n;
    REP(i, n)
    cin >> h[i];

    int res = 0;

    while (true)
    {
        int i = 0;
        while (i < n && h[i] == 0)
            i++;

        if (i >= n)
            break;

        while (i < n && h[i] > 0)
            h[i]--, i++;

        res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define m 1000000007
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>> a(n,vector<int>(n));
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    vector<int> dp(1<<n);
    dp[0] = 1;
    for(int mask = 0;mask<(1<<n)-1;mask++){
        int i = __builtin_popcount(mask);
        for(int j=0;j<n;j++){
            if(a[i][j]&&!(mask&(1<<j))){
                int temp = mask^(1<<j);
                dp[temp]+=dp[mask];
                dp[temp]%=m;
            }
        }
    }
    cout<<dp[(1<<n)-1]<<"\n";
    return 0;
}

Measured memory_bytes: 8448
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
using namespace std;
int n,m;
char s[101][101];
bool tf[101][101],k;
int main(){
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf(" %c",&s[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		k=true;
		for(int j=1;j<=m;j++) if(s[i][j]!='.') k=false;
		if(k){
			for(int j=1;j<=m;j++) tf[i][j]=true;
		}
	}
	for(int i=1;i<=m;i++){
		k=true;
		for(int j=1;j<=n;j++) if(s[j][i]!='.') k=false;
		if(k){
			for(int j=1;j<=n;j++) tf[j][i]=true;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) if(!tf[i][j]) printf("%c",s[i][j]);
		k=true;
		for(int j=1;j<=m;j++) if(!tf[i][j]) k=false;
		if(!k) printf("\n");
	}
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		sc.close();
		int n = Integer.parseInt(a + b);
		int root = (int) Math.sqrt(n);
		if (root * root == n) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}

}


Measured memory_bytes: 21716
#include <stdio.h>
#define N 105
#define BLACK -2
#define WHITE 1
#define INF 100000
#define NIL -5

typedef struct {
  int color, d, pi;  
}Record;


void prim(int);



int adj[N][N];
int n;
Record data[N];



int main () {
  int m, i, j, sum =0;

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++) {
    for(j = 1 ; j <= n ; j++) {
      scanf("%d",&m);
      
      adj[i][j] = m;

      //Insert(m, i);
    }
  }
  

  prim(1);

  for(i = 1 ; i<= n ; i++) {
    //printf("i = %d, data[i] = %d\n", i, data[i].d);
    sum += data[i].d;
  }
  printf("%d\n",sum);

  return 0;
}



void prim(int r) {
  int i, u, mincost = 0;

  for(i = 1 ; i <= n ; i++) {
    data[i].color = WHITE;
    data[i].d = INF;
    data[i].pi = NIL;

  }

  data[r].d = 0;
  

  while(1) {
    mincost = INF;

    for(i = 1 ; i <= n ; i++) {
      if(data[i].color != BLACK) {
	if(data[i].d < mincost) {
	  mincost = data[i].d;
	  u = i;
	  //printf("from %d to %d connected (cost %d)\n", u, i, data[i].d);
	}
      }
    }

    if(mincost == INF) break;

    data[u].color = BLACK;

    for(i = 1 ; i <= n ; i++) {
      if(data[i].color != BLACK && adj[u][i] < data[i].d && adj[u][i] != -1) {
	data[i].pi = u;
	data[i].d = adj[u][i];
	
      }
    }
  }
}












Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

bool che(vector<ll> ar, int k, ll n, ll m, ll v, ll p){
    if (k <= p-1) return true;
    if (ar[k]+m <ar[p-1]) return false;
    ll hyo = 0;
    hyo += (p-1) * m + (n - k) * m;
    reppl(i,k,p-1){
        hyo += min(ar[k]+m-ar[i],m);
    }
    if (hyo < m * v) return false;
    else return true;
}

int main() {
    ll n, m, v, p; cin >> n >> m >> v >> p;
    vector<ll> ar(n);
    repl(i,n) cin >> ar[i];
    sort(ar.rbegin(),ar.rend());
    //printvec(ar);
    int le = 0;
    int ri = n;
    int mid = (le + ri) / 2;
    while (ri - le > 1){
        if (che(ar,mid,n,m,v,p)){
            //cout << mid << " yes" << endl;
            le = mid;
        }
        else {
            //cout << mid << " no" << endl;
            ri = mid;
        }
        mid =(le + ri) / 2;
    }
    cout << le+1 << endl;
}

Measured memory_bytes: 1792
def solve():
    c = [[int(i) for i in input().split()] for _ in range(3)]
    if not (c[0][0]-c[1][0] == c[0][1]-c[1][1] == c[0][2]-c[1][2]):
        return 'No'
    elif not (c[1][0]-c[2][0] == c[1][1]-c[2][1] == c[1][2]-c[2][2]):
        return 'No'
    elif not (c[0][0]-c[0][1] == c[1][0]-c[1][1] == c[2][0]-c[2][1]):
        return 'No'
    elif not (c[0][1]-c[0][2] == c[1][1]-c[1][2] == c[2][1]-c[2][2]):
        return 'No'
    else:
        return 'Yes'

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

Measured memory_bytes: 3064
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
d = dd(int)
a = []
for i in range(N):
  t = input()[: -1]
  x, y = "", ""
  z = 0
  if "." in t:
    x, y = t.split(".")
    y = y.ljust(9, "0")
    z = int(x) * 10 ** 9 + int(y)
  else: z = int(t) * 10 ** 9
  zz = 1
  while z % 2 == 0:
    z //= 2
    zz *= 2
  while z % 5 == 0:
    z //= 5
    zz *= 5
  d[zz] += 1
  a.append(zz)
ks = sorted(d.keys())
table = dd(int)
for k in ks:
  for kk in ks:
    z = k * kk
    c = 0
    while z % 10 == 0:
      z //= 10
      c += 1
    table[k * kk] = c >= 18
res = 0
for x in ks:
  cc = N
  for k in ks:
    z = x * k
    if table[z]:
      cc -= x == k
      continue
    cc -= d[k]
  res += cc * d[x]
print(res // 2)

Measured memory_bytes: 84796