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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

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

    cout << (0 < n % k ? 1 : 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
ll f[1001000],fi[1001000];
ll mod_pow(ll x,ll n,ll mod){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret=ret*x%mod;
        }
        x=x*x%mod;
        n>>=1;
    }
    return ret;
}

void fact(ll n){
	f[0]=1;
	for(ll i=1;i<=n;i++){
		f[i]=f[i-1]*i%MOD;
	}
	fi[n]=mod_pow(f[n],MOD-2,MOD);
	for(ll i=n-1;i>=0;i--){		
		fi[i]=fi[i+1]*(i+1)%MOD;
	}
}

ll ncr(ll n,ll k){
	if(n<k)return 0;
	if(k==0){
		return 1;
	}else{
		return f[n]*fi[k]%MOD*fi[n-k]%MOD;
	}
}

int main(){
	ll n;cin>>n;n--;
	fact(1000010);
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	ll ans=f[n+1];
    for(ll i=0;i<n;i++){
		ans-=((ncr(n-i-1,i)%MOD*f[i])%MOD*f[n-i])%MOD;
		(ans+=MOD)%=MOD;
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 16380
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp;
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

ll powMod(ll a, ll n, ll mod){
    if(n == 0) return 1;
    if(n%2 == 0)
        return powMod(a, n/2, mod) * powMod(a, n/2, mod) % mod;
    else
        return a * powMod(a, n-1, mod)% mod;
}

ll ncrMod(ll n, ll r, ll mod){
    ll x=1, y=1;
    for(ll i = 1; i <= r; ++i){
        x *= n-i+1;
        x %= mod;
        y *= i;
        y %= mod;
    }
    return x * powMod(y, mod-2, mod) % mod;
}

int main() {
    int mat[3][3];
    int N;
    int b[10];

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> mat[i][j];
        }
    }

    cin >> N;

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

    for (int i = 0; i < N; i++) {
        for (int s_i = 0; s_i < 3; s_i++) {
            for (int s_j = 0; s_j < 3; s_j++) {
                if (b[i] == mat[s_i][s_j]) {
                    mat[s_i][s_j] = 0;
                }
            }
        }
    }


    for (int i = 0; i < 3; i++) {
        int cnt_r = 0;
        int cnt_c = 0;
        for (int j = 0; j < 3; j++) {
            if (mat[i][j] == 0) cnt_r++;
            if (mat[j][i] == 0) cnt_c++;
        }

        if (cnt_r == 3 || cnt_c == 3) {
            cout << "Yes";
            return 0;
        }
    }

    int cnt_1 = 0;
    int cnt_2 = 0;
    for (int i = 0; i < 3; i++) {
        if (mat[i][i] == 0) cnt_1++;
        if (mat[2-i][i] == 0) cnt_2++;
    }

    if (cnt_1 == 3 || cnt_2 == 3) {
        cout << "Yes";
        return 0;
    }


    cout << "No";

    return 0;
}



Measured memory_bytes: 256
numbers = [int(i) for i in input().split()]
sequences = [int(i) for i in input().split()]
x = numbers[0]
y = numbers[0]
a = True
if numbers[0] not in sequences:
    print(numbers[0])
    a = False
while a:
    x += 1
    y -= 1
    if y not in sequences:
        print(y)
        break
    elif x not in sequences:
        print(x)
        break

Measured memory_bytes: 9144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.Linq.Expressions;

static class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int N;
    private int[] A;
    private int cnt;
    private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        A = new int[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(Console.ReadLine());
        }
    }
    private void InsertionSort(int g)
    {
        for (int i = g; i < N; i++)
        {
            int v = A[i];
            int j = i - g;
            while (j >= 0 && A[j] > v)
            {
                A[j + g] = A[j];
                j = j - g;
                cnt++;
            }
            A[j + g] = v;
        }
    }

    public void Solve()
    {
        Scan();
        cnt = 0;
        List<int> g = new List<int>();
        g.Add(1);
        for(int i=1; ; i++)
        {
            int next = g[i - 1] * 3 + 1;
            if (next > N)
            {
                break;
            }
            g.Add(next);
        }
        g.Reverse();
        foreach(int i in g)
        {
            InsertionSort(i);
        }
  
        Console.WriteLine(g.Count);
        Console.WriteLine(string.Join(" ", g.Select(i => i.ToString()).ToArray()));
        Console.WriteLine(cnt);
        Console.WriteLine(string.Join("\n", A.Select(i => i.ToString()).ToArray()));
    }
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  LL n, m;
  scanf("%lld %lld", &n, &m);

  if (n > m) {
    swap(n, m);
  }

  LL ans;
  if (n == 1) {
    if (m == 1) ans = 1;
    else if (m == 2) ans = 0;
    else ans = m - 2;
  } else if (n == 2) {
    ans = 0;
  } else {
    ans = m * n - (2 * n + 2 * (m - 2)); 
  }

  printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w,h,n;cin >> w >> h >> n;
	int lx = 0, rx = w, ly = 0, ry = h;
	rep(i,n){
		int x,y,a;cin >> x >> y >> a;
		if(a == 2) rx = min(rx, x);
		else if(a == 1) lx = max(lx, x);
		else if(a == 4) ry = min(ry, y);
		else ly = max(ly, y);
	}
	cout << max(0, ry - ly) * max(0, rx - lx) << endl;
}


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

