akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define input freopen("1.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define ll long long int
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
#define pii pair<int, int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpi vector<pii>
#define vpl vector<pll> 
#define ss second 
#define ff first

using namespace std;

const int p = 1e9 + 7;
const int maxn = 1e5 + 1;

void solve() {
    // int n; cin >> n;
    string s; cin >> s;
    int m = 0;
    int ans = -p;
    for(int i = 0; i < 3; i++) {
        if(s[i] == 'R') m++;
        else {
            ans = max(ans, m);
            m = 0;
        }
    }
    ans = max(ans, m);
    cout << ans ;
}

int main() {
    fast
    int t = 1; 
    // cin >> t;
    while(t--) solve();
    return 0;
}

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

int main(){
  long long n,k,array[100001],ans[100001]={},ans2[100001]={};
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  for(int i=0;i<=n-k;i++){
    ans[i]+=abs(array[i]);
    ans[i]+=abs(array[i+k-1]-array[i]);
  }
  sort(ans,ans+(n-k+1));
  reverse(array,array+n);
  for(int i=0;i<=n-k;i++){
    ans2[i]+=abs(array[i]);
    ans2[i]+=abs(array[i+k-1]-array[i]);
  }
  sort(ans2,ans2+(n-k+1));
  cout<<min(ans2[0],ans[0])<<endl;
}

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

using namespace std;

int main(void)
{
    int i, l;
    string s;

    cin >> s;
    l = s.size();

    for(i = 0; i < l; i++)
    {
        if(s[i] == '7')
            break;
    }

    if(i == l)
        cout << "No\n";
    else
        cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 3596
// topological sort with dfs algorithm
// reference Programming Contest Challenge Book Second Edition
// verify https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/1/GRL_4_B

#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;

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

template<typename T> struct edge {
  int to;

  edge(int to_) : to(to_) {}
};

template<typename T,template <typename ELEM> class C> struct Topological_Sort {
  vector<vector<C<T>>> G;
  vector<bool> used;
  int V;//0,...,|V|-1
  T INF;

  Topological_Sort (int V_) {
    init(V_);
  }

  void init(int V_) {
    V = V_;

    G.clear();
    G.resize(V);
  }

  void add_edge(int from,int to) {
    G[from].push_back(C<T>(to));
  }

  bool dfs (int i,set<int> pars,vector<int> &sorted) {
    pars.insert(i);
    used[i] = true;

    rep(j,(int)G[i].size()) {
      if (!used[G[i][j].to]) {
        if(dfs(G[i][j].to,pars,sorted)) {
          return true;
        }
      } else {
        if (pars.find(G[i][j].to) != pars.end())  {
          return true;
        }
      }
    }

    pars.erase(i);
    sorted.push_back(i);
    return false;
  }

  bool topological_sort (vector<int> &sorted) { // 成功ならtrue 失敗ならfalseを返す
    used.clear();
    used.resize(V,false);

    sorted.clear();

    rep (i,V) {
      if (!used[i] && dfs(i,set<int>(),sorted)) {
        return false;;
      }
    }

    reverse(sorted.begin(),sorted.end());

    return true;
  }

};

using ll = long long;

int main() {
  ll V,E;
  cin >> V >> E;
  Topological_Sort<ll,edge> ts(V);
  rep(i,E) {
    ll s,t;
    cin >> s >> t;
    ts.add_edge(s,t);
  }

  vector<int> ans;

  ts.topological_sort(ans);

  for (auto v : ans) {
    cout << v << endl;
  }
  return 0;
}



Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>
#include<algorithm>
#define ll long long

using namespace std;

int main()
{
	int k;
	cin>>k;
	int ans = 1, seven = 7;
	while(seven % k)
	{
		ans++;
		seven = (seven * 10 + 7 )% k;
		if(ans > 1000000) break;
	}
	if(ans > 1000000) puts("-1");
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3188
from sys import stdin, setrecursionlimit as srl
from threading import stack_size
srl(int(1e9)+7)
stack_size(int(1e8))

prime = 10**9 + 7

def get(i, j, m, value):
    if i==h-1 and j==w-1:
        return 1
    if value[i][j]!=-1:
        return value[i][j]
    ans = 0
    if i < h-1 and m[i+1][j]=='.':
        value[i+1][j] = get(i+1, j, m, value)
        ans += value[i+1][j]
    if j < w-1 and m[i][j+1]=='.':
        value[i][j+1] = get(i, j+1, m, value)
        ans += value[i][j+1]
    return ans%prime

h, w = map(int,input().split())
m = []
for i in range(h):
    m.append(input())
value = [[-1 for i in range(w)] for j in range(h)]
ans = get(0, 0, m, value)
print(ans)

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

using namespace std;
int n,i,v[100005][4],din[100005][4],j,k;
int main()
{
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>v[i][1]>>v[i][2]>>v[i][3];
    }
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=3;j++)
        {
            for (k=1;k<=3;k++)
            {
                if (k!=j)
                {
                    din[i][j]=max(din[i][j],din[i-1][k]+v[i][j]);
                }
            }
        }
    }
    cout<<max(din[n][1],max(din[n][2],din[n][3]));
    return 0;
}


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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n;
	cin >> n;
	cout << n * n * n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <climits>
