akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m%MOD*COM(m-1,n)%MOD*modinv(m-n,MOD)%MOD;
}
 

int main()
{
  ll n;
  cin >> n;
  printf("%lld",((n-1)/111+1)*111);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class P{
    static void Main(){
        int[] hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        char[][] a = new char[hw[0]][];
        for (int i = 0;i < hw[0];i++)
            a[i] = Console.ReadLine().ToCharArray();
        var i1 = new SortedSet<int>();
        var i2 = new SortedSet<int>();
        for (int i = 0;i < hw[0];i++){
            for (int j = 0;j < hw[1];j++){
                if (a[i][j] == '#'){
                    i1.Add(i);
                    i2.Add(j);
                }
            }
        }
        foreach (var j1 in i1){
            foreach (var j2 in i2){
                Console.Write(a[j1][j2]);
            }
            Console.WriteLine();
        }
    }
}

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

int main(){
    int n;
    int m;
    cin >> n >> m;
    char a[n][n];
    char b[m][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin >> b[i][j];
        }
    
    }

    bool ans = false;

    for(int i=0;i<(n-m)+1;i++){
        for(int j=0;j<(n-m)+1;j++){
            bool sw = true;
            for(int k=0;k<m;k++){
                for(int l=0;l<m;l++){
                    if(a[i+k][j+l] !=b[k][l]){
                        sw = false;
                    }
                }
            }
            if(sw){
                ans = true;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
    cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import static java.lang.System.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(in);

        int n = sc.nextInt();
		
		if(n%2 == 0){
			out.println((n-2)*(n/2));
			for(int i=1; i<n; i++) {
				for(int j=i+1; j<=n; j++) {
					if(i+j == n+1) continue;
					out.println(i + " " + j);
				}
			}
		}
		else{
			out.println((n-2)*(n/2)+(n-1)/2);
			for(int i=1; i<n; i++) {
				for(int j=i+1; j<=n; j++) {
					if(i+j == n) continue;
					out.println(i + " " + j);
				}
			}		
		}
	}
}


Measured memory_bytes: 23764
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        String x = scanner.nextLine();
        int r = 3;
        int s = 0;

        for(int i = 0;i < r;i++){
            if(x.charAt(i) == '1'){
                s++;
            }
        }
        System.out.println(s);
    }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std; 
int main()
{
	int a,h=0,sum=0,n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a>=sum)
		{
			sum=a;
			h++;
		}
	}
	cout<<h<<endl;
	return 0;
}

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

int main(){
  int N; cin >> N;
  if(N==1){
    cout << 1 << endl;
    return 0;
  }
  string S; cin >> S;
  int ans=0;
  S+='0';
  for(int i=1;i<=N;i++){
    if(S[i]!=S[i-1]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> a(n); for (auto&& e : a) cin >> e;
  V<> b(m), c(m); for (int i = 0; i < m; ++i) cin >> b[i] >> c[i];
  V<> idx(m);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int i, int j) { return c[i] > c[j]; });
  int r = n;
  multiset<int> se(begin(a), end(a));
  for (int i : idx) {
    int t = min(r, b[i]);
    for (int j = 0; j < t; ++j) se.insert(c[i]);
    r -= t;
  }
  while ((int)se.size() > n) {
    se.erase(begin(se));
  }
  lint res = 0;
  for (int e : se) res += e;
  cout << res << '\n';
}

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

int main()
{
    int n;
    while(cin >> n && n) {
        int a = 0, b = 0, c, d;
        for(int i=0; i < n; ++i) {
            cin >> c >> d;
            if (c > d) a += c+d;
            else if (d > c) b += c+d;
            else a += c, b += d;
        }

        printf("%d %d\n", a, b);
    }

    return 0;
}

Measured memory_bytes: 1140
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

while True:
    n,r = inpl()
    if n == 0:
        break
    else:
        yama = [n-i for i in range(n)]
        for _ in range(r):
            p,c = inpl()
            next_yama = yama[p-1:p-1+c] + yama[:p-1] + yama[p-1+c:]
            yama = next_yama
        print(yama[0])



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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using namespace std;