constexpr int64_t MOD= 1'000'000'007;
constexpr bool is_FACTORIAL_STORED= false; // 階乗を配列に格納をする前処理をする/しない
constexpr int Nfac= is_FACTORIAL_STORED ? 200'007
                                        : 0;
/* 剰余環 Z/nZ */
struct mint{ // Z/nZ に関する演算(n:素数の場合は除算も)をサポートする構造体
  int64_t rep; // 出力すべき代表元 rep \in {0,1,..,MOD- 1}
  mint(int64_t x=0): rep(((x%MOD)+ MOD)% MOD){}
  mint operator-() const { return mint(-rep);}
  mint& operator+=(const mint& x){
    rep+= x.rep; 
    if(rep>= MOD) rep-= MOD;
    return *this;
  }
  mint& operator-=(const mint& x){
    rep-= x.rep;
    if(rep< 0) rep+= MOD;
    return *this;
  }
  mint& operator*=(const mint& x){
    rep*= x.rep; rep%= MOD;
    return *this;
  }
  mint operator+(const mint x) const {
    mint ans(*this);
    ans+= x;
    return ans;
  }
  mint operator-(const mint x) const {
    mint ans(*this);
    ans-= x;
    return ans;
  }
  mint operator*(const mint x) const {
    mint ans(*this);
    ans*= x;
    return ans;
  }
  bool operator==(const mint x) const {
    return rep==x.rep;
  }
  bool operator!=(const mint x) const {
    return rep!=x.rep;
  }

  mint pow(int64_t d) const{
    assert(d >= 0); // ここで引っかかったら this.pow(d)= 0 or this.pow(-d).inv() のどちらかを選べ
    assert(!(*this==0 && d==0)); //   this.pow(d)= 0 or 1           　     のどちらかを選べ
    mint ans= 1;
    mint x= *this;
    while(d > 0){
      if(d&1){ ans*= x; }
      d >>= 1;
      x*= x;
    }

    return ans;
  }

  friend istream& operator >> (istream &is, mint& x) noexcept{
    int64_t a;
    is >> a;
    x= a;
    return is;
  }
  friend ostream& operator << (ostream &os, const mint& x) noexcept{
      return os << x.rep;
  }
  // MOD が素数(<=> Z/nZ が体)のとき
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint& x){
    *this *= x.inv();
    return *this;
  }
  mint operator/(const mint x) const {
    mint ans(*this);
    ans/= x;
    return ans;
  }
};
// ^^^ テンプレここまで ^^^
enum class Color{
  Black,
  White,
};

using Graph= vector<vector<int>>;
using idx= pair<int, Color>;

mint search(const Graph &tree, int parent, int v, Color color, map<idx, mint> *memo){
  idx id_v= make_pair(v, color);
  if(memo->count(id_v)){ return memo->at(id_v); }
  else{
    mint ans= 1;
    for(auto ngh:tree.at(v)){
      if(ngh != parent){
        if(color==Color::White){ ans*= search(tree, v, ngh, Color::White, memo)+ search(tree, v, ngh, Color::Black, memo); }
        if(color==Color::Black){ ans*= search(tree, v, ngh, Color::White, memo); }
      }
    }

    return memo->operator[](id_v)= ans;
  }
}

int main(){
  int N;
  cin >> N;
  const int M= N-1;

  Graph tree(N);

  int v1,v2;
  for(int j=0; j<M; j++){
    cin >> v1 >> v2;
    v1--; v2--; // 1-indexed -> 0-indexed
    tree.at(v1).emplace_back(v2);
    tree.at(v2).emplace_back(v1);
  }
  map<idx, mint> memo;

  mint ans= search(tree, -1, 0, Color::White, &memo)+ search(tree, -1, 0, Color::Black, &memo);

  cout << ans << endl;
}