#include <cmath>

using namespace std;

int main(void){
	int r;
	cin >> r;

	if(r<1200){
		cout << "ABC" << endl;
	}else if(1200<= r && r < 2800){
		cout << "ARC" << endl;
	}else{
		cout << "AGC" << endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <map>
using namespace std;
int main() {
	int N;
	map<int, int> m1;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		m1[tmp]++;
	}

	cout << m1.size() << endl;

	return 0;
}

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

const int mod = 1e9 + 7;
const int maxn = 2000 + 7;

long long f[maxn][maxn];
long long step[maxn * maxn], inv[maxn * maxn];

long long C(int n, int m) {
    return step[n] * inv[m] % mod * inv[n - m] % mod;
}

int main() {
    int n, k;
    cin >> n >> k;
    if (k == 1) {
        printf("1\n");
        return 0;
    }

    long long ans = 1;
    for (int i = 1; i <= n; i++) ans = ans * i % mod;

    step[0] = 1;
    for (int i = 1; i <= n * k; i++) step[i] = step[i - 1] * i % mod;

    inv[0] = inv[1] = 1;
    for (int i = 2; i <= n * k; i++) 
        inv[i] = mod - (mod / i) * inv[mod % i] % mod;
    for (int i = 2; i <= n * k; i++) 
        inv[i] = inv[i  - 1] * inv[i] % mod;
    
    f[0][0] = 1;

    for (int i = 0; i <= n; i++) 
    for (int j = i; j <= n; j++) {
        long long &rt = f[i][j];

        if (j > i) 
            rt = C((k - 1) * j + i - 1, k - 2) * f[i][j - 1] % mod;
        if (i > 0) {
            rt = (rt + f[i - 1][j]) % mod;
        }
    }

    cout << ans * f[n][n] % mod << endl;
    return 0;
}

Measured memory_bytes: 94464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
ll INF = 10000000000;

int main(void){
    ll N,K;
    cin >> N >> K;
    vector<ll> H(N);
    for(ll i = 0; i < N; i++){
        cin >> H.at(i);
    }
    sort(H.begin(), H.end());
    ll ans = 0;
    for(int i = 0; i < N - K; i++){
        ans += H.at(i);
    }
    printf("%lld", ans);
    
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = a; i < b; i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

int main() {
	fast_io;
	int k; cin>>k;
	queue<ll> q;
	lp(i,1,10)
		q.push(i);
	ll x;
	while(k--){
		x=q.front();q.pop();
		if(x%10!=0) q.push(10*x+x%10-1);
		q.push(10*x+x%10);
		if(x%10!=9) q.push(10*x+x%10+1); 
	}
	cout<<x;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>
#define pi3 pair<int, pi>
#define pi4 pair<pi, pi>

const int MX=300000+10;
const ll mod=998244353;

int T[4*MX];

void up(int p, int l, int h, int x, int vl)
{
    if(l==h)
    {
        T[p]=vl; return;
    }
    int mid=(l+h)/2;
    if(x<=mid) up(2*p, l, mid, x, vl);
    else       up(2*p+1, mid+1, h, x, vl);

    T[p]=max(T[2*p], T[2*p+1]);
}

int Q(int p, int l, int h, int x, int y)
{
    if(l>y || h<x) return 0;
    if(l>=x && h<=y) return T[p];

    int mid=(l+h)/2;
    return max(Q(2*p, l, mid, x, y), Q(2*p+1, mid+1, h, x, y));
}

int a[MX];

int main()
{
    FasterIO;

    int n, k, N=300001; cin>>n>>k;

    for(int i=1; i<=n; a[i]++, i++) cin>>a[i];

    int mx=0;

    for(int i=n; i>=1; i--)
    {
        int r=Q(1, 1, N, max(1, a[i]-k), min(N, a[i]+k));
        up(1, 1, N, a[i], r+1);
        mx=max(mx, 1+r);
    }

    cout<<mx<<endl;

    return 0;
}


Measured memory_bytes: 8928
package main

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

type Scanner struct {
	reader *bufio.Scanner
}

func (s *Scanner) Next() string {
	s.reader.Scan()
	return s.reader.Text()
}

func (s *Scanner) NextInt() int {
	s.reader.Scan()
	val, err := strconv.Atoi(s.reader.Text())
	if err != nil {
		panic(err)
	}
	return val
}

var sc *Scanner

func init() {
	sc = &Scanner{bufio.NewScanner(os.Stdin)}
	sc.reader.Split(bufio.ScanWords)
}

func main() {
	a := sc.NextInt()
	b := sc.NextInt()
	c := sc.NextInt()

	vals := []int{a, b, c}
	sort.Ints(vals)
	fmt.Printf("%d %d %d\n", vals[0], vals[1], vals[2])
}



Measured memory_bytes: 1116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ll mod=1e9+7;
const ld PI = 2 * acos(0.0);
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
	if(b==0)
		return 1;
	ll d=power(a,b/2,m);
	d=(d*d)%m;
	if(b&1)
		d=(d*a)%m;
	return d;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	int s,w;cin>>s>>w;
	if(w>=s)
	{
		cout<<"unsafe\n";
	}
	else
		cout<<"safe\n";
	return 0;
}

Measured memory_bytes: 3656
N, K = map(int, input().split())
S = input()

que = [(S[0], 0)]
cur = S[0]
for i in range(1, N):
    if cur != S[i]:
        que.append((S[i], i))
        cur = S[i]

ans = []
LEN = len(que)
for i in range(LEN):
    if que[i][0] == '0':
        if i + 2 * K < LEN:
            ans.append(que[i + 2 * K][1] - que[i][1])
        else:
            ans.append(N - que[i][1])
    else:
        if i + 2 * K + 1 < LEN:
            ans.append(que[i + 2 * K + 1][1] - que[i][1])
        else:
            ans.append(N - que[i][1])
            
print(max(ans))


Measured memory_bytes: 59000
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
	
    string s;
    cin >> s;
    int ans = 700;
    rep(i,3){
      if(s[i]=='o'){
        ans += 100;
      }
    }
    cout << ans << endl;
    return 0;
  }    

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int i, x, y;
    int arr[2999][2] = {};

    i = 0;

    while (1)
    {
        std::cin >> x >> y;

        if ((x == 0 && y == 0) || i > 2999)
        {
            break;
        }

        if (x > y)
        {
            arr[i][0] = y;
            arr[i][1] = x;
        }
        else
        {
            arr[i][0] = x;
            arr[i][1] = y;
        }

        i++;
    }


    for (int n = 0; n < i; n++)
    {
        std::cout << arr[n][0] << " " << arr[n][1] << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3112
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pint> p(n);
    int ans = 0;
    REP(i, n){
        cin >> p[i].fst >> p[i].snd;
    }
    REP(i, n){
        ans += p[i].snd - p[i].fst + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;
#define INF 100000100LL

int main(){
    int A, B, M;
    cin >> A >> B >> M;
    ll ans = INF, MINa = INF, MINb = INF;
    vector<ll> a(A), b(B);
    rep(i, A){
        cin >> a[i];
        MINa = min(MINa, a[i]);
    }
    rep(i, B){
        cin >> b[i];
        MINb = min(MINb, b[i]);
    }
    ans = min(ans, MINa + MINb);
    rep(i, M){
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        ll tmp = a[x] + b[y] - c;
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
    #include <string>
          #define ll int
          #define N 100000
          #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
          #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
          #define po pop_back
          #define pb push_back
          #define pp pair<ll,ll>
          #define lb lower_bound
          #define fi first
          #define se second
          #define debug(x) cout << #x << " = " << x << endl
          #define ub upper_bound
          #define ibs ios_base::sync_with_stdio(false)
          #define cti cin.tie(0)
          #define all(x) x.begin(),x.end()
          #define PI 3.14159265
          #define cot cout.tie(0)
          using namespace std;
         /**
          * @author :: Sawlani
          *
          */
          int main()
          {
              ll n;
              cin >>  n;
              string s;
              cin >> s;

              string k=s.substr(0,n/2);
              string j=s.substr(n/2,n/2);
              if(k==j&&n%2==0)
              cout << "Yes" << endl;
              else
                cout << "No" << endl;



          }


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


ll i,n,num,ans=0;
void dfs(ll);

int main(){
    
    cin>>n;
    num=n;

    
    
    dfs(3);
    dfs(5);
    dfs(7);

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

void dfs(ll k){
    ll dis=0,div=1;

    if(k>n){
        return;
    }

    bool d3,d5,d7;d3=d5=d7=false;
    for(i=1;i<10;i++){
        int dis=k/div;
        dis%=10;
        if(dis==3){d3=true;}
        if(dis==5){d5=true;}
        if(dis==7){d7=true;}
        div*=10;
    }
    if(d3==true && d5== true && d7==true){ans++;}//753数なら加算


    dfs(k*10+3);
    dfs(k*10+5);
    dfs(k*10+7);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define MOD 1000000007
using pi = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    ll a[n+2], b = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        b += a[i];
        b %= MOD;
    }
    ll sum = 0;
    for(int i = 1; i <= n; i++)
    {
        b -= a[i];
        if(b < 0) b += MOD;

        sum += a[i]*b;
        sum %= MOD;
    }
    cout << sum << endl;
}


Measured memory_bytes: 5152
import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static class Root {
        int root;
        Set<Integer> friends;
        Root (int root) {
            this.root = root;
            this.friends = new HashSet<>();
            this.friends.add(root);
        }
    }

    static Root find(int i) {
        if(roots[i].root == i) {
            return roots[i];
        }
        roots[i].root = roots[roots[i].root].root;
        return find(roots[i].root);
    }

    static void union(Root a, Root b) {
        if(a.root == b.root) return;
        if(a.friends.size() < b.friends.size()){
            a.root = b.root;
            b.friends.addAll(a.friends);
        } else {
            b.root = a.root;
            a.friends.addAll(b.friends);
        }
    }

    static Root[] roots;

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int K = scan.nextInt();
        roots = new Root[N];
        int[] friends = new int[N];
        int[] blocks = new int[N];
        for(int i = 0; i < N; i++) {
            roots[i] = new Root(i);
        }

        for(int i = 0; i < M; i++) {
            int A = scan.nextInt()-1;
            int B = scan.nextInt()-1;
            friends[A]++;
            friends[B]++;
            Root rootA = find(A);
            Root rootB = find(B);
            union(rootA, rootB);
        }

        for(int i = 0; i < K; i++) {
            int C = scan.nextInt()-1;
            int D = scan.nextInt()-1;
            Root rootC = find(roots[C].root);
            Root rootD = find(roots[D].root);
            if(rootC.root == rootD.root) {
                blocks[C]++;
                blocks[D]++;
            }
        }

        for(int i = 0; i < N; i++) {
            Root root = find(i);
            int possible = root.friends.size() - friends[i] - blocks[i] - 1;
            os.print(possible);
            if(i != N-1)
                os.print(" ");
        }
        os.println();
    }
}

Measured memory_bytes: 161628
#include <atcoder/fenwicktree>
#include <algorithm>
#include <stdio.h>
using namespace std;
using namespace atcoder;
long long x[200000];
long long y[200000];
long long z[200000];
int w[200000];
int a[200000];
int s;
long long n;
int main() {
	scanf("%lld", &n);
	fenwick_tree<long long> fw(n);
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", x + i, y + i);
		x[i]--;
		y[i]--;
		z[i] = x[i] * n + y[i];
	}
	std::sort(z, z + n);
	for (int i = 0; i < n; i++) {
		fw.add(z[i] % n, 1);
		if (fw.sum(n - i - 1, n) == i + 1) {
			w[i] = 1;
		}
	}
	s = 0;
	for (int i = 1; i <= n; i++) {
		if (w[i - 1]) {
			for (int j = s; j < i; j++) {
				a[j] = i - s;
			}
			s = i;
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%d\n", a[x[i]]);
	}
}

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

int main()
{
	ll x,a,b,c,y;
	cin>>a>>b>>c>>x;
	
	y=x/50;
	ll ans=0;
	if(10*a+2*b+c<y) cout<<"0"<<endl;
	else if(10*a+2*b+c==y) cout<<"1"<<endl;
	else
	{
		for(ll i1=a;i1>=0;i1--)
		{
			if(i1*10+2*b+c<y) break;
			for(ll i2=b;i2>=0;i2--)
			{
				if(i1*10+2*i2+c<y) break;
				
				for(ll i3=c;i3>=0;i3--)
				{
				if(i1*10+2*i2+i3<y) break;
				else if(i1*10+2*i2+i3==y) ans+=1;		
				}
			}
		}
	
	
	cout<<ans<<endl;
	}
	
	return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    int A[N];
    int total = 0;
    for ( int i = 0; i < N; ++i){
        cin >> A[i];
        total = total + A[i];
    }
    
    int syo,amari;
    syo = total / ( 4 * M );
    amari = total % ( 4 * M );
    if ( amari == 0 ){
        syo = syo - 1;
    }
    
    int count = 0;
    for ( int i = 0; i < N; ++i){
        if ( A[i] > syo ){
            count = count + 1;
        }
    }
    
    if ( count >= M ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
        
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;

char itoa(int x){
    char c='a'+x;
    return c;
}

int main()
{ 
    LL n;
    cin>>n;
    LL cnt=26;
    LL cnt2=1;
    LL sum=0;
    while(n-sum>cnt){
        sum=sum+cnt;
        cnt=cnt*26;
        cnt2++;
    }
    n=n-sum-1;
    string ans;
    for(int i=0;i<cnt2;i++){
        LL x=n%26;
        ans.push_back(itoa(x));
        n=n/26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}

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

int n, x = 0;
int cnt[3] = {0};
bool ans = 0;

int main() {
  int i, a;
  cin >> n;
  for(i = 0; i < n; ++i) {
    cin >> a;
    if(a % 4 == 0)
      ++cnt[0];
    else if(a % 2 == 0)
      ++cnt[1];
    else
      ++cnt[2];
  }
  if(cnt[0] + cnt[1] == n) ans = 1;
  if(cnt[1] > 0) {
    x = cnt[1] - 1;
    ++cnt[2];
  }
  if(cnt[0] >= cnt[2] && (n - x) % 2 == 0) ans = 1;
  if(cnt[0] + 1 >= cnt[2] && (n - x) % 2 == 1) ans = 1;
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200005;
 
ll n, k;
array<ll, N> old, nw;
bitset<N> used;
 
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    vector<ll> a(n);
    for (auto& i : a) cin >> i;
    
    for (int i = 0; i < n; ++i) {
        old[max(0ll, i - a[i])]++;
        old[min(n, i + a[i] + 1)]--;
    }
    
    for (int i = 1; i < k; ++i) {
        ll psum = 0;
        used.reset();
        for (int j = 0; j < n; ++j) {
            if (i % 2) {
                psum += old[j];
                // cout << i << ' ' << j << ' ' << psum << '\n';
                ll mn = max(0ll, j - psum), mx = min(n, j + psum + 1);
                if (!used[j]) {
                    used[j] = 1;
                    nw[j] = 0;
                }
                if (!used[mn]) {
                    used[mn] = 1;
                    nw[mn] = 0;
                }
                if (!used[mx]) {
                    used[mx] = 1;
                    nw[mx] = 0;
                }
 
                // cout << j << ' ' << mn << ' ' << mx << '\n';
                nw[mn]++;
                nw[mx]--;
            } else {
                psum += nw[j];
                // cout << i << ' ' << j << ' ' << psum << '\n';
                ll mn = max(0ll, j - psum), mx = min(n, j + psum + 1);
                if (!used[j]) {
                    used[j] = 1;
                    old[j] = 0;
                }
                if (!used[mn]) {
                    used[mn] = 1;
                    old[mn] = 0;
                }
                if (!used[mx]) {
                    used[mx] = 1;
                    old[mx] = 0;
                }
 
                // cout << j << ' ' << mn << ' ' << mx << '\n';
                // cout << old[mn] << ' ' << old[mx] << '\n';
                old[mn]++;
                old[mx]--;
            }
        }

        if (nw == old) break;
    }
 
    if (k % 2) {
        ll psum = 0;
        for (int i = 0; i < n; ++i) {
            psum += old[i];
            cout << psum << ' ';
        }
    } else {
        ll psum = 0;
        for (int i = 0; i < n; ++i) {
            psum += nw[i];
            cout << psum << ' ';
        }
    }
}


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

int gcd(int a, int b) {
    if(a < b) swap(a,b);
    if(a % b == 0) return b;
    else return (a / b, a % b);
}

int main() {
    int N,P;
    cin >> N >> P;
    int cnt1=0, cnt2=0;
    for(int i=0; i<N; ++i) {
        int a; cin >> a;
        if(a % 2) ++cnt1;
        else ++cnt2;
    }

    if(cnt1 == 0) {
        if(P) cout << 0 << endl;
        else cout << (1LL << cnt2) << endl;
    } else {
        cout << ((1LL << (cnt1 - 1)) << cnt2) << endl;
    }
}

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

if n % 2 == 1:
    print(0)
    exit()

count2 = 0
num = 2
while num <= n:
    count2 += n // num
    num *= 2

count5 = 0
num = 10
while num <= n:
    count5 += n // num
    num *= 5

print(min(count2, count5))

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

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

int main()
{
	fast;
	int n;
	cin >> n;
	int ans = 7 % n;
	for (int i = 1; i < 1e7; i++)
	{
		if (ans == 0)
		{
			cout << i;
			return 0;
		}
		ans = (ans * 10 + 7) % n;
	}
	cout << -1;
}

Measured memory_bytes: 3668
import java.util.*;
import java.lang.*;

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

        int N = sc.nextInt();
        int K = sc.nextInt()-1;
        String S = sc.next();
        System.out.println(S.substring(0,K) + S.substring(K,K+1).toLowerCase() + S.substring(K+1, S.length()));

    }
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, q;
	string s;
	cin >>n >>q >>s;
	
	VI p(n), sm(n+1);
	rep(i, n-1){
		if(s.substr(i,2)=="AC") p[i+1] = 1;
	}
	rep(i, n) sm[i+1] = sm[i] + p[i];
	rep(i, q){
		int l, r;
		cin >>l >>r;
		int ans = sm[r] - sm[l];
		cout << ans <<"\n";
	}
	return 0;
}


Measured memory_bytes: 1872
n,m,q = gets.to_s.split.map{|t|t.to_i}

abcd = Array.new(q) do
  a, b, c, d = gets.to_s.split
  a, b, c, d = a.to_i-1, b.to_i-1, c.to_i, d.to_i
end.sort

puts (1..m).to_a.repeated_combination(n).map{ |cmb| 
  abcd.reduce(0){ |s,(a,b,c,d)| cmb[b] - cmb[a] == c ? s+d : s }
}.max

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

#define MAXN 
typedef long long LL;

int n, k;

int f(int n)
{
	if (n == 0) return 0;
	return (n + k - 2) / (k - 1);
}

int main()
{
	int p, ans = 1e9;
 	cin >> n >> k;
 	for (int i = 1, x; i <= n; ++i)
 	{
 		cin >> x;
 		if (x == 1) p = i;
    }
    for (int i = max(p - k + 1, 1); i <= min(p, n - k + 1); ++i)
    {
     	ans = min(ans, f(i - 1) + f(n - (i + k - 1)) + 1);	
	}
	cout << ans << endl;
	
		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    int n = s.length();
    VI a(n);
    FOR(i, 0, n)a[i] = s[i] - '0';
    if (a.front() == 0 || a.back() == 1) {
        cout << "-1\n";
        return 0;
    }
    FOR(i, 0, n / 2) {
        if (a[i] != a[n - 2 - i]) {
            cout << "-1\n";
            return 0;
        }
    }

    int num = 2;
    vector<pair<int, int>> ans = { { 0,1 } };
    for (int i = 1; i < n; i = num - 1) {
        while (num < n && a[num - 1] == 0) {
            ans.emplace_back(i, num);
            ++num;
        }
        if (num == n)break;
        ans.emplace_back(i, num);
        ++num;
    }
    each(i, ans)cout << i.first + 1 << " " << i.second + 1 << "\n";
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
int parent[100000];
int p[100000];
int findparent(int x)
{
	if(parent[x]!=x)
	{
		parent[x]=findparent(parent[x]);
	}
	return parent[x];
}
void unionset(int a,int b)
{
	if((a=findparent(a))==(b=findparent(b)))
		return;
	parent[a]=b;
}
int main()
{
	int n,m,i,j,x,y,ans=0;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
		parent[i]=i;
	}
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&x,&y);
		unionset(p[y],p[x]);
	}
	for(i=1;i<=n;i++)
	{
		if(findparent(i)==findparent(p[i]))
		{
			ans++;
		}
	}
	printf("%d",ans);
}

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

print(0)
nex=input()
if nex=="Vacant":
    exit()
nleft=0
left=nex
print(N-1)
nex=input()
if nex=="Vacant":
    exit()
nright=N-1
right=nex

for i in range(20):
    nmid=(nright+nleft)//2
    print(nmid)
    nex=input()
    if nex=="Vacant":
        exit()
    mid=nex
    flag=True
    if nleft%2!=nmid%2:
        if left==mid:
            right=mid
            nright=nmid
            flag=False
    else:
        if left!=mid:
            right=mid
            nright=nmid
            flag=False
    if flag:
        left=mid
        nleft=nmid
    

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

using namespace std;

int main(){
cin.sync_with_stdio(0); cin.tie(0);
	string a, b; cin >> a;
	b = a;
	reverse(a.begin(), a.end());
	if (a == b){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

return 0;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
//RABBI ZIDNI ILMA
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define endl "\n"
#define inf (1LL<<61)
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define all(x) x.begin(), x.end()
#define int_pow(n, p) (ll)(pow(n, p) + 0.5)
#define fastio ios_base::sync_with_stdio(0);cout<< fixed<< setprecision(10);
#define debug(x) cout<<"["<<#x<<": "<<x<<"]\n"
#define debug2(x, y) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]\n"
#define debug3(x, y, z) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]\n"
#define debug4(x, y, z, k) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]"<<"  ["<<#k<<": "<<k<<"]\n"

const ll N = 1e6 + 9;

ll fact[N];

int main()
{
    fastio
    fact[0] = 1;
    for(ll i=1; i<N; i++){
        fact[i] = fact[i-1]*i;
        fact[i]%=mod;
    }
    ll ans = 1;
    ll n;
    cin>>n;
    if(n==1){
        cout<<0;
        return 0;
    }
    for(int i=0; i<n; i++){
        ans *= 10;
        ans %=mod;
    }
    //debug(ans);
    ll a = 1, b=1;
    for(int i=0; i<n; i++){
        a *= 9; b*=8;
        a %=mod; b%=mod;
    }
    //debug2(a,b);
    ans -= ((2*a)%mod-b)%mod;
    ans += mod;
    ans %= mod;
    cout<< ans;
}



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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int n;
string s;
string assignment()
{
	VS ans(4, string(n, ' '));
	ans[0][0] = 'W', ans[0][1] = 'W';
	ans[1][0] = 'S', ans[1][1] = 'S';
	ans[2][0] = 'W', ans[2][1] = 'S';
	ans[3][0] = 'S', ans[3][1] = 'W';
	
	for(int iter = 0; iter < 4; ++iter)
	{
		bool valid = true;
		for(int i = 2; i < n; ++i)
		{
			int prev = (i - 1 < 0) ? n - 1 : i - 1;
			if(ans[iter][prev] == 'S' && s[prev] == 'o' ||
				ans[iter][prev] == 'W' && s[prev] == 'x')
			{
				int pp = (i - 2 < 0) ? i - 2 + n : i - 2;
				ans[iter][i] = ans[iter][pp];
			}
			else if(ans[iter][prev] == 'S' && s[prev] == 'x' ||
					ans[iter][prev] == 'W' && s[prev] == 'o')
			{
				int pp = (i - 2 < 0) ? i - 2 + n : i - 2;
				ans[iter][i] = 'W' + 'S' - ans[iter][pp];
			}
		}
		
		for(int i = 0; i < n; ++i)
		{
			int prev = (i - 1 < 0) ? n - 1 : i - 1;
			if(ans[iter][prev] == 'S' && s[prev] == 'o' ||
				ans[iter][prev] == 'W' && s[prev] == 'x')
			{
				int pp = (i - 2 < 0) ? i - 2 + n : i - 2;
				if(ans[iter][i] != ans[iter][pp]) {
					valid = false;
					break;
				}
			}
			else if(ans[iter][prev] == 'S' && s[prev] == 'x' ||
					ans[iter][prev] == 'W' && s[prev] == 'o')
			{
				int pp = (i - 2 < 0) ? i - 2 + n : i - 2;
				if(ans[iter][i] == ans[iter][pp]) {
					valid = false;
					break;
				}
			}
		}
		if(valid)
			return ans[iter];
	}
	 return "-1";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n >> s;

	cout << assignment() << endl;

	return 0;
}

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

#define INT_MAX 2147483647

int main()
{
    int n,m,a[50],b[50],c[50],d[50],i,j,min = INT_MAX,l,ans;

    scanf("%d %d",&n,&m);
    for (i = 0; i < n; i++)
    {
        scanf("%d %d",&a[i],&b[i]);
    }
    for (i = 0; i < m; i++)
    {
        scanf("%d %d",&c[i],&d[i]);
    }

    for (i = 0; i < n; i++)
    {
        min = INT_MAX;
        for (j = 0; j < m; j++)
        {
            l = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(min > l)
            {
                ans = j + 1;
                min = l;
            }
        }
        printf("%d\n",ans);
    }
}

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

int N;
int A[100010];
int L[100010] = {},R[100010] = {};
int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	int ans = 0;
	L[1] = 1;
	for(int i=2;i<=N;i++){
		if(A[i]!=A[i-1]) L[i] = L[i-1]+1;
		else L[i] = 1;
		ans = max(ans,L[i]);
	}
	R[N] = 1;
	for(int i=N-1;i>=1;i--){
		if(A[i]!=A[i+1]) R[i] = R[i+1]+1;
		else R[i] = 1;
		ans = max(ans,R[i]);
	}
	for(int i=2;i<=N;i++){
		if(A[i]==A[i-1]){
			ans = max(ans,L[i-1]+L[i-1-L[i-1]]+R[i]);
			ans = max(ans,L[i-1]+R[i]+R[i+R[i]]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4264
A, B = gets.chomp.split(" ").map(&:to_i)
S = gets.chomp

ans = 'Yes'
(0..A+B).each{|i|
  if i == A then
    (ans = 'No'; break) if S[i] != '-'
  else
    (ans = 'No'; break) if S[i] == '-'
  end
}

puts ans


Measured memory_bytes: 1788
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")

#include <map>
#include <list>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
string s; 
int main()
{
	cin>>s;
	if (s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I')
	   cout<<"Yes\n";
	else
	   cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

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

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

    int X[N];
    rep(i, N){
        cin >> X[i];
    }

    int max = X[0];
    int min = X[0];
    rep(i, N){
        if(X[i] > max){
            max = X[i];
        }
        if(X[i] < min){
            min = X[i];
        }
    }

    int mindis = -1;
    for(int P = min; P <= max; P++){
        int distance = 0;
        rep(i, N){
            distance += (X[i] - P)*(X[i] - P);
        }
        if(mindis == -1){
            mindis = distance;
        }
        else{
            if(mindis > distance){
                mindis = distance;
            }
        }
    }

    cout << mindis << endl;

    return 0;
}

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

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

  int price = 700;
  for (int i = 0; i < 3; i ++) {
    if (s.at(i) == 'o') {
      price += 100;
    }
  }

  cout << price << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = null;
		String output = "No";

		try {
			sc = new Scanner(System.in);

			String str = sc.nextLine();
			String ring = str + str;

			String check = sc.nextLine();

			if (ring.indexOf(check) != -1) {
				output = "Yes";
			}
			System.out.println(output);
		} finally {
			sc.close();
		}
	}

}

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

 long long int p=1e9+7; 

 int  main() {
     ios_base::sync_with_stdio(false);cin.tie(NULL);
      long long int n,k;
      cin>>n>>k;
      
      
     
      long long int s=0;
      
       long long int t=(n*(n+1))/2;
      long long int  i=k-1;
      long long int j=n-k;
      long long int cnt=0,l=n-k+1;
       while(cnt<l){
          long long int min=(i*(i+1))/2;
          long long int max=t-(j*(j+1))/2;
           
           
           
           s=((s%p)+(max-min+1)%p)%p;
           i++;
           j--;
           cnt++;
       }    
       
       cout<<s+1<<endl;
      
      
      
    
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3484
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <utility>
#include <iomanip>
#define input(a) cin >> a
#define print(x) cout << x << endl
#define rep(a,n) for(int i = a; i < n; i++)
#define ll long long int
using namespace std;


int main(){
    int n,a;
    string ans;
    input(n);
    input(a);
    int ex = n%500;
    if (ex <= a) ans = "Yes";
    else ans = "No";
    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    string s; cin >> s;

    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256