int main(){
    int N;
    int A;
    map<int,int> count;
    cin>>N;

    rep(i,N) {
        cin>>A;
        count[A]++;
    }

    bool check=true;
    for (auto i = count.begin(); i != count.end(); i++)
    {
        if (i->second>=2)
        {
            check=false;
        }
        
    }
    
    check?cout<<"YES"<<endl:cout<<"NO"<<endl;

    
    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);

  char S[n+1];
  scanf("%s",S);

  int count=0,i,j,min;
  
  for(i=0;i<n;i++){
    if(S[i]=='.')count++;
  }
  //  printf("%d\n",count);
  if(S[0]=='.'){count--; min=count;}
  else {min=count; count++;}
  //  printf("%d min:%d\n",count,min);

  
  for(i=1;i<n;i++){
    if(S[i]=='.')count--;
    else count++;
    if(count<min){min=count;}
    //  printf("%d\n",count);
  }
  printf("%d\n",min);
}





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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */
int main(){
    lint h, w; cin >> h >> w;
    if(h % 3 == 0 || w % 3 == 0 || h * 3 == w * 2 || h * 2 == w * 3){
        out(0); return 0;
    }
    lint res = INF;
    repn(k, w - 1){
        lint m = min(h*(w-k), min((h+1)/2*k, h/2*k));
        lint M = max(h*(w-k), max((h+1)/2*k, h/2*k));
        res = min(res, M - m);
    }
    repn(k, h - 1){
        lint m = min(w*(h-k), min((w+1)/2*k, w/2*k));
        lint M = max(w*(h-k), max((w+1)/2*k, w/2*k));
        res = min(res, M - m);
    }
    res = min(min(h, w), res);
    out(res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef pair<ll,ll> pll;

int x,y;
vector<int> h, v;
int end_r;

int main(void)
{
    string s;
    cin >> s;
    cin >> x >> y;

    int n = s.size();
    int hv = 0;
    int prev_t = 0;
    REP(i, n){
        if(s[i]=='T'){
            if(!hv) h.pb(i-prev_t);
            else v.pb(i-prev_t);
            hv++;hv %= 2;
            prev_t = i+1;
        }
    }
    if(prev_t != n){
        if(!hv) h.pb(n-prev_t);
        else v.pb(n-prev_t);
    }
    
    int nh = h.size(), nv = v.size();

    vector<set<int>> vx(nh);
    vx[0].insert(h[0]);
    Rep(i,1,nh){
        REPA(cx, vx[i-1]){
            vx[i].insert(cx+h[i]);
            vx[i].insert(cx-h[i]);
        }
    }
    if(vx[nh-1].find(x)==vx[nh-1].end()){
        pr("No");
        return 0;
    }

    if(nv==0){
        pr("Yes");
        return 0;
    }

    vector<set<int>> vy(nv);
    vy[0].insert(v[0]);
    vy[0].insert(-v[0]);
    Rep(i,1,nv){
        REPA(cx, vy[i-1]){
            vy[i].insert(cx+v[i]);
            vy[i].insert(cx-v[i]);
        }
    }
    if(vy[nv-1].find(y)==vy[nv-1].end()){
        pr("No");
        return 0;
    }


    pr("Yes");
}

Measured memory_bytes: 193988
<?php
$input = explode(' ', trim(fgets(STDIN)));
$x_cnt = $input[0];
$y_cnt = $input[1];
$table = [];
$is_can = true;
for ($i=1; $i <= $y_cnt; $i++) {
  $tmp_arr = str_split(trim(fgets(STDIN)));
  foreach ($tmp_arr as $key => $value) {
    $table[$i][$key+1] = $value;
  }
}
for ($i=1; $i <= $y_cnt; $i++) {
  for ($j=1; $j <= $x_cnt; $j++) {
    if ($table[$i][$j] == '#' && checkBlackGrid($i, $j+1) && checkBlackGrid($i, $j-1) && checkBlackGrid($i+1, $j) && checkBlackGrid($i-1, $j)) {
      $is_can = false;
    }
  }
}
echo ($is_can ? 'Yes' : 'No')."\n";

function checkBlackGrid($x, $y) {
  global $table;
  return isset($table[$x][$y]) && $table[$x][$y] != '#';
}


Measured memory_bytes: 4340
from collections import Counter
from math import factorial


def nc2(n):
    return factorial(n) // 2 // factorial(n - 2)


N = int(input())
counter = Counter()

for _ in range(N):
    s = input()
    counter[''.join(sorted(s))] += 1

print(sum([nc2(count) for count in counter.values() if count > 1]))


Measured memory_bytes: 18144
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int len = S.length;
        int[] cnt = new int[26];
        for(char c : S) {
            cnt[c - 'a']++;
        }

        int odd = 0, even = 0;
        for(int n : cnt) {
            if(n % 2 == 0) even++;
            else odd++;
        }
        if(len % 2 == 0 && odd == 0) {
            long k = fact(len / 2);
            for(int n : cnt) {
                k /= (fact(n / 2));
            }
            System.out.println(k);

        }
        else if(len % 2 == 1 && odd == 1) {
            long k = fact(len / 2);
            for(int n : cnt) {
                k /= (fact(n / 2));
            }
            System.out.println(k);
        }
        else {
            System.out.println(0);
        }
    }

    static long fact(int n) {
        return n < 2 ? 1 : n * fact(n - 1);
    }
}