Measured memory_bytes: 30792
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mod 1000000007
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int sz=18;

int n;
int w_max = 21322;



struct S{
    int w,s;
    ll v;
    
    void read(){
        cin>>w>>s>>v;
    }
};

bool cmp(S a,S b){
    return (a.w + a.s) < (b.w + b.s);
}


int main()
{  
    ios::sync_with_stdio(false);   
    cin.tie(0);
    
    cin>>n;
    vector<S> v(n);
    for(int i=0;i<n;i++){
    	v[i].read();
	}
    
    sort(v.begin(),v.end(),cmp);
    
    //dp(j) = with j weights, what is max value
    vector<ll> dp(w_max+1);
    for(int i=0;i<n;i++){
    	for(int j=min(v[i].s,w_max-v[i].w);j>=0;j--){
    		dp[j+v[i].w]=max(dp[j+v[i].w],dp[j]+v[i].v);
		}
	}
	ll ans=0;
	for(int i=0;i<=w_max;i++){
		ans=max(ans,dp[i]);
	}
	cout<<ans<<"\n";
}



Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int long long a, b, c;
	cin>>a>>b>>c;
	cout<<floor(a*min(b-1, c)/b)<<endl;
	return 0;
}

Measured memory_bytes: 3764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		String ret = "";
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(str.length() - i - 1);
			ret += ch;
		}
		System.out.println(ret);
	}
}

Measured memory_bytes: 16864
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int A,B,C,X;
	long int ans = 0;
	cin >> A >> B>> C >>X;
	for (int i = 0;i <= A;i++) {
		for (int j = 0; j <= B;j++) {
			for (int k = 0;k <= C;k++) {
				if (X == i * 500 + j * 100 + 50 * k)
					ans++;
			}
		}
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 2e5+17;
const int MOD = 1e9+7;
int dp[MAXN],nxt[MAXN][26+3],ocr[26+3];
int main(int argc ,char const *argv[])
{
  #ifdef noob
  freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
  #endif  
  string str;
  cin>>str;
  int n = str.length();
  for (int i = 0; i < 26; ++i)
  {
    ocr[i] = n;
  }
  for (int i = n-1; i > -1; --i)
  {
    ocr[str[i]-'a'] = i;
    for (int j = 0; j < 26; ++j)
    {
      nxt[i][j] = ocr[j];
    }
    dp[i] = MOD;
  }


  dp[n] = 1;
  for (int i = n-1; i > -1; --i)
    for (int j = 0; j < 26; ++j)
      dp[i] = min(dp[i],dp[nxt[i][j]+1]+1);

  for (int i = 0; dp[0]; --dp[0])
  {
    for (int j = 0; j < 26; ++j)
    {
      if(dp[i]==dp[nxt[i][j]+1]+1)
      {
        printf("%c",j+'a');
        i = nxt[i][j]+1;
        break;
      }
    }
  }

  cout<<endl;

  return 0; 
}


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

int main() {
    int N; cin >> N;
    vector<pair<string, int>> SP(N), saveSP(N);
    for (int i = 0; i < N; i++) {
        cin >> SP.at(i).first >> SP.at(i).second;
        SP.at(i).second *= -1;
        saveSP.at(i).first = SP.at(i).first;
        saveSP.at(i).second = SP.at(i).second;
    }
    sort(SP.begin(), SP.end());
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (saveSP.at(j) == SP.at(i)) {
                cout << j + 1 << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
n=int(input())
arr=[2]
new=[]
for num in range(3,55556):
    isprime=True
    for i in arr:
        if num%i==0:
            isprime=False
            break
    if isprime:
        arr+=[num]
        if num%10==3:
            new+=[num]
    if len(new)==55:
        break

print(' '.join(list(map(str,new[:n]))))


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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    int sum = 0;
    for (int i = 0; i < s.size(); i++) {
        sum += s[i] - '0';
    }
    if (n % sum == 0) {
        yes();
    } else {
        no();
    }
}

Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int k;
	cin >> k;

	long long ans = 0;

	for(int i = 1; i <= k; i++) {
		for(int j = 1; j <= k; j++) {
			for(int t = 1; t <= k; t++) {
				ans += __gcd(i, __gcd(j, t));
			}
		}
	}

	cout << ans;


	return 0;
}


Measured memory_bytes: 3628
N, K = map(int,input().split())
x = list(map(int,input().split()))
ans = float("inf")
for i in range(N-K+1):
    ans = min(ans, abs(x[i])+abs(x[i]-x[i+K-1]))
    ans = min(ans, abs(x[i+K-1])+abs(x[i]-x[i+K-1]))
print(ans)

Measured memory_bytes: 20040
L, R = map(int, input().split())
M = 2019


def solve():
    if (R - L) > M:
        return 0

    m = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            if (i * j) % 2019 < m:
                m = (i * j) % 2019
    return m


print(solve())


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int n;
qp<P<llong, int> > q;
Vec<Vec<P<llong, int> > > vec;
Vec<llong> score;

void hawawa()
{
  cin >> n;
  vec.resize(n);
  score.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    vec[a].push_back(make_pair(c, b));
    vec[b].push_back(make_pair(c, a));
  }
  int que, k;
  cin >> que >> k;
  k--;
  score[k] = 0;
  set<int> s;
  for (auto&& i : vec[k]) {
    q.push(i);
  }
  s.insert(k);
  while (s.size() < n) {
    auto status = q.top();
    q.pop();
    if (s.count(status.second)) continue;
    s.insert(status.second);
    score[status.second] = status.first;
    for (auto&& i : vec[status.second]) {
      if (s.count(i.second)) continue;
      q.push(make_pair(status.first + i.first, i.second));
    }
  }
  while (que--) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    cout << score[x] + score[y] << "\n";
  }
}

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

