akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define REP(i, a) for (int i(0); i < (a); ++i)
#define FOR(i, a, b) for (int i(a); i <= (b); ++i)

#ifdef LOCAL
#define NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define F_1(F, ARG) F(ARG)
#define F_2(F, ARG, ...) F(ARG) F_1(F, __VA_ARGS__)
#define F_3(F, ARG, ...) F(ARG) F_2(F, __VA_ARGS__)
#define F_4(F, ARG, ...) F(ARG) F_3(F, __VA_ARGS__)
#define F_5(F, ARG, ...) F(ARG) F_4(F, __VA_ARGS__)
#define F_6(F, ARG, ...) F(ARG) F_5(F, __VA_ARGS__)
#define FOR_EACH(F, ...)                                                       \
  NTH_ARG(__VA_ARGS__, F_6, F_5, F_4, F_3, F_2, F_1)(F, __VA_ARGS__)

#define C_RED "\033[2;31m"
#define C_BLUE "\033[1;34m"
#define C_GREEN "\033[1;32m"
#define C_RESET "\033[0m"

#define watch(x) cerr << C_GREEN #x " = " C_BLUE << (x) << C_RESET "; ";
#define debug(...)                                                             \
  cerr << C_RED "Line " << __LINE__ << ": " C_RESET;                           \
  FOR_EACH(watch, __VA_ARGS__)                                                 \
  cerr << endl
#else
#define debug(...)
#endif

using namespace std;

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << '{' << p.first << ", " << p.second << '}';
}

template <class T, class = decltype(begin(declval<T>())),
          class = enable_if_t<!is_same<T, string>::value>>
ostream &operator<<(ostream &os, const T &c) {
  os << '[';
  for (auto it = begin(c); it != end(c); ++it)
    os << (it == begin(c) ? "" : ", ") << *it;
  return os << ']';
}
using ll = long long;

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  const int MOD = 1e9 + 7;

  auto addOp = [&](int a, int b) { return (a + b) % MOD; };

  vector<int> pref(n + 1);
  pref[1] = 1;

  for (int len = 2; len <= n; ++len) {
    partial_sum(ALL(pref), pref.begin(), addOp);
    vector<int> nxt(n + 1);
    for (int last = 1; last <= len; ++last) {
      int l, r;
      if (s[len - 2] == '<') {
        l = 1;
        r = last - 1;
      } else {
        l = last;
        r = len - 1;
      }
      nxt[last] = (pref[r] - pref[l - 1] + MOD) % MOD;
    }
    pref.swap(nxt);
  }
  ll ans = accumulate(ALL(pref), 0, addOp);
  cout << ans << "\n";
}

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

  int T = 1;
  // cin >> T;
  while (T--) {
    solve();
  }
}


Measured memory_bytes: 3656
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        x: usize,
        s: [usize; n],
    }
    let mut s = s;
    s.sort();
    let mut dp = vec![0; x + 1];
    for i in 0..(x + 1) {
        dp[i] = i;
    }
    let p = 1000000007;
    for i in 0..n {
        for j in (0..(x + 1)).rev() {
            dp[j] = (i * dp[j] + dp[j % s[i]]) % p;
        }
    }
    println!("{}", dp[x]);
}

fn main() {
    run();
}


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

#define IN(H,W,y,x) (x>=0&&x<W&&y>=0&&y<H)

