akhauriyash/Code-Regression huggingface dataset:
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<double>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<vector<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

ll h, w;
VecS s;
VecVec dist;

void init(){
	rep(i, h) fill(all(dist[i]), LINF);
}

void wfs(ll x, ll y){
	queue<P> que;
	que.push({x*w+y, 0});
	while(!que.empty()){
		P p = que.front(); que.pop();
		ll x1 = p.fs/w, y1 = p.fs%w;
		if(dist[x1][y1] != LINF) continue;
		dist[x1][y1] = p.sc;
		if(x1-1 >= 0 && s[x1-1][y1] == '.' && dist[x1-1][y1] == LINF) que.push({(x1-1)*w+y1, p.sc+1});
		if(y1-1 >= 0 && s[x1][y1-1] == '.' && dist[x1][y1-1] == LINF) que.push({x1*w+y1-1, p.sc+1});
		if(x1+1 < h && s[x1+1][y1] == '.' && dist[x1+1][y1] == LINF) que.push({(x1+1)*w+y1, p.sc+1});
		if(y1+1 < w && s[x1][y1+1] == '.' && dist[x1][y1+1] == LINF) que.push({x1*w+y1+1, p.sc+1});
	}
}

ll maxDist(){
	ll res = 0;
	rep(i, h){
		rep(j, w) if(dist[i][j] != LINF) chmax(res, dist[i][j]);
	}
	return res;
}

int main(void){
	cin >> h >> w;
	s.resize(h);
	rep(i, h) cin >> s[i];
	dist.resize(h);
	rep(i, h) dist[i].resize(w);

	ll ans = 0;
	rep(i, h){
		rep(j, w) if(s[i][j] == '.'){
			init();
			wfs(i, j);
			chmax(ans, maxDist());
		}
	}
	co(ans);

	return 0;
}


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

int main() {
    string o, e, s = "";
	cin >> o >> e;
  	int s_long = o.length() + e.length();
  	for(int i = 1; i <= s_long; i++){
    	if(i % 2 == 1){
        	s += o[i/2];
        }else{
        	s += e[(i/2)-1];
        }
    }
  	cout << s << endl;
    return 0;
}

Measured memory_bytes: 384
import sys

def main():
    X = int(input())

    for a in range(-1000, 1000):
        for b in range(-1000, 1000):

            if X == a**5 - b**5:
                break

        else:
            continue
        break

    print(a, b)
    return

if __name__ == '__main__':
    main()
    sys.exit(0)

Measured memory_bytes: 64680
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
#define ll long long
#define trace(x) cerr << #x << " = " << x << endl
using namespace std;

/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
int main()
{
   /*
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("ouput.txt","w",stdout);
    #endif 
   */

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1; 
    while(t--){
         string s;
	 cin>>s;
	 int count = 0;
	 int ans = 0;
	 for(int i =0; i <(int)s.size(); i++){
		 if(s[i] == 'R'){
			 count++;
		 }
		 else{
			count = 0;
                        
		 }
                 ans = max(ans, count);
	}
	cout<<ans<<endl;
    }
    return 0;
} 


Measured memory_bytes: 3652
a, b, c, x, y = map(int,input().split())

min_xy = min(x, y) 
max_xy = max(x, y)

min_xy_cost = min(a + b, c * 2) * min_xy

if x >= y:
  rest = x - y
  rest_cost = rest * min(a, c * 2)
else:
  rest = y - x
  rest_cost = rest * min(b, c * 2)
  
total = min_xy_cost + rest_cost

print(total)

Measured memory_bytes: 9192
import java.io.FileNotFoundException;
import java.util.Scanner;

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

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int K = sc.nextInt();
    	if(K%2==0||K%5==0) {
    		System.out.println(-1);
    	} else {
//    		BigInteger a = BigInteger.valueOf(K);
//    		BigInteger b = BigInteger.valueOf(K);
//    		boolean flg = true;
//    		String S = "";
//    		while(flg==true) {
//    			a =a.add(b);
//    			S = a.toString();
//    			if(S.matches("7*")) {
//    				flg = false;
//    			}
//    		}
    		int a = 0;
    		boolean flg = true;
    		int count = 0;
    		while(flg) {
    			a = (a*10+7)%K;
    			count++;
    			if(a==0) {
    				flg=false;
    			}

    		}

    		System.out.println(count);
    	}
    }

}