Measured memory_bytes: 15472
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 100005;
int n, a[maxn];
int main()
{
    // freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    LL sum = 0;
    int cnt = 0;
    int mn = INT_MAX;
    for(int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        if(x < 0){
            cnt++;
            x = -x;
        }
        sum += x;
        mn = min(x, mn);
    }
    if(cnt & 1){
        sum -= mn*2;
    }
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        var h = cin.ArrayLong(N);

        var dp = new long[100010];
        dp[0] = 0;
        dp[1] = Math.Abs(h[1] - h[0]);
        for (int i = 2; i < N; i++) {
            dp[i] = Math.Min(dp[i - 1] + Math.Abs(h[i] - h[i - 1]), dp[i - 2] + Math.Abs(h[i] - h[i - 2]));
        }
        Console.WriteLine(dp[N - 1]);
        Console.ReadLine();
    }
}

Measured memory_bytes: 22752
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
vector<ll>primeFactors(ll n)  
{ 
    vector<ll>vec;
    while (n % 2 == 0)  
    {  
       vec.push_back(2);
        n = n/2;  
    }  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {   
        while (n % i == 0)  
        {  
            vec.push_back(i);  
            n = n/i;  
        }  
    }  
    if (n > 2)  
        vec.push_back(n); 
    return vec;
}
ll count(ll n) 
{ 
    return (ll)((-1 + sqrt(1 + 8 * n)) / 2); 
} 
int main() {
    ll n;
    cin>>n;
    vector<ll>vec=primeFactors(n);
    map<ll,ll>mx;
    for(ll i=0;i<vec.size();i++)
    {
        mx[vec[i]]++;
    }
    ll ans=0;
    for(auto i : mx)
    {
        ll p=count(i.second);
        ans+=p;
    }
    cout<<ans<<endl;
	return 0;
}

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

// 書いてから気づいたけど冗長…
int main() {
  int n;
  cin >> n;
  int a[1010];
  rep(i,1010) a[i] = 0;
  rep(i,n) {
    int x;
    cin >> x;
    a[x]++;
  }
  int mina = 1010;
  int maxa = -1;
  rep(i,1010) {
    if (a[i] >= 1) {
      mina = min(mina,i);
      maxa = max(maxa,i);
    }
  }
  cout << maxa - mina << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)

main(){
  string pattern, target; cin >> pattern;
  int n; cin >> n;
  int cnt = 0;
  rep(i, n){
    cin >> target;
    target += target;
    if ( target.find(pattern) != string::npos ) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 0
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

k,x = l()

p = [x + i for i in range(2*k - 1)]

for i in range(len(p)):
    p[i] -= k - 1 

print(jo(p))

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

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

  for(i=0;i<N;i++){
    string s;
    cin>>s;
   	if(s=="Y"){
    	cout<<"Four"<<endl;
      	break;
    }else if(i+1==N){
    	cout<<"Three"<<endl;
    }
  }    
}

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

//#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main() {
    int A,B,K;
    int flag=0;

    cin >> K >> A >> B;

    for(int i=1; ;i++){
        if( A<=K*i && K*i<=B){
            flag = 1;
        }
        if(B<K*i){
            break;
        }
    }

    if(flag==1){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }



}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