int main() {
  int H,W;
  cin>>H>>W;
  string s, output;
  for(int y=0;y<H;y++) {
    cin>>s;
    for(int x=0;x<W;x++) {
      if (s.at(x) != '#') {
        if (s.at(x)=='.') s.at(x) = '0';
      } else {
        for(int i : {x-1,x,x+1}) {
          if (IN(H,W, y - 1, i) && output.at(i) !='#')  {
            output.at(i) = output.at(i) - '0' + 1 + 48;
          }
        }
        for(int i : {x-1,x+1}) {
          if (IN(H,W, y, i) && s.at(i) !='#')  {
            if (s.at(i) == '.') s.at(i) = '1';
            else s.at(i) = s.at(i) - '0' + 1 + 48;
          }
        }
      }
    }
    if (y>0) {
      for(int x=0;x<W;x++) {
        if (output.at(x)=='#') {
          for(int i : {x-1,x,x+1}) {
            if (IN(H, W, y,i) && s.at(i) != '#')
              s.at(i) = s.at(i) - '0' + 1 + 48;
          }
        }
      }
    }
    if (output.size() > 0) cout << output << endl;
    output = s;
  }
  cout << output << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a;
int main() {
  cin >> n;
  read_n(a, n, 1);

  map<i64, i64> left, cnt;
  for (i64 i = n; i > 0; --i) {
    left[a[i]] = i;
    cnt[a[i]]++;
  }

  vector<i64> xs;
  xs.push_back(0);
  for (auto p : left) {
    xs.push_back(p.first);
  }

  vector<i64> ans(n + 1);
  for (i64 i = xs.size() - 1, l = n, c = 0; i > 0; --i) {
    i64 x = xs[i];
    l = min(l, left[x]);
    c += cnt[x];
    ans[l] += c * (x - xs[i - 1]);
  }

  for (i64 i = 1; i <= n; ++i) {
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 15992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n;
int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    vector<int> v1;
    vector<int> v2;
    for(int i = 0; i < n; ++i) {
        int c;
        cin >> c;
        if (i & 1) {
            v2.push_back(c);
        } else v1.push_back(c);
    }

    if (n & 1) {
        reverse(v1.begin(), v1.end());
        for(auto c: v1) cout << c << ' ';
        for(auto c: v2) cout << c << ' ';
        
    } else {
        reverse(v2.begin(), v2.end());
        for(auto c: v2) cout << c << ' ';
        for(auto c: v1) cout << c << ' ';
    }
    cout << endl;
}

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

int main(){
	int N , m , i , j , g = 1;
	scanf( "%d%d" , &N , &m );
	int limit = sqrt( m );		

	for( i = 1 ; i <= limit ; ++i ){
		if( m % i != 0 ) continue;
		j = m / i;
		if( (m / i) >= N ) g = max( g , i );
		if( (m / j ) >= N ) g = max( g , j ); 
	}

	printf( "%d\n" , g );
	return 0;	
}

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


using namespace std;

int main(){
  long long  A ,B , ans;

  cin >> A >> B;
  int flag =0;
  for(long long  i =0; i< 1000000000; i++){
    if(abs(A-i) == abs(B -i)){
      flag = 1;
      ans = i;
    }
  }
  if(flag)cout << ans << endl;
  else cout << "IMPOSSIBLE" << endl;
  
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;


ll h, w;
vector<string> s(403);
bool used[403][403];
vector<ll> di = { 1, 0, -1, 0 }, dj = { 0, 1, 0, -1 };

pair<ll, ll> func(ll pi, ll pj) {
	if (used[pi][pj]) return { 0, 0 };
	used[pi][pj] = true;
	pair<ll, ll> ret = { 0,0 };
	for (ll t = 0; t < 4; t++) {
		if (!(0 <= pi + di[t] && pi + di[t] < h)) continue;
		if (!(0 <= pj + dj[t] && pj + dj[t] < w)) continue;
		if (used[pi + di[t]][pj + dj[t]]) continue;
		if (s[pi][pj] == s[pi + di[t]][pj + dj[t]]) continue;
		auto a = func(pi + di[t], pj + dj[t]);
		ret.first += a.first;
		ret.second += a.second;
	}
	if (s[pi][pj] == '#') ret.first++;
	else ret.second++;
	return ret;
}

int main() {
	cin >> h >> w;
	for (ll i = 0; i < h; i++) cin >> s[i];
	ll ans = 0;
	for (ll i = 0; i < h; i++) {
		for (ll j = 0; j < w; j++) {
			if (used[i][j]) continue;
			auto a = func(i, j);
			ans += a.first*a.second;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;

int main()
{
    LL k;cin>>k;
	LL x=7%k,ans=1;
    while(1){ 
        if(!x) break;
        if(ans>1000000) break;
        x=x*10+7;
        x%=k;
        ans++;
    }
    if(!x) cout<<ans<<"\n";
    else cout<<"-1\n";

    return 0;
}


Measured memory_bytes: 3604
using System;

namespace AtCoderABC133D
{
    class Program
    {
        static void Main(string[] args)
        {
            long total = 0;

            int N = int.Parse(Console.ReadLine());

            string[] s = Console.ReadLine().Split(' ');

            int[] A = new int[N];
            int[] X = new int[N];

            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(s[i]);
                total += A[i];
            }

            long X0 = total;

            for(int i=1;i<N;i+=2)
            {
                X0 -= A[i] * 2;
            }

            X[0] = (int)X0;
            Console.Write(X[0].ToString());

            for(int i=1;i<N;i++)
            {
                X[i] = A[i - 1] * 2 - X[i - 1];
                Console.Write(" " + X[i].ToString());
            }

            Console.WriteLine();
            
        }
    }
}


Measured memory_bytes: 30168
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

vector< vector<long long> > dp(110, vector<long long>(10100, 0));
int n, W;
struct vwdata {
    int v; int w;
};

int main() {
    cin >> n >> W;
    vector<vwdata> vw(n);
    for(int i = 0; i < n; ++i) {
        cin >> vw.at(i).v >> vw.at(i).w;
    }

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= W; ++j) {
            if(j-vw.at(i).w >= 0) {
                chmax(dp[i+1][j], dp[i+1][j-vw.at(i).w]+vw.at(i).v);
            }
            chmax(dp[i+1][j], dp[i][j]);
        }
    }

    cout << dp[n][W] << endl;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int a,b;
  cin >> a >> b;
  if((a+b)%2==1)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << (a+b)/2 << endl;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for(int i=0;i<N;i++){
    cin >> l.at(i);
  }
  sort(l.rbegin(),l.rend());
  int ans=0;
  for(int i=0;i<K;i++){
    ans+=l.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int is_mm(int d){
  return (d >= 1 && d <= 12);
}

int main(){
  int input;
  scanf("%d", &input);
  int t = input/100;
  int b = input%100;
  
  if(is_mm(t)){
    if(is_mm(b)) printf("AMBIGUOUS");
    else printf("MMYY");
  }else{
    if(is_mm(b)) printf("YYMM");
    else printf("NA");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int,int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x){
  return x * x;
}
ll mod = 1e9 + 7;

signed main (){
  int n,m;cin >> n >> m;
 
  cout << (n-1) * (m-1) << endl;
    return 0;
}


Measured memory_bytes: 3604
# C - Vacation
n=int(input())
abc=[list(map(int,input().split())) for i in range(n)]
# i日目にjを選んだ場合の幸福度の総和をdp[i][j]とする。
dp=[[0]*3 for i in range(n+1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j==k:continue
            dp[i+1][k]=max(dp[i+1][k],dp[i][j]+abc[i][k])
ans=0
for i in range(3):
    ans=max(ans,dp[n][i])
print(ans)


Measured memory_bytes: 74072
import math
a, b, C = map(int, input().split())
C = math.radians(C)
S, h = (1/2)*a*b*math.sin(C), b*math.sin(C)
L = a+b+math.sqrt((a**2)+(b**2)-(2*a*b*math.cos(C)))
print("{0:.8f}".format(S))
print("{0:.8f}".format(L))
print("{0:.8f}".format(h))

Measured memory_bytes: 7840
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define ld long double
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const ll maxn = 4e5 , N = 1000 + 10 , mod = 1e9 + 7 , INF = 1e9 + 1 , lg = 32;

char a[N][N];
ll dist[N][N];
int n , m , x , y , s , e;
set <pair <ll , pii> > se;

inline void get() {
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if(i == x && j == y) {
				dist[i][j] = 0;
			}
			else {
				dist[i][j] = INF;
			}
			se.insert({dist[i][j] , {i , j}});
		}
	}
	// for (int i = 0; i < n; ++i) {
	// 	for (int j = 0; j < m; ++j) {
	// 		cout << dist[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }
	while(se.size()) {
		auto curr = *se.begin();
		int i = curr.S.F , j = curr.S.S; ll d = curr.F;
		for (int t = -1; t < 2; ++t) {
			if(i + t < n && i + t >= 0 && a[i + t][j] == '.' && d < dist[i + t][j]) {
				se.erase({dist[i + t][j] , {i + t , j}});
				dist[i + t][j] = d;
				se.insert({dist[i + t][j] , {i + t , j}});
 			}
			if(j + t < m && j + t >= 0 && a[i][j + t] == '.' && d < dist[i][j + t]) {
				se.erase({dist[i][j + t] , {i , j + t}});
				dist[i][j + t] = d;
				se.insert({dist[i][j + t] , {i , j + t}});
			}
		}

		for (int t = -2; t < 3; ++t) {
			for (int f = -2; f < 3; ++f) {
				if(i + t >= n || i + t < 0 || j + f >= m || j + f < 0) {
					continue;
				}
				if(a[i + t][j + f] == '.' && d + 1 < dist[i + t][j + f]) {
					se.erase({dist[i + t][j + f] , {i + t , j + f}});
					dist[i + t][j + f] = d + 1;
					se.insert({dist[i + t][j + f] , {i + t , j + f}});
				}
			}
		}
		se.erase(curr);
	}
	// for (int i = 0; i < n; ++i) {
	// 	for (int j = 0; j < m; ++j) {
	// 		cout << dist[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }
}

int main() {
	FAST
	cin >> n >> m >> x >> y >> s >> e;
	x--; y--; s--; e--;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> a[i][j];
		}
	}
	get();
	cout << (dist[s][e] == INF ? -1 : dist[s][e]) << endl;
}


Measured memory_bytes: 75000
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define __ cout<<fixed;cout<<setprecision(10);
#define int long long

void solve() {
	int n;
	cin >> n; int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	int sum = a[0];
	int j = 1;
	int flag = 0;
	for (int i = 1; i < (n - 1); i++) {
		sum += a[j];
		flag++;
		if (flag == 2) {
			j++;
			flag = 0;
		}
	}
	cout << sum << "\n";
}

int32_t main() {
	_ __
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

#ifndef ONLINE_JUDGE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif

	return 0;
}

Measured memory_bytes: 5256
#include <iostream>                                             
#include <vector>                                               
using namespace std;                                            
                                                                
int main() {                                                    
  int n, m;                                                     
  while (true) {                                                
    cin >> n;                                                   
    if (n==0) {                                                 
      break;                                                    
    }                                                           
    vector<char> from(n);                                       
    vector<char> to(n);                                         
    for (int i=0; i<n; i++) {                                   
      cin >> from[i] >> to[i];                                  
    }                                                           
    cin >> m;                                                   
    vector<char> v(m);                                          
    for (int i=0; i<m; i++) {                                   
      cin >> v[i];                                              
      for (int j=0; j<n; j++) {                                 
        if (v[i]==from[j]) {                                    
          v[i] = to[j];                                         
          break;                                                
        }                                                       
      }                                                         
    }                                                           
    for (int i=0; i<m; i++) {                                   
      cout << v[i];                                             
    }                                                           
    cout << "\n";                                               
  }                                                             
  return 0;                                                     
}                                                               
                              

Measured memory_bytes: 3004
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long MOD = 1e9 + 7;

template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    int R;
    cin >> R;
    cout << fixed << setprecision(6) << double(M_PI * R * 2) << endl;
}

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

public class Main {	
		public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int l = scan.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = scan.next();
		}
		Arrays.sort(s);
		String r = s[0];
		for (int i = 1; i < n; i++) {
			r = r + s[i];
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 23892
use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{stdin, Read};
use std::os::raw::{c_double, c_float};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let q = read::<usize>();
    let ab = (0..n - 1)
        .map(|_| (read::<usize>(), read::<usize>()))
        .collect::<Vec<_>>();
    let px = (0..q)
        .map(|_| (read::<usize>(), read::<usize>()))
        .collect::<Vec<_>>();
    let mut es = vec![vec![]; n];
    for (a, b) in ab {
        es[a].push(b)
    }
    let mut t = vec![0; n + 1];
    for (p, x) in px {
        t[p] += x;
    }

    for i in 0..es.len() {
        for &node in &es[i] {
            t[node] += t[i]
        }
    }

    let mut first = true;
    let tt = &t[1..];
    for &x in tt {
        if !first {
            print!(" ");
        }
        print!("{}", x);
        first = false;
    }
}


Measured memory_bytes: 24828
# input here
_INPUT = """\
10 2
4
5
"""
"""
K = int(input())
H, W, K = map(int, input().split())
a = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(N)]
p = tuple(map(int,input().split()))
"""
def main():
    N, M = map(int, input().split())
    a = set([int(input()) for i in range(M)])
    inf = 10**9+7

    #動的計画法問題
    dp = [0] * (N+1)
    dp[0] = 1
    if 1 not in a:
        dp[1] = 1
    else:
        dp[1] = 0

    for i in range(2,N+1):
        if i in a:
            continue
        dp[i] = dp[i-1] + dp[i-2]
        
        dp[i] %= inf

    print(dp[N]) 

     
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 95152
n = int(input())

def make_divisors(n):
    from collections import deque
    divisors = deque([])
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    lst_divisors = list(divisors)
    lst_divisors.sort()
    return lst_divisors

lst = make_divisors(n)

#g = (n//m)*m + (n//m)
#g = (n//m)*(m+1)

ans = 0
for y in lst:
    if y > 1 and n//(y-1) == n%(y-1):
        ans += y-1
        
print(ans)

Measured memory_bytes: 68416
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// StringTokenizer st = new StringTokenizer(br.readLine());
		int n1 = Integer.parseInt(br.readLine());
		boolean flg = false;

		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				if (i * j == n1) {
					System.out.print("Yes");
					flg = true;
					break;
				}
			}
			if (flg == true) {
				break;
			}
		}
		if (!flg) {
			System.out.print("No");
		}
	}
}


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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int n;

