akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<vector>
#include<climits>
#include<functional>
using namespace std;
const int MAXN = 100010;
int p[MAXN];
int dist[MAXN];
int n;
int bfs(){
  //queue<int> q;
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
  q.push(make_pair(0,0));//(Distance,Node)
  fill(dist,dist+MAXN,INT_MAX/2);
  dist[0] = 0;
  while(!q.empty()){
    
    pair<int,int> current = q.top();q.pop();
    int id = current.second;
    int d = current.first;

    if(id == n-1){
      return dist[n-1];
    }
    if(p[id] != 0){
      bool update = false;
      while(dist[id + p[id]] > dist[id]
            && p[id] != 0){
        dist[id+ p[id]] = dist[id];
        id += p[id];
        update = true;
      }
      if(update)q.push(make_pair(d,id));
    }else{
      for(int i = 1;i <= 6;i++){
        if(dist[id+i] > dist[id] + 1){
          dist[id+i] = dist[id] + 1;
          q.push(make_pair(dist[id+i],id+i));
        }
      }
    }
  }
}

int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> p[i];
  }
  cout << bfs() << endl;
}

Measured memory_bytes: 1996
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

char map[20][21];
bool ch[20][20];
int ans;

void dfs(int w, int h, char map[20][21], bool c[20][20], int x, int y){
	//cout << x << " " << y << " " << ans << endl;
	ans++;
	c[x][y] = 1;
	if(x>0 && map[x-1][y]=='.' && c[x-1][y]==0){
		dfs(w,h,map,c,x-1,y);
	}
	if(x<h-1 && map[x+1][y]=='.' && c[x+1][y]==0){
		dfs(w,h,map,c,x+1,y);
	}
	if(y>0 && map[x][y-1]=='.' && c[x][y-1]==0){
		dfs(w,h,map,c,x,y-1);
	}
	if(y<w-1 && map[x][y+1]=='.' && c[x][y+1]==0){
		dfs(w,h,map,c,x,y+1);
	}
}

int main(){
	int i, j, w, h, x, y;
	while(1){
		cin >> w >> h;
		if(!w) break;
		for(i=0;i<h;i++){
			cin >> map[i];
			for(j=0;j<w;j++){
				ch[i][j] = 0;
				if(map[i][j] == '@'){
					x = i;
					y = j;
				}
			}
		}
		ans = 0;
		dfs(w,h,map,ch,x,y);
		
		cout << ans << endl;
	}
	return 0;
}

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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        n: usize,
        a: [u32; n],
    }
    let mut dp = vec![0; n + 1];
    dp[0] = 1000000000 + 1;
    let mut len = 0;
    for &x in &a {
        if dp[len] >= x {
            len += 1;
            dp[len] = x;
            continue;
        }
        let mut l = 0;
        let mut r = len;
        while l + 1 < r {
            let m = (l + r) / 2;
            if dp[m] >= x {
                l = m;
            } else {
                r = m;
            }
        }
        dp[r] = x;
    }
    println! ("{}", len);
}