typedef long long ll;
using namespace std;

int p[3] = {10000, 5000, 1000};
ll n,y;
int main() {
  cin >> n >> y;

  for(ll i = 0; i < n+1; i++){
    for(ll j = 0; j < n+1; j++){
      if(i+j > n){
        continue;
      } 
      else{
        ll k = n-(i+j);
        if(y == 10000*i + 5000*j + 1000*k){
          printf("%lld %lld %lld\n",i,j,k);
          return 0;
        }
      }
    }
  }
  printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
import bisect

N = int(input())
A = sorted(list(map(int,input().split())))
B = list(map(int,input().split()))
C = sorted(list(map(int,input().split())))
ans = 0
for x in B:
    ai = bisect.bisect_left(A,x)
    ci = bisect.bisect_right(C,x)
    ans += (ai*(N-ci))
print(ans)

Measured memory_bytes: 24224
#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 1000000007
#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};

struct plane{
    ll n;
    string d;
    bool operator<(const plane& a)const{
        return n < a.n;
    }   
};

int main(){
    ll N;
    cin>>N;
    map<ll,vector<plane>> mx;
    map<ll,vector<plane>> my;
    map<ll,vector<plane>> mx45;
    map<ll,vector<plane>> my45;
    rep(i,0,N){
        ll x,y;
        char u;
        cin>>x>>y;
        cin>>u;
        plane tmp;
        tmp.n = y;tmp.d = u;
        my[x].push_back(tmp);
        tmp.n = x;
        mx[y].push_back(tmp);
        tmp.n =y-x;
        my45[x+y].push_back(tmp);
        tmp.n =x+y;
        mx45[y-x].push_back(tmp);
    }
    ll ans = INF;
    ll R_min,L_min,U_min,D_min;
    vector<plane> now;

    rep(i,-200000,200001){
        now = mx[i];
        sort(all(now));
        R_min=INF;
        rep(j,0,now.size()){
            if(now[j].d=="R"){
                R_min = now[j].n;
            }
            else if(now[j].d == "L" && R_min != INF){
                ans = min(ans,(now[j].n-R_min) * 5);
            }
        }

        now = my[i];
        sort(all(now));
        //if(now.size()!= 0)cout<<i<<" "<<now[0].n<<" "<<now[1].n;
        U_min=INF;
        rep(j,0,now.size()){
            if(now[j].d=="U"){
                U_min = now[j].n;
            }
            else if(now[j].d == "D" && U_min != INF){
                ans = min(ans,(now[j].n-U_min) * 5);
            }
        }
    }
    rep(i,-400000,400001){
        now = mx45[i];
        sort(all(now));
        R_min=INF;
        U_min=INF;
        rep(j,0,now.size()){
            if(now[j].d=="R"){
                R_min = now[j].n;
            }
            else if(now[j].d=="U"){
                U_min = now[j].n;
            }
            else if(now[j].d == "D" && R_min != INF){
                ans = min(ans,(-R_min+now[j].n) * 5);

            }
            else if(now[j].d == "L" && U_min != INF){
                ans = min(ans,(-U_min+now[j].n) * 5);

            }
        }


        now = my45[i];
        sort(all(now));
        L_min=INF;
        U_min=INF;
        rep(j,0,now.size()){
            if(now[j].d=="L"){
                L_min = now[j].n;
            }
            else if(now[j].d=="U"){
                U_min = now[j].n;
            }
            else if(now[j].d == "D" && L_min != INF){
                ans = min(ans,(-L_min+now[j].n) * 5);

            }
            else if(now[j].d == "R" && U_min != INF){
                ans = min(ans,(-U_min+now[j].n) * 5);

            }
        }
        
    }
    if(ans==INF) cout<<"SAFE"<<endl;
    else cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 237772
#include <iostream>
#include <stdio.h>

int main(){
  int n;
  std::cin >> n;
  int a[n];
  int order[n];
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    order[a[i]-1] = i+1;
  }

  for(int i = 0; i < n; i++) printf("%d ", order[i]);
  printf("\n");

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  
  int ans=1;
  int t=0,x=0,y=0;
  
  for(int i=0;i<n;i++){
    int a,b,c;
    cin >> a >> b >> c;
    int p=max(b-x,x-b)+max(c-y,y-c);
    ans*=(a-t>=p&&(a-t-p)%2==0);
    if(ans==0) break;
    t=a;
    x=b;
    y=c;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(a,b,c);
    cout << min(b/a,c) << nn;
    return 0;
}

Measured memory_bytes: 256
# ABC127C - Prison
# l-max < i < r-min -> count i
n, m = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(m)]
l, r = lst[0][0], lst[0][1]
for i in lst[1:]:
    l = max(l, i[0])
    r = min(r, i[1])
print(max(0, r - l + 1))

Measured memory_bytes: 28100
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		if(a>x){
			System.out.println("NO");
		}else if(x-a<=b){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

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

int main(){
  int n,count=0;
  cin>>n;
  for(int i=1;i<=n;i++){
	int a;
    cin>>a;
    if(a%2==1&&i%2==1)count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <chrono>
#include <random>
#include <bits/stdc++.h>
 
using namespace std;
template <typename T> T max(T a, T b) {return a>b?a:b;}
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
#define ll long long
#define PI 3.14159265358979323846
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a<b)?(b):(a))
#define abs(a) ((a>0)?a:-(a))

const double eps = (double)1e-6;
const int maxn = 2e5+5;
const ll mod = 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll arr[maxn];

ll quickpow(ll n) {
    ll base = 2, ans = 1;
    while (n) {
        // if (n&1) ans *= base %= mod;
        // base *= base %= mod;
        if (n & 1) ans = (ans * base) % mod;
        base = (base * base) % mod;
        n >>= 1;
    }
    return ans;
}

int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr+n, greater<ll>());
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans = (ans + ((i+2) * arr[i]) % mod) % mod;
    }
    ans = (ans*quickpow(2*n-2)) % mod;
    cout << ans << endl;
        
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	x := getNextInt64(scanner)

	mx := 0
	for i := 0; pow5(i+1) <= math.MaxInt64>>5; i++ {
		mx = i + 1
	}
	for i := -mx; i < mx; i++ {
		for j := -mx; j < mx; j++ {
			if pow5(i)-x == pow5(j) {
				fmt.Fprintln(writer, fmt.Sprintf("%d %d", i, j))
				return
			}
		}
	}
}