Measured memory_bytes: 17312
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<b;i++)
#define f(i,n) for(int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define vint vector<int>
#define pb(a) push_back(a);
#define bug(x) cout<<#x<<" = "<<x<<"\n";
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)


int main(){
	fastio;
	int n,k; cin>>n>>k;
	unordered_set<int> s;
	f(i,n){int t; cin>>t; s.insert(t);}
	vint dp(k+1);
	//dp states represent the optimal x to be selected from array A, in order to win. or -2 if it is impossible to win.
	// so if dp[k] = -2, impossible to win for the current player
	// else dp[k] = ai, for some ai belonging to Array A, and represents the optimal number to be selected.
	f(i,k+1){
		if(i==0){dp[i]=-2;}
		else if(s.find(i)!=s.end()){
			dp[i]=i;
		}
		else{
			bool possible=false;
			unordered_set<int>::iterator x=s.begin();
			for(;x!=s.end();x++){
				if((*x)<=i && dp[i-(*x)]==-2){
					dp[i]=(*x);
					possible = true;
				}
			}
			if(possible==false){
				dp[i]=-2;
			}
		}
	}

	if(dp[k]==-2){cout<<"Second\n";}
	else{cout<<"First\n";}
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  string A;
  map<string,int> S;
  for(int i=0;i<N;i++)
  {
    cin >> A;
    if(S.count(A))
    {
      S.at(A)++;
    }
    else{
      S[A]=1;
    }
  }
  int mak = 0;
  vector<string> ans;
  for(auto i=S.begin();i!=S.end();i++)
  {
    if(mak<i->second)mak=i->second;
  }
  for(auto i=S.begin();i!=S.end();i++)
  {
    if(mak==i->second)ans.push_back(i->first);
  }
  sort(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++){
    cout << ans.at(i) << endl;
  }
  
}

Measured memory_bytes: 26868
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        for (int i = A; i <= B; i++) {
            if (i % K == 0) {
                System.out.println("OK");
                System.exit(0);
            }
        }
        System.out.println("NG");
        sc.close();
    }
}