fn main() {
    run();
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

mp::cpp_int gcd(mp::cpp_int a, mp::cpp_int b) {
  while (true) {
    if (a == 0) {
      return b;
    }
    b %= a;
    if (b == 0) {
      return a;
    }
    a %= b;
  }
}

mp::cpp_int lcm(mp::cpp_int a, mp::cpp_int b) {
  mp::cpp_int const temp = gcd(a, b);
  return temp ? (a / temp * b) : mp::cpp_int(0);
}

int calc(const std::vector<int> as) {
  int ret = 0;
  mp::cpp_int x = 1;
  for (const auto& a : as) {
    x = lcm(x, static_cast<mp::cpp_int>(a));
  }
  x -= 1;
  for (const auto& a : as) {
    ret += static_cast<int>(x % static_cast<mp::cpp_int>(a));
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as(n);
  for (auto& a : as) {
    std::cin >> a;
  }
  std::cout << calc(as) << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;

int main() {
    string s;
    cin >> s;
    string t = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int cnt[26] = {0};

    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < 26; j++) {
            if (s[i] == t[j]) {
                cnt[j]++;
            }
        }
    }

    int ans = 0;
    int zero = 0;
    for (int i = 0; i < 26; i++) {
        if (cnt[i] > 0) ans += cnt[i];
        else zero++;
    }

    if (ans == 4 && zero == 24) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using i64 = int64_t;

int main(){
    int h, w, n, sr, sc;
    cin >> h >> w >> n >> sr >> sc;
    string s, t;
    cin >> s >> t;
    int c = sc;
    bool ok = false;
    for(int i=0;i<n;++i){ //right
        if(s[i] == 'R')c++;
        if(c > w){
            ok = true;
            break;
        }
        if(t[i] == 'L' && c > 1)c--;
    }
    c = sc;
    for(int i=0;i<n;++i){ //left
        if(s[i] == 'L')c--;
        if(c < 1){
            ok = true;
            break;
        }
        if(t[i] == 'R' && c < w)c++;
    }
    int r = sr;
    for(int i=0;i<n;++i){ //up
        if(s[i] == 'U')r--;
        if(r < 1){
            ok = true;
            break;
        }
        if(t[i] == 'D' && r < h)r++;
    }
    r = sr;
    for(int i=0;i<n;++i){ //down
        if(s[i] == 'D')r++;
        if(r > h){
            ok = true;
            break;
        }
        if(t[i] == 'U' && r > 1)r--;
    }
    if(ok)cout << "NO" << endl;
    else cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 776
def distance(a, b):
    d = len(a)
    s = 0
    for i in range(d):
        s += (a[i] - b[i]) ** 2
    return s ** 0.5


n, _ = map(int, input().split())
xs = [list(map(int, input().split()))
      for _ in range(n)]

cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        d = distance(xs[i], xs[j])
        if (d - int(d)) == 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 3064
object Main extends App {
  val a = (1 to 3).map { _ =>
    scala.io.StdIn.readLine.split(" ").map(_.toInt)
  }
  val aa = Array.ofDim[Boolean](3, 3)

  val n = scala.io.StdIn.readLine.toInt
  (0 until n).foreach { _ =>
    val b = scala.io.StdIn.readLine.toInt
    (0 to 2).foreach { i =>
      (0 to 2).foreach { j =>
        if (a(i)(j) == b) {
          aa(i)(j) = true
        }
      }
    }
  }

  if (aa(0).forall(_ == true) || aa(1).forall(_ == true) || aa(2).forall(_ == true) ||
    (aa(0)(0) && aa(1)(0) && aa(2)(0)) ||
    (aa(0)(1) && aa(1)(1) && aa(2)(1)) ||
    (aa(0)(2) && aa(1)(2) && aa(2)(2)) ||
    (aa(0)(0) && aa(1)(1) && aa(2)(2)) ||
    (aa(2)(0) && aa(1)(1) && aa(0)(2))) {
    println("Yes")
  } else {
    println("No")
  }

}


Measured memory_bytes: 54772
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

int a[20];

int dfs(int n, int i, int A, int B)
{
  static int diff = 1000000;

  if (i == 0) diff = 1000000;
  if (i == n) {
    diff = min(diff, abs(A - B));
  } else {
    dfs(n, i + 1, A + a[i], B);
    dfs(n, i + 1, A, B + a[i]);
  }

  return diff;
}

int main()
{
  int n;

  while (1) {
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }

    cout << dfs(n, 0, 0, 0) << endl;
  }
}



Measured memory_bytes: 3088
#include <stdio.h>

int main() {
	int i, D, N;

	scanf("%d %d", &D, &N);

	if (N != 100) {
		if (D == 0) printf("%d\n", N);
		else if (D == 1) printf("%d\n", N * 100);
		else printf("%d\n", N * 10000);
	}
	else {
		if (D == 0) printf("%d\n", 101);
		else if (D == 1) printf("%d\n", 10100);
		else printf("%d\n", 1010000);
	}

	return 0;
}

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.range;

long K;
long[50] R;

void main()
{
    K = readln.chomp.to!long;

    if (K == 0) {
        writeln("2\n0 0");
    } else if (K == 1) {
        writeln("2\n2 0");
    } else if (K <= 50) {
        writeln(K);
        writeln( 1.iota(K+1).map!(to!string).joiner(" ") );
    } else {
        foreach (i; 0..50) R[i] = 50 - i;
        auto t = K / 50 - 1;
        foreach (ref r; R) r += t;
        foreach (i; 0..K%50) R[i] += 1;

        writeln(50);
        writeln(R.dup.map!(to!string).joiner(" ")); 
    }
}

Measured memory_bytes: 256
N,M=map(int,input().split())
r=[]
k=[]
for i in range(N):
  k.append([])

for i in range(M):
  a,b=map(int,input().split())
  k[a-1].append(b)
  k[b-1].append(a)

d=[0]+[-1]*N
ans=[0]+[-1]*N
q=[0]
while q:
  u=q.pop(0)
  for v in range(len(k[u])):
    o=k[u][v]
    if d[o-1]<=0:
        d[o-1]=d[u]+1
        ans[o-1]=u
        q.append(o-1)
print("Yes")
for i in range(1,N):
  print(ans[i]+1)
    

Measured memory_bytes: 37268
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;
	ll ans = 0, cr = 0;
	for(int i = 0; i < n; i++) {
		ll inp;
		cin >> inp;
		ans = (ans + cr * inp) % MOD;
		cr = (cr + inp) % MOD;
	}
	cout << ans << '\n';
}



Measured memory_bytes: 3656
n = gets.to_i
s = gets.chomp

h = {"(" => 1, ")" => -1}
l = r = a = b = 0
n.times do |i|
    l += h[s[i]]
    r += h[s[n - i - 1]]

    if l < 0
        a += 1
        l += 1
    end

    if r > 0
        b += 1
        r -= 1
    end
end

puts "(" * a + s + ")" * b



Measured memory_bytes: 1788
#ifndef BZ
#pragma GCC optimize -O3
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = double;
using ull = uint64_t;

const ll MOD = 1e9 + 7;
const int MAXN = 5002;
int s[MAXN];

vector<int> e[MAXN];

ll f[MAXN][2][MAXN];
ll g[2][MAXN];
ll c[MAXN];


void dfs(int v, int p) {
    s[v] = 1;
    auto it = find(e[v].begin(), e[v].end(), p);
    if (it != e[v].end()) {
        e[v].erase(it);
    }

    auto cf = ::f[v];
    cf[0][1] = 1;

    for (int u: e[v]) {
        dfs(u, v);
        memcpy(g, cf, sizeof(g));
        memset(cf, 0, sizeof(g));
        for (int jl = 0; jl < 2; ++jl) {
            for (int jr = 0; jr < 2; ++jr) {
                for (int cl = 0; cl <= s[v]; ++cl) {
                    for (int cr = 0; cr <= s[u]; ++cr) {
                        auto& nf = cf[jl ^ jr][cl + cr];
                        nf = (nf + g[jl][cl] * f[u][jr][cr]) % MOD;
                    }
                }
            }
        }

        s[v] += s[u];
    }

    for (int i = 0; i < 2; ++i) {
        for (int j = 2; j <= s[v]; j += 2) {
            ll& nf = cf[i ^ 1][0];
            nf = (nf + cf[i][j] * c[j]) % MOD;
        }
    }
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n;
    cin >> n;
    c[0] = 1;
    for (int i = 2; i <= n; i += 2) {
        c[i] = ll(i - 1) * c[i - 2] % MOD;
    }

    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    dfs(1, 1);
    cout << (f[1][1][0] - f[1][0][0] + MOD) % MOD << endl;
}

Measured memory_bytes: 392064
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)       ((int)(n).size())
#define all(n)      (n).begin(), (n).end()
#define anal           '\n'
#define mod         1000000007
#define fst         first
#define sec         second
#define pr(n)       cerr << n  << " ";
#define pfor(a)       for(auto (w) : (a)) pr(w)
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-