func pow5(a int) int64 {
	b := int64(a)
	return b * b * b * b * b
}


Measured memory_bytes: 1816
let rec smaller n ar =
  let rec f h t =
    let m = (h + t) / 2 in
    if h = m then if ar.(h) < n then h + 1 else h
    else if ar.(m) < n then f m t
    else f h m
  in
  f 0 (Array.length ar)


let rec larger n ar =
  let rec f h t =
    let m = (h + t) / 2 in
    if h = m then
      if ar.(h) <= n then Array.length ar - (h + 1) else Array.length ar - h
    else if ar.(m) <= n then f m t
    else f h m
  in
  f 0 (Array.length ar)


let id x = x
let n = Scanf.scanf "%d\n" id
let a = Array.init n (fun _ -> Scanf.scanf "%d " id)
let b = Array.init n (fun _ -> Scanf.scanf "%d " id)
let c = Array.init n (fun _ -> Scanf.scanf "%d " id)

let () =
  Array.fast_sort ( - ) a ;
  Array.fast_sort ( - ) b ;
  Array.fast_sort ( - ) c ;
  Array.fold_left (fun pre n -> smaller n a * larger n c + pre) 0 b
  |> Printf.printf "%d\n"

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


// 2011/10/21

//@0177 nãÌ£ 
public class Main {

	/*
	 *  x²ªo0xûü
	 *  y²ªo90xûü
	 *  z²ªkÜ90x(kÉ)ûü
	 */
	
	// kÜÆo©ç »Ìûüðw·PÊxNgðßé
	double[] calc(double hokui, double toukei) {
		
		double z = Math.sin(hokui / 180 * Math.PI);
		double xy = Math.cos(hokui / 180 * Math.PI);
		double x = xy * Math.sin(toukei / 180 * Math.PI);
		double y = xy * Math.cos(toukei / 180 * Math.PI);
		return new double[] { x, y, z };
	}
	
	
	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		String s = reader.readLine();
		String[] sp = s.split(" ");
		double[] a = new double[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Double.parseDouble(sp[i]);
		}
		if (a[0] == -1 && a[1] == -1 && a[2] == -1 && a[3] == -1)
			return false;

		double[] v1 = calc(a[0], a[1]);
		double[] v2 = calc(a[2], a[3]);
		