Measured memory_bytes: 35876
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,M,Q;
    cin >> N >> M >> Q;
    ll L,R;
    ll p,q;
    ll i,j;
    ll sta[N][N],ans[N][N];
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
        sta[i][j]=0;
      }
    }
    for(i=0;i<M;i++){
      cin >> L >> R;
      sta[L-1][R-1]++;
    }
    for(i=0;i<N;i++){
      for(j=1;j<N;j++){
        sta[i][j]+=sta[i][j-1];
      }
    }
    for(j=N-1;j>=0;j--){
      for(i=j-1;i>=0;i--){
        sta[i][j]+=sta[i+1][j];
      }
    }
    for(i=0;i<Q;i++){
      cin >> p >> q;
      cout <<sta[p-1][q-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 2816
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<int,int> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;


int main(){
    int h,a;
    cin >> h >> a;
    int ans = (h+a-1)/a;
    cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, x, l, sum = 0, ans = 1;
	scanf("%d %d", &n, &x);
	while (n--) {
		scanf("%d", &l);
		sum += l;
		if (sum > x)
			break;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

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

template<typename T> inline void chmax(T& t, T f){if(t < f)t = f;}

int main(){
    int n;
    while(cin >> n, n){
        vector<pair<int, int> > events;
        events.reserve(n<<1);
        rep(i, n){
            int h1, m1, s1, h2, m2, s2;
            char d;
            cin >> h1 >> d >> m1 >> d >> s1 >> h2 >> d >> m2 >> d >> s2;
            events.emplace_back(3600 * h1 + 60 * m1 + s1, 1);
            events.emplace_back(3600 * h2 + 60 * m2 + s2, -1);
        }
        sort(all(events));
        int ans = 1, now = 0;
        rep(i, n<<1)chmax(ans, now += events[i].second);
        cout << ans << '\n';
    }
    return 0;
}

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


typedef struct{
  int i;
  int cnt;
} Data;

int main(){
  int n;
  cin >> n;
  vector<int> graph[100010];

  int a,b;
  for(int i = 0;i < n-1;i++){
    cin >> a >> b;
    a--; b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  int memo[100010] = {};
  memo[0] = 1;
  memo[n-1] = 2;


  queue<Data> que1,que2;
  Data d;
  d.i = 0;
  d.cnt = 0;
  que1.push(d);
  d.i = n-1;
  que2.push(d);
  int c = 0;
  while(!que1.empty() || !que2.empty()){
    while(!que1.empty()){
      Data tmp = que1.front();
      if(tmp.cnt != c){
        break;
      }
      que1.pop();
      if(memo[tmp.i] == 0 || c == 0){
      memo[tmp.i] = 1;
      for(int i = 0;i < graph[tmp.i].size();i++){
        if(memo[graph[tmp.i][i]] == 0){
          Data t2;
          t2.i = graph[tmp.i][i];
          t2.cnt = c+1;
          que1.push(t2);
        }
      }
      }
    }


    while(!que2.empty()){
      Data tmp = que2.front();
      if(tmp.cnt != c){
        break;
      }
      que2.pop();
      if(memo[tmp.i] == 0 || c == 0){
        memo[tmp.i] = 2;
        tmp.cnt;
        for(int i = 0;i < graph[tmp.i].size();i++){
          if(memo[graph[tmp.i][i]] == 0){
            Data t2;
            t2.i = graph[tmp.i][i];
            que2.push(t2);
          }
        }
      }
    }
    c++;
  }

  a = b = 0;

  for(int i = 0;i < n;i++){
    if(memo[i] == 1){
      a++;
    }else if(memo[i] == 2){
      b++;
    }
  }

  if(a > b){
    cout << "Fennec" << endl;
  }else{
    cout << "Snuke" << endl;
  }

  return 0;
}

Measured memory_bytes: 6400
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    double r;
    scanf("%lf", &r);
    
    double A = M_PI*r*r;
    double L = M_PI*2*r;
    
    printf("%f %f\n", A, L);
    
    return 0;
}


Measured memory_bytes: 2028
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int u = scanner.nextInt() - 1;
    int v = scanner.nextInt() - 1;

    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node(i);
    for (int i = 0; i < N - 1; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nodes[a].adjacent.add(nodes[b]);
      nodes[b].adjacent.add(nodes[a]);
    }

    dfs1(nodes[v], null);
    dfs2(nodes[v], null);

    Node a = nodes[u];
    int l = 0;
    while (a != nodes[v]) {
      a = a.prev;
      l++;
    }
    int res = l - 1;
    a = nodes[u].prev;
    for (int i = 1; i <= (l - 1) / 2; i++) {
      res = Math.max(res, a.depth + l - i - 1);
      a = a.prev;
    }
    System.out.println(res);
  }

  private static void dfs1(Node node, Node parent) {
    node.depth = 0;
    for (Node a : node.adjacent) {
      if (a != parent) {
        dfs1(a, node);
        node.depth = Math.max(node.depth, a.depth + 1);
      }
    }
  }

  private static void dfs2(Node node, Node parent) {
    node.prev = parent;
    for (Node a : node.adjacent) {
      if (a != parent) dfs2(a, node);
    }
  }

  private static class Node {
    private final int id;
    private Node prev;
    private int depth = -1;

    public Node(int id) {
      this.id = id;
    }
    private final List<Node> adjacent = new ArrayList<>();
  }
}


Measured memory_bytes: 112408
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let s: Vec<&str> = line.trim().split(",").collect();
    println!("{} {} {}", s[0], s[1], s[2]);
}


Measured memory_bytes: 4352
n,h,*L=map(int,open(x:=0).read().split());a=max(L[::2]);B=sorted([l for l in L[1::2] if l>a])
for b in B[::-1]:
  h-=b
  x+=1
  if h<1:break
print(x-min(0,-h//a))

Measured memory_bytes: 31916
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll N,A,B,C,D;
int main(){
	cin>>N>>A>>B>>C>>D;
	ll X = B-A;
	N--;
	bool ok = 0;
	rep(i,N+1){
		ll L = C*i + -D*(N-i);
		ll R = D*i + -C*(N-i);
		if(L<=X&&X<=R) ok = 1;
	}
	if(ok) puts("YES");
	else puts("NO");
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int s,i,j,k,num;
    char t[9];
    scanf("%d",&num);
    for (i=0; i<num; i++) {
        scanf("%d",&s);
        printf("Case %d:\n",i+1);
        for (j=0; j<10; j++) {
        	s=s*s;
            sprintf(t,"%08d",s);
            s=(t[5]-'0')+(t[4]-'0')*10+(t[3]-'0')*100+(t[2]-'0')*1000;
            printf("%d\n",s);
        }
    }
    return 0;
}

Measured memory_bytes: 616
local mod = 1000000007

local function bmul(x, y)
  return (x * y) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = pow // 2
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local n, k = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local s, t = 0, 0
for i = 1, n do
  local v = 0
  for j = 1, i - 1 do
    if a[i] < a[j] then
      v = v + 1
    end
  end
  s = badd(s, v)
  for j = i + 1, n do
    if a[i] < a[j] then
      v = v + 1
    end
  end
  t = badd(t, v)
end
local ret = bmul(k, s)
local z = bmul(bmul(k - 1, k), 500000004)
ret = badd(ret, bmul(z, t))
print(ret)


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

using namespace std;

int main() {
	int n;
	int total;
	int ave;

	while (1) {
		int tmp;
		vector<int> v;
		cin >> n;
		if (n == 0)break;

		for (int i = 0; i<n; i++) {
			cin >> tmp;
			v.push_back(tmp);
		}

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

		total = 0;
		for (int i = 0; i<n; i++) {
			total += v[i];
		}

		total = total - (v[0] + v[n - 1]);
		ave = total / (n - 2);

		cout << ave << endl;

		
	}
}

Measured memory_bytes: 3028
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	cout << "? ";
	for (int i = 1; i <= N; i++) cout << i << " ";
	cout << endl;

	string s_0;
	cin >> s_0;

	auto flip = [](string &s) {

		if (s == "Red") return "Blue";
		if (s == "Blue") return "Red";

		exit(-1);

	};

	string s_N = flip(s_0);

	auto binary_search = [&]() {

		auto ok = 1;
		auto ng = N + 1;

		while (abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;

			cout << "?";
			for (int i = mid; i < mid + N; i++) cout << " " << i;
			cout << endl;

			string s_mid;
			cin >> s_mid;

			if (s_mid == s_0) ok = mid;
			else ng = mid;

		}

		return ok;
	};

	int lb = binary_search();

	vector<char> ans(2 * N);
	ans[lb - 1] = s_0[0];
	ans[lb + N - 1] = s_N[0];

	for (int i = 1; i < lb; i++) {

		cout << "? " << i;
		for (int j = lb + 1; j < lb + N; j++) cout << " " << j;
		cout << endl;

		string s_i;
		cin >> s_i;

		ans[i - 1] = s_i[0];

	}

	for (int i = lb + N + 1; i <= 2 * N; i++) {

		cout << "? " << i;
		for (int j = lb + 1; j < lb + N; j++) cout << " " << j;
		cout << endl;

		string s_i;
		cin >> s_i;

		ans[i - 1] = s_i[0];

	}

	for (int i = lb + 1; i < lb + N; i++) {

		cout << "? " << i;
		for (int j = 1; j < lb; j++) cout << " " << j;
		for (int j = lb + N + 1; j <= 2 * N; j++) cout << " " << j;
		cout << endl;

		string s_i;
		cin >> s_i;

		ans[i - 1] = s_i[0];

	}

	cout << "! ";
	for (int i = 0; i < 2 * N; i++) cout << ans[i];
	cout << endl;

	return 0;
}

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

int main() {

    int n, k;
    int p[1010];

    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        scanf("%d", &p[i]);
    }

    sort(p,p+n);
    
    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans+=p[i];
    }

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

Measured memory_bytes: 3664
n=int(input())
s=input()
# どこを境目として撮るかということを尺取法で考えてみる！
lists=[0]*(n+1)
count=0
for  _ in range(n):
    if s[_]==".":
        count+=1
lists[0]=count
for i in range(1,n+1):
    #それぞれのインデックスについてそこが#か.に等しいのかをチェックする
    if s[i-1]!=".":
        count+=1
        lists[i]=count
    else:
        count-=1
        lists[i]=count
print(min(lists))    

Measured memory_bytes: 11240
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		if((g%2 == 0 && b%4 == 0) || (g%2 == 1 && b%4 == 2)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n<3200)
	{
		cout<<"red";	
	}
	else
	{
		cout<<s;
	}
	return 0;//198B;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	//public static int N,K,a=-1;
	public static String ans="",s;

	//public static int a[][]=new int[5][5];

	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int x=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			x-=a[i];
		}
		Arrays.sort(a);
		int ans=n;
		for(;;) {
			x-=a[0];
			if(x<0)break;
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <stack>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;

char str[10000];
stack <int> st;

int main(void) {
    while (scanf("%s", str) != EOF) {
        int a, b;
        if (str[0] == '+') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a + b);
        }
        else if (str[0] == '-') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(b - a);
        }
        else if (str[0] == '*') {
            a = st.top(); st.pop();
            b = st.top(); st.pop();
            st.push(a * b);
        }
        else {
            int s;
            s = atoi(str);
            st.push(s);
        }
    }
    cout << st.top() << endl;
    return 0;
}



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