//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
     
    int n, x, t;
    cin >> n >> x >> t;
    int ans = (n/x) + (n%x > 0);
    cout << t*ans;



     
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
int n,l,a[100002],pos;
bool f;
int main()
{
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]+a[i-1]>=l&&i>1)
		{
			f=1;
			pos=i-1;
		}
	}
	if(f==0)printf("Impossible");
	else
	{
		printf("Possible\n");
		for(int i=1;i<pos;i++)
			printf("%d\n",i);
		for(int i=n-1;i>=pos;i--)
			printf("%d\n",i);
	}
}

Measured memory_bytes: 1152
n, m = map(int, input().split())

# 隣接リストをつくる 
adj_list = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  adj_list[a].append(b)
  adj_list[b].append(a)
  
# どの連結成分に属してるかを把握するための配列
group = [-1 for i in range(n)]

# 各頂点 i から探索をする
for i in range(n):
  if group[i] != -1: continue
  # i から DFS
  newly_visited = [i]
  group[i] = i
  while len(newly_visited) > 0:
    now = newly_visited.pop()
    for j in adj_list[now]:
      if group[j] != -1: continue
      newly_visited.append(j)
      group[j] = i

hist = [0 for i in range(n)]
for g in group:
  hist[g] += 1
print(max(hist))


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

