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

vector<long long> divisor (long long N) {
  vector<long long> res;
  for (long i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      res.push_back(i);
      if (i != N / i) {
        res.push_back(N / i);
      }
    }
  }
  return res;
}

long long digit(long long a) {
  long long result = 0;
  while (a > 0) {
    result++;
    a /= 10;
  }
  return result;
}

int main() {

  long long N;
  cin >> N;

  vector<long long> d = divisor(N);

  long long answer = 1LL<<60;

  for (int i = 0; i < d.size(); i++) {
    long long a_ = N / d[i];
    long long b_ = digit(d[i]);
    long long c_ = digit(a_);
    long long d_ = max(b_, c_);
    answer = min(d_, answer);
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MOD 1000000007
typedef long long ll;
int main(){
  int H,W,K;
  cin>>H>>W>>K;
  vector<vector<ll>> dp(H+1,vector<ll>(W+1,0));
  int F[9];
  F[0] = F[1] =  1;
  for(int i=2;i<=W;i++)
    F[i] = F[i-2] + F[i-1];
  dp[0][1] = 1;
  for(int i=0;i<H;i++){
    for(int j=1;j<=W;j++){
      if(j-1 >= 1){
        dp[i+1][j-1] += F[j-2] * F[W-j] * dp[i][j];
        dp[i+1][j-1] %= MOD;
      }
      dp[i+1][j] += F[j-1] * F[W-j] * dp[i][j];
      dp[i+1][j] %= MOD;
      if(j+1 <= W){
        dp[i+1][j+1] += F[j-1] * F[W-j-1] * dp[i][j];
        dp[i+1][j+1] %= MOD;
      }
    }
  }
  cout<<dp[H][K]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

vector<ll> calc_divisor(ll n) {
  vector<ll> res;
  for (ll i = 1LL; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      ll j = n / i;
      if (i != j) {
        res.push_back(j);
      }
    }
  }
  sort(res.begin(), res.end());
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  
  ll ans = 1;
  vector<ll> res = calc_divisor(m);
  for (auto d : res) {
    if (d * n <= m) {
      ans = max(ans, d);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
 
 
int main () {
    int N;
    cin >> N;

    int num = N;
    int sum =0;
    while( num > 0){
        sum += (num % 10);
        num /= 10 ;
    }

    if((N % sum) == 0)cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc057_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[,] student = new int[a[0], 2];
            for (int i = 0; i < a[0]; i++)
            {
                int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
                student[i, 0] = b[0];
                student[i, 1] = b[1];
            }
            int[,] check = new int[a[1], 2];
            for (int i = 0; i < a[1]; i++)
            {
                int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
                check[i, 0] = c[0];
                check[i, 1] = c[1];
            }
            for (int i = 0; i < a[0]; i++)
            {
                int min = int.MaxValue;
                int minpoint = -1;
                for (int j = 0; j < a[1]; j++)
                {
                    int now = Math.Abs(student[i, 0] - check[j, 0]) + Math.Abs(student[i, 1] - check[j, 1]);
                    if (min > now)
                    {
                        min = now;
                        minpoint = j;
                    }
                }
                Console.WriteLine(minpoint + 1);
            }
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h, w; int n; cin >> h >> w >> n;
  vector<ll> A(n), B(n);
  rep(i, n) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
  }
  map<pair<ll, ll>, int> mp;
  rep(i, n) {
    for(int j=-1; j<=1; j++) {
      for(int k=-1; k<=1; k++) {
        int a = A[i]+j, b = B[i]+k;
        if(a<=0 || a>=h-1 || b<=0 || b>=w-1) continue;
        mp[{a, b}]++;
      }
    }
  }
  vector<ll> ans(10);
  for(auto ele: mp) {
    ans[ele.second]++;
  }
  ans[0] = (h-2)*(w-2) - accumulate(begin(ans)+1, end(ans), 0LL);
  rep(i, 10) cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 60968
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    count = 0
    x = [True]*n

    for i in range(m):
        y = list(map(int, input().split()))

        if h[y[0]-1] > h[y[1]-1]:
            x[y[1]-1] = False
        if h[y[1]-1] > h[y[0]-1]:
            x[y[0]-1] = False

        if h[y[1]-1] == h[y[0]-1]:
            x[y[0]-1] = False
            x[y[1]-1] = False

        # print(x)

    for i in x:
        if i:
            count += 1
    # print(x)
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 998244353
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

ll inv(ll x){
    // MOD=10e9+7
	ll n=MOD-2,a=1;
	while(n>0){
		if(n%2) a=a*x%MOD;
		x=x*x%MOD;
		n=n/2;
	}
	return a;
}

ll Comb(ll n,ll m){
    ll ans = 1; 
    for(int i=0;i < m; i++){
        ans *= ((n-i)*inv(i+1)) % MOD;
        ans %= MOD;
    }
    while(ans<0)ans+=MOD;
    return ans;
}

ll PowMod(ll N,ll P,ll M){
    ll ans = 1;
    while(P >= 1){
        if(P % 2)ans = ans * N % M;
        N = N*N %M;
        P /= 2;
    }
    ans %= M;
    return ans;
}

int main(){
    ll N,S;
    cin>>N>>S;
    v A(N);
    rep(i,0,N)cin>>A[i];
    v dp(3001);
    dp[0] = 1;
    rep(i,0,N){
        v new_dp(3001);
        rep(j,0,3001){
            new_dp[j] = (dp[j]*2)%MOD;
        }
        rep(j,0,3001){
            if(A[i] + j <=3000){
                new_dp[A[i] + j] += dp[j];
                new_dp[A[i] + j]%=MOD;
            }
        }
        dp = new_dp;
    }
    while(dp[S]<0)dp[S]+=MOD;
    cout<<dp[S]%MOD;
    return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define int long long

using namespace std;

#define forn(i, a, b) for(int i = a; i <= b; i++)

const double EPS = 1e-9;
const double pi = acos( -1. );
const int mod = 1e9 + 7;
int MAX = -1e18;
int MIN = 1e18;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))

int mul_mod(int a, int b, int mod)
{
    int res = 0;
    while( b )
    {
        if( b & 1 )
            res = (res + a) % mod;
        a = (a + a) % mod;
        b >>= 1;
    }
    return res;
}

int binpow(int a, int b, int mod)
{
    if(b==0) return 1;
    if(b%2==1) return mul_mod(a,binpow(a,b-1,mod),mod);
    else
    {
        int d=binpow(a, b/2, mod)%mod;
        return 1ll * mul_mod(d, d, mod) % mod;
    }
}

inline int GCD_E ( int a, int b, int & x, int & y )
{
    if ( !a )
    {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = GCD_E ( b % a, a, x1, y1 );
    x = y1 - ( b / a ) * x1;
    y = x1;
    return d;
}


inline int divMOD ( int a, int b, int m = mod)
{
    int x, y;
    int g = GCD_E ( b, m, x, y );
    x = ( x % m + m ) % m;
    return ( a * x ) % m;
}

bool is_prime( int n )
{
    int d = n - 1;
    int s = 0;
    while(d % 2 == 0)
    {
        s++;
        d >>= 1;
    }
    int a[9] = { 2, 3, 5, 7, 11, 13, 17, 19, 23};
    forn ( i, 0, 8 )
    {
        bool comp = ( binpow(a[i], d, n) != 1);
        if( comp )
            forn( j, 0, s-1 )
        {
            int fp = binpow(a[i], (1ll << j) * d, n);
            if(fp == n-1)
            {
                comp = false;
                break;
            }
        }
        if( comp ) return false;
    }
    return true;
}

bool isprime(int n)
{
    if(n<2) return false;
    for(int i=2; i*i*i<=n; ++i) if(n%i==0) return false;
    for(int it=0; it<1e5; ++it)
    {
        int i = rand()%(n-1)+1;
        if(__gcd(i,n)!=1) return false;
        if(binpow(i,n-1,n)!=1) return false;
    }
    return true;
}

bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
int phi(int n)
{
    int result = n;

    for (int p = 2; p * p <= n; ++p)
    {
        if (n % p == 0)
        {
            while (n % p == 0)
                n /= p;
            result -= result / p;
        }
    }

    if (n > 1)
        result -= result / n;
    return result;
}
main()
{
  int x;
  cin >> x;
  if(x >= 30){
    cout << "Yes";
  }
  else cout << "No";
}


Measured memory_bytes: 3632
#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;

char ans[105][105];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int H,W;cin>>H>>W;
    string s[100];
    REP(i,H) cin >> s[i];
    REP(i,H+2) REP(j,W+2) ans[i][j]='#';
    REP(i,H) REP(j,W) ans[i+1][j+1] = s[i][j];
    REP(i,H+2){
        REP(j,W+2) cout << ans[i][j];
        cout << '\n';
    }
    return 0;
}

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

int main(void){
	while(true){
		int n, m, count = 0, x = 10 ,y = 10, a, b;
		cin >> n;
		if(n == 0)return 0;
		int z[21][21] = {};
		for(int i = 0; i < n; i++){
			cin >> a >> b;
			z[a][b] = 1;
		}
		count = n;
		cin >> m;
		char temp;
		int temp2;
		for(int i = 0; i < m; i++){
			cin >> temp;
			cin >> temp2;
			for(int j = 0;j < temp2; j++){
				if(temp == 'N') y++;
				if(temp == 'W') x--;
				if(temp == 'S') y--;
				if(temp == 'E') x++;
				if(z[x][y] == 1) {count--; z[x][y] = 0; }
			}
		}
		if(count == 0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}

	return 0;
}


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

int main(){
	int n,q;
	cin>>n>>q;
	string name = "kogakubu10gokan";
	while(n--){
		int year;
		cin>>year;
		if(year > q){
			cout<<name<<endl;
			return 0;
		}
		cin>>name;
	}
	cout<<name<<endl;
}

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

int n,m,*b,ans;

int main(){
	while(true){
		cin >> n >> m;
		if(!n && !m)
			return 0;
		b = new int[n];
		ans = 0;
		for(int i=0; i<n; i++)
			cin >> b[i];
		sort(b,b+n,greater<int>());
		for(int i=1; i<=n; i++){
			if(i%m == 0)
				continue;
			ans += b[i-1];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N, turi, mai;
    N = sc.nextInt();
    if (N % 1000 == 0)
      mai = N / 1000;
    else
      mai = N / 1000 + 1;
    turi = 1000 * mai - N;
    System.out.print(turi);
  }
}

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

string s;

int main() {
	cin >> s;
	
	char ans[10]; int cor = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'B') {
			if (cor == 0) continue;
			cor--;
		}
		else {
			ans[cor++] = s[i];
		}
	}
	
	for (int i = 0; i < cor; i++) {
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
h,w=map(int,input().split())

b=[]
d=[]
k=0
for i in range(w):
    d.append(i)

for i in range(h):
    a=input()
    if a!="."*w:
        b.append(a)
    else:
        h-=1
        
for i in range(w):
    c=0
    for j in range(h):
        if b[j][i]=="#":
            c+=1
    if c==0:
        del(d[k])
    else:
        k+=1
            
for i in range(h):
    for j in d:
       sys.stdout.write(b[i][j]) 
    print("")
            

Measured memory_bytes: 3700
import java.util.Scanner;
import javax.swing.tree.TreeNode;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Vector;
import static java.lang.System.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		String s = sc.next();
		int ans = 0;
		for(int i = 0; i < 3; i++) {
			if(s.charAt(i) == 'R') {
				ans++;
			}
		}
		if(s.charAt(1) == 'S' && ans == 2) {
			ans = 1;
		}
		System.out.println(ans);
		
	}
	
}



Measured memory_bytes: 26996
using System;

public class AtCoder
{
    public static void Main()
    {
        string s;
        s = Console.ReadLine().Trim();

        int[] t = new int[s.Length];
        if (s != null)
        {
            for (int i = 0; i < t.Length; i++)
            {
                t[i] = int.Parse(s.Substring(i, 1));
            }
        }

        int n = 999999;
        int m;
        for (int i = 0; i < t.Length - 2; i++)
        {
            m = t[i] * 100 + t[i + 1] * 10 + t[i + 2] - 753;
            if (m < 0) m = -m;
            if (m < n) n = m;
        }
        Console.WriteLine(n);
    }
}


Measured memory_bytes: 11092
import sys
import math

ct= 0
def insertion_sort(a, n, g):
    global ct
    for j in range(0,n-g):
        v = a[j+g]
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j-g
            ct += 1
        a[j+g] = v

n = int(input())
a = list(map(int, sys.stdin.readlines()))

b = math.floor(2.25*701)
g = [x for x in [1,4,10,23,57,132,301,701] if x <= n]

while b<=n:
    g.append(b)
    b = math.floor(2.25*b)
g = g[::-1]

for i in g:
    insertion_sort(a, n, i)

print(len(g))
print(*g, sep=" ")
print(ct)
print(*a, sep="\n")

Measured memory_bytes: 118624
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		Map<Long , Long> tm = new TreeMap<Long , Long>();
		int n = Integer.parseInt(sc.next());
		long m = Long.parseLong(sc.next());
		long a = 0;
		long b = 0;
		for(int i = 0 ; i < n ; i++){
			a = Long.parseLong(sc.next());
			b = Long.parseLong(sc.next());
			if(tm.containsKey(a)){
				tm.put(a , b + tm.get(a));
			}else{
				tm.put(a , b);
			}
		}
		sc.close();
		long yono = 0;
		for(long i : tm.keySet()){
			yono += i * tm.get(i);
			m -= tm.get(i);
			if(m <= 0){
				yono += i * (long)m;
				break;
			}
		}
		ou.print(yono + "\n");
		ou.flush();
    }
}

Measured memory_bytes: 66240
#include<stdio.h>
#include<string>
 
int main(void){
  int n,i,ans=0;
  std::string tmp;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    tmp = std::to_string(i);
    //printf("%s\n",tmp.c_str());
    if(tmp.length()%2==1) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  cin>>n;
int count=0;
  if(n/100==7){
    count++;
  }
    if(n/10%10==7){
    count++;
  }
    if(n%100%10==7){
    count++;
  }
 
  if(count>=1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
 
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  int ans=0;
  
  vector<int> p(2019,0);
  p[0]=1;
  
  int now = 0;
  int ju = 1;
  for(int i = n-1;i>=0;i--) {
  int x = s[i]-'0';
  now += x*ju;
  now %= 2019; 
  p[now]++;
  ju = (ju*10)%2019;
  }
  
  rep(i,2019) {
    if(p[i]>=2) ans+=p[i]*(p[i]-1)/2;
  }
  
  
  cout << ans << endl;       
}

Measured memory_bytes: 3760
#include<iostream>
#include<math.h>
#define int long long
using namespace std;
int ceil(int x,int y){
	if(x%y==0){
		return x/y;
	}
	return x/y+1;
}
signed main(){
	int s;
	cin>>s;
	cout<<0<<" "<<0<<" "<<1000000000<<" "<<1<<" "<<ceil(s,1000000000)*1000000000-s<<" "<<ceil(s,1000000000);
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	result := "WA"
	nowC := 0
	if string(s[0]) == "A" {
		count := 0
		for i := 2; i < len(s)-1; i++ {
			if string(s[i]) == "C" {
				count++
				nowC = i
			}
		}
		if count != 1 {
			fmt.Println("WA")
			return
		}

		for i, c := range s {
			if !(c >= 'a' && c <= 'z' || i == nowC || i == 0) {
				fmt.Println("WA")
				return
			}
		}
		result = "AC"

	} else {
		result = "WA"
	}
	fmt.Println(result)

}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    
  int h , w;
  cin >> h >> w;
  while(h!=0){
      
    int i,j;
    for(i=0;i<h;i++){
        
      for(j=0;j<w;j++){
          
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
     cin >> h >> w;
  }
  
  return 0;
}



Measured memory_bytes: 3100
#include"bits/stdc++.h"
using namespace std;


int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int ans=0;
	if (A > C * 2 && B > C * 2) {
		ans = C*2 * max(X,Y);
	}
	else if (A + B > C * 2) {
		if (X > Y) {
			ans += C*2 * Y;
			X -= Y;
			if (A > C * 2)
				ans += C*2 * X;
			else
				ans += A * X;
		}
		else {
			ans += C*2 * X;
			Y -= X;
			if (B > C * 2)
				ans += C*2 * Y;
			else
				ans += B * Y;
		}
	}
	else {
		ans += A*X + B*Y;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
 /*   double t,x;
    cin>>t>>x;
    t=t/x;
    cout<<t*1.0<<'\n';*/
  
   /* int a,b,c;
    cin>>a>>b>>c;
    cout<<(a*b)/2<<'\n';*/

   /* int d;
    cin>>d;
    if(d==22){
        cout<<"Christmas Eve Eve Eve"<<'\n';
    }else if(d==23){
        cout<<"Christmas Eve Eve"<<'\n';
    }else if(d==24){
        cout<<"Christmas Eve"<<'\n';
    }else if(d==25){
        cout<<"Christmas"<<'\n';
    }*/

   /* int x,y;
    cin>>x>>y;
    y=y/2;
    cout<<x+y<<'\n';*/

   /* int n,a,b;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<'\n';
    }else{
        cin>>a>>b;
        cout<<a+b<<'\n';
    }*/

   /* int n;
    cin>>n;
    if(n==111){
        cout<<999<<'\n';
    }else if(n==119){
        cout<<991<<'\n';
    }else if(n==199){
        cout<<911<<'\n';
    }else if(n==191){
        cout<<919<<'\n';
    }else if(n==999){
        cout<<111<<'\n';
    }else if(n==911){
        cout<<199<<'\n';
    }else if(n==919){
        cout<<191<<'\n';
    }else if(n==991){
        cout<<119<<'\n';
    }*/

  /*  int a[5];
    for(int i=0; i<3; i++){
        cin>>a[i];
    }
    sort(a,a+3,greater<int>());
    a[0]=a[0]*10;
    a[0]=a[0]+a[1]+a[2];
    cout<<a[0]<<'\n';*/

    int a,b;
    cin>>a>>b;
    a=a*b;
    if(a%2==0){
        cout<<"No"<<'\n';
    }else{
        cout<<"Yes"<<'\n';
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> grid(H + 2, vector<char>(W + 2, '#'));
    char a;
    rep(1, i, H + 1)
    {
        rep(1, j, W + 1)
        {
            cin >> a;
            grid.at(i).at(j) = a;
        }
    }

    rep(0, i, H + 2)
    {
        rep(0, j, W + 2)
        {
            cout << grid.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int a[] = new int[3];
		int min = 0;

		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}

		sc.close();

		Arrays.sort(a);

		min = a[1] - a[0];
		min += a[2] - a[1];

		System.out.print(min);

	}
}


Measured memory_bytes: 23252
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

/*
int main(){
    long long a;
    int b;
    int c;
    long double bt;
    cin >> a >> bt >> c;
    b = bt*100;
    cout << ((a*b)/(long long)100 + 0.5) << endl;
    return 0; 
}*/

int main(){
    long double a,b;
    cin >> a >> b;
    cout << static_cast<long long>(floor(a*b))<< endl;
}

Measured memory_bytes: 3728
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long LL;

void solve(long long n, long long m, std::string s) {
	LL goal = n, prev = -1;
	vector<LL> ans;
	for (LL i = n - 1; i >= 0; --i) {
		if (i + m < goal) {
			if (prev < 0) {
				cout << -1 << endl;
				return;
			}
			ans.push_back(goal);
			goal = prev;
			prev = -1;
		}
		if (s[i] == '0') {
			prev = i;
		}
	}
	ans.push_back(goal);
	if (prev >= 0) {
		ans.push_back(0);
	}
	reverse(ans.begin(), ans.end());
	for (LL i = 1; i < (LL)ans.size(); ++i) {
		if (i > 1) {
			cout << " ";
		}
		cout << (ans[i] - ans[i - 1]);
	}
	cout << endl;
}

int main() {
    long long N;
	scanf("%lld", &N);
	long long M;
	scanf("%lld", &M);
	std::string S;
	std::cin >> S;
	solve(N, M, S);
	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,M;
int A[111111],B[111111],C[111111];

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

void dijkstra(int s,vector<vpint>&G,vint &dist,vint &way){
    dist=vint(N,INF);
    way=vint(N);
    dist[s]=0;
    way[s]=1;
    priority_queue<pint,vector<pint>,greater<pint>>que;
    que.push({0,s});
    while(que.size()){
        int c,v;
        tie(c,v)=que.top();
        que.pop();
        if(dist[v]<c)continue;
        for(auto &e:G[v]){
            if(dist[e.fi]<c+e.se)continue;
            if(dist[e.fi]==c+e.se)add(way[e.fi],way[v]);
            else{
                dist[e.fi]=c+e.se;
                way[e.fi]=way[v];
                que.push({dist[e.fi],e.fi});
            }
        }
    }
}

signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);

    cin>>N>>M;
    rep(i,M){
        cin>>A[i]>>B[i]>>C[i];
        A[i]--;B[i]--;
    }

    vint dist0,dist1;
    vint way0,way1;

    vector<vpint>G0(N),G1(N);
    rep(i,M){
        G0[A[i]].pb({B[i],C[i]});
        G1[B[i]].pb({A[i],C[i]});
    }
    dijkstra(0,G0,dist0,way0);
    dijkstra(1,G1,dist1,way1);


    int X=dist0[1];

    rep(i,M){
        int tmp=dist0[B[i]]+C[i]+dist1[A[i]];
        if(tmp<X){
            cout<<"HAPPY"<<endl;
        }
        else if(dist0[A[i]]+C[i]+dist1[B[i]]>X){
            cout<<"SOSO"<<endl;
        }
        else if(way0[A[i]]*way1[B[i]]%mod==way0[1]){
            cout<<"SAD"<<endl;
        }
        else{
            cout<<"SOSO"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19460
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, k; rd(n, k);
  auto x=new long[](n), y=new long[](n);
  foreach(i; 0..n) rd(x[i], y[i]);

  long mn=5_000_000_000_000_000_000;
  foreach(i1; 0..n)foreach(i2; (i1+1)..n){
    foreach(j1; 0..n)foreach(j2; (j1+1)..n){
      auto x1=x[i1], x2=x[i2];
      auto y1=y[j1], y2=y[j2];
      if(x1>x2) swap(x1, x2);
      if(y1>y2) swap(y1, y2);
      // if((x2-x1)*(y2-y1)>=mn) continue;
      int cnt=0;
      foreach(t; 0..n){
        if(x1<=x[t] && x[t]<=x2 && y1<=y[t] && y[t]<=y2) cnt++;
      }
      if(cnt>=k) mn=min(mn, (x2-x1)*(y2-y1));
    }
  }
  writeln(mn);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
ll sequence(int n,ll cnt,vector<ll>sum,vector<ll> a) {
	for (int i = 1; i < n; i++) {
		sum[i] = sum[i - 1] + a[i];
		if (sum[i - 1] > 0) {
			if (sum[i] >= 0) {
				cnt += sum[i] + 1;
				sum[i] = -1;
			}
		}
		else if (sum[i - 1] < 0) {
			if (sum[i] <= 0) {
				cnt += abs(sum[i]) + 1;
				sum[i] = 1;
			}
		}
	}
	return cnt;
}
int main() {
	int n;
	cin >> n;
	vector<ll>sum(n),a(n),sum2(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll count = 0;
	ll count2 = 0;
	sum[0] = a[0];
	if (sum[0]>0) {
		sum2[0] = -1;
		count2 += sum[0] + 1;
	}
	else if (sum[0] < 0) {
		sum2[0] = 1;
		count2 += abs(sum[0])+1;
	}
	else {
		sum[0] = 1;
		count++;
		sum2[0] = -1;
		count2++;
	}
	cout<<min(sequence(n, count, sum, a) 
		,sequence(n, count2, sum2, a))<< endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

vector<ll> z_algorithm(const string& S){
  const ll n=S.length();
  vector<ll> A(n);
  A[0] = n;
  int i = 1, j = 0;
  while (i < n) {
    while (i+j < n && S[j] == S[i+j]) ++j;
    A[i] = j;
    if (j == 0) { ++i; continue;}
    ll k = 1;
    while (i+k < n && k+A[k] < j) A[i+k] = A[k], ++k;
    i += k; j -= k;
  }
  return A;
}

struct alpha{
  vector<ll> cnt;
  ll sum;
};
alpha operator+(const alpha& a,const alpha& b){
  vector<ll> ncnt(26,0);
  ll nsum=0;
  rep(i,26){
    ncnt[i]=a.cnt[i]+b.cnt[i];
    nsum+=ncnt[i];
  }
  return (alpha){ncnt,nsum};
}

alpha alphas[101];

alpha calc2(const string& sa,const string& sb,ll i,ll len){
  if(i==0){
    vector<ll> cnt(26,0);
    ll sum=0;
    rep(j,len){
      cnt[sb[j]-'a']++; sum++;
    }
    return (alpha){cnt,sum};
  }else if(i==1){
    vector<ll> cnt(26,0);
    ll sum=0;
    rep(j,len){
      cnt[sa[j]-'a']++; sum++;
    }
    return (alpha){cnt,sum};
  }else{
    if(alphas[i-1].sum>=len){
      return calc2(sa,sb,i-1,len);
    }else{
      return alphas[i-1]+calc2(sa,sb,i-2,len-alphas[i-1].sum);
    }
  }
}

alpha calc(const string& S, const string& sa,const string& sb, ll len){
  if(len<=(ll)S.size()){
    vector<ll> cnt(26,0);
    ll sum=0;
    rep(i,len){
      cnt[S[i]-'a']++; sum++;
    }
    return (alpha){cnt,sum};
  }
  ll crt=0;
  alpha res=alphas[1];
  while(res.sum+alphas[crt].sum<len){
    res=res+alphas[crt];
    crt++;
  }
  res=res+calc2(sa,sb,crt,len-res.sum);
  return res;
}

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

  string S;
  cin>>S;
  int N=S.size();
  S=S.substr(0,N/2);
  N/=2;
  vector<ll> Z=z_algorithm(S);

  int L=N;
  repl(i,1,N){
    if(Z[i]==N-i){
      L=i; break;
    }
  }

  alpha A,B;
  A.cnt.resize(26,0); A.sum=0;
  B.cnt.resize(26,0); B.sum=0;
  rep(i,L){
    A.cnt[S[i]-'a']++; A.sum++;
  }
  repl(i,L,N){
    B.cnt[S[i]-'a']++; B.sum++;
  }
  alphas[0]=B; alphas[1]=A;
  repl(i,2,100){
    if(alphas[i-1].sum<2e18&&alphas[i-2].sum<2e18) alphas[i]=alphas[i-1]+alphas[i-2];
    else break;
  }

  ll l,r;
  cin>>l>>r;
  l--;
  alpha resl=calc(S,S.substr(0,L),S.substr(L,N-L),l);
  alpha resr=calc(S,S.substr(0,L),S.substr(L,N-L),r);
  rep(i,26)cout<<resr.cnt[i]-resl.cnt[i]<<" ";
  cout<<endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int n, l;
    scanf("%d %d", &n, &l);
    string s[100];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s, s + n);
    string ans = "";
    for (int i = 0; i < n; i++) {
        ans += s[i];
    }
    
    printf("%s\n", ans.c_str());
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string
//main
signed main(){
  int N,M,O,P,Q,count=0,count2=0,count3=0;
  double D=0;
  int c='A'-'a';
  //char C;
  str S,T;
  cin>>N;
  int A[N],B[N];
  rep(0,N){
    cin>>A[i];
    B[A[i]-1]=i+1;
  }
  rep(0,N)cout<<B[i]<<endl;
}


Measured memory_bytes: 2432
//C - Many Formulas: 30Min; 
//Assunto: Brute Force;
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

ll ans = 0;

void solve(string s, int idx, int ini, ll soma, int size) {
    string aux;
    if(idx >= s.size()) {
        ans += soma;
        return;
    }
    if(idx+1 < s.size()) solve(s, idx+1, ini, soma, size+1);
    aux = s.substr(ini, size);
    soma += stol(aux);
    solve(s, idx+1, idx+1, soma, 1);

}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s;
    cin >> s;
    solve(s, 0, 0, 0, 1);
    cout << ans << "\n";
}

Measured memory_bytes: 256
/**
 * Created by hiramekun at 20:07 on 2019-08-27.
 */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vl = vector<ll>;

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

int main() {
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vl a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];

    vl ab;
    rep(i, x) rep(j, y) ab.emplace_back(a[i] + b[j]);
    sort(all(ab), greater<>());
    sort(all(c), greater<>());

    vl ans;
    rep(i, min(k, x * y)) rep(j, min(k, z)) ans.emplace_back(ab[i] + c[j]);
    sort(all(ans), greater<>());

    rep(i, k) cout << ans[i] << '\n';

    return 0;
}

Measured memory_bytes: 43240
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int count=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='7')
		count++;
	}
	if(count>0)
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

int main(){
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    rep(i,X) cin >> A[i];
    rep(i,Y) cin >> B[i];
    rep(i,Z) cin >> C[i];

    vector<ll> AB;
    rep(i,X){
        rep(j,Y){
            AB.push_back(A[i]+B[j]);
        }
    }

    sort(AB.rbegin(), AB.rend());

    vector<ll> ABC;
    rep(i,min(K, int(AB.size()))){
        rep(j,Z){
            ABC.push_back(AB[i]+C[j]);            
        }
    }

    sort(ABC.rbegin(), ABC.rend());

    rep(i,K) cout << ABC[i] << endl;

}

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

using namespace std;

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

const long long MAX = 510000;  // 最大を決めておく
// fac…階乗、inv…逆数、finv…逆数の累積積
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理、先にやっておく
void nPr_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// nPrを計算する (前処理は忘れないように)
long long nPr(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fac[n] * finv[n - r] % MOD;
}

int n, k;
bool visited[100010];
vector<ll> dp(100010);
vector<int> g[100010];

ll dfs(int now, int parent) {
  if (now != 0 && g[now].size() == 1) return 1;    // 葉に到達したら戻る
  int child = g[now].size() - 1 + (parent == -1);  // 子の数を計算

  ll ret = 1;
  ret *= nPr(k - 2 + (parent == -1), child);
  // cout << nPr(k - 2 + (parent == -1), child) << endl;
  for (auto x : g[now]) {
    if (x != parent) ret *= dfs(x, now), ret %= MOD;
  }
  return ret;
}

// ====================================================================

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

  ll ans = dfs(0, -1);  // dfs(今いる頂点, 親)
  ans = ans * k % MOD;  // 頂点だけは好きなように塗れるので

  cout << ans << endl;
}


Measured memory_bytes: 23296
#include <iostream>
#define MOD 1000000007
using namespace std;
int fact[100005];
int inv[100005];
int N;
int V[100005];
int lgpow(int b,int e)
{
    int p=1;
    while(e)
    {
        if(e&1)p=(1LL*b*p)%MOD;
        b=(1LL*b*b)%MOD;
        e>>=1;
    }
    return p;
}
int C(int N,int K)
{
    return (1LL*((1LL*fact[N]*inv[K])%MOD)*inv[N-K])%MOD;
}
int elem;
int main()
{
    fact[0]=inv[0]=1;
    for(int i=1;i<=100004;i++)fact[i]=(1LL*fact[i-1]*i)%MOD;inv[100004]=lgpow(fact[100004],MOD-2);
    for(int i=100003;i;i--)inv[i]=(1LL*inv[i+1]*(i+1))%MOD;
    cin>>N;
    for(int i=1;i<=N+1;i++)
    {
        cin>>V[i];
        elem^=i^V[i];
    }
    elem^=(N+1);
    int fpos,lpos;fpos=lpos=0;
    for(int i=1;i<=N+1;i++)
    {
        if(elem==V[i])
        {
            if(!fpos)fpos=i;
            lpos=i;
        }
    }
    for(int i=1;i<=N+1;i++)
    {
        if(i-1>N+1-(lpos-fpos+1))
        {
            cout<<C(N+1,i);
        }
        else
        {
            cout<<(0LL+C(N+1,i)-C(N+1-(lpos-fpos+1),i-1)+MOD)%MOD;
        }
        cout<<"\n";
    }
    return 0;
}


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

int count(const std::string str, const std::string subStr, int size) {
    int count = 0;

    int pos = str.find(subStr);

    while(pos != std::string::npos) {
        count++;
        pos = str.find(subStr, pos + 1);
    }
    return count;
}

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

    cout << count(s, "ABC", n) << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int N;
string s;

bool f(vector<char> &ans){
    for(int i=0;i<N;i++){
        int cur = (i+1)%N;
        int l = (cur-1+N)%N;
        int r = (cur + 1) % N;

        char c;
        if (s[cur] == 'o' && ans[cur] == 'S' || s[cur] == 'x' && ans[cur] == 'W') {
            c = ans[l];
        } else {
            c = (ans[l] == 'W' ? 'S' : 'W');
        }

        if(ans[r] == 0){
            ans[r] = c;
        }else{
            if (c != ans[r]) return false;
        }
    }
    return true;
/*
    for(int i=1;i<N-1;i++){
        if(s[i] == 'o' && ans[i] == 'S' || s[i] == 'x' && ans[i] == 'W'){
            ans[i + 1] = ans[i - 1];
        }else{
            ans[i + 1] = (ans[i - 1] == 'W' ? 'S' : 'W');
        }
    }

    

    if(s[N-1] == 'o' && ans[N-1] == 'S' || s[N-1] == 'x' && ans[N-1] == 'W'){
        return ans[N - 2] == ans[0];
    }else{
        return ans[N - 2] != ans[0];
    }
    */
}

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

    vector<string> c = {"SS", "SW", "WS", "WW"};

    for(int i=0;i<4;i++){
        vector<char> ans(N);
        ans[0] = c[i][0];
        ans[1] = c[i][1];
        if(f(ans)){
            cout << join(ans, "") << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}


Measured memory_bytes: 3908
N = int(input())

uvw= [[int(i) for i in input().split()] for _ in range(N-1)]

path = [[] for _ in range(N+1)]

for u, v, w in uvw :
    path[u].append((v, w))
    path[v].append((u, w))

paint = [0] * (N + 1)

queue = [1]
visited = [False] * (N + 1)

while queue :
    current = queue.pop(0)
    w = paint[current]

    for destination, w_ in path[current] :
        if not visited[destination] :
            paint[destination] = (w + w_) & 1
            queue.append(destination)
            visited[destination] = True

for i in paint[1:] :
    print(i) 

Measured memory_bytes: 52112
n = int(input())
ans = 0
ary = []
i = 1
ary.append(1)
while 9**i < n+1:
    ary.append(9**i)
    i += 1

i = 1
while 6**i < n+1:
    ary.append(6**i)
    i += 1
ary.sort()

dp = [100002] * (n+1)
dp[0] = 0

for i in range(1,n+1):
    tmp = dp[i] + 1
    for j, aa in enumerate(ary):
        if i >= aa:
            tmp = min(tmp, dp[i-aa] + 1)
        else:
            break
    dp[i] = tmp
print(dp[n])


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

int main(void){
int n,i,j;
double s[1005],S,m,sgm;
while(1){
   scanf("%d",&n);
   if(n==0){break;}
   S=0;
   for(i=0;i<n-1;i++){
      scanf("%lf ",&s[i]);
      S=S+s[i];
   }
   scanf("%lf",&s[n-1]);
   S=S+s[n-1];
   m=S/(double) n;
   sgm=0;
   for(i=0;i<n;i++){
   sgm=sgm+(s[i]-m)*(s[i]-m);
   }
   printf("%.6lf\n",sqrt(sgm/(double)n));
}

return(0);
}



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

namespace AtCoder {
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static long cln(long D = -1) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return long.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			var Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static int[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		static string read() { return Console.ReadLine(); }
		#endregion

		static void Main(string[] args) {
			var N = cin();
			var K = cin();
			var X = cins();
			var X2 = X.Select(k => 2 * Math.Min(k, K - k));
			print(X2.Sum());
			read();
		}
	}
}


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

int distanceA(int x){
  return (x * 2);
}

int distanceB(int x, int k){
  return ((k - x) * 2);
}

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

  int x;
  int sum = 0;
  for(int i = 0;i < N; ++i){
    cin >> x;
    sum += min(distanceA(x), distanceB(x, K));
  }
  
  cout << sum << endl;
}


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

int main()
{
  int n, a, min_a = 1000, max_a = 0;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    min_a = min(min_a, a);
    max_a = max(max_a, a);
  }
  cout << max_a - min_a << endl;
}

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

int n,m;
string s[100005];
int t1,t2,t3,t4;

inline int qr()
{
	int x=0,w=1;char a=0;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a<='9'&&a>='0'){x=(x<<3)+(x<<1)+(a^48);a=getchar();}
	return x*w;
}

int main()
{
	n=qr();
	for(register int i=1;i<=n;i++)
		cin>>s[i];
	for(register int i=1;i<=n;i++)
	{
		if(s[i][0]=='A')
			t1++;
		if(s[i][0]=='W')
			t2++;
		if(s[i][0]=='T')
			t3++;
		if(s[i][0]=='R')
			t4++;
	}
	printf("AC x %d\n",t1);
	printf("WA x %d\n",t2);
	printf("TLE x %d\n",t3);
	printf("RE x %d\n",t4);
	return 0;
} 

Measured memory_bytes: 6804
#include<cstdio>
#include<map>
#include<list>
#define linep(x) ((x).first)
#define lineq(x) ((x).second)

using namespace std;
typedef std::list<std::pair<int, int> > Line;

int main(void){
  int now, n, m, a, h, p, q;
  map<int, Line> amida;
  while(scanf("%d %d %d", &n, &m, &a) != EOF)
    {
      if(n == 0 && m == 0 && a == 0) break;
      amida.clear();
      for(int i = 0; i < m; i++)
        {
          scanf("%d %d %d", &h, &p, &q);
          amida[h].push_back(make_pair(p, q));
        }
      // we don't use first < second cond because of efficiency
      now = a;
      for(map<int, Line>::reverse_iterator itr = amida.rbegin(); itr != amida.rend(); itr++)
        {
          for(Line::iterator itr2 = ((*itr).second).begin(); itr2 != ((*itr).second).end(); itr2++)
            {
              if(linep(*itr2) == now) now = lineq(*itr2);
              else if(lineq(*itr2) == now) now = linep(*itr2);
            }
        }
      printf("%d\n", now);
    }
  return 0;
}

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

const double inf = 1e10;

double BMI(double w, double h) {
  return w / pow(h, 2);
}

int main() {
  int n;
  while(cin >> n && n) {
    pair<double,int> p(inf, 0);
    for(int i = 0; i < n; ++i) {
      int id;
      double h, w;
      cin >> id >> h >> w;
      h /= 100.0;
      p = min(p, make_pair(abs(22.0-BMI(w,h)), id));
    }
    cout << p.second << endl;
  }
  return 0;
}

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

int main() {
    long long N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    long long sum = accumulate(A.begin(), A.end(), 0LL);
    long long m = N * (N + 1) / 2;
    if (sum % m != 0) {
        cout << "NO" << endl;
        return 0;
    }
    long long num = sum / m;

    for (int i = 0; i < N; i++) {
        long long gap = 0;
        if (i != N - 1) {
            gap = A[i + 1] - A[i] - num;
        } else {
            gap = A[0] - A[N - 1] - num;
        }
        if (gap % N != 0 || gap > 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e3+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int a[N] , dp[N][N] , pre[N];

int sum(int l ,int r ) 
{
	return pre[r] - pre[l-1];
}

int makeAns( int i = 1, int j = n)
{
	if( i >= j ) return 0;

	int& ans = dp[i][j];
	if( ~ans ) return ans;

	ans = INF;

	fo(k,i,j)
	{
		int now = sum(i,k)  + sum(k+1,j);
		ans = min( ans , now + makeAns(i,k) + makeAns(k+1,j) );
	}

	return ans;
}

void go()
{
	cin >> n;

	fo(i,1,n+1) cin >> a[i] , pre[i] = pre[i-1] + a[i];

	memset( dp ,-1 , sizeof dp );
	int ans = makeAns();

	cout << ans << endl;


}

int32_t main()
{
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}



Measured memory_bytes: 31872