int main()
{
	double x, y, a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		y = (c*d - a*f) / (b*d - a*e);
		x = (c - b*y) / a;
		cout << fixed << setprecision(3) << x << ' ' << y << '\n';
	}
}

Measured memory_bytes: 3220
/*2019/10/19 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return -1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return 1;}
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return 1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return -1;}
int main(){
    ll n;
    ll ans=0;
    ll now=0;
    int flg=0;
    scanf("%lld",&n);
    ll x,r;
    ll min=__LONG_LONG_MAX__;
    for(ll i=1;i<=1000000;i++){
        if(n<i)break;
        x=n/i;
        r=n%i;
        if(r==0){
            if(i-1+x-1<min){
                min=i-1+x-1;
            }
        }
    }
    printf("%lld\n",min);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(int i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
vector<ll> v1,v2;
vector<ll> ::iterator it;
int main(){
    fast;
    ll n,m,q,ele;
    cin>>n>>m>>q;
    f(i,0,n){
        cin>>ele;
        v1.pb(ele);
    }
    f(i,0,m){
        cin>>ele;
        v2.pb(ele);
    }
    while(q--){
        cin>>ele;
        ll shl=1e11,shr=1e11;
        ll tpl=1e11,tpr=1e11;
        it = lower_bound(all(v1),ele);
        if(it!=v1.end())shr=*it;
        if(it!=v1.begin()){
            it--;
            shl=*it;
        }
        it = lower_bound(all(v2),ele);
        if(it!=v2.end())tpr=*it;
        if(it!=v2.begin()){
            it--;
            tpl=*it;
        }
        //cout<<shl<<" "<<shr<<" "<<tpl<< " "<<tpr<<endl;
        ll ans=LONG_LONG_MAX;
        if(tpl!=1e11 && shr!=1e11)
            ans=min(ans,min(ele-tpl+shr-tpl,shr-ele+shr-tpl));
        if(tpr!=1e11 && shl!=1e11)
            ans=min(ans,min(ele-shl+tpr-shl,tpr-ele+tpr-shl));
        if(shl!=1e11 && tpl!=1e11)
            ans=min(ans,ele-min(shl,tpl));
        if(shr!=1e11 && tpr!=1e11)
            ans=min(ans,max(shr,tpr)-ele);
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 3060
N=int(input())
S=list(str(input()))
hyp=[["S","S"],["S","W"],["W","S"],["W","W"]]
flag=0
for i in range(4):
    if flag==2:
        break
    flag=0
    ans=[]
    ans.append(hyp[i][0])
    ans.append(hyp[i][1])
    for j in range(1,N+1):
        if j>=N-1:
            if j==N:
                j=0
                t=1
            else:
                t=0
            
            if ans[j]=="S":
                if S[j]=="o":
                    if ans[j-1]=="S":
                        if ans[t]=="S":
                            flag+=1
                    else:
                        if ans[t]=="W":
                            flag+=1
                else:
                    if ans[j-1]=="S":
                        if ans[t]=="W":
                            flag+=1
                    else:
                        if ans[t]=="S":
                            flag+=1
            else:
                if S[j]=="o":
                    if ans[j-1]=="S":
                        if ans[t]=="W":
                            flag+=1
                    else:
                        if ans[t]=="S":
                            flag+=1
                else:
                    if ans[j-1]=="S":
                        if ans[t]=="S":
                            flag+=1
                    else:
                        if ans[t]=="W":
                            flag+=1
                            
        else:
            if ans[j]=="S":
                if S[j]=="o":
                    if ans[j-1]=="S":
                        ans.append("S")
                    else:
                        ans.append("W")
                else:
                    if ans[j-1]=="S":
                        ans.append("W")
                    else:
                        ans.append("S")
            else:
                if S[j]=="o":
                    if ans[j-1]=="S":
                        ans.append("W")
                    else:
                        ans.append("S")
                else:
                    if ans[j-1]=="S":
                        ans.append("S")
                    else:
                        ans.append("W")

if flag!=2:
    print(-1)
else:
    for i in range(len(ans)):
        if i!=len(ans)-1:
            print(ans[i],end="")
        else:
            print(ans[i])
            

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

int main () {
    int n ;
    cin >> n ;
    bool flag = false ;
    if(n % 10 == 7){
        flag = true ;
    }
    n = n / 10 ; 
    if(n % 10 == 7){
        flag = true ;
    }
    n = n / 10 ;
    if(n == 7){
        flag = true ;
    }

    if(flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0 ;
}

 


Measured memory_bytes: 3620
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,i,j,z;
            cin>>n;
            z=n;
            vector<ll> v;
            ll x=sqrt(n);
            int ct=0;
            for(i=2;i<=x;++i)
            {
                if(z%i==0)
                {
                    ct=0;
                    while(z%i==0)
                    {
                        ++ct;
                        z=z/i;
                    }
                    v.pb(ct);
                }
            }
            if(z>1)
            {
                v.pb(1);
            }
            int ans=0;
            for(auto it:v)
            {
                for(i=1;i<=n;++i)
                {
                    if(i*(i+1)/2 > it)
                        break;
                }
                ans=ans+i-1;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

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

int main(){
	int n;cin>>n;
	ll t[n];
	rep(i,n) cin>>t[i];

	ll lcm=1;
	rep(i,n){
		lcm=lcm/gcd(lcm,t[i])*t[i];
		//cout<<lcm<<"\n";
	}

	cout<<lcm<<"\n";
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var input = Reads();
            var a = input[0];
            var b = input[1];
            var k = input[2];
            if (b - a + 1 > 2 * k)
            {
                for (long i = a; i < a + k; i++)
                {
                    Console.WriteLine(i);
                }
                for (long i = b - k + 1; i <= b; i++)
                {
                    Console.WriteLine(i);
                }
            }
            else
            {
                for (long i = a; i <=b; i++)
                {
                    Console.WriteLine(i);
                }
            }



            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

ll mod_pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main()
{
  ll N; cin>>N;
  vector<ll> C(N); rep(i,N) cin>>C[i];
  sort(C.rbegin(),C.rend());
  
  ll ans=0;
  rep(i,N){
    ans+=C[i]%MOD*(i+2)%MOD;
    ans%=MOD;
  }
  ans=ans*mod_pow(4,N-1)%MOD;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4840
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        String O = sc.nextLine();
        String E = sc.nextLine();
        StringBuilder sb = new StringBuilder();
        for (int i = 0, oi = 0, ei = 0; i < O.length() + E.length(); ++i) {
            if (i % 2 == 1) {
                sb.append(E.charAt(ei));
                ++ei;
            } else {
                sb.append(O.charAt(oi));
                ++oi;
            }
        }
        _out.println(sb);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21844
from sys import stdin
ans = 'Yes'
di = {}
di['b'] = 1
di['d'] = -1
di['p'] = 2
di['q'] = -2
a = stdin.readline().strip()
l = len(a)
if l%2:
 ans = 'No'
else:
 for i in xrange(l/2):
  if di[a[i]] + di[a[l-1-i]]:
   ans = 'No'
print ans

Measured memory_bytes: 2820
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <stack> 
#include <algorithm>
using namespace std;
const int num = 25, NIL = -1;
struct Node {
	int l, r, p, si;
};
Node T[num];
int Dp[num], Dg[num], H[num];
inline void getDepth(int u, int p) {
	Dp[u] = p;
	if (T[u].l != NIL) 
		getDepth(T[u].l, p + 1);
	if (T[u].r != NIL)
		getDepth(T[u].r, p + 1);
	
}
inline void getDegree(int u) {
	Dg[u] = 0;
	if (T[u].l != NIL) Dg[u]++;
	if (T[u].r != NIL) Dg[u]++;
}
inline int getHeight(int u) {
	int h1 = 0, h2 = 0;
	if (T[u].l != NIL) h1 = 1 + getHeight(T[u].l);
	if (T[u].r != NIL) h2 = 1 + getHeight(T[u].r);
	H[u] = max(h1, h2);
	return H[u];
}
int main() {
	int n, rootnum, h = 0, u;
	cin >> n;
	for (int i = 0; i < n; i++)
		T[i].l = T[i].r = T[i].p = T[i].si = H[i] =  NIL;
	for (int i = 0; i < n; i++) {
		cin >> u;
		cin >> T[u].l >> T[u].r;
	}
	for (int i = 0; i < n; i++) {

		T[T[i].l].si = T[i].r;
		T[T[i].r].si = T[i].l;
		T[T[i].l].p = i;
		T[T[i].r].p = i;
	}
	for (int i = 0; i < n; i++)
		if (T[i].p == NIL) rootnum = i;
	getDepth(rootnum, 0);
	for (int i = 0; i < n; i++)
		getDegree(i);
	/*for (int i = 0; i < n; i++) {
		if (T[i].l == NIL && T[i].r == NIL)H[i] = h;
	}
	for (int j = 0; j < 13; j++) {
		for (int i = 0; i < n; i++) {
			if (H[i] != 0 && H[T[i].l] != NIL && H[T[i].r] != NIL)
				H[i] = 1 + max(H[T[i].l], H[T[i].r]);
		}
		if (H[rootnum] != NIL) break;
	}*/
	getHeight(rootnum);
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << T[i].p << ", sibling = " << T[i].si << ", degree = " << Dg[i] << ", depth = " << Dp[i] << ", height = " << H[i] << ", ";
		if (T[i].p == NIL) cout << "root" << endl;
		else if (T[i].l == NIL && T[i].r == NIL) cout << "leaf" << endl;
		else cout << "internal node" << endl;
	}

}

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

int main(){
    int n;
    cin >> n;
    map <int,int> table;
    vector <int> kind(0);

    rep(i,n){
        int a;
        cin >> a;
        if(table.count(a)){
            table.at(a)++;
        }
        else{
            table[a] = 1;
            kind.push_back(a);
        }
    }

    int ans;
    for(int x:kind){
        if(table.at(x) <  x){
            ans += table.at(x);
        }
        if(table.at(x) > x){
            ans += (table.at(x)-x);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5112
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
using namespace std;
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define sc(a) cin>>a
#define pr(a) cout<<a
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)<=(a);(i)--)
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
///////////////////////////////////////////////////////////
int main(){
 ll x,y,i;
 sc(x);sc(y);
 rep(i,1,llmax){if(x*llpow(2,i)>y)break;}
 pr(i);
return 0;}

Measured memory_bytes: 256