int main()
{
    char c;
    cin >> c;
    if (c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
    return 0;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n, m;
    cin >> n >> m;
    int x[n] = {};
    int y[m] = {};
    int numX, numY;
    cin >> numX >> numY;
    rep(i, n) { cin >> x[i]; }
    rep(i, m) { cin >> y[i]; }

    // 処理
    for (int z = numX + 1; z <= numY; z++) {
        bool flg                     = true;
        rep(i, n) if (x[i] >= z) flg = false;
        rep(i, m) if (y[i] < z) flg  = false;
        if (flg) {
            cout << "No War" << endl;
            return 0;
        }
    }

    // 出力
    cout << "War" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"







int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

     int n;
     cin>>n;
     vector<int>v(n);

     f(n)cin>>v[i];
     int k=1;
     int count=0;
     for(int i=0;i<n;i++)
     {
         if(v[i]!=k) count++;
         else k++;



     }
     if (count==n) cout<<"-1"<<endl;
     else 
        cout<<count<<endl;








}

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

#define ll   long long int
#define ull   unsigned long long int
#define PI 3.14159265358979
#define zig ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

const ll N=1e18;

int main()
{
    zig
    ull a, ans;
    double b;
    cin>>a>>b;
    ans=a*lround(b*100.0);
    cout<<ans/100;
    return 0;
}


Measured memory_bytes: 3788
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
 
const int maxN = 83, B = maxN * maxN * 2;

bool dp[maxN][maxN][B * 2];
int x[maxN][maxN];

void solve()
{
	int n, m;
	scanf ("%d%d", &n, &m);
	FOR(i, 1, n+1) FOR(j, 1, m+1)
		scanf ("%d", &x[i][j]);
	FOR(i, 1, n+1) FOR(j, 1, m+1)
	{
		int a;
		scanf ("%d", &a);
		x[i][j] = abs(x[i][j] - a);
	}
	
	dp[1][1][B + x[1][1]] = dp[1][1][B - x[1][1]] = true;
	
	FOR(i, 1, n+1) FOR(j, 1, m+1) FOR(k, 0, B*2) if (dp[i][j][k])
	{
		if (i < n)
		{
			for (int k2 : {k + x[i+1][j], k - x[i+1][j]})
				if (0 <= k2 and k2 < B*2)
					dp[i+1][j][k2] = true;
		}
		
		if (j < m)
		{
			for (int k2 : {k + x[i][j+1], k - x[i][j+1]})
				if (0 <= k2 and k2 < B*2)
					dp[i][j+1][k2] = true;
		}
	}
	
	int res = B * 2;
	
	FOR(k, 0, B*2)
		if (dp[n][m][k])
			res = min(res, abs(B - k));
	printf("%d\n", res);
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


Measured memory_bytes: 180480
N = int(input())
S = str(input())
R = 0
G = 0
B = 0
Z = 0
for i in range(N):
    if S[i] == 'R':
        R += 1
    if S[i] == 'G':
        G += 1
    if S[i] == 'B':
        B += 1

for i in range(N-1):
    for j in range(i+1, N):
        k = 2 * j - i
        if k > N-1:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            Z += 1
print(R*G*B-Z)

Measured memory_bytes: 68020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    vector<int> zero;
    vector<int> one;
    bool is_zero = false;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(is_zero && s[i]=='0'){
            cnt++;
        }else if(is_zero && s[i]=='1'){
            is_zero = false;
            zero.push_back(cnt);
            cnt = 1;
        }else if(!is_zero && s[i]=='1'){
            cnt++;
        }else if(!is_zero && s[i]=='0'){
            is_zero = true;
            one.push_back(cnt);
            cnt = 1;
        }
    }
    if(is_zero){
        zero.push_back(cnt);
    }else{
        one.push_back(cnt);
    }
    if(s[n-1]=='0'){one.push_back(0);}
    if(k>zero.size()){k = zero.size();}

    int ans = 0;
    int tmpans = 0;
    for(int i = 0; i < k; i++){
        tmpans += zero[i];
        tmpans += one[i];
    }
    tmpans += one[k];
    ans = tmpans;
    for(int i = k; i < zero.size(); i++){
        tmpans += zero[i];
        tmpans += one[i+1];
        tmpans -= zero[i-k];
        tmpans -= one[i-k];
        ans = max(ans, tmpans);
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    vector<int> a(6);

    for(int i=0;i<6;++i)
        cin>>a[i];
    for(int i=0;i<5;++i)
        for(int j=i+1;j<5;++j)
            if(abs(a[i]-a[j])>a[5])
            {
                cout<<":("<<endl;
                return 0;
            }
    cout<<"Yay!"<<endl;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = LONG_LONG_MAX;
  for (ll i = 1; i <= (n / 2); i++) {
    ll a = i;
    ll b = n / a;
    if (a > b) {
      break;
    }
    if (n % a != 0) {
      continue;
    }
    ans = min(ans, a - 1 + b - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int s=nextInt();
		int w=nextInt();
		if(w>=s)
			out.println("unsafe");
		else
			out.println("safe");
	}

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

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 32912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF = 1000000000000000;

string s;
int main(){
	int n,max = 0,cnt = 0;
	cin >> n;
	vector<int> a(n);
	REP(i, n){
		cin >> a[i];

		if(cnt > 0){
			if(a[i] <= a[i-1]){

				if(cnt > max){
					max = cnt;
				}
			}
			else{
				cnt = 0;
			}
		}
	  cnt++;
	}

	cout << max << endl;


}


Measured memory_bytes: 640
/**
 *   author: malviyanshiv
 *   created: 01 May 2019  15:36:45
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define FORE(a) for(auto ele : a )
#define ALL(a) begin(a), end(a)
#define RPB(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define F first
#define S second
#define TC int t; cin >> t; while(t--)
#define SET(a,b) memset(a,b,sizeof(a))

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

typedef long long ll;
typedef pair< int, int > PII;


void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

int main(){
	optimizeIO();

	int n, cnt = 0;
	cin >> n;
	vector<ll> val(n);
	bool flag = false;
	ll sm = 0;
	ll mn = 1e9;
	REP(i, 0, n){
		cin >> val[i];
		mn = min(mn, abs(val[i]));
		if( val[i] < 0 ){
			cnt++;
		}else if( val[i] == 0 )
			flag = true;
		sm += abs(val[i]);
	}
	//trace4(sm, flag, mn, cnt);
	if( cnt&1 ){
		if( !flag )
			sm -= (2*mn);
	}
	cout << sm << endl;	
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m=MI()
counter=[0 for i in range(n)]
for i in range(m):
    a,b=MI()
    counter[a-1]+=1
    counter[b-1]+=1
for i in range(n):
    if counter[i]%2==1:
        print("NO")
        sys.exit()
print("YES")

Measured memory_bytes: 80844
#include <iostream>


int strlen (char *str) {
  int len = 0;
  while (*str != '\0') {
    str++;
    len++;
  }
  return len;
}


int main() {
  char deck[200];
  int m, h, mid;
  int h_sum, card_num;

  while (true) {
    std::cin >> deck;
    if (deck[0] == '-') break;
    std::cin >> m;
    h_sum = 0;
    for (int i = 0; i < m; i ++) {
      std::cin >> h;
      h_sum += h;
    }
    card_num = strlen(deck);
    mid = h_sum % card_num;
    for (int i = mid; i < card_num; i ++) {
      std::cout << deck[i];
    }
    for (int i = 0; i < mid; i ++) {
      std::cout << deck[i];
    }
    std::cout << std::endl;

  }
  return 0;
}



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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
long long dp[100100];

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

    double ans = 0;
    for(int i = 0; i < N; i++) {
        double x; cin >> x;
        string u; cin >> u;
        if(u == "JPY") ans += x;
        else ans += 380000.0 * x;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int w, a, b;
  cin >> w >> a >> b;
  
  if(a <= b ){
    if (a + w >= b){
      cout << 0 << endl;
      return 0;
    }else{
      cout << b - (a + w) << endl;
      return 0;
    }
  }else{
    if (b + w >= a){
      cout << 0 << endl;
      return 0;
    }else{
      cout << a - (b + w) << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ?????? '''


class Dictionary(object):
    """ Dictionary """

    def __init__(self):
        self.dict = {}

    def insert(self, x):
        self.dict[x] = 0

    def find(self, x):
        if x in self.dict.keys():
            print('yes')
        else:
            print('no')

if __name__ == '__main__':
    N = int(input())

    d = Dictionary()

    for _ in range(N):
        command, key = list(input().split())
        if command == 'insert':
            d.insert(key)
        elif command == 'find':
            d.find(key)

Measured memory_bytes: 37384
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 3030, mo = 1e9+7,inv2=(mo+1)/2;
int n,q,a[N],f[N][N],res,dfn[N][N],mrk=1;
void add(int &x,int y){x=x+y<mo?x+y:x+y-mo;}
struct qq{int a,b,c;}s[600000];int len;
inline void tt(int a, int b, int x, int y){
	if(!f[a][b])return;
	++len;s[len].c=1LL*f[a][b]*inv2%mo;
	s[len].a=a==x?y:(a==y?x:a);
	s[len].b=b==x?y:(b==y?x:b);
	f[a][b]=1LL*f[a][b]*inv2%mo;
}
int main() {
	read(n);read(q);rep(i,1,n)read(a[i]);
	rep(i,1,n)rep(j,1,n)if(a[i]>a[j])f[i][j]++;
	rep(t,1,q){
		//rep(i,1,n)rep(j,1,n)if(f[i][j])printf("%d %d %d:%lld\n",t,i,j,1LL*f[i][j]*mrk%mo);
		int x,y;read(x);read(y);len=0;mrk=2LL*mrk%mo;
		rep(j,1,n){
			if(dfn[x][j]!=t)dfn[x][j]=t,tt(x,j,x,y);
			if(dfn[y][j]!=t)dfn[y][j]=t,tt(y,j,x,y);
		}
		rep(i,1,n){
			if(dfn[i][x]!=t)dfn[i][x]=t,tt(i,x,x,y);
			if(dfn[i][y]!=t)dfn[i][y]=t,tt(i,y,x,y);
		}
		while(len)add(f[s[len].a][s[len].b],s[len].c),len--;
	}
	rep(i,1,n)rep(j,i+1,n)add(res,f[i][j]);cout<<(1LL*res*mrk%mo+mo)%mo;
	return 0;
}

Measured memory_bytes: 72704
import collections

N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

c_d = dict(collections.Counter(D))
c_t = dict(collections.Counter(T))
ans = 'YES'

for k,v in c_t.items():
  if (k in c_d and c_t[k] <= c_d[k]):
    continue
  else:
    ans = 'NO'
    break
print(ans)


Measured memory_bytes: 131408
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> vi;
typedef unsigned long long ull;

int rot[] = {0,4,5,1,3,7,6,2};
vector<vi> rots;

void next(vi &x){
  rep(i,3){
    swap(x[i],x[i+1]);
    swap(x[i+4],x[i+5]);
  }
}

ull t[1<<18];

int main(){
  vi tmp;
  rep(i,8)tmp.push_back(i);
  rots.push_back(tmp);
  rep(i,3){
    next(tmp);
    rots.push_back(tmp);
  }

  rep(i,4){
    tmp = rots[i];
    reverse(all(tmp));
    rots.push_back(tmp);
  }

  rep(i,16){
    tmp.resize(8);
    rep(j,8)tmp[j] = rots[i][rot[j]];
    rots.push_back(tmp);
  }

  string s;
  while(cin >> s){
    map<string,int> m;
    m[s]++;
    rep(i,7)cin >> s, m[s]++;
    vi v;
    int id=0;
    for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
      rep(i,it->second)v.push_back(id);
      id++;
    }

    int ans = 0;
    rep(i,1<<18)t[i] = 0ULL;

    do{
      int h = 0;
      rep(i,8)h*=8,h+=v[i];
      if( !((t[h>>6]>>(h&63))&1ULL) ){
	rep(i,24){
	  h = 0;
	  rep(j,8)h*=8,h+=v[rots[i][j]];
	  t[h>>6] |= 1ULL<<(h&63);
	}
	ans++;
      }
    }while(next_permutation(all(v)));

    cout << ans << endl;
  }
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
const ll inf = 1e18, mod = 1e9 + 7;
using namespace std;


ll fact[1000001]; ll inv[1000001];
ll primes[100007];
ll arr[1000007];
ll modPower(ll b, ll p) {
	if (p == 0)
		return 1;

	ll halfpow = modPower(b, p / 2);
	ll toReturn = (halfpow * halfpow) % mod;
	if (p % 2)
		toReturn = (toReturn * b) % mod;

	return toReturn;
}

ll fastPower(ll b, ll p) {
	if (p == 0)
		return 1;
	ll ans = fastPower(b, p / 2);
	ans = (ans * ans);
	if (p % 2 != 0)
		ans = (ans * b);
	return ans;
}
ll GcdRecursive(ll a, ll b) {
	if (b == 0) return a;
	return GcdRecursive(b, a % b);
}
ll modLCM(ll a, ll b) {
	ll val = GcdRecursive(a, b);
	ll tmp = ((a % mod) * (b % mod)) % mod;
	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
	return finalVal;

}
ll LCM(ll a, ll b) {
	return (a * b) / GcdRecursive(a, b);
}
void move1step(ll& a, ll& b, ll q) { // a and b by reference
	ll c = a - q * b;
	a = b;
	b = c;
}
ll GcdIterative(ll a, ll b) {
	while (b) move1step(a, b, a / b);
	return a;
}

void pre(ll n) {

	fact[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i <= n; i++) {
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = modPower(fact[i], mod - 2);
		arr[i] = modPower(i, mod - 2);
	}
}

ll npr(ll n, ll r) {
	return ((fact[n] * inv[n - r]) % mod);
}

ll ncr(ll n, ll r) {
	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
}

void sieve(ll val) {
	memset(primes, 1, sizeof primes);
	primes[0] = primes[1] = false;
	for (int i = 2; i <= val; i++) {
		if (primes[i]) {
			for (int j = i * i; j <= val; j += i) {
				primes[j] = 0;
			}
		}
	}

}

map<ll, ll> factors;

void getPrimeFactors(ll n) {
	map<ll, ll> tmp;
	while (n % 2 == 0) {
		n /= 2;
		tmp[2]++;
	}
	for (int i = 3; i * i <= n; i+=2) {
		while (n % i == 0) {
			//cout << i << endl;
			n /= i;
			tmp[i]++;
		}
	}
	if (n > 2) tmp[n]++;
	for (auto elem : tmp) {
		if (factors[elem.first] < elem.second)
			factors[elem.first] = elem.second;
	}
}






int main()
{
	MohamedMotaz;
	//pre(1000001);
	ll x; cin >> x;
	vector<ll> vals;
	while (x--) {
		ll m; cin >> m; vals.push_back(m); getPrimeFactors(m);
	}
	/*for (auto elem : factors) {
		cout << elem.first << " " << elem.second << endl;
	}*/
	ll lcm = 1;
	for (auto elem : factors) {
		lcm = ((lcm % mod) * (modPower(elem.first, elem.second) % mod)) % mod;
	}
	//cout << lcm << endl;
	ll sum = 0;
	for (auto elem : vals) {
		ll val = lcm * modPower(elem, mod - 2);
		sum = sum + val;
		sum = sum % mod;
	}

	cout << sum % mod;
}





















Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=300005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	void solve(){
		lli N,M,obj,tot=0,i;
		cin>>N>>M>>obj;
		if(N>M)swap(N,M);
		for(i=0;i<N;i++){
			tot+=M;
			if(tot>=obj)break;
		}		
		cout<<i+1<<"\n";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}

Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).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;}