Measured memory_bytes: 35680
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ls = [0] * n
    cnt = 0
    ans = []
    for i in range(n-1, -1, -1):
        t = 0
        for j in range(i, n, (i + 1)):
            t += ls[j]
        if t % 2 != a[i]:
            ls[i] += 1
            cnt += 1
            ans.append(i + 1)
    print(cnt)
    if cnt != 0:
        print(*ans)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 66268
S=input()
dp=[[0]*13 for i in range(len(S)+1)]
#dp[i][k] iばんめまでであまりがｋ
dp[0][0]=1
MOD=10**9+7
L=[]
for i in range(13):
    L.append((i*10)%13)
N=len(S)
for i in range(N):
    if S[i]!="?":
        j=ord(S[i])-ord('0')
        for k in range(13):
            dp[i+1][(L[k]+j)%13]+=dp[i][k]
            dp[i+1][(L[k]+j)%13]%=MOD
    else:
        for j in range(10):
            for k in range(13):
                dp[i+1][(L[k]+j)%13]+=dp[i][k]
                dp[i+1][(L[k]+j)%13]%=MOD
print(dp[N][5])


Measured memory_bytes: 61788
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define int __int64_t
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
  bool minus1 = false;
  long long result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus1 = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus1)
    return -result;
  else
    return result;
}

multiset<int> s1;
multiset<int> s2;
multiset<int> s3;

int min_R_1;
int min_R_2;


pair<int, int> a[MAXN];
int n;