		//àÏ
		double naiseki = v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2];
		
		// È·px
		double r = Math.acos(naiseki);
		
		int d = (int)Math.round(r * 6378.1);
		
		// ðÌ\¦
		System.out.printf("%d\n", d);
		
		return true; // ³íI¹ Ö
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

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

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "35.68 139.77 51.15 359.82,-1 -1 -1 -1,";
			//String inputStr = "35.68 139.77 51.15 359.82,-1 -1 -1 -1,";
			inputStr = inputStr.replace(",", "\n");

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}
		
		//int N = readIntArray()[0];

		for(int i = 0; /*i < N*/; i++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè1sªÌXy[XæØèÌ®lðÇÞ
	// EOFÌêÍnullðÔ·
	private static int[] readIntArray() throws IOException {
		
		String s = reader.readLine();
		if (s == null)
			return null;
		String[] sp = s.split(" ");
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}

Measured memory_bytes: 0
import java.io.*;
import java.util.StringTokenizer;
class Main {

	public static void main(String args[])throws IOException
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
		String s=BR.readLine();
		
		StringTokenizer st=new StringTokenizer(s);
		long a=Long.parseLong(st.nextToken());
		long b=Long.parseLong(st.nextToken());
		long c=Long.parseLong(st.nextToken());
		long k=Long.parseLong(st.nextToken());
		/*for(int i=0;i<k;i++)
		{
			long temp1=b+c;
			long temp2=a+c;
			long temp3=a+b;
			a=temp1;
			b=temp2;
			c=temp3;
			System.out.println(a+" "+b+" "+c+" "+(a-b));
		}*/
		long q=a-b;
		//long g=(long) Math.pow(10,18);
		//System.out.println(g);
		if(q>Math.pow(10, 18))
		{
			System.out.println("Unfair");
		}
		else
			{			
			if(k%2==0)
				System.out.println((q));
			else
				System.out.println(-(q));
			}
	}
}


Measured memory_bytes: 21332
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<deque>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

int main() {

	int n; cin >> n;
	for (int i = 0 ; i < n; i++) {
		string trans; cin >> trans;
		string org; cin >> org;
		reverse(org.begin(),org.end());
		reverse(trans.begin(),trans.end());

		for (int i = 0; i < trans.size(); i++){
			if (trans[i] == 'J'){
				string str1 = org.substr(0,1);	
				string str2 = org.substr(1,org.size()-1);	
				org = str2 + str1;
			}else if (trans[i] == 'C'){
				string str1 = org.substr(0,org.size()-1);	
				string str2 = org.substr(org.size()-1,1);	
				org = str2 + str1;
			}else if (trans[i] == 'E'){
				if (org.size() % 2 == 0){
					string str1 = org.substr(0,org.size()/2);	
					string str2 = org.substr((org.size()/2),org.size()-(org.size()/2));	
					org = str2 + str1;
				}else{
					string str1 = org.substr(0,org.size()/2);	
					string str2 = org.substr((org.size()/2),1);	
					string str3 = org.substr((org.size()/2)+1,org.size()-(org.size()/2));	
					org = str3 + str2 + str1;
				}

			}else if (trans[i] == 'A'){
				reverse(org.begin(),org.end());
			}else if (trans[i] == 'M'){
				for (int j = 0; j < org.size(); j++){
					if (isdigit(org[j])){
						int tmp = (org[j] - 48 + 1 + 10 )%10;
						org[j] = (tmp + '0');	
					}
				}
			}else if (trans[i] == 'P'){
				for (int j = 0; j < org.size(); j++){
					if (isdigit(org[j])){
						int tmp = (org[j] - 48 - 1 + 10)%10;
						org[j] = (tmp + '0');	
					}
				}
			}
		}

		reverse(org.begin(),org.end());
		cout << org << endl;

	}
	return 0;
}

Measured memory_bytes: 2996
n=int(input())
s=input()
animals=["#"]*len(s)

def oppositeAnimal(animal):
  if animal=="S":
    return "W"
  else:
    return "S"

def getNextAnimal(animal,answer,pastanimal):
  if animal=="S":
    if answer=="o":
      return pastanimal
    else:
      return oppositeAnimal(pastanimal)
  else:
    if answer=="o":
      return oppositeAnimal(pastanimal)
    else:
      return pastanimal

for a0 in ("S","W"):
  for a1 in ("S","W"):
    animals=["#"]*len(s)
    animals[0]=a0
    animals[1]=a1
    for i in range(2,len(s)):
      animals[i]=getNextAnimal(animals[i-1],s[i-1],animals[i-2])
    if getNextAnimal(animals[len(s)-1],s[len(s)-1],animals[len(s)-2])==animals[0]:
      if getNextAnimal(animals[0],s[0],animals[len(s)-1])==animals[1]:
        print("".join(animals))
        exit(0)
print(-1)

Measured memory_bytes: 4852
#include <stdio.h>
#define mod 998244353
typedef long long ll;

ll mul(ll a, ll b) {
  return a * b % mod;
}

int main(void) {
  ll i, j, k, n, ans = 1, now[3] = {0, 0, 0}, t = 0, c;
  scanf("%lld", &n);
  char s[3 * n + 10];
  bool flg[3 * n], flg2[3 * n];
  for(i = 0; i < 3 * n; ++i) flg[i] = false;
  ll max[n], min[n], cnt[3];
  for(i = 0; i < n; ++i) min[i] = -1;
  scanf("%s", s);
  for(i = 0; s[i]; ++i) {
    if(s[i] == 'R') s[i] = t = 0;
    else if(s[i] == 'G') s[i] = t = 1;
    else s[i] = t = 2;
    if(min[now[t]] == -1) min[now[t]] = i;
    max[now[t]] = i;
    now[t]++;
  }
  for(i = 0; i < n; ++i) 
    flg[min[i]] = flg[max[i]] = true, flg2[min[i]] = true, flg2[max[i]] = false;
  t = 0;
  now[0] = now[1] = now[2] = 0;
  for(i = 0; i < 3 * n; ++i) {
    if(flg[i]) {
      if(flg2[i]) c = s[i], t++;
      else ans = mul(ans, now[s[i]]), now[s[i]]--;
    } else {
      ans = mul(ans, t), t--;
      now[3 - c - s[i]]++;
    }
  }
  for(i = 1; i <= n; ++i) ans = mul(ans, i);
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int edit_distance(string src, string dst){
    // initializations
    auto ns = src.size();
    auto nd = dst.size();
    vector<int> dp_next(nd + 2);
    vector<int> dp_prev(nd + 2);
    for (int i = 0; i != nd + 1; ++i) dp_prev[i] = i;
    dp_prev[nd + 1] = ns + nd;
    dp_next[nd + 1] = ns + nd;

    // fill dp
    for (int i = 0; i != ns; ++i){
        auto s = src[i];
        dp_next[0] = i + 1;
        for (int j = 0; j != nd; ++j){
            int inc = (s == dst[j]) ? 0 : 1;
            dp_next[j + 1] = min(dp_prev[j] + inc, min(dp_prev[j + 1], dp_next[j]) + 1);
        }
        swap(dp_next, dp_prev);
    }
    
    return dp_prev[nd];
}


int main()
{
    string src;
    string dst;
    cin >> src;
    cin >> dst;
    cout << edit_distance(src, dst) << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int main(void){
    int x;
    cin>>x;
    if(x%7==0){
        cout<<"thu"<<endl;
    }
        if(x%7==1){
        cout<<"fri"<<endl;
    }
        if(x%7==2){
        cout<<"sat"<<endl;
    }
        if(x%7==3){
        cout<<"sun"<<endl;
    }
        if(x%7==4){
        cout<<"mon"<<endl;
    }
        if(x%7==5){
        cout<<"tue"<<endl;
    }
        if(x%7==6){
        cout<<"wed"<<endl;
    }
    
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod)
{
        a %= _mod; b %= _mod; ll res = 1;
        switch (op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break;
        } 
        if (res < 0) { res += _mod; } return res;
}

vector<string> v;
ll N;

void rec(string s, ll cur, char last)
{
        if (cur == N) {
                v.push_back(s);
                return;
        }

//         char mx = *max_element(all(s));
//         if (len(s) == 0) mx = 'a';
//         char nx = mx + 1;
// //        rec(s+mx, cur+1, mx);
//         // rec(s+nx, cur+1, nx);
        
        for (char c = 'a'; c <= last; ++c) {
                char nc = last;
                if (nc == c) ++nc;
                rec(s+c, cur+1, nc);
        }
}

int main()
{
        cin >> N;

        rec("", 0, 'a');
        rep(i, 0, len(v)) {
                cout << v[i] << endl;
        }
}


Measured memory_bytes: 7232
#include <bits/stdc++.h>
using namespace std;
int N,D,pro=1,result=0; 
int main()
{
    cin>>D>>N;
    for(int i=1;i<=D;i++)
    {
        pro=pro*100;
    }
    if(N==100)
    {
        result=result+pro;
    }
    cout<<result+pro*N<<endl;
    return 0;
}


Measured memory_bytes: 256