vl x;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    x = vl(5);
    for(int i = 0; i < 5; ++i){
        cin >> x[i];
    }
    solve();
}

// 入力として与えられる x_1, x_2, x_3, x_4, x_5 の値は、すぬけくんが操作を行ったあとのものとしてありえるものである。

// vl x
// すぬけくんが 0 を代入した変数が x_i であるとき、整数 i を出力せよ。
void solve(){
    rep(i,5){
        if(x[i]!=i+1)cout<<i+1<<endl;
    }
}


Measured memory_bytes: 3528
#include <stdio.h>
int solve(int ,int);

int n;
int A[20];

int main(void){
  int q,i,judge=0;
  int M[200];

  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) scanf("%d",&M[i]);

  for(i=0; i<q; i++){
    judge = solve(0,M[i]);
    if(judge == 0) printf("no\n");
    else printf("yes\n");
  }

  return 0;

}

int solve(int x,int M){
  if(x == n && M == 0) return 1;
  if(x == n && M != 0) return 0;
  else return solve(x+1,M)+solve(x+1,M-A[x]);
}

Measured memory_bytes: 580
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(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 rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main(){
	fast;
	string s,t;
	cin>>s>>t;
	string ans=t+s;
	cout<<ans;	
	return 0;
}


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

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

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

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

lint mypow(lint a, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

int main() {

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

	lint N;
	cin >> N;

	if (N & 1) {
		cout << 0 << "\n";
		return 0;
	}

	lint num = 1;
	lint ans = 0;
	while (true) {

		auto now = mypow(5, num);
		if (now > N) break;

		ans += (N / now / 2 - N / now / 5 / 2) * num;

		num++;

	}

	cout << ans << "\n";

	return 0;
}

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

int frog2(int*s, int n, int k){
  int dp[100005];
  dp[1]=0;
  for(int i=2;i<=n;i++){
    dp[i] = INT_MAX;
  	for(int j=i-1; j>=1 && (i-j)<=k; j--){
    	dp[i] = min(dp[i],abs(s[i]-s[j]) + dp[j]);
    }
  }
  return dp[n];
}

int main(){
  int n,k;	cin>>n>>k;
  int a[100006];
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  cout<<frog2(a,n,k);
  return 0;
}

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


struct Node {
    int key;
    Node *right,*left,*parent;
    };

Node *root,*NIL;

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x; 
        if(z->key < x->key){
            x=x->left;
        }else{
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }else{
        if(z->key < y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}
Node* find(Node *u,int k){
    while(u!=NIL&&k!=u->key){
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
}

//2人子がいることしか考えてない
Node* nextchilld(Node *u){
    Node *ans=u->right;
    while(ans->left!=NIL){
        ans=ans->left;
    }
    return ans;
}
void deleteN(Node* u){
    if(u->left==NIL && u->right==NIL){
        if((u->parent)->left==u){
            (u->parent)->left=NIL;
        }
        else {
            (u->parent)->right=NIL;
        }
    }else if(u->left==NIL){
        if((u->parent)->left==u){
            (u->parent)->left=u->right;
        }else (u->parent)->right=u->right;
        (u->right)->parent=u->parent;
    }else if(u->right==NIL){
        if((u->parent)->left==u){
        (u->parent)->left=u->left;
        }else (u->parent)->right=u->left;
        (u->left)->parent=u->parent;
    }else{
        //uの次接点を求める
        Node *nchild=nextchilld(u);
        u->key=nchild->key;
        deleteN(nchild);
    }
}
void preorder(Node* u){
    if(u==NIL)return;
    cout<<" "<<u->key;
    preorder(u->left);
    preorder(u->right);
}
void inorder(Node *u){
    if(u==NIL)return;
    inorder(u->left);
    cout<<" "<<u->key;
    inorder(u->right);
}

int main(){
    int m;
    cin>>m;
    string s;
    int k;
    rep(i,m){
        cin>>s;
        if(s=="insert"){
            cin>>k;
            insert(k);
        }else if(s=="find"){
            cin>>k;
            Node* t=find(root,k);
            if(t!=NIL)cout<<"yes"<<endl;
            else cout<<"no"<<endl;
            /*if(find(k))cout<<"yes"<<endl;
            else cout<<"no"<<endl;*/
        }else if(s=="delete"){
            cin>>k;
            deleteN(find(root,k));
        }
        else if(s=="print"){
            inorder(root);
            cout<<endl;
            preorder(root);
            cout<<endl;
        }
    
    }
        return 0;
}

    


Measured memory_bytes: 21888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);

		int N = stdIn.nextInt();

		if(N < 1000)
		{
			System.out.println("ABC");
		}
		else
		{
			System.out.println("ABD");
		}

	}

}


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

class PriorityQueue {
    int H = 0;
    long[] A;

    PriorityQueue() {
        A = new long[2000000];
    }

    void insert(long key) {
        H++;
        A[H] = Long.MIN_VALUE;
        heapIncreaseKey(H, key);
    }

    private void swap(int i, int j) {
        long tmp = A[i];
        A[i] = A[j];
        A[j] = tmp;
    }

    private void heapIncreaseKey(int i, long key) {
        if (key < A[i]) return;
        A[i] = key;
        while (i > 1 && A[i / 2] < A[i]) {
            swap(i, i / 2);
            i = i / 2;
        }
    }

    long extract() {
        if (H < 1) throw new ArrayIndexOutOfBoundsException("The queue is empty.");

        long max = A[1];
        A[1] = A[H];
        H--;
        maxHeapfy(1);

        return max;
    }

    private void maxHeapfy(int i) {
        int left = i * 2;
        int right = i * 2 + 1;

        int largest = i;
        if (left <= H && A[left] > A[i])
            largest = left;
        if (right <= H && A[right] > A[largest])
            largest = right;

        if (largest != i) {
            swap(i, largest);
            maxHeapfy(largest);
        }
    }
}

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            PriorityQueue queue = new PriorityQueue();

            String order = in.readLine();
            while (!order.equals("end")) {
                if (order.startsWith("i")) {
                    long k = Long.parseLong(order.split(" ")[1]);
                    queue.insert(k);
                } else {
                    System.out.println(queue.extract());
                }
                order = in.readLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 177520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int count = 0;
  for(int i = 0; i < N; i++ ){
    int h;
    cin >> h;
    if( h >= K ){
      count++;
    }
  }
  cout << count << endl;
}

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

int main() {
	int	N;
	cin >> N;
	set<int> s;
	rep(i, N)
	{
		int	a, b;
		cin >> a >> b;
		if (a == 0)
		{
			s.insert(b);
			cout << s.size() << endl;
		}
		else if (a == 1)
			cout << (s.find(b) != s.end()) << endl;
		else if (a == 2)
			s.erase(b);
		else
		{
			int c;
			cin >> c;
			for (set<int>::iterator it = s.lower_bound(b); it != s.upper_bound(c); it++)
				cout << *it << endl;
		}
	}
}



Measured memory_bytes: 12416
s=input()
S=list(s)
for i in range(len(S)):
    S[i]=int(S[i])
ans=0
count=0
count1=0
N=list(s)
if len(S)==1:
    ans=0
else:
    for j in range(1,len(N)-1):
        if N[j-1]==N[j]==N[j+1]:
            if N[j]!=0:
                N[j]=0
            else:
                N[j]=1
            count+=1
        elif N[j-1]==N[j] and N[j+1]!=N[j]:
            N[j-1]=N[j+1]
            count+=1
        elif N[j-1]!=N[j] and N[j+1]==N[j]:
            N[j+1]=N[j-1]
            count+=1
    for k in range(len(S)-2,0,-1):
        if S[k-1]==S[k]==S[k+1]:
            if S[k]!=0:
                S[k]=0
            else:
                S[k]=1
            count1+=1
        elif S[k-1]==S[k] and S[k+1]!=S[k]:
            S[k-1]=S[k+1]
            count1+=1
        elif S[k-1]!=S[k] and S[k+1]==S[k]:
            S[k-1]=S[k+1]
            count1+=1
    if count>count1:
        ans=count1
    else:
        ans=count
print(ans)

Measured memory_bytes: 4852
import java.util.*;

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

        int n = sc.nextInt();

        Map<Integer,Integer> m = new HashMap<Integer,Integer>();

        boolean b = true;
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            if(m.containsKey(a)){
                b = false;
                break;
            }else{
                m.put(a, a);
            }
        }
        System.out.println(b ? "YES":"NO");

    }
}


Measured memory_bytes: 104780