int alp_salganda_newe(pair<int,int> x) {
	s1.erase(s1.find(x.S));
    auto nxt = s1.end();
    int res = 0;
	if (nxt != s1.begin()) {
        nxt--;
        res = max(1ll * min(1ll * x.S, 1ll * (*nxt)) - x.F + 1, 0ll) +
                      max(1ll * min((s1.size() > 0 ? *s1.begin() : (int)MOD), min_R_2) - a[n].F + 1, 0ll);
	}
	s1.insert(x.S);
	return res;
}


 main() {
  n = readInt();
  for (int i = 1; i <= n; i++) {
    a[i] = {readInt(), readInt()};
  }
  sort(a + 1, a + 1 + n);
  
  for (int i = 1; i <= n; i++) {
    s2.insert(a[i].S);
  	s3.insert(a[i].F);
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
  	s2.erase(s2.find(a[i].S));
	s3.erase(s3.find(a[i].F));
	ans = max(ans, 1ll * a[i].S - a[i].F + 1 + max(0ll, 1ll * (*s2.begin()) - *s3.rbegin() + 1));	    	
	s2.insert(a[i].S);
  	s3.insert(a[i].F);
  }
  for (int i = 1; i < n; i++) {
    /// min(R) - max(L) + 1
    s2.erase(s2.find(a[i].S));
    s1.insert(a[i].S);
    
    min_R_1 = *s1.begin();
    min_R_2 = *s2.begin();
    
    ans = max(ans, max(1ll * min_R_1 - a[i].F + 1, 0ll) +
                       max(1ll * min_R_2 - a[n].F + 1, 0ll));
  	
  	ans = max(ans, 1ll * alp_salganda_newe(a[i]));
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    while(true){
        int h,w;
        cin >> h >> w;
        if(h==0 && w==0){
            break;
        }
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}




Measured memory_bytes: 3096
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

long long add_modp(long long a, long long b, long long p){
    // a+b mod p
    return (a % p + b % p) % p;
}

long long modp(long long a, long long p) {
    long long res = a % p;
    if (res < 0) res += p;
    return res;
}

long long dif_modp(long long a, long long b, long long p){
    // a-b mod p
    return modp(a % p - b % p, p);
}

long long mul_modp(long long a, long long b, long long p){
    // a*b mod p
    return ((a % p) * (b % p)) % p;
}

long long modinv(long long a, long long p){
    // a^{-1} = 1/a mod p (拡張Euclidの互除法)
    long long b = p, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= p;
    if (u < 0) u += p;
    return u;
}

long long div_modp(long long a, long long b, long long p){
    // a/b mod p
    return mul_modp(a, modinv(b, p), p);
}

int main(void){
    ll N,K; cin >> N >> K;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    SORT(A);

    ll nCk = 1;
    vector<ll> nCkarr(N-K+1, 0);
    nCkarr[N-K] = 1;
    for(ll i=N-K-1; i>=0; i--){
        nCk = mul_modp(div_modp(N-1-i, N-K-i, INF), nCk, INF);
        nCkarr[i] = nCk;
    }

    ll mn=0;
    for(ll i=0; i<N-K+1; i++){
        mn = add_modp(mn, mul_modp(A[i], nCkarr[i], INF), INF);
    }

    ll mx = 0;
    for(ll i=N-1; i>=K-1; i--){
        mx = add_modp(mx, mul_modp(A[i], nCkarr[N-1-i], INF), INF);
    }
    cout << dif_modp(mx, mn, INF) << endl;
    return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  int N, M, X, cs[12], as[12][12], memo[12];

  void init() {
    cin >> N >> M >> X;
    rep(i, N) {
      cin >> cs[i];
      rep(j, M) cin >> as[i][j];
    }
  }

  void solve() {
    int minv = IINF;
    rep(k, 1<<N) {
      int res = 0;
      rep(j, M) memo[j] = 0;
      rep(i, N) if((k>>i)&1) {
        res += cs[i];
        rep(j, M) memo[j] += as[i][j];
      }
      bool satisfied = true;
      rep(j, M) satisfied &= X <= memo[j];
      if(satisfied) minv = min(minv, res);
    }
    cout << (minv == IINF ? -1 : minv) << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

int a, b, c;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> a >> b >> c;
    cout << min(b / a, c);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC133
{
    class Program
    {
        static void Main(string[] args)
        {
            string Str = Console.ReadLine().Trim();
            string[] StrArr = Str.Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
            int[] IntArr = StrArr.Select(int.Parse).ToArray();
            int densha = IntArr[0] * IntArr[1];
            int taxi = IntArr[2];

            if (densha < taxi)
            {
                Console.WriteLine(densha);
            }
            else
            {
                Console.WriteLine(taxi);
            }

        }
    }
}


Measured memory_bytes: 13268
import numpy as np
n = int(input())
a_list = [int(i) for i in input().split()]
res1 = max(a_list)
a_list.remove(res1)
res_med = res1 / 2
res2 = a_list[np.argmin([abs(i - res_med) for i in a_list])]
print(str(res1)+' '+str(res2))

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

const ll MOD = 1e9 + 7;
const int N = 1024;

string s[N];
ll dp[N][N];

int main() {
    ios::sync_with_stdio(false);
    int r, c;
    cin >> r >> c;
    for (int i=0; i<r; i++) {
        cin >> s[i];
    }
    dp[r-1][c-1] = 1;
    for (int i=r-1; i>=0; i--) {
        for (int j=c-1; j>=0; j--) {
            if (dp[i][j]) continue;
            if (s[i][j] != '.') continue;
            dp[i][j] = (dp[i+1][j] + dp[i][j+1]) % MOD;
        }
    }
    cout << dp[0][0] << '\n';
}


Measured memory_bytes: 9472
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> c(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		if (c[i] < v[i]) {
			res += v[i] - c[i];
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

signed main() {
	ios::sync_with_stdio(false);
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = a; i <= min(b, a + k - 1); i++) cout << i << endl;
	for (int i = max(b - k + 1, a + k); i <= b; i++)cout << i << endl;
	return 0;
}



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

using namespace std;

priority_queue<long long> Q , QQ;

long long a[(int)(3*(1e5+10))] , n , s1[(int)(3*(1e5+10))] , s2[(int)(3*(1e5+10))] , s3[(int)(3*(1e5+10))] , res;

int main()
{
    s1[0] = s2[0] = s3[0] = 0;
    cin >> n;
    for (int i=1 ; i<=3*n ; i++)
        cin >> a[i];
    for (int i=1 ; i<=3*n ; i++)
        s1[i] = s1[i-1] + a[i];
    for (int i=1 ; i<=n ; i++)
        Q.push(-a[i]);
    for (int i=n+1 ; i<=2*n ; i++)
    {
        Q.push(-a[i]);
        s2[i-n] = s2[i-n-1] - Q.top();
        Q.pop();
    }
    for (int i=3*n ; i>=2*n+1 ; i--)
        QQ.push(a[i]);
    for (int i=2*n ; i>=n ; i--)
    {
        QQ.push(a[i]);
        s3[2*n-i+1] = s3[2*n-i] + QQ.top();
        QQ.pop();
    }
    res = -1e18;
    for (int i=n ; i<=2*n ; i++)
    {
        long long ts1=s1[i],ts2=s1[3*n]-s1[i];
        int len1=i-n,len2=2*n-i;
        res=max(res,ts1-s2[len1]-ts2+s3[len2]);
    }
    cout << res;
}


Measured memory_bytes: 10100
#include<stdio.h>

int main(){

  int n,i,j,max,mini,R[200000];

  scanf("%d",&n);

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

  max=R[1]-R[0];
  mini=R[0];

  for(j=2;j<n;j++){
    if(mini > R[j-1])mini=R[j-1];
    if(max < R[j]-mini)max=R[j]-mini;
  }
    

  printf("%d\n",max);

  return 0;
}

Measured memory_bytes: 1376
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  REP(i, N) cout << S[i] << T[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    string s, t;
    cin >> s >> t;
    int res = 0;
    rep(i, 0, s.size())
        if (s[i] != t[i])
            res++;
    cout << res;
    return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, k;
	cin >>n >>m >>k;
	VL a(n), b(m), rs(m+1);
	rep(i, n) cin >>a[i];
	rep(i, m) cin >>b[i];
	rep(i, m) rs[i+1] = rs[i] + b[i];
	int ans =0;
	ll sma =0;
	rep(i, n+1){
		if(sma > k) break;
		int ix = upper_bound(all(rs), k-sma) - rs.begin();
		ans = max(ans, i + max(0, ix-1));
		if(i<n) sma += a[i];
	}
	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 7908
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string st;
    cin >> st;
    int cnt=0;
    F0R(i,sz(st)/2)
    {
        if(st[i]!=st[sz(st)-1-i])
            cnt++;
    }
    cout << cnt;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e15
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


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

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

int main()
{
	double w, h, x, y;
	
	cin >> w >> h >> x >> y;

	cout << setiosflags(ios::fixed | ios::showpoint) << w * h / 2 << " ";

	if (x * 2 == w && y * 2 == h)
		cout << 1 << endl;
	else
		cout << 0 << endl;

	return 0;
}

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

max_d = 0
max_count = 0

current_min = 999999999
current_max = 0

for a in A:
    if a < current_min:
        current_min = a
        current_max = 0
        if max_d < (current_max - current_min):
            max_d = current_max - current_min
            max_count = 1
        elif max_d == (current_max - current_min):
            max_count += 1

    if a > current_max:
        current_max = a
        if max_d < (current_max - current_min):
            max_d = current_max - current_min
            max_count = 1
        elif max_d == (current_max - current_min):
            max_count += 1

print(max_count)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int my_abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
    string S;
    cin >> S;
    string ans = "yes";
    vector<char> SS(S.size());
    for(int i = 0;i<S.size();i++){
        SS.at(i) = S.at(i);
        //cout << SS.at(i);
    }
    sort(SS.begin(),SS.end());
    for(int j = 0;j<SS.size()-1;j++){
        //cout << SS.at(j+1);
        if(SS.at(j) == SS.at(j+1)){
            ans = "no";
            break;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int f[100005],h[100005];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	scanf("%d",&h[i]);
	f[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;++i)
	f[i]=min(f[i-2]+abs(h[i]-h[i-2]),f[i-1]+abs(h[i]-h[i-1]));
	printf("%d",f[n]);
	return 0;
} 


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

const int W = 50, H = 50;
int w, h;
int board[H][W];

void search(int y, int x){
	board[y][x] = 0;
	for(int dx = -1; dx <= 1;++dx){
		for(int dy = -1; dy <= 1;++dy){
			int nx = x + dx, ny = y + dy;
			if(0 <= ny && 0 <= nx && nx < w && ny < h){
				if(board[ny][nx]) search(ny, nx);
			}
		}
	}
	return;
}

int main(){
	int c;
	while(cin >> w >> h, w){
		c = 0;
		for(int i = 0;i < h;++i){
			for(int j = 0;j < w;++j){
				cin >> board[i][j];
			}
		}
		for(int i = 0;i < h;++i){
			for(int j = 0;j < w;++j){
				if(board[i][j]){
					search(i, j);
					++c;
				}
			}
		}
		cout << c << endl;
	}
	return 0;
}

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

int n, k;
int d[10];

bool check(int x)
{
  while(x){
    int y = x % 10;
    for(int i = 0; i < k; i++){
      if(y == d[i]) return false;
    }
    x /= 10;
  }

  return true;
}

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

  for(int i = 0; i < k; i++) cin >> d[i];

  int ans = n;
  while(!check(ans)){
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
ll min2(ll a,ll b){
  ll ans=a;
  if(ans>b)ans=b;
  return ans;
}
int main(){
  int n;cin>>n;
  vector<ll> a(n+1,0);
  vector<ll> sum(n+1,0);
  vector<ll> ori(n+1,0);
  rep(i,n)cin>>a[i];
  sum[0]=a[0];
  rep1(i,n)sum[i]=sum[i-1]+a[i];
  rep(i,n)ori[i]=sum[i];
  ll odd=0;
  ll even=0;
  //  cout<<"odd"<<endl;
  rep(i,n){
    if(i%2==0){
      if(sum[i]<=0){
	odd+=1-sum[i];
	sum[i]=1;
      }
    }
    else{
      if(sum[i]>=0){
	odd+=sum[i]+1;
	sum[i]=-1;
      }
    }
    sum[i+1]=sum[i]+a[i+1];
    //    cout<<sum[i]<<endl;
  }
  rep(i,n)sum[i]=ori[i];
  //  cout<<odd<<endl;
  //  cout<<"even"<<endl;
  rep(i,n){
    if(i%2==0){
      if(sum[i]>=0){
	even+=1+sum[i];
	sum[i]=-1;
      }
    }
    else{
      if(sum[i]<=0){
	even+=1-sum[i];
	sum[i]=1;
      }
    }
    sum[i+1]=sum[i]+a[i+1];
    //    cout<<sum[i]<<endl;
  }
  //  cout<<even<<endl;
  //  cout<<"ans"<<endl;
  cout<<min2(odd,even)<<endl;
  return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <stack>

using namespace std;

int main(void){
    int i,j,d;
    stack<int> train;
    while(cin >> d){
        if(d==0){
            cout << train.top() << endl;
            train.pop();
        }
        else train.push(d);
    }
    return 0;
}

Measured memory_bytes: 3088
# import math
N, Q = map(int, input().split())
# line = list(map(int, input().split()))
# line = input()
S = input()
question = []
ac = [0] * N
ans = []
count = 0
for _ in range(Q):
    question.append(list(map(int, input().split())))

for i in range(N):
    if S[i] == 'C' and S[i-1] == 'A':
        count += 1
        ac[i] = count
    else:
        ac[i] = count

# print(ac)

for i in range(Q):
    start = question[i][0] - 1
    end = question[i][1] - 1
    tmp = ac[end] - ac[start]
    ans.append(tmp)

for i in range(len(ans)):
    print(ans[i])


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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

string S;
map<char, bool> mp;
signed main() {
    cin >> S;
    rep(i, S.length()) { mp[S[i]] = true; }
    if (mp['N'] == mp['S'] && mp['W'] == mp['E']) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin>>n;
    cout<<n*(n+1)/2<<endl;
}


Measured memory_bytes: 256
# coding: utf-8
import sys

A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

a = [[0,0,0],[0,0,0],[0,0,0]]

N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        if b in A[j]:
            a[j][A[j].index(b)] = 1

flag = False

for i in range(3):
    if 0 not in a[i]: flag = True
    if a[0][i]*a[1][i]*a[2][i] == 1: flag = True
    
if a[0][0]*a[1][1]*a[2][2] == 1: flag = True
if a[0][2]*a[1][1]*a[2][0] == 1: flag = True

print('Yes') if flag == True else print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct node{
	int x,y;
}a[10010],b[10010];
int jl(int x1,int x2,int y1,int y2){
	return abs(x1-x2)+abs(y1-y2);
}
int main(){
	int n,m,i,j,mn,id;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		cin>>a[i].x>>a[i].y;
	}
	for(i=1;i<=m;i++){
		cin>>b[i].x>>b[i].y;
	}
	for(i=1;i<=n;i++){
		mn=2100000000;
		for(j=1;j<=m;j++){
			if(jl(a[i].x,b[j].x,a[i].y,b[j].y)<mn){
				mn=jl(a[i].x,b[j].x,a[i].y,b[j].y);
				id=j;
			}
		}
		cout<<id<<endl;
	}
	return 0;
}


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

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

const int N = 3e5 + 10;

int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++) {
		int t = s[i] - 'A';
		t += n;
		t %= 26;
		cout << (char)(t + 'A');
	}
}

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

int main(){
int raw,j,a[100];
while (1) {
	//cout << "????????°?????\???" << endl;
	cin >> raw;
	if (raw == 0) { break;
	}
	else {
		//cout << "?????????????§?" << endl;

		for (j = 0; j < raw; j++) { cin >> a[j]; }
		int min = a[0], max = a[0];
		for (j = 0; j < raw; j++) {
			if (a[j] < min) { min = a[j]; }	
		if (a[j] > max) { max = a[j]; }
	}
	int sum = 0;
	for (j = 0; j < raw; j++) { sum = sum+a[j]; }
	cout << (sum - min - max) / (raw - 2)<<endl;
	}
}
return 0;}

Measured memory_bytes: 1160
#include<iostream>
#include<set>

int main(){

    size_t n;
    std::cin >> n;

    std::set<size_t> a;

    for(size_t i = 0; i < n; i++){
        size_t tmp;
        std::cin >> tmp;
        a.emplace(tmp);
    }

    if(n == a.size()){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;
int n;
vector<int> str(11);
void dfs(int saidai,int phase){
    if(phase==n) {
        rp(i,n){
            char ch='a'+str[i];
            cout << ch;
        }
        cout << endl;
        return;
    }
    rp(i,saidai+2){
        str[phase]=i;
        if(i<=saidai){
            dfs(saidai,phase+1);
        }
        else{
            dfs(i,phase+1);
        }
    }
}
int main(){
    cin >> n;
    str[0]=0;
    dfs(0,1);
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> l(c);
    rep(i, 0, c) cin >> l[i];
    vector<P> d(n);
    rep(i, 0, n){
        cin >> d[i].second >> d[i].first;
    } 
    sort(all(d));
    reverse(all(d));
    int ans = 0;
    rep(i, 0, n){
        if(m <= 0) break;
        int id = d[i].second - 1;
        if(l[id] <= 0) continue;
        m--;
        l[id]--;
        ans += d[i].first;
    }
    cout << ans << endl;
}


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

int f,n,sum=0;
String op;
while(true){
f=sc.nextInt();
op=sc.next();
n=sc.nextInt();
if(op.contains("+"))
	sum=f+n;
if(op.contains("-"))
	sum=f-n;
if(op.contains("*"))
	sum=f*n;
if(op.contains("/"))
	sum=f/n;
	
if(op.contains("?"))
	break;
System.out.println(sum);
}


}

}


Measured memory_bytes: 26276
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NMAX=1e5,HMAX=1e9,INF=1e9+1;
int n,h,a[NMAX],b[NMAX],maxB[NMAX],iMax[NMAX];


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> h;
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	int minimum=INF,maximum=a[0];
	sort(b,b+n);
	
	for(int i=1;i<n;i++){
		if(a[i]>maximum){
			maximum=a[i];
		}
	}
	
	minimum=min(minimum,h/maximum+(h%maximum!=0));
	for(int i=1;i<=n;i++){
		h-=b[n-i];
		if(h<=0) minimum=min(minimum,i);
		else minimum=min(minimum,i+h/maximum+(h%maximum!=0));
	}
	
	cout << minimum << '\n';
}

Measured memory_bytes: 1024
x = input()
a=[int(x[0]), int(x[1]), int(x[2]), int(x[3])]
op=['+', '-']
for i in range(2):
  for j in range(2):
    for k in range(2):
      ops = [op[i], op[j], op[k]]
      tmp = a[0]
      for l in range(3):
        if ops[l]=='+':
          tmp = tmp + a[l+1]
        else:
          tmp = tmp - a[l+1]
      if tmp==7:
        break
    if tmp==7:
      break
  if tmp==7:
    break

print(str(a[0])+ops[0]+str(a[1])+ops[1]+str(a[2])+ops[2]+str(a[3])+'=7')


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

template <class T>
inline T gcd(T a, T b)
{
    return a ? gcd(b % a, a) : b;
}

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

    return false;
}

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

    vector<int> A(N);
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    vector<int> left(N + 1, 0);
    for(int i = 0; i < N; i++)
    {
        left[i + 1] = gcd(left[i], A[i]);
    }

    vector<int> right(N + 1, 0);
    for(int i = N - 1; i >= 0; i--)
    {
        right[i] = gcd(right[i + 1], A[i]);
    }

    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        chmax(ans, gcd(left[i], right[i + 1]));
    }

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

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

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

  for(int i=1;i<=n;i++){
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
  }
  else{
        for(;x>0;){
            if ( x % 10 == 3 ){
            cout << " " << i;
            break;
            }
            else{
                x /= 10;
            }
        }
  } 
  }
  cout << endl;

}


Measured memory_bytes: 3100
'use strict'

function main(s) {

  const N = Number(s);
  let answer = 10000000000;

  for (let i = 1; i <= Math.sqrt(N); i++) {
    if (Number.isInteger(N / i)) {
      const max = Math.max(String(i).length, String(N / i).length);
      answer = Math.min(answer, max);
    }
  }

  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8780
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll n, m;
string s;
ll x[100000];
int main() {
	ll a, b;
	cin >> n >> a >> b;
	rep(i, n) {
		cin >> x[i];
	}
	ll ans = 0;
	rep(i, n - 1) {
		ans += min((x[i + 1] - x[i])*a, b);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

ans = 0

L = [1] * N
for a, b in AB:
  a -= 1
  b -= 1
  if H[a] <= H[b]:
    L[a] = 0
  if H[a] >= H[b]:
    L[b] = 0

print(sum(L))


Measured memory_bytes: 32008
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define MOD 1000000007

vector<long long> v;

void prime(long long N)
{
	int i, j, k;
	if (N >= 2) {
		v.emplace_back(2);
	}
	for (i = 3;i <= N;i += 2)
	{
		k = 0;
		for (j = 3;j <= sqrt(i);j += 2)
		{
			if (i%j == 0)
			{
				k = 1;
				break;
			}
		}

		if (k == 0) v.emplace_back(i);
	}
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long N; cin >> N;
	long long prime_sum = N;
	long long ans = 1;

	prime(N);
	for (int i = 0; i < v.size(); i++) {
		int p = v[i];
		int cnt = 0;
		while (p <= N) {
			cnt += N / p;
			p = p*v[i];
		}
		ans = (ans * (cnt + 1))%MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
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 ll mod=1e9+7;

vector<vector<ll>> G;



int main(){
    ll h,w;
    cin >> h >>w;
    vector<vector<char>> c(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    vector<vector<ll>> dp(h,vector<ll>(w));
    rep(i,h){
        rep(j,w){
            if(c[i][j]=='#') continue;
            if(i==0 && j==0){
                dp[i][j]=1;
            }
            else{
                if(j-1>=0){
                    dp[i][j]+=dp[i][j-1];
                }
                if(i-1>=0){
                    dp[i][j]+=dp[i-1][j];
                }
            }
            dp[i][j]%=mod;
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
} 

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 1e6 + 5;
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    ll dp[n + 1][k + 1] = {};
    dp[0][0] = 1;
    f (n) {
        int x;
        cin >> x;
        for (int j = 0 ; j <= k ; j++) {
            dp[i + 1][j] += dp[i][j] * 2;
            dp[i + 1][j] %= mod;
            if (j + x <= k) {
                dp[i + 1][j + x] += dp[i][j];
                dp[i + 1][j + x] %= mod;
            }
        }
    }
    cout << dp[n][k] << '\n';
}

Measured memory_bytes: 73964
#!/usr/bin/env python3
def main():
    from math import gcd

    N = int(input())
    A = []
    INF = 10 ** 6 + 5
    frequency = [0] * INF
    for a in [int(x) for x in input().split()]:
        A.append(a)
        frequency[a] += 1
    
    pairwise = True
    for i in range(2, INF):
        cnt = 0
        for j in range(i, INF, i):
            cnt += frequency[j]
        if cnt > 1:
            pairwise = False
    if pairwise:
        print("pairwise coprime")
        return

    g = 0
    for i in range(N):
        g = gcd(g, A[i])
        if g == 1:
            print('setwise coprime')
            return
    
    print('not coprime')


if __name__ == '__main__':
    main()


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

using namespace std;

int main(){
  string S;
  string out = " ";
  
  int i, len;
  
  cin >> S;
  
  len = S.size();
  
  for(i = 0; i < len; i++){
    out += "x";
  }
  
  cout << out << endl;
  
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll dp[1010][1010];

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

    ll N, K;
    cin >> N >> K;
    	
    ll res = K;
    REP(i, N-1){
    	res *= (K-1);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  cout << (pow(n,3)) << endl;
  
  
}

Measured memory_bytes: 384
def dot(vector1,vector2):
    return vector1[0]*vector2[0]+vector1[1]*vector2[1]

q = int(input())
for _ in range(q):
    x1,y1,x2,y2,x3,y3,x4,y4 = map(int,input().split())
    vector1 = [x1-x2,y1-y2]
    vector2 = [x3-x4,y3-y4]
    
    if dot(vector1,vector2)==0:
        print(1)
    elif dot(vector1,vector2)**2==dot(vector1,vector1)*dot(vector2,vector2):
        print(2)
    else:
        print(0)


Measured memory_bytes: 5620
from itertools import accumulate as ac
from collections import Counter as co
n=int(input())
a=list(map(int,input().split()))
b=[0]+a
b=list(ac(b))
#print(b)
c=co(b)
cc=c.most_common()
#print(c,cc)
cnt=0
for i in cc:
    if i[1]>1:
        cnt+=(i[1]*(i[1]-1)//2)

print(cnt)

Measured memory_bytes: 48144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
        long min = Math.min(N%K, K-N%K);
        System.out.println(min);
    }
}


Measured memory_bytes: 35708
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
int main(){
	fast;
	ll x,n; cin>>x>>n;
	set<ll> ss;
	for(auto i=0;i<n;++i){
		ll x; cin>>x;
		ss.insert(x);
	}
	ll ans=1e9,cnt=-1;
	for(auto i=0;i<=1001;++i){
		if(ans>abs(i-x) && ss.find(i)==ss.end()){
			ans=abs(i-x);
			cnt=i;
		}
	}
	cout<<cnt<<'\n';
	return 0;
}

Measured memory_bytes: 3656