void solve() {
  int nums[10];
  rep(i,10) nums[i] = 0;
  
  rep(i,n) {
    int ii; cin>>ii;
    nums[ii]++;
  }
  
  rep(i,10) {
    if (nums[i]) rep(j,nums[i]) cout<<"*";
    else cout<<"-";
    cout<<endl;
  }
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
int main()
{
  ios::sync_with_stdio(false);cin.tie(0);
  //freopen("input.txt" , "r" , stdin );
  ll k;
  string s;
  cin>>k>>s;
  ll n = s.length();
  if(n<=k)
    cout<<s;
  else
  {
      string ans = s.substr(0,k) + "...";
      cout<<ans;
  }
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long;
using lli = long long int;

void ABC076D()
{
	int N;
	cin >> N;
	vector<int> ti(N);
	vector<int> Ti(N + 1);
	vector<int> vi(N+1);
	for (int i = 0; i < N; ++i)
	{
		cin >> ti[i];
		Ti[i + 1] = Ti[i] + ti[i];
	}
	for (int i = 0; i < N; ++i)
		cin >> vi[i];

	vi[N] = 0;
	for (int i = N-1; i >= 0; --i)
	{
		vi[i] = min(vi[i], vi[i + 1] + ti[i]);
	}

	int v = 0;
	double d = 0.0;
	for (int i = 0; i < N; ++i)
	{

		if (v + ti[i] < min(vi[i], vi[i + 1]))
		{
			d += v * ti[i] + 0.5 * ti[i] * ti[i];
			v += ti[i];
		}
		else
		{
			int t1 = vi[i] - v;
			int s = max(0, vi[i] - vi[i + 1]);
			int t2 = ti[i] - s;
			if (t1 <= t2)
			{
				d += v * ti[i] + 0.5 * t1 * t1 + (vi[i] - v) * (ti[i] - t1) - 0.5 * s * s;
			}
			else
			{
				double tmax = 0.5 * (ti[i] + vi[i + 1] - v);
				d += 0.5 * ((2 * v + tmax) * tmax + (vi[i + 1] + v + tmax) * (ti[i] - tmax));
			}
			v = min(vi[i], vi[i + 1]);
		}
	}
	cout << std::fixed << std::setprecision(10) << d << endl;
}
int main()
{
	ABC076D();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;



int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    int n,ans;
    string a,b,c;
    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; ++i)
    {
        if (a[i]!=b[i] && a[i]!=c[i] && b[i]!=c[i]) ans+=2;
        else if (a[i]==b[i] && a[i]==c[i]) continue;
        else ++ans;
    }
    cout << ans;
}


Measured memory_bytes: 256
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=1e5+10;
int n,m,d[N];
signed main(){
	cin>>n>>m;
	for(int i=1,a,b;i<=m;i++)	cin>>a>>b,d[a]++,d[b]++;
	for(int i=1;i<=n;i++)	if(d[i]&1)	return puts("NO"),0;
	puts("YES");
	return 0;
}


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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  
  
  int dx = tx - sx, dy = ty - sy;
  for (int i = 0; i < dy; i++) {
    cout << "U";
  }
  for (int i = 0; i < dx; i++) {
    cout << "R";
  }
  
  for (int i = 0; i < dy; i++) {
    cout << "D";
  }
  for (int i = 0; i < dx+1; i++) {
    cout << "L";
  }
  
  
  for (int i = 0; i < dy + 1; i++) {
    cout << "U";
  }
  
  for (int i = 0; i < dx + 1; i++) {
    cout << "R";
  }
  cout << "DR"; 
  for (int i = 0; i < dy + 1; i++) {
    cout << "D";
  }
  
  for (int i = 0; i < dx + 1; i++) {
    cout << "L";
  }
  cout << "U" << endl;
  
}

Measured memory_bytes: 3584
a = [int(input()) for i in range(5)]
a.sort(reverse=True)
x=10
last=a[4]
for i in a:
    if i%10!=0 and x>i%10:
        last=i
        x=i%10
a.remove(last)

ans=last
for i in a:
    ans=ans+i+(0 if i%10==0 else 10-i%10)
print(ans)

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

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < (int) s.length(); i++) {
		ans += s[i] == '1';
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  ll N,A,B; cin>>N>>A>>B;
  vector<ll> X;
  vector<ll> walk;
  rep(i,N){
    ll x; cin>>x;
    X.push_back(x);
  }
  rep(i,N-1){
    ll a=A*(X[i+1]-X[i]);
    walk.push_back(a);
  }
  
  ll count=0;
  rep(i,N-1){
    if(walk[i]<B) count+=walk[i];
    else count+=B;
  }
  
  cout<<count<<endl;
}
      
    

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

int main()
{
	long long N;
	long long A;
	long long B;
	cin >> N>>A>>B;

	long long result = 0;

	if ((A-B)%2==0){
		if (A - B > 0) {
			result = (A - B)/2;
		}
		else {
			result=(B - A) / 2;
		}
	}
	else {
		long long A1 = A - 1;
		long long AN = N - A;
		long long B1 = B - 1;
		long long BN = N - B;

		long long AB = A - B;
		if (AB < 0)AB *= -1;
		AB -= -1;

		if (A1 <= AN && A1 <= B1 && A1 <= BN) {
			result = A1 + AB / 2;
		}
		else if (AN <= A1 && AN <= B1 && AN <= BN) {
			result = AN + AB / 2;
		}
		else if(B1 <= AN && B1 <= A1 && B1 <= BN) {
			result = B1 + AB / 2;
		}
		else {
			result = BN + AB / 2;
		}
			
	}
	


    cout << result<<endl;
}



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

using namespace std;

int main() {
  string N;
  cin >> N;
  char last_digit = N[0];
  int cnt = 1;
  for (int i = 1; i < (int)N.size(); ++i) {
    if ((int)N[i] == (int)last_digit) {
      cnt++;
    } else {
      cnt = 1;
      last_digit = N[i];	
    }
    if (cnt == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{ 
   static class Fast{
     public BufferedReader br;
     public StringTokenizer st;
     
     public Fast(){
          br =new BufferedReader(new InputStreamReader(System.in));
     }
     
     String next(){
          while(st==null || !st.hasMoreTokens()){
               try{
                    st=new StringTokenizer(br.readLine());
               }
               catch(IOException e){
                    throw new RuntimeException(e);
               }
               
          }
               return st.nextToken();
          }
     int nextInt(){
          return Integer.parseInt(next());
     }

     long nextLong(){
          return Long.parseLong(next());
     }

 }
  
	public static void main(String[] args)throws Exception{
         //StringTokenizer st;//! @ % & * () _ {} # ~ : < > ? "" | ^
          Fast f=new Fast();
         PrintWriter out = new PrintWriter(System.out);
        // StringBuilder str=new StringBuilder();
         //  int x=Integer.parseInt(st.nextToken());
         
        //st=new StringTokenizer(br.readLine()); 

        
        int n=f.nextInt();
        int h[]=new int[n+1];
        for (int i=0;i<n;i++ ) {
          h[i+1]=f.nextInt();
        }

        int dp[]=new int[n+1];
        dp[0]=0;dp[1]=0;dp[2]=Math.abs(h[2]-h[1]);
        int way1=0,way2=0;
        for (int i=3;i<dp.length;i++) {
            way1=dp[i-1]+Math.abs(h[i]-h[i-1]);
            way2=dp[i-2]+Math.abs(h[i]-h[i-2]);
           dp[i]=Math.min(way1,way2);
        }

        out.println(dp[n]);
    out.close();

}
}




Measured memory_bytes: 43176
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

//int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);

//////////////////////////////////////////

long long a[5];
long long N;

int main(){
    scanf("%lld",&N);
    for(int i = 0;i < 5;i++){
        scanf("%lld",&a[i]);
    }
    long long m = 1000000000000001;
    for(int i = 0;i < 5;i++){
        if(m > a[i]){
            m = a[i];
        }
    }

    long long g = 1;

    g = (N-1)/m + 1;


    printf("%lld\n",g+4);
    
    return 0;
}



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


Measured memory_bytes: 128
n = gets.to_i
t,x,y = n.times.map { gets.split.map(&:to_i) }.transpose
t.unshift(0); x.unshift(0); y.unshift(0);
can = true
for i in 0...n
  dt = t[i+1] - t[i]
  dist = (x[i+1]-x[i]).abs + (y[i+1]-y[i]).abs
  can = false if dt < dist
  can = false if dist % 2 != dt % 2
end

puts can ? 'Yes' : 'No'

Measured memory_bytes: 13180
#!/usr/bin/env python3

import heapq
import sys
input=sys.stdin.readline

t=int(input())
for _ in range(t):
    n=int(input())
    arr=[list(map(int,input().split())) for _ in range(n)]
    q=[]
    ans=0
    camels1=[[] for _ in range(n+1)]
    camels2=[[] for _ in range(n+1)]
    for k,l,r in arr:
        if l>=r:
            camels1[k].append((l,r))
        else:
            camels2[k].append((l,r))
    for i in range(1,n+1):
        for l,r in camels1[i]:
            heapq.heappush(q,(l-r,l,r))
        while len(q)>i:
            _,_,r=heapq.heappop(q)
            ans+=r
    while len(q)!=0:
        _,l,_=heapq.heappop(q)
        ans+=l
    for i in range(n,0,-1):
        for l,r in camels2[i]:
            heapq.heappush(q,(r-l,l,r))
        while len(q)>(n-i):
            _,l,_=heapq.heappop(q)
            ans+=l
    while len(q)!=0:
        _,_,r=heapq.heappop(q)
        ans+=r
    print(ans)

Measured memory_bytes: 160248
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+9;
#define ll long long
ll a[N],sum[N],n,k;
//map<ll,ll>mp;
#define P pair<int,int>
P b[N];
int q[N],hd,tl;
int main(){
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  cin>>n>>k;
  for(int i=1;i<=n;i++)cin>>a[i],sum[i]=(sum[i-1]+a[i])%k;
  for(int i=1;i<=n;i++)sum[i]=((sum[i]-i)%k+k)%k;
  for(int i=0;i<=n;i++)b[i]=P(sum[i],i);
  sort(b,b+n+1);
//  for(int i=0;i<=n;i++)cout<<b[i].first<<" "<<b[i].second<<endl;
  ll ans=0;
  for(int i=0;i<=n;i++){
    int j=i;
    while(j<=n&&b[j].first==b[i].first)j++;
    j--;
    hd=0,tl=-1;
    for(int l=i;l<=j;l++){
      if(hd>tl)q[++tl]=l;
      while(q[tl]+1<=j&&b[q[tl]+1].second-b[l].second<k)q[tl+1]=q[tl]+1,tl++;
      ans+=(tl-hd);
      hd++;
    }
    i=j;
  }
  cout<<ans<<endl;
  return 0;
}


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

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    vector<int> a {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    var(size_t, K);
    output(a[K - 1]);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int str[30];
char cin1[3];
int main(){
	    str[0]=str[1]=str[2]=1;
	int sum = 0;
	char a,b,c;
	cin>>cin1[0]>>cin1[1]>>cin1[2];
	for(int i=0;i<=2;i++){
		sum+=str[cin1[i]-'a'];
		str[cin1[i]-'a'] = 0;
	}
	if(sum==3) printf("Yes\n");
	else printf("No\n");
	return 0;
}
	

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

int t[maxn], a[maxn], n;
string st;

int main() {
//    fin("t.in");
    sync;
    cin >> n;
    cin >> st;
    ri(0, st.size()) {
        t[i + 1] = st[i] == 'x';
    }
    fi(0, 1) {
        fj(0, 1) {
            a[1] = i;
            a[2] = j;
            fk(3, n + 1) {
                a[k] = a[k - 2] ^ (t[k - 1] ^ a[k - 1]);
            }
            if (a[n + 1] != a[1])
                continue;
            if ((a[2] ^ (a[1] ^ t[1])) != a[n])
                continue;
            fk(1, n) {
                if (!a[k])
                    cout << "S";
                else
                    cout << "W";
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 1360
N = int(input())
s = input()
def caesar(s, n):
    ns = []
    for ch in s:
        # A - Z
        if ('A' <= ch and ch <= 'Z'):
            ns.append(chr((ord(ch) - ord('A') + n) % 26 + ord('A')))
        # a - z
        elif ('a' <= ch and ch <= 'z'):
            ns.append(chr((ord(ch) - ord('a') + n) % 26 + ord('a')))
        # 0 - 9
        elif ('0' <= ch and ch <= '9'):
            ns.append(chr((ord(ch) - ord('0') + n) % 10 + ord('0')))
        # no change for other characters
        else:
            ns.append(ch)
    return "".join(ns)

result = caesar(s, N)
print(result)

Measured memory_bytes: 39920
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int h, w;
    char bor[105][105];
    bool val[105][105], ok=true;
    memset(val, true, sizeof(val));
    cin>>h>>w;
    for (int i=0; i<h; i++) for (int j=0; j<w; j++) cin>>bor[i][j];
    for (int i=0; i<h; i++)
    {
        ok=true;
        for (int j=0; j<w; j++) if (bor[i][j]!='.') ok=false;
        if (ok) for (int j=0; j<w; j++) val[i][j]=false;
    }
    for (int i=0; i<w; i++)
    {
        ok=true;
        for (int j=0; j<h; j++) if (bor[j][i]!='.' && val[j][i]) ok=false;
        if (ok) for (int j=0; j<h; j++) val[j][i]=false;
    }
    for (int i=0; i<h; i++)
    {
        ok=false;
        for (int j=0; j<w; j++)
        {
            if (val[i][j]) { cout<<bor[i][j]; ok=true; }
        }
        if (ok) cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a,b) for(int i=int(a);i>int(b);--i)
using namespace std;
using ll = long long;

int N,Y;

int main()
{
  cin >> N >> Y;
  Y /= 1000;

  rep(i,min((Y/10)+1,N+1)){
    rep(j,min(((Y-10*i)/5)+1,N+1-i)){
      if(i*10+j*5+(N-i-j)==Y){
        cout << i << " " << j << " " << N-i-j << "\n";
        return 0;
      }
    }
  }
  cout << "-1 -1 -1\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int n;
  cin>>n;
  vector<int> l;
  for(int i=1;i<=n;i++){
    l.pb(i);
  }
  map<int,pair<double,double>> m;
  for(int i=1;i<=n;i++){
    pair<double,double> xy;
    cin>>xy.first>>xy.second;
    m[i]=xy;
  }
  double num=0;
  int count=0;
  do{
    for(int i=0;i<n-1;i++){
      double xx=pow(m[l[i]].first-m[l[i+1]].first,2);
      double yy=pow(m[l[i]].second-m[l[i+1]].second,2);
      num+=sqrt(xx+yy);
    }
    count++;
  } while(next_permutation(all(l)));
  cout<<setprecision(10)<<fixed<<num/count<<endl;

}

Measured memory_bytes: 256
string = input()
n = int(input())
for i in range(n):
    command = list(input().split())
    if command[0] == "print":
        print(string[int(command[1]):int(command[2])+1])
    elif command[0] == "reverse":
        tmp1 = string[:int(command[1])]
        tmp2 = string[int(command[1]):int(command[2])+1]
        tmp2 = tmp2[::-1]
        tmp1 += tmp2
        tmp1 += string[int(command[2])+1:]
        string = tmp1
    elif command[0] == "replace":
        tmp = string[:int(command[1])]
        tmp += command[3]
        tmp += string[int(command[2])+1:]
        string = tmp


Measured memory_bytes: 5620
# https://arc061.contest.atcoder.jp/tasks/arc061_a

S = list(input())
# print(S)

answer = 0
for i in range(1 << (len(S)-1)):
    expression = []
    for j in range(len(S)):
        if ((i >> j) & 1) == 1:
            expression.append("{}+".format(S[j]))
        else:
            expression.append(S[j])
    # print(eval("".join(expression)))
    answer += eval("".join(expression))

print(answer)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}



signed main(){
	//IOS();
	vector<int>ans;
	while(1){
		int N;
		cin>>N;
		if(!N)break;
		int imos[123456]={};
		rep(i,0,N){
			int h,m,s;
			scanf("%lld:%lld:%lld",&h,&m,&s);
			imos[h*3600+m*60+s]++;
			scanf("%lld:%lld:%lld",&h,&m,&s);
			imos[h*3600+m*60+s]--;
		}
		int ma = 0;
		rep(i,0,123455)imos[i+1]+=imos[i];
		rep(i,0,123456)chmax(ma,imos[i]);
		ans.push_back(ma);
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}


Measured memory_bytes: 4168
#!/usr/bin/env ruby

X, N = gets.chomp.split.map(&:to_i)
P = gets.chomp.split.map(&:to_i)

L = (0..101).to_a - P

min = Float::INFINITY
ans = nil

L.each do |p|
  diff = (p - X).abs
  if min > diff
    min = diff
    ans = p
  end
end

puts ans


Measured memory_bytes: 14300