akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstdio>
#include <iomanip>
#define NUM 30
using namespace std;

double heron(double x0, double y0, double x1, double y1, double x2, double y2){
	double a, b, c, z, x, y;
	x = x0 - x1;
	y = y0 - y1;
	a = sqrt(x*x + y*y);

	x = x1 - x2;
	y = y1 - y2;
	b = sqrt(x*x + y*y);

	x = x2 - x0;
	y = y2 - y0;
	c = sqrt(x*x + y*y);

	z = (a+b+c) / 2.0;
	
	return sqrt(z * (z-a) * (z-b) * (z-c));
}

int main(){
	int n = 0;
	double ans = 0;
	double x[NUM], y[NUM];
	while (~scanf("%lf,%lf", &x[n], &y[n]) ) {
		n++;
	} 
	for (int i = 0; i < n-2; i++) {
		ans += heron(x[0], y[0], x[i+1], y[i+1], x[i+2], y[i+2]);
	}
	cout << setprecision(20);
	cout << ans << endl;

	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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

signed main()
{   
  gearup;
  ll L,R; cin >> L >> R;
  if(R-L>2020)out(0);
  else{
      ll res = L_INF;
      for(ll i=L;i<R;i++){
          for(ll j=i+1;j<=R;j++){
              res = min(res,(i*j)%2019LL);
          }
      }
      out(res);
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    long MOD = (long)Math.pow(10, 9) + 7;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    int[] b = new int[n + 1];
    b[0] = 0;
    for(int i = 0; i < n; i++) {
      b[i + 1] = b[i] ^ a[i];
    }
    long ans = 0;
    if(b[n] != 0) {
      int p = b[n];
      long[] dp1 = new long[n + 1];
      long[] dp2 = new long[n + 1];
      dp1[0] = 1;
      dp2[0] = 0;
      for(int i = 1; i < n + 1; i++) {
        if(b[i] == 0) {
          dp1[i] = (dp1[i - 1] + dp2[i - 1]) % MOD;
        } else {
          dp1[i] = dp1[i - 1];
        }
        if(b[i] == p) {
          dp2[i] = (dp2[i - 1] + dp1[i - 1]) % MOD;
        } else {
          dp2[i] = dp2[i - 1];
        }
      }
      ans = (dp2[n] - dp2[n - 1] + MOD) % MOD;
    } else {
      long kosuu = 0;
      long[] q = new long[n + 1];
      q[0] = 1;
      for(int i = 1; i < n + 1; i++) {
        if(b[i] == 0) {
          q[i] = q[i - 1] + 1;
        } else {
          q[i] = q[i - 1];
        }
      }
      kosuu = q[n - 1] - q[0];
      long t = 1;
      for(long i = 0; i < kosuu; i++) {
        t = (t * 2) % MOD;
      }
      ans = t;
      HashMap<Integer, ArrayList<Integer>> map = new HashMap<Integer, ArrayList<Integer>>();
      for(int i = 1; i < n; i++) {
        if(b[i] != 0) {
          if(map.containsKey(b[i])) {
            ArrayList<Integer> list = map.get(b[i]);
            list.add(i);
            map.put(b[i], list);
          } else {
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(i);
            map.put(b[i], list);
          }
        }
      }
      for(int p : map.keySet()) {
        ArrayList<Integer> list = map.get(p);
        int x = list.size();
        long[] dp1 = new long[x];
        long[] dp2 = new long[x];
        dp1[0] = 1;
        dp2[0] = 1;
        for(int i = 1; i < x; i++) {
          int k = list.get(i);
          int s = list.get(i - 1);
          long w = q[k] - q[s];
          long m = (dp1[i - 1] * w) % MOD;
          dp1[i] = (dp1[i - 1] + m + dp2[i - 1]) % MOD;
          dp2[i] = (m + dp2[i - 1]) % MOD;
        }
        ans = (ans + dp1[x - 1]) % MOD;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 200528
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define rep(i,a,b,c)            for(int i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(int i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define vpii                    vector<pair<int,int>>
#define si                      set<int>
#define usi                     unordered_set<int>
#define vi                      vector<int>
#define vld                     vector<ld>
#define vvi                     vector<vector<int>>
#define vvld                    vector<vector<ld>>
#define pii                     pair<int,int>
#define vvpii                   vector<vector<pair<int,int>>>
#define pqi                     priority_queue<int>
#define mii                     map<int,int>
#define mic                     map<int,char>
#define um                      unordered_map
#define umii                    um<int,int>
#define umic                    um<int,char>
#define umci                    um<char,int>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    int Testcases;cin>>Testcases;while(Testcases--)
#define input(a,n)              for(int i=0;i<n;++i) cin>>a[i];
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main()
{
	fastIO
	inp_out();
	int n;
	cin>>n;
	vi a(n);
	input(a,n);

	vi cnt(n,0);

	for(int i=0;i<n;++i)
	{
		if(i+a[i]<n)
			cnt[i+a[i]]++;
	}

	int ans=0;
	for(int i=0;i<n;++i)
	{
		if(i>=a[i])
			ans+=cnt[i-a[i]];
	}

	cout<<ans;

	return 0;
}

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

struct Dice{
	int num[6];
	void roll(char c){
		char tmp;
		if(c == 'N'){
			tmp = num[4];
			num[4] = num[0];
			num[0] = num[1];
			num[1] = num[5];
			num[5] = tmp;
		}
		else if(c == 'E'){
			tmp = num[2];
			num[2] = num[0];
			num[0] = num[3];
			num[3] = num[5];
			num[5] = tmp;
		}
		else if(c == 'S'){
			tmp = num[1];
			num[1] = num[0];
			num[0] = num[4];
			num[4] = num[5];
			num[5] = tmp;
		}
		else if(c == 'W'){
			tmp = num[3];
			num[3] = num[0];
			num[0] = num[2];
			num[2] = num[5];
			num[5] = tmp;
		}
	}
};

int main(){
	Dice d;
	string s;
	for(int i = 0; i < 6; i++){
		cin >> d.num[i];
	}
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		d.roll(s[i]);
	}
	cout << d.num[0] << endl;
}


Measured memory_bytes: 3192
#include<stdio.h>
int main() {
	int d, i, s;
	while (scanf("%d", &d) != EOF) {
		s = 0;
		for (i = 1;i*d < 601 - d;i++) {
			s += i*i*d*d*d;
		}
		printf("%d\n", s);
	}
	return 0;
}

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

bool month(int mm)
{
    return (1 <= mm && mm <= 12);
}

void solve(std::string S)
{
    int th = stoi(S.substr(0, 2));
    int bh = stoi(S.substr(2, 2));
    if (month(th) && month(bh)) {
        cout << "AMBIGUOUS\n";
    } else if (month(th) && !month(bh)) {
        cout << "MMYY\n";
    } else if (!month(th) && month(bh)) {
        cout << "YYMM\n";
    } else {
        cout << "NA\n";
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort
F = gets.split.map(&:to_i).sort.reverse

ans = (0 .. F.first * A.last).bsearch do |t|
  k = N.times.inject(0) do |s, i|
    a = A[i]
    b = F[i]
    if a * b <= t
      s
    else
      k_ = a - t / b
      s + k_
    end
  end
  k <= K
end
puts ans


Measured memory_bytes: 33120
def ipt(N=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
#        return [list(map(int,input().split())) for _ in range(N)]
        return [int(input()) for _ in range(N)]

N=int(input())
D,X=ipt()
A=ipt(N)
cnt=0

for a in A:
    i=0
    while(i * a + 1 <= D):
        cnt+=1
        i += 1
print(cnt+X)

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  if (n & 1) n *= 2;
  out(n);
}

Measured memory_bytes: 3532
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


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


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


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


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
R = int(input())
print(R*2*(math.pi))


Measured memory_bytes: 68756
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <bitset>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define ep emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( 1e9 + 7 )


int main()
{
	int N, K;
	string S;

	cin >> N >> K >> S;
	S[K - 1] = (char)( (char)S[K - 1] + abs('a' - 'A') );

	cout << S << endl;
	return ( 0 );
}


Measured memory_bytes: 888
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  int n; cin >> n;
  int v[n]; FOR(i,0,n) cin >> v[i];
  ll dp[n][21]; CLR(dp);
  dp[1][v[0]] = 1;
  FOR(i,1,n-1) {
    FOR(j,0,21) {
      //if(dp[i][j] == 0) continue;
      if(j+v[i] <= 20) dp[i+1][j+v[i]] += dp[i][j];
      if(j-v[i] >= 0) dp[i+1][j-v[i]] += dp[i][j];
    }
  }
  cout << dp[n-1][v[n-1]] << endl;
  return 0;
}

Measured memory_bytes: 3104
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def S(): return sys.stdin.readline().rstrip()

N,K = map(int,S().split())
A = LI()
F = LI()
A = sorted(A)
F = sorted(F,reverse=True)

if sum(A) <= K:
    print(0)
    exit()

left = 0
right = 10**12
while left + 1 < right:
    mid = (left + right) // 2
    if sum(max(0,A[i]-mid//F[i]) for i in range(N)) <= K:
        right = mid
    else:
        left = mid

print(right)

Measured memory_bytes: 114080
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
signed main(){
  string s;
  cin>>s;
  string n="CODEFESTIVAL2016";
  int g=0;
  rep(i,16){
  if(s[i]!=n[i])
    g++;
  }
  cout<<g;
  }


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
#define max 100000
using namespace std;
ll l = 1000000007;

ll p[100] = {};

int main()
{
	ll n, a, b;
	ll x = 0;
	ll y = 0;
	ll z = 0;


	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}

	for (int i = 0; i < n; i++)
	{
		if (p[i] <= a) {
			x++;
		}
		else if (a + 1 <= p[i] && p[i] <= b) {
			y++;
		}
		else if (b + 1 <= p[i]) {
			z++;
		}
	}

	cout << min({ x, y, z }) << endl;
	return 0;
	
}



Measured memory_bytes: 256
import Control.Monad

main = do
    [n, m, c] <- map read . words <$> getLine
    b <- map read . words <$> getLine
    a <- map (map read . words) <$> replicateM n getLine
    putStrLn $ show $ length $ filter (>0) $ map (+c) $ map sum $ map (zipWith (*) b) a


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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    bool x = true;
    while (S.size() != 0)
    {
        if (S.size() >= 5 && S.substr(0, 5) == "maerd")
            S.erase(0, 5);
        else if (S.size() >= 7 && S.substr(0, 7) == "remaerd")
            S.erase(0, 7);
        else if (S.size() >= 5 && S.substr(0, 5) == "esare")
            S.erase(0, 5);
        else if (S.size() >= 6 && S.substr(0, 6) == "resare")
            S.erase(0, 6);
        else
        {
            x = false;
            break;
        } 
    }
    cout << (x ? "YES" : "NO");
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx=2e3+5;
int a[maxx][maxx];
int main(){
    int n,m; cin>>n>>m;
    int cnt=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%d",&a[i][j]);
        }
        
        for(int j=1;j<i;j++){
            int res=0;
            for(int k=1;k<=m;k++){
                res+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            int ans=(int)sqrt(1.0*res);
            if(ans*ans==res){
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    
}

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>;
const ll MX=1e18;

int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll ans=1;
  sort(a.begin(),a.end());
  rep(i,n){
    if(a[i]==0){
      cout << 0 << endl;
      return 0;
    }
    if(ans>MX || MX/ans<a[i]){
      cout << -1 << endl;
      return 0;
    }
    ans*=a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
int main(){
    int cnt=0,max=0;
    string s;
    cin>>s;
    for(char c:s){
        if(c-65&&c-67&&c-71&&c-84){
            if(cnt>max) max=cnt;
            cnt=0;
        }else{
            cnt++;
        }
    }
    if(cnt>max) max=cnt;
    printf("%d\n",max);
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
int main()
{
  	int A, B, K;
  
  	std::cin >> K >> A >> B;
    
   	while(A <= B)
    {
      if(A % K == 0)
      {
        std::cout << "OK";
        return 0;
      }
      A++;
    }
  	std::cout << "NG";
  	return 0; 
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
 
#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c)
#define rsort(a,n) sort(a,a+n,greater<>())
 
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100;
 
int main(void){
    ll a,b;

    in2(a,b);
    if (a < b && a != 1) prl("Bob");
    else if (a > b && b != 1) prl("Alice");
    else if (a == 1 && b != 1) prl("Alice");
    else if (b == 1 && a != 1) prl("Bob");
    else prl("Draw");

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	vector<int> vec;
	int n, m;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		int ho, mi;
		cin >> ho >> mi;
		vec.push_back(ho * 60 + mi);
	}

	cin >> m;
	for(int i = 0; i < m; i++)
	{
		int ho, mi;
		cin >> ho >> mi;
		vec.push_back(ho * 60 + mi);
	}

	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());

	for(int i = 0; i < vec.size(); i++)
	{
		int ho = vec[i] / 60;
		int mi = vec[i] % 60;
		if(i > 0)cout << " ";
		printf("%d:%02d", ho, mi);
	}
	cout << endl;
}

Measured memory_bytes: 1252
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int m, k;
    cin >> m >> k;

    if (k >= pow(2, m))
    {
        cout << -1 << endl;
        return 0;
    }

    if (m == 1 && k == 1)
    {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;

    if (k == 0)
    {
        for (int i = 0; i < pow(2, m); i++)
        {
            ans.push_back(i);
            ans.push_back(i);
        }
    }
    else
    {
        for (int i = 0; i < pow(2, m); i++)
        {
            if (i == k)
                continue;

            ans.push_back(i);
        }
        ans.push_back(k);
        for (int i = pow(2, m) - 1; i >= 0; i--)
        {
            if (i == k)
                continue;

            ans.push_back(i);
        }
        ans.push_back(k);
    }

    for (int i = 0; i < ans.size(); i++)
    {
        i == 0 ? (cout << ans[i]) : (cout << ' ' << ans[i]);
    }
    cout << endl;
}

Measured memory_bytes: 2932
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


int count(int n){
  int sum = 0;
  while(n) sum += n%10, n/=10;
  return sum;
}

int top(int n){
  while(n/10) n/=10;
  return n;
}

int calc(int n){
  int num = top(n)-1;
  while(num * 10 + 9 < n) num = num * 10 + 9;
  return count(num);
}

signed main(){
  int n;
  cin>>n;
  int ans = max(count(n),calc(n));
  cout<<ans<<endl;
  
  
  return 0;
}


Measured memory_bytes: 764
while 0<n=gets.to_i;a=[0]*(n+1);n.times{s=gets.split.map(&:to_i);s.push s.inject(:+);i=-1;puts s.map{|x|a[i+=1]+=s[i];"%5d"%x}.join};puts a.map{|x|"%5d"%x}.join;end

Measured memory_bytes: 6120
def factorization(n):
    def sieve(n):
        is_prime = [True for _ in range(n+1)]
        is_prime[0] = False

        for i in range(2, n+1):
            if is_prime[i-1]:
                j = 2 * i
                while j <= n:
                    is_prime[j-1] = False
                    j += i
        table = [ i for i in range(1, n+1) if is_prime[i-1]]
        return table
    arr = []
    temp = n
    for i in sieve(int(n**0.5)):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
cnt=1
n,p= map(int, input().split())
a=factorization(p)
for x in a:
    cnt*=x[0]**(x[1]//n)
print(cnt)

Measured memory_bytes: 113904
import math


def solve(N, As):
    As = [a - (i + 1) for i, a in enumerate(As)]
    high = 10 ** 10
    low = -10 ** 10
    while True:
        b = (high + low) // 2
        tans1 = sum(abs(a - b) for a in As)
        tans2 = sum(abs(a - b + 1) for a in As)
        if low == b:
            return min(tans1, tans2)

        if tans1 > tans2:
            high = b
        elif tans1 < tans2:
            low = b
        else:
            return min(tans1, tans2)


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Measured memory_bytes: 26608
using System;
class main
{
    static void Main(String[] args)
    {
        string str = Console.ReadLine();
        string[] s = new string[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            s[i] = str[i].ToString();
        }
        Array.Reverse(s);
        string a = string.Join("", s);
        Console.WriteLine(a);
        //Console.ReadKey();
    }
}

Measured memory_bytes: 5272
main(){
  int a[11],b,c,i;
  a[0]=0;
  for(;;){
    for(i=0;i<10;i++)
      if(scanf("%d,",&a[i+1])==-1)
	break;
      else
	a[i+1]+=a[i];
    if(i!=10)
      break;
    if(scanf("%d,%d",&b,&c)==-1)
      break;
    for(i=1;i<11;i++)
      if(a[i]>=(double)a[10]/(b+c)*b){
	printf("%d\n",i);
	break;
      }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    int qn;
    cin >> qn;
    vector<int> A;
    ll B = 0;
    ll mid = 0;
    priority_queue<int, vector<int>, less<int>> que_gre;//大きいものから取り出したい
    priority_queue<int, vector<int>, greater<int>> que_less;//小さいものから取り出したい
    rep(i, qn){
        int q, a, b;
        cin >> q;
        if (q == 1) cin >> a >> b;
        if (i == 0){
            que_gre.push(a);
            que_less.push(a);
            B += b;
            continue;
        }

        if (q == 1){
            que_gre.push(a);
            que_less.push(a);
            int g_top = que_gre.top();
            int l_top = que_less.top();
            if ( g_top > l_top){
                mid += g_top - l_top;
                que_gre.pop();
                que_less.pop();
                que_gre.push(l_top);
                que_less.push(g_top);
            }
            B += b;
        } else {
            cout << que_gre.top() <<" "<< mid + B << endl;
        }
    }
}



Measured memory_bytes: 3828
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int a[3],i,sum=3;;
	for(i=0;i<3;i++)
	{
		cin >> a[i];
	}
	if(a[0]==a[1]) sum--;
	if(a[1]==a[2]) sum--;
	if(a[0]==a[2]) sum--;
	if(a[0]==a[1]&&a[1]==a[2]) sum++;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    char a;
    cin >> a;
    if ('A' <= a and a <= 'Z') {
        cout << "A\n";
    } else {
        cout << "a\n";
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N[4];

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

  rep(i, 4) cin >> N[i];

  bool judge = true;
  bool tmp = false;
  for (int i = 0; i < 4; ++i) {
      if (N[i] == 1) tmp = true;
  }
  judge &= tmp;
  tmp = false;
  for (int i = 0; i < 4; ++i) {
      if (N[i] == 9) tmp = true;
  }
  judge &= tmp;
  tmp = false;
  for (int i = 0; i < 4; ++i) {
      if (N[i] == 7) tmp = true;
  }
  judge &= tmp;
  tmp = false;
  for (int i = 0; i < 4; ++i) {
      if (N[i] == 4) tmp = true;
  }
  judge &= tmp;

  if (judge) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> yd(n+1);
    vector<int> p(m);
    vector<int> y(m);

    for(int i = 0; i < m; i++)
    {
        cin >> p[i] >> y[i];
        yd[p[i]].push_back(y[i]);
    }
    for(int i = 0; i < n; i++)
    {
        sort(yd[i+1].begin(), yd[i+1].end());
    }

    for(int i = 0; i < m; i++)
    {
        int num = lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) - yd[p[i]].begin();
        printf("%06d%06d\n", p[i], num+1);
    }

}


Measured memory_bytes: 7808
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <climits>

using namespace std;

#define MAX_V 5010

typedef pair<int, int> P;

struct edge{
  int to, cost;
  edge(int _to, int _cost){
    to = _to;
    cost = _cost;
  }  
};

struct node{
  int cost, mincost, v, n;
  bool operator < (const node a) const{
    return a.mincost < mincost;
  }
};

vector<int> G[MAX_V];
vector<node> Node;
vector<int> can[MAX_V];
int d[MAX_V];

int N, K;

void init(){
  for(int i = 0 ; i < MAX_V ; i++){
    G[i].clear();
  }
}

void dijkstra(int s){
  priority_queue<node> que;
  fill(d, d+MAX_V, INT_MAX);
  
  que.push(Node[0]);  
  d[s] = 0;
  
  while(!que.empty()){
    node p = que.top(); que.pop();
    int v = p.v;
    if(d[v] < p.mincost) continue;

    for(int i = 0 ; i < can[v].size() ; i++){
      int e = can[v][i];

      if(d[e] > d[v] + Node[v].cost){
	d[e] = d[v] + Node[v].cost;
	node tmp;
	tmp.v = can[v][i];
	tmp.mincost = d[e];
	que.push(tmp);
      }
    }
  }
}

vector<edge> G2[MAX_V];
int d2[MAX_V];

void dijkstra2(int s){
  priority_queue<P, vector<P>, greater<P> > que;
  
  fill(d2, d2+MAX_V, (1<<29));
  d2[s] = 0;  
  que.push(P(0, s));
  
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d2[v] < p.first) continue;
    for(int i = 0 ; i < G2[v].size() ; i++){
      edge e = G2[v][i];
      if(d2[e.to] > d2[v] + e.cost){
	d2[e.to] = d2[v] + e.cost;
	que.push(P(d2[e.to], e.to));
      }
    }
  }  
}

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

  for(int i = 0 ; i < N ; i++){
    node tmp;
    tmp.v = i;
    cin >> tmp.cost >> tmp.n;
    Node.push_back(tmp);
  }  
  int from, to;
  for(int i = 0 ; i < K ; i++){
    cin >> from >> to;
    from--;
    to--;
    
    G[from].push_back(to);
    G[to].push_back(from);
    
    G2[to].push_back(edge(from, 1));
    G2[from].push_back(edge(to, 1));    
  }

  for(int i = 0 ; i < N ; i++){
    dijkstra2(i);
    for(int j = 0 ; j < N ; j++){
      if(d2[j] <= Node[i].n) can[i].push_back(j);
    }
  }
  
  dijkstra(0);
  
  
  for(int i = 0 ; i < N ; i++){
    cout << "";
  }
  cout << d[N-1] << endl;
  
  return 0;
}

Measured memory_bytes: 69676
n = int(input())
s1 = input().strip()
s2 = input().strip()

p = 1
i = 0
prevm = 0
while i < len(s1):
  if s1[i] != s2[i]:
    if prevm == 0:
      p *= 6
    elif prevm == 1:
      p *= 2
    elif prevm == 2:
      p *= 3
    prevm = 2
    i += 1
  else:
    if prevm == 0:
      p *= 3
    elif prevm == 1:
      p *= 2
    prevm = 1
  i += 1
    
print(p % 1000000007)

Measured memory_bytes: 3064
a, b, m = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
qupons = [list(map(int, input().split())) for _ in range(m)]

cand1 = min(A) + min(B) # Without qupon
A_with_qupons = A[:]
B_with_qupons = B[:]
prices_with_qpons = [A[q[0]-1] + B[q[1]-1] - q[2] for q in qupons]
cand2 = min(prices_with_qpons) # With qupon
print(min([cand1, cand2]))

Measured memory_bytes: 44068
#include<stdio.h>
#include<stdlib.h>

#define MAX 500001

int A[MAX];
int H;

int left(int i){
  return 2*i;
};

int right(int i){
  return 2*i+1;
};

int parent(int i){
  return 2/i;
};

void print(){
  int i;

  for(i = 1; i <= H; i++){
    printf(" %d",A[i]);
  }
  
  printf("\n");
}

void maxHeapify(int i){
  int l,r,largest;
  int v;

  l = left(i);
  r = right(i);

  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;

  if(largest != i){
    v = A[i];
    A[i] = A[largest];
    A[largest] = v;
    maxHeapify(largest);
  }
  
}
int main(){
  int i;

  scanf("%d",&H);

  for(i = 1; i <= H; i++){
    scanf("%d",&A[i]);
  }

  for(i = H/2; i >= 1; i--)maxHeapify(i);
  
  print();
  
  return 0;
}



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

int main() {
  int n, m;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  cin >> m;
  vector<string> t(m);
  rep(i, m) cin >> t[i];

  vector<int> score(n, 0);
  for (int i = 0; i < n; i++) {
    score[i]++;
    for (int j = i + 1; j < n; j++) {
      if (s[i] == s[j]) 
        score[i]++;
    }
    for (int j = 0; j < m; j++) {
      if (s[i] == t[j]) 
        score[i]--;
    }
  }

  int ans = score[0];
  for (int i = 1; i < n; i++) {
    ans = max(ans, score[i]);
  }

  if (ans < 0)
    cout << 0 << endl;
  else cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[1001];
	char t[1001];
	int i, j, k, memo, mcount, slen, len;

	if(scanf("%s\n%s",s,t) < 2)
		return 0;
	len = 0;
	slen = 0;
	while (t[len])
		len++;
	while (s[slen])
		slen++;
	mcount = 0;
	i = 0;
	while (i < slen - len + 1)
	{
		j = 0;
		k = i;
		memo = 0;
		while (t[j])
		{
			if (s[k] == t[j])
				memo++;
			k++;
			j++;
		}
		if (memo > mcount)
			mcount = memo;
		i++;
	}
	printf("%d",len - mcount);
	return 0;
}

Measured memory_bytes: 1672
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<set>

#include<vector>

using namespace std;
int n,c=0,ret=100;
int cnt[200];
char s[100];
int k;
int main(){
	//freopen("a.in","r",stdin);
	scanf("%d%s%d",&n,s+1,&k);
	ret=s[k]-'a';
	for(int i=1;i<=n;i++)if(s[i]-'a'==ret)printf("%c",s[i]);else printf("*");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 4007, T1 = 2000, mod = 1e9 + 7;
int n, ans, inv2 = 500000004;
int x[200007], y[200007];
int f[N][N], fac[10000], invfac[10000], inv[10000];
void add(int &a, int b) {
	a += b;
	if(a >= mod) a -= mod;	
}
int C(int n, int m) {
	return (LL) fac[n] * invfac[n - m] % mod * invfac[m] % mod;	
}
int main() {
#ifndef ONLINE_JUDGE
#endif
	fac[0] = invfac[0] = inv[1] = 1;
	rep(i, 1, 9999) {
		if(i ^ 1) inv[i] = (LL) (mod - mod / i) * inv[mod % i] % mod;
		fac[i] = (LL) fac[i - 1] * i % mod;
		invfac[i] = (LL) invfac[i - 1] * inv[i] % mod;	
	}
	n = gi();
	rep(i, 1, n) x[i] = gi(), y[i] = gi(), f[-x[i] + T1][-y[i] + T1] ++;
	for(int i = -T1; i <= T1; ++i)
	for(int j = -T1; j <= T1; ++j) if(f[i + T1][j + T1]) {
		if(i ^ T1)
			add(f[i + T1 + 1][j + T1], f[i + T1][j + T1]);
		if(j ^ T1)
			add(f[i + T1][j + T1 + 1], f[i + T1][j + T1]);
	}
	rep(i, 1, n) add(ans, (f[x[i] + T1][y[i] + T1] - C(2 * (x[i] + y[i]), 2 * x[i]) + mod) % mod);
	printf("%d\n", (LL) ans * inv2 % mod);
	return 0;
}

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

const string SW = "SW";

int main() {
  int N; cin >> N;
  string s; cin >> s;;
  string ans[] = {"SS", "SW", "WS", "WW"};
  int ok = -1;
  for (int i = 0; i < 4; ++i) {
    for (int j = 1; j < N; ++j) {
      ans[i] += SW[(s[j] == 'o') ^ (ans[i][j - 1] == ans[i][j])];
    }
    if (ans[i][0] == ans[i][N]) {
      if ((s[0] == 'o') ^ (ans[i][0] == 'S') ^ (ans[i][1] == ans[i][N - 1])) ok = i;
    }
  }
  if (ok == -1) {
    cout << -1 << endl;
  } else {
    cout << ans[ok].substr(0, N) << endl;
  }
  return 0;
}


Measured memory_bytes: 1152
x=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
c=input()
for i in range(25):
    if(c==x[i]):
        k=x[i+1]
        break
    else:
        pass
print(k)

Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <math.h>
#define rep(i,l,n) for(int i=(l);i<(n);i++)

int n,r,i,card[55],change[55]={0};

void shuffle(int p,int c){
	rep(i,1,c+1) change[i]=card[p-1+i];
	rep(i,1,p) change[c+i]=card[i];
	rep(i,1,c+p) card[i]=change[i];
}
int main(void){
	int c,p;
	while(1){
		r=0;
		scanf("%d %d",&n,&r);
		//printf("%d %d\n",n,r);
		if(n==0 && r==0) break;
		rep(i,1,n+1) card[i]=n+1-i;
		rep(i,0,r){
			scanf("%d %d",&p,&c);
			//printf("pc %d %d %d\n",r,p,c);
			shuffle(p,c);
		}
		printf("%d\n",card[1]);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
vector<int> a[1000000];
int g[1000000],level[1000000],ances[1000000];
queue<int> q;

void bfs(int v)
{
	g[v]=1;
	level[v]=0;
	int u1=v;
	q.push(v);
	int temp;
	while(!q.empty())
	{
		temp=q.front();
		// cout<<temp<<" "<<level[temp]<<endl;
		q.pop();
		for(auto u: a[temp])
		{
			if(!g[u])
			{
				q.push(u);
				g[u]=1;
				level[u]=level[temp]+1;
				ances[u]=temp;
		//		u1=u;
			}
		}
	}
}

int main()
{
	int n,e,u,v;
	scanf("%d %d",&n,&e);
	for(int i=0;i<e;i++)
	{
		scanf("%d %d",&u,&v);
		a[u].push_back(v);
		a[v].push_back(u);
	}
	//        for(int i=0;i<n;i++)
	//                if(g[i]==0)
	bfs(1);
	int count=0;
	for(int i=1;i<=n;i++)
		if(g[1]==1)
			count++;
	if(count!=n)
		printf("No\n");
	else
	{
		printf("Yes\n");
		for(int i=2;i<=n;i++)
			printf("%d\n",ances[i]);
	}
}



Measured memory_bytes: 32536
'use strict'

function main(input) {
  input = input
    .trim()
    .split(' ')
    .map(Number)
  const a = input[0]
  const b = input[1]
  if (a % 3 === 0 || b % 3 === 0 || (a + b) % 3 === 0) {
    console.log('Possible')
  } else {
    console.log('Impossible')
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    int B[N];
    for(int i=0;i<N;i++) B[i] = A[i];
    sort(A.begin(),A.end(),greater<int>());
    for(int i=0;i<N;i++){
        if(B[i]==A[0]){
            cout << A[1] << endl;
        }
            else cout << A[0] << endl;
    }
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int; 

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int t[1000006];
map<int, int> sum;
map<int, int> diff;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> t[i];
    sum[t[i] + i]++;
    diff[i - t[i]]++;
  }
  LL res = 0;

  for (int i = 1; i <= n; ++i) {
    res += (LL)(diff[i + t[i]]);
    // res += (LL)(sum[t[i] - i]);
  }
  cout << res << endl;
}


Measured memory_bytes: 30056
import collections

s = input()

list_s = [s[i] for i in range(len(s))]
count = collections.Counter(list_s)
count = [v for v in count.values()]

if len(count) != 2:
  print('No')
else:
  if (count[0]==2) and (count[1]==2):
    print('Yes')

Measured memory_bytes: 38256
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define BUFSIZE 1024

char buf[BUFSIZE];
int main()
{
	int n = atoi(fgets(buf, BUFSIZE, stdin)); 
	while (n--) {
		fgets(buf, BUFSIZE, stdin);
		for (int i = 0; i < strlen(buf); ++i) {
			if (strncmp(buf + i, "Hoshino", 7) == 0)
				buf[i+6] = 'a';
		}
		printf(buf);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>
#include <stack>
#include <limits>
#include <list>

using namespace std;
using ll = long long;
const ll INF = numeric_limits<ll>::max();
const int MOD = 1000000007;

void chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
    }
}
void chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
    }
}

int main()
{
    ll N;
    ll K;
    cin >> N >> K;
    vector<ll> heights = vector<ll>(N);
    for (int i = 0; i < N; i++)
    {
        ll h;
        cin >> h;
        heights[i] = h;
    }

    vector<ll> dp = vector<ll>(N, INF);
    dp[0] = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = 1; j <= K; j++)
        {
            if (i - j >= 0)
            {
                chmin(dp[i], dp[i - j] + abs(heights[i] - heights[i - j]));
            }
        }
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>

int main()
{
  int N, Y, result_10000 = -1, result_5000 = -1, result_1000 = -1;
  std::cin >> N >> Y;
  
  for(int i = 0; i <= N; i++)
  {
    for(int j = 0; j <= N - i; j++)
    {
      int k = N - i - j;
      if(Y == (10000*i + 5000*j + 1000*k))
      {
        result_10000 = i;
        result_5000 = j;
        result_1000 = k;
      }
    }
  }
  
  std::cout << result_10000 << " " << result_5000 << " " << result_1000;
  return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;cin >> s;
    for(char c='a';c<='z';++c){
        if(find(s.begin(),s.end(),c)==s.end()){
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    while(true) {
      val in = StdIn.readLine().split(" ").map(_.toInt)
      if(in(0) == 0 && in(1) == 0) return
      for(i <- 1 to in(0)){println("#" * in(1))}
      println()
    }
  }
}

Measured memory_bytes: 45124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll h,m;
	cin>>h>>m;
	vector<ll>ch;
	for(ll i=0;i<h;i++){
		ll now;
		cin>>now;
		ch.push_back(now);
	}
	sort(ch.begin(),ch.end());
	ll cnt=0;
	for(ll i=0;i<h-m;i++){
		cnt+=ch[i];
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 5288
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    
    
    
    cout << 'D';
    REP1(i,dx + 1) cout << 'R';
    REP1(i,dy + 1) cout << 'U';
    REP1(i,dx + 1) cout << 'L';
    REP1(i,dy) cout << 'D';
    REP1(i,dx) cout << 'R';
    REP1(i,dy + 1) cout << 'U';
    REP1(i,dx + 1) cout << 'L';
    REP1(i,dy + 1) cout << 'D';
    cout << 'R' << endl;

    return 0;
}

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

int main(){

	int n;
	while (std::cin >> n, n){

		std::vector<int>taro, hanako;
		bool used[201];

		memset(used, 0, sizeof(used));

		for (int i = 0; i < n; i++){
			int a;
			std::cin >> a;
			taro.push_back(a);

			used[a] = true;
		}

		for (int i = 1; i <= 2 * n; i++){
			if (!used[i])hanako.push_back(i);
		}

		std::sort(taro.begin(), taro.end());
		std::sort(hanako.begin(), hanako.end());

		int table = 0, tscore = 0, hscore = 0;

		while (true){

			if (hanako.size() > 0){
				for (int i = 0; i < taro.size(); i++){
					if (taro[i] > table){
						table = taro[i];
						taro.erase(taro.begin() + i);
						break;
					}
					if (i == taro.size() - 1)table = 0;
				}
			}
			else break;

			if (taro.size() > 0){
				for (int i = 0; i < hanako.size(); i++){
					if (hanako[i] > table){
						table = hanako[i];
						hanako.erase(hanako.begin() + i);
						break;
					}
					if (i == hanako.size() - 1)table = 0;
				}
			}
			else break;
		}

		if (taro.size() == 0)tscore = hanako.size();
		if (hanako.size() == 0)hscore = taro.size();

		std::cout << tscore << std::endl << hscore << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1224