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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, k; read(n, k);
	vector<int> v(n);
	rep(i, 0, n) read(v[i]);
	int g = v[0], mx = v[0];
	rep(i, 0, n) g = __gcd(g, v[i]), mx = max(mx, v[i]);
	die((k <= mx && k % g == 0) ? "POSSIBLE" : "IMPOSSIBLE");
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main() {
	string n;
	cin >> n;

	if (n == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (n == "Rainy") {
		cout << "Sunny" << endl;
	}
	else {
		cout << "Rainy" << endl;
	}

}


Measured memory_bytes: 384
import java.util.*;
 
public class Main {
  
  public static void main(String[] args){
  Scanner s=new Scanner(System.in);
  String S=s.next();
  
  if(S.equals("AAA") || S.equals("BBB")){
    System.out.print("No");
  }else{
    System.out.print("Yes");
  }
  }
}


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

int main() {
  
  int D,T,S;
  cin >> D >> T >> S;
  
  int Dis;
  Dis = S*T;
  
  if (S*T >= D) {
    cout << "Yes" << endl;
  }
  else {
   cout << "No" << endl; 
  }
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();

		if(N==1){
			System.out.println("Hello World");
		}else if(N==2){
			int A = scan.nextInt();
			int B = scan.nextInt();
			System.out.println(A + B);
		}
	}
}


Measured memory_bytes: 22608
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  ll a,b;
  cin >> a >> b;
  b++;

  ll xor_a = a % 2 == 0 ? a/2 % 2 : (a/2 % 2) ^ (a-1);

  ll xor_b = b % 2 == 0 ? b/2 % 2 : (b/2 % 2) ^ (b-1);

  cout << (xor_a^xor_b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;
int a[100005];
int main()
{
    int N, x;
    while(scanf("%d%d", &N, &x)!=EOF)
    {
        for(int i=1; i<=N; i++)
            scanf("%d", &a[i]);
        long long int sum=0;
        int last = 0;
        for(int i=1; i<=N; i++)
        {
            if(last+a[i]<=x)
                last = a[i];
            else
            {
                sum+=last+a[i]-x;
                last=a[i]-(last+a[i]-x);
            }
        }
        printf("%lld\n", sum);
        return 0;
    }
}

Measured memory_bytes: 640
N, K = gets.split.map(&:to_i)
A = gets.split.map{|t| t.to_i - 1}
NA = Array.new(N, -1)
now = 0
k = 0
loc = 0 # loop
c = 0 # %

ng = false
while true do
    break if k == K
    if NA[now] != -1
        loc = k - NA[now]
        c = (K - k) % loc
        ng = true
        break
    end

    NA[now] = k
    k += 1
    now = A[now]
end

c.times do
    now = A[now]
end if ng

puts now + 1


Measured memory_bytes: 28932
#include<iostream>
using namespace std;
int main(void){
    int n,m,l;
    int i,j,k;
    cin >> n >> m >>l;
    int M1[n][m],M2[m][l];
    long lSum;
    for (i=0;i<n;i++){
        for (j=0;j<m;j++){
            cin >> M1[i][j];
        }
    }
    for (i=0;i<m;i++){
        for (j=0;j<l;j++){
            cin >> M2[i][j];
        }
    }
    for (i=0;i<n;i++){
        for (j=0;j<l;j++){
            if (j!=0){
                cout << ' ';
            }
            lSum=0;
            for (k=0;k<m;k++){
                lSum+=M1[i][k]*M2[k][j];
            }
            cout << lSum;
        }
        cout << endl;
    }
    
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    int a;
    cin >> a;
    if(a >= 30){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No"  << endl;
    return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, K; cin >> N >> K;
    ll res = 0;

    ll m0=0, mh=0;
    rep1(i, N){
        if(i % K == 0) m0++;
        if(K % 2 == 0 && i % K == K/2) mh++;
    }

    res = m0*m0*m0 + mh*mh*mh;

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
/*
* Created by: WeirdBugsButOkay
*/

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

void solve()
{
    int n;
    cin >> n;
    map <string, int> m;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
}

int main()
{
    int q = 1;
    //scanf("%d", &q);
    for(int i = 1; i <= q; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;
const int n = 1e5;

ll N, A, B, ans, H[n];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> A >> B;
  FOR(i, 0, N)cin >> H[i];
  sort(H, H + N);
  ll s = 0, mid, t, d = A - B, p, h;
  ans = inf;
  while(ans - s > 1){
    mid = (ans + s) / 2;
    p = mid * B;
    t = mid;
    FOR(i, 0, N){
      h = H[N - i - 1] - p;
      if(h > 0){
        t -= h / d;
        if(h % d)t -= 1;
      }else{
        break;
      }
    }
    if(t >= 0){
      ans = mid;
    }else{
      s = mid;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
double w,h,x,y;
  cin >>w>> h>> x >> y;
auto ans = w*h/2;
  
  if(x==w/2 && y==h/2.0)
    cout << ans << " "<< 1  <<endl;
  else
    cout << ans << " "<<0<<endl;
}


Measured memory_bytes: 256
from itertools import permutations
class Solve():
    def __init__(self):
        self.N, self.M, self.R = map(int, input().split())
        self.r = list(map(int, input().split()))
        self.route = [[float('inf') for _ in range(self.N)] for _ in range(self.N)]
        for _ in range(self.M):
            a, b, c = map(int, input().split())
            self.route[a - 1][b - 1] = c
            self.route[b - 1][a - 1] = c
        for i in range(self.N):
            self.route[i][i] = 0

    def WarshallFloid(self):
        for k in range(self.N):
            for i in range(self.N):
                for j in range(self.N):
                    if self.route[i][j] > self.route[i][k] + self.route[k][j]:
                        self.route[i][j] = self.route[i][k] + self.route[k][j]

    def execute(self):
        self.WarshallFloid()
        ans = float('inf')
        checked = set()
        for path in permutations(self.r):
            if tuple(reversed(path)) in checked:
                continue
            checked.add(tuple(reversed(path)))
            temp = 0
            for i in range(self.R - 1):
                temp += self.route[path[i] - 1][path[i + 1] - 1]
            ans = min(ans, temp)
        print(ans)


if __name__ == '__main__':
    Solve().execute()

Measured memory_bytes: 59608
#include <iostream> 
#include <math.h>  
using namespace std; 
  
// function to print number of 
// digits 
void fnd(long n, int base) 
{ 

    int dig = (int)(floor( log(n) /  
                         log(base)) + 1);  
      
    // printing output 
    cout <<dig;
} 
  
// Driver method  
int main() 
{ 
    // taking inputs 
    long n;cin>>n;
    int b;cin>>b;
      
    // calling the method 
    fnd(n, b); 
    return 0; 
} 

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
using namespace std;
int n, k;
int main(){
    while(cin >> n >> k, n||k){
        vector<string> v;
        for(int i=0; i<n; ++i){
            string st; cin >> st;
            v.push_back(st);
        }
        sort(v.begin(), v.end());
        
        set<string> st;
        do{
            string num="";
            for(int i=0; i<k; ++i){
                num += v[i];
            }
            st.insert(num);
        }while(next_permutation(v.begin(), v.end()) );
        cout << st.size() << endl;
    }
    return 0;
}


Measured memory_bytes: 3408
#include<stdio.h>
#include<string.h>


int main(){
char S[10],T[10],U[10];
int A,B;

scanf("%s",&S);
scanf("%s",&T);
scanf("%d",&A);
scanf("%d",&B);
scanf("%s",&U);
if(strcmp(S,U) == 0){
A--;
}
if(strcmp(T,U) == 0){
B--;
}
printf("%d %d\n",A,B);

return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <climits>
#include <cassert>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x","<<#y":"<<x<<","<<y<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

vi num;
vi num_odd;
int N;
int N_odd;

void init(){
    int t=1;
    int i=1;
    while(t<1000000){
        num.EB(t);
        i++;
        t = i*(i+1)*(i+2)/6;
    }
    N = num.size();

    for(i=0;i<N;i++){
        if(num[i]%2==1) num_odd.emplace_back(num[i]);
    }
    N_odd = num_odd.size();
}

void solve(int n){
    vi dp(n+10,INF);
    dp[0]=0;
    for(int i=0;i<N;i++){
        for(int j=num[i];j<=n;j++){
            dp[j] = min(dp[j],dp[j-num[i]]+1);
        }
    }

    cout << dp[n] << " ";

    dp = vector<int>(n+10,INF);
    dp[0] = 0;
    for(int i=0;i<N_odd;i++){
        for(int j=num_odd[i];j<=n;j++){
            dp[j] = min(dp[j],dp[j-num_odd[i]]+1);
        }
    }
    cout << dp[n] << endl;
}

int main(){
    init();
    int n;


    while(cin>>n){
        if(n==0) break;
        solve(n);
    }
}

Measured memory_bytes: 14080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
const ll mod = 1e9+7;


int main(){
  string s;
  cin >> s;
  if (s =="Sunny") cout << "Cloudy" << endl;
  else if (s == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;


  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i;
    cin>>n;
    string st;
    long long p=0,q=0,r=0,s=0;
    string a="AC",b="WA",c="TLE",d="RE";
    for(i=0;i<n;i++)
    {
        cin>>st;
        if(st==a)
            p++;
        else if(st==b)
            q++;
        else if(st==c)
            r++;
        else
            s++;
    }
    cout<<"AC x "<<p<<endl;
    cout<<"WA x "<<q<<endl;
    cout<<"TLE x "<<r<<endl;
    cout<<"RE x "<<s<<endl;
}


Measured memory_bytes: 3624
N = int(input())
A = [list(map(int,input().split())) for i in range(N)]

B = [[a[0],a[1],a[0]+a[1]] for a in A]
B = sorted(B, key=lambda x: x[2], reverse=True)
Taka=0
Aoki=0

for i, b in enumerate(B):
    if i%2==0:
        Taka+=b[0]
    else:
        Aoki+=b[1]
    

print(Taka-Aoki)


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long LL;

const int INF = 0x3f3f3f3f;

int main(void) {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N, W, w, v;
    cin >> N >> W;
    LL dp[W+5] = {0};

    for (int i = 0; i < N; ++i) {
        cin >> w >> v;
        for (int j = W; j >= w; --j) {
            dp[j] = max(dp[j], dp[j-w]+v);
        }
    }

    cout << dp[W] << endl;

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(){
	ll n,a,b;

	cin>>n>>a>>b;
	ll res;
	res = (n/(a+b))*a;
	res += min(n%(a+b),a);
	cout<<res;

}
 

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int s = 0;
  for (auto& e : a) {
    cin >> e;
    s += e;
  }
  sort(a.rbegin(), a.rend());
  cout << (a[m - 1] * 4 * m >= s ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <utility>
#include <algorithm>

using namespace std;

template<typename T>
int partition(T ar[], int p, int r){
    T pivot = ar[r];
    int i = p - 1;
    for (int j = p; j <= r - 1; j++) {
        if(ar[j] <= pivot){
            i++;
            swap(ar[i], ar[j]);
        }
    }
    i++;
    swap(ar[i], ar[r]);
    return i;
}

template<typename T>
void quicksort(T ar[], int p, int r){
    if(p < r){
        int q = partition(ar, p, r);
        quicksort(ar, p, q - 1);
        quicksort(ar, q + 1, r);
    }
}

class Card {
    public:
        char squit;
        int value;
        bool operator <=(const Card &c){
            return this->value <= c.value;
        }

        bool operator != (const Card &c){
            return this->value != c.value || squit != c.squit;
        }

        bool operator > (const Card &c){
            return this->value > c.value;
        }
};

Card qs[100000];
Card bs[100000];

int main(int argc, char const* argv[])
{
    int n;

    scanf("%d ", &n);
    
    for (int i = 0; i < n; i++) {
        char s;
        int v;
        scanf("%c %d ", &s, &v);
        qs[i].squit = s;
        qs[i].value = v;
        bs[i].squit = s;
        bs[i].value = v;
    }

    quicksort(qs, 0, n - 1);
    stable_sort(bs, bs+n,
        [](const Card &fst, const Card &snd) -> bool
        {
            if(fst.value < snd.value) return true;
            return false;
        });

    bool is_stable = true;
    for (int i = 0; i < n; i++) {
        if(qs[i] != bs[i]){
            is_stable = false;
            break;
        }
    }

    if (is_stable) {
        puts("Stable");
    } else {
        puts("Not stable");
    }

    for (int i = 0; i < n ; i++) {
        printf("%c %d\n", qs[i].squit, qs[i].value);
    }

    return 0;
}

Measured memory_bytes: 4296
ISLANDS, BRIDGES = gets.split(" ").map(&:to_i)
FIRST = ISLANDS*(ISLANDS-1) / 2

inputs = (0...BRIDGES).map do
  gets.split(" ").map(&:to_i)
end
inputs.reverse!

class Node
  attr_accessor :parent, :rank

  def initialize(n)
    @parent = n
    @rank = 0
  end
end

class UnionFindTree
  def initialize(n)
    @nodes = (0..n).to_a.map { |i| Node.new(i) }
    @count = Array.new(n+1, 1)
  end

  def find(x)
    return x if @nodes[x].parent == x

    return @nodes[x].parent = find(@nodes[x].parent)
  end

  def count(x)
    @count[find(x)]
  end

  def unite(a, b)
    # p [a,b]
    # p @count

    a = find(a)
    b = find(b)
    return if a == b

    if @nodes[a].rank < @nodes[b].rank
      @count[find(b)] = count(a) + count(b)
      @nodes[a].parent = b
    else
      @count[find(a)] = count(a) + count(b)
      @nodes[b].parent = a
      @nodes[a].rank += 1 if @nodes[a].rank == @nodes[b].rank
    end
  end

  def same?(a, b)
    find(a) == find(b)
  end

  # 確認用。アルゴリズムとは関係無い
  def parents
    @nodes.map(&:parent)
  end
end

@utree = UnionFindTree.new(ISLANDS)
@score = FIRST

res = inputs.map do |v|
  @score = @score - @utree.count(v[0])*@utree.count(v[1]) if @score != 0 && !@utree.same?(v[0], v[1])
  @utree.unite(v[0], v[1])
  @score
end
res.reverse!
res.slice!(0, 1)

puts res if res.size != 0
puts FIRST


Measured memory_bytes: 19124
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)
#define adiii \                               
  ios_base::sync_with_stdio(false); \                                      
  cin.tie(NULL);  \
  cout.tie(NULL);									
 
ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}
ll gcd(ll a,ll b) {if (b == 0) return a;return gcd(b, a % b);}

int main(){
	adiii
	ll n;cin>>n;
	string s;cin>>s;
	vector <bool> cr(n+1,0),cb(n+1,0),cg(n+1,0);
	vector <ll> ir,ib,ig;
	rep(i,0,n){
		if(s[i]=='R') ir.pb(i+1),cr[i+1]=1;
		if(s[i]=='B') ib.pb(i+1),cb[i+1]=1;
		if(s[i]=='G') ig.pb(i+1),cg[i+1]=1;
	}
	ll rs = ir.size();
	ll bs = ib.size();
	ll gs = ig.size();
	ll ans = rs*bs*gs;
	//cout<<ans<<endl;
	rep(i,0,rs){
		ll idx = ir[i];
      	ll lt = (n%2==0) ? n/2 : n/2+1;
		rep(d,1,lt){
          	//cout<<d<<endl;
			if(idx+2*d <=n) {if( (cb[idx+d]==true && cg[idx + 2*d]==true) || (cg[idx+d]==true && cb[idx + 2*d]==true)) ans--;}
			if(idx-d>=1 && idx+d<=n) {if(cb[idx-d]==true && cg[idx+d]==true || cg[idx-d]==true && cb[idx+d]==true) ans--;}
			if(idx-2*d>=1) {if(cb[idx-d] == true && cg[idx-2*d]==true || cg[idx-d] == true && cb[idx-2*d]==true) ans--;}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3724
from bisect import bisect_left

n = int(input())
L = sorted(list(map(int, input().split())))

# 二分探索
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        a, b = L[i], L[j]
        # c < a + b
        r = bisect_left(L, a+b)
        l = j+1
        cnt += max(0, r-l)
print(cnt)

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

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

    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;

    ll ans = 0;
    if (N >= 2) {
        ll DQ = 8 * Q, DH = 4 * H, DS = 2 * S;
        ll minCost = min(DQ, min(DH, min(DS, D)));
        ans += minCost * (N / 2);
        N %= 2;
    }
    ll SQ = 4 * Q, SH = 2 * H;
    ll minCost = min(SQ, min(SH, S));
    ans += minCost * N;

    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    cout << fixed << setprecision(12);

    ll n;
    cin >> n;
    for(ll i = 1; i < 10; i++){
        if(n % i == 0 && n/i < 10){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
x,y = map(int,input().split())
MOD = 10**9 + 7

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod  
  
#まず目的地まで行けるかどうか判定する。
#移動回数
n = (x+y)//3

a = -1
for i in range(n+1):
  if i+2*(n-i) == x and  2*i+(n-i) == y:
    a = i
    
if a == -1:
  print(0)
else:
  ans = comb(n,a,MOD)
  print(ans%MOD)
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
     return false;
}
template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}
template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}

int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x):
        x((x%mod + mod) % mod){}
    mint& operator+=(const mint a) { 
        if (x += a.x > mod) x-=mod;
        return *this;
    }
    mint& operator-=(const mint a) { 
        if (x += mod - a.x >= mod) x-=mod;
        return *this;
    }
    mint& operator*=(const mint a) { 
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll a) const{
        if (a == 0) return 1;
        mint b = pow(a >> 1);
        b *= b;
        if (a&1) b *= (*this);
        return b;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) { 
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const { 
        mint res(*this);
        return res /= a;
    }
};

using namespace std;




int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    ll K,  ans = 1, iti = 1, n = 0;
    bool ok = false;
    cin >> K;
    if (K % 7 == 0)  K /= 7;
    rep(i, K){
        n += iti;
        n %= K;
        iti *= 10;
        iti %= K;
        if (n == 0) {
            ok = true;
            break;
        }
        ans++;
    }
    if (!ok) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n,q;
    string s;
    cin>>n>>s>>q;
    rep(r,q){
        int k;
        cin>>k;
        ll ans=0,d=0,m=0,dm=0;
        rep(i,n){
            if(0<=i-k){
                if(s[i-k]=='D'){
                    --d;
                    dm-=m;
                }
                else if(s[i-k]=='M'){
                    --m;
                }
            }
            if(s[i]=='D'){
                ++d;
            }
            else if(s[i]=='M'){
                ++m;
                dm+=d;
            }
            else if(s[i]=='C'){
                ans+=dm;
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1412
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int s,w;
  cin>>s>>w;
  if(s<=w){
    cout<<"unsafe"<<endl;
  }else{
    cout<<"safe"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3616
while True :
    n=int(input())
    if n==0:
        break
    
    ice=list([0] * 10)
    for i in range(n):
        ice[int(input())] += 1
    

    for i in range(10):
        if ice[i] > 0:
            for j in range(ice[i]):
                print("*", sep="", end="")
            print( )
        else:
            print("-")


Measured memory_bytes: 7588
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var d = new Dictionary<int,int>();
		for(int i=0;i<N;i++){
			if(d.ContainsKey(A[i]) == false) d.Add(A[i],0);
			d[A[i]]++;
		}
		
		Console.WriteLine(d.Select(kvp => kvp.Value%2).Sum());
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = new int[N];
		for(int i=0;i<N;i++) A[i] = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 20828
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define veci(x,n) vector<int> x((int) (n))
#define vecs(x,n) vector<string> x((int) (n))
#define vecbf(x,n) vector<bool> x((int) (n), false)

long answer = 0;

long calc(vector<char> data,int len){
  long tmp = 0;
  long post = 0;
  rep(i,2*len){
    if(data.at(i) == '-') continue;
    if(data.at(i) == '+'){
      post += tmp;
      tmp = 0;
    }else{
      tmp *= 10;
      tmp += data.at(i) - '0'; 
    }
  }
  return post;
}

void maker(vector<char> data,int i,int &len){
  if(i == 2*len-1){
    data.at(2*len-1) = '+';
    answer += calc(data,len);
    return;
  }
  
  maker(data,i+2,len);
  
  data.at(i) = '+';
  maker(data,i+2,len);
}

int main(){
  string s;
  cin >> s;
  int len = s.size();
  vector<char> data(2*len,'-');
  rep(i,len) data.at(2*i) = s.at(i);
  maker(data,1,len);
  cout << answer << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	m := make(map[byte]int)
	for i := 0; i < len(s); i++ {
		m[s[i]]++
	}
	if len(m) == len(s) {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}


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

template<typename T>
vector<T> compress(vector<T> A){
    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    return A;
}

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> H(N+1);
    for(int i=0; i<N; i++) cin >> H[i];
    auto cmp = compress(H);
    int M = cmp.size();

    static int64_t dp[301][301][302];
    for(int i=0; i<=N; i++) for(int j=0; j<M; j++) for(int k=0; k<=K; k++) dp[i][j][k] = 1e18;
    dp[0][0][0] = 0;
    for(int i=0; i<N; i++){
        int hj = lower_bound(cmp.begin(), cmp.end(), H[i]) - cmp.begin();
        for(int k=0; k<=K; k++){
            int64_t upper[301];
            for(int j=M-1; j>=0; j--){
                upper[j] = dp[i][j][k];
                if(j<M-1) chmin(upper[j], upper[j+1]);
            }
            int64_t lower = dp[i][0][k];
            for(int j=0; j<M; j++){
                chmin(dp[i+1][j][k+(j!=hj)], min(lower, upper[j]));
                if(j<M-1) lower = min(lower+cmp[j+1]-cmp[j], dp[i][j+1][k]);
            }
        }
    }

    int64_t ans = 1e18;
    for(int j=0; j<M; j++) for(int k=0; k<=K; k++) chmin(ans, dp[N][j][k]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 214016
N, M = map(int,input().split())
s = [-1]*N
for i in range(2**N):
    for j in range(N):
        if (i >> j) & 1:
            s[j] = 1
        else:
            s[j] = 0
k = [None]*M
si = [None]*M
for i in range(M):
    tmp = list(map(int,input().split()))
    k[i] = tmp[0]
    si[i] = tmp[1:]
p = list(map(int,input().split()))

s = [-1]*N
ans = 0
for i in range(2**N):
    for j in range(N):
        if (i >> j) & 1:
            s[j] = 1
        else:
            s[j] = 0
    f = True
    for x in range(M):
        tmp = sum([1 for y in si[x] if s[y-1]==1]) % 2
        if tmp != p[x]:
            f = False
            break
    if f:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
int main(){
    string s;
    int k;
    cin >> s >> k;
    long long ans;
    if(s.size() == 1){
        ans = k/2;
        cout << ans;
        return 0;
    }
    int count = 0;
    for(int i=0; i<s.size()-1;i++){
        if(s.at(i) == s.at(i+1)){
            count ++;
            i++;
        }
    }
    ans = (long long)count * k;
    int count_front = 0;
    for(int i=0;i<s.size()-1;i++){
        if(s.at(i) == s.at(i+1)){
            count_front ++;
        }else{
            break;
        }
    }
    count_front ++;
    if( count_front == s.size()){
        ans = (long long)s.size() * k / 2;
        cout << ans;
        return 0;
    }
    int count_back = 0;
    for(int i=s.size()-1 ; i>0 ; i--){
           if(s.at(i) == s.at(i-1)){
            count_back ++;
        }else{
            break;
        }
    } 
    count_back ++;
    if(count_front % 2 == 1 && count_back % 2 == 1 && s.at(0) == s.at(s.size()-1)){
        ans = (long long) ans + (k-1);
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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


fn main() {
    let d:u32 = read();
    let mut n:u128 = read();
    if n == 100 {
        n += 1;
    }
    println!("{}", 100u128.pow(d) * n);
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
//答え見た　図を書くのが大切
int main() {
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int x3,y3,x4,y4;
  
  int dx,dy;
  
  dx = x2 - x1;
  dy = y2 - y1;
  
  x3 = x2 - dy;
  y3 = y2 + dx;
  
  x4 = x1 -dy;
  y4 = y1 + dx;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		long ans = x;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			ans += d / a;
			if(d % a >= 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

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

const int maxn = 3e6 + 50 , K = 25;
vector <int> edges[maxn];
ll a[maxn] , n , ans;

void dfs(int v, int p = -1) {
    int b = 0;
    for (auto u : edges[v]){
        if (u == p) continue;
        dfs(u , v);
        for (int i = b; i < K; ++i) {
            if ((a[v] & a[u]) & (1 << i)) {
                b = i + 1;
            }
        }
        a[v] |= a[u];
        while (a[v] & (1 << b)) {
            b++;
        }
    }
    for (int i = 0; i < b; ++i) {
        if (a[v] & (1 << i)) {
            a[v] ^= (1 << i);
        }
    }
    a[v] |= (1 << b);
}
int main() {
    FAST
    cin >> n;
    for (int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        edges[u].PB(v);
        edges[v].PB(u);
    }
    dfs(1);
    for (int i = 0; i < K; ++i) {
        if (a[1] & (1 << i)) {
            ans = i;
        }
    }
    cout << ans << endl;
}

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    ll n,k,q;
    cin >> n>>k>>q;
    vector<ll> points(n);
    rep(i,n){
        points[i] = k-q;
    }
    rep(i,q){
        ll answer;
        cin>>answer;
        points[answer-1]++;
    }
    rep(i,n){
        if(points[i]>0) cout << "Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 4008
def gcd(a,b):
    while b > 0:
        r = a % b
        a = b
        b = r
    return a

n = int(input())
x = int(input())
for _ in range(n-1):
    i = int(input())
    x = (x * i) // gcd(x,i)

print(x)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
    int n;
    int a[32];
    int b[32];
    int c[32];
    int s = 0;
    int k, l;

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

    l = -1;
    for(int i=1; i<=n; ++i){
        k = a[i];
        s += b[k];
        if(k == l + 1) s += c[l];
        l = k;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B,K;
    cin >> A >> B >> K;
    int c = 0;
    for(int i = min(A,B);i >= 1;i--){
        if(A % i == 0 && B % i == 0){
            c++;
        }
        if(c == K){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 2e5+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
ll fact[MAXN],ifact[MAXN];
ll dp[MAXN],d[MAXN];
ll a[MAXN];
vvi g;
ll C(ll n,ll k)
{
    if (k>n)
        return 0;
    assert(n<MAXN);
    ll ans=fact[n];
    ans*=ifact[k];
    ans%=mod1;
    ans*=ifact[n-k];
    ans%=mod1;
    return ans;
}
ll bin_pow(ll base,ll deg)
{
    if (deg==0)
        return 1;
    ll t=bin_pow(base,deg/2);
    if (deg&1)
        return (((t*t)%mod1)*base)%mod1;
    else
        return (t*t)%mod1;
}
void dfs(int s,int p)
{
    dp[s]=1;
    d[s]=1;
    ll now=0;
    for (auto to:g[s])
    {
        if (to==p)
            continue;
        dfs(to,s);
        d[s]+=d[to];
    }
    for (auto to:g[s])
    {
        if (to==p)
            continue;
        dp[s]*=(dp[to]*C(d[s]-1-now,d[to]))%mod1,now+=d[to];
        dp[s]%=mod1;
    }
}
void dfss(int s,int p)
{
    a[s]=dp[s];
    for (auto to:g[s])
    {
        if (to==p)
            continue;
        dp[s]*=bin_pow(C(d[s]-1,d[to]),mod1-2);
        dp[s]%=mod1;
        dp[s]*=bin_pow(dp[to],mod1-2);
        dp[s]%=mod1;
        d[s]-=d[to];
        d[to]+=d[s];
        dp[to]*=dp[s];
        dp[to]%=mod1;
        dp[to]*=C(d[to]-1,d[s]);
        dp[to]%=mod1;
        dfss(to,s);
        dp[to]*=bin_pow(C(d[to]-1,d[s]),mod1-2);
        dp[to]%=mod1;
        dp[to]*=bin_pow(dp[s],mod1-2);
        dp[to]%=mod1;
        d[to]-=d[s];
        d[s]+=d[to];
        dp[s]*=C(d[s]-1,d[to]);
        dp[s]%=mod1;
        dp[s]*=dp[to];
        dp[s]%=mod1;
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll f=1;
    for (ll i=0;i<MAXN;i++)
    {
        fact[i]=f,f*=(i+1),f%=mod1;
        ifact[i]=bin_pow(fact[i],mod1-2);
    }
    int n;
    cin>>n;
    g=vvi(n);
    for (int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        u--,v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(0,0);
    dfss(0,0);
    rep(i,n)
    cout<<a[i]<<'\n';





}

Measured memory_bytes: 21748
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

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

	cout << (N<1200?"ABC":"ARC") << endl;
	return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    V<Vi> a(3,Vi(3));
    REP(i,3) REP(j,3) cin>>a[i][j];
    V<Vi> card(3,Vi(3));

    int n;
    cin>>n;
    Vi b(n);
    REP(i,n) cin>>b[i];

    REP(i,3){
        REP(j,3){
            REP(k,n){
                if(b[k] == a[i][j]){
                    card[i][j] = 1;
                }
            }
        }
    }

    Vi yoko(3), tate(3), naname(2);
    REP(i,3){
        REP(j,3){
            if(card[i][j] == 1){
                yoko[i]++;
                tate[j]++;
                if(i==j) naname[0]++;
                if(i==2-j) naname[1]++;
            }
        }
    }

    REP(i,3) {
        if(yoko[i] == 3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    REP(i,3) {
        if(tate[i] == 3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    REP(i,2) {
        if(naname[i] == 3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

int main() {
  ll N;
  cin >> N;
  vector<ll> right(N);
  vector<ll> left(N);
  REP(i, N) {
    ll A;
    cin >> A;
    if (i + A < N) {
      right[i + A]++;
    }
    if (0 <= i - A) {
      left[i - A]++;
    }
  }
  ll count = 0;
  REP(i, N) { count += right[i] * left[i]; }
  cout << count << endl;
  return 0;
}


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

int main(int argc, char *argv[]) {
  int a, b;
  cin >> a >> b;
  for (int i = 1; i <= 3; ++i) {
    int d = a * b * i;
    if (d % 2 != 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import Foundation
// 第一引数に、素因数分解したい自然数を渡す
func prime_factorization(n:Int)->[[Int]]{
    // n = 1 なら素因数分解できないので空の二次元配列を返す
    if n == 1{
        return []
    }
    // 戻り値のなる二次元配列を初期化
    var arr:[[Int]] = []
    // nの値を変数に格納
    var temp = n
    // 計算するのは√nまでで十分
    for i in 2...Int(sqrt(Double(n)))+1{
        // 割り切れる -> その数を素因数に持つ
        if temp%i==0{
            var cnt=0
            // 素因数の字数を計算
            while temp%i==0{
                // 割り切れるなら次数を一つ増やす
                cnt+=1
                // tempをiで割る
                temp /= i
            }
            // 素因数とその次数をarrに追加
            arr.append([i,cnt])
        }
    }
    // temp ≠ 1ならtempは素因数なのでarrに追加
    if temp != 1{
        arr.append([temp, 1])
    }
    // arrが空なら n = (素数) なのでarrに追加
    if arr==[] {
        arr.append([n, 1])
    }
    // arrを返す
    return arr
}

// 標準入力の受け取り
let n = Int(readLine()!)!

// nを素因数分解
let factorization = prime_factorization(n:n)

// 答えを入れる変数の初期化
var ans = 0

// 各素因数についてループを回す
for i in factorization{

    // 計算に使う変数を初期化
    var num = i[1]
    var cnt = 1
    
    // もし以前の操作で選んだどの整数とも異なる整数を作れるなら ans += 1
    while num >= cnt{
        ans += 1
        num -= cnt
        cnt += 1
    }
}

// 答えを出力
print(ans)

Measured memory_bytes: 13128
def insertion_sort(data, g, cnt):
    for i in range(1, len(data)):
        v = data[i]
        j = i-g
        while j >= 0 and data[j] > v:
            data[j+g] = data[j]
            j -= g
            cnt += 1
        data[j+g] = v
    return data, cnt


def shell_sort(data):
    cnt = 0
    G = [1]
    m = 4
    while m < len(data):
        G.append(m)
        m = 3*m + 1
    G.sort(reverse=True)
    for g in G:
        data, cnt = insertion_sort(data, g, cnt)
    return data, cnt, G


if __name__ == '__main__':
    data = []
    n = int(input())
    for _ in range(n):
        data.append(int(input()))
    data, cnt, G = shell_sort(data)
    print(len(G))
    print(*G)
    print(cnt)
    for i in range(n):
        print(data[i])



Measured memory_bytes: 45520
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;

class UnionFind{
public:
  //親の番号を格納する変数。数値がマイナスの場合は親であり、その絶対値のサイズのグループを持っている
  vector<int> Parent;
  
  //コンストラクタ。-1で初期化する。
  UnionFind(int N){
    Parent = vector<int>(N,-1);
  }
  
  //Aが何処のグループに属しているか返す
  int root(int A){
    if(Parent[A] < 0) return A; //0以下の時は自分が親。自分のグループなので自分を返す
    return Parent[A] = root(Parent[A]); //根でなかった場合は再帰的に関数を呼ぶ。ついでにParent[A]を更新して次の時高速化する。
  }
  
  //自分の親の頂点数を返す。マイナスでグループのサイズを持っているので反転して返す。
  int size(int A){
    return -Parent[root(A)];
  }
  
  //AとBを連結する関数
  bool connect(int A, int B){
    A = root(A); //Aの親を持ってくる
    B = root(B); //Bの親を持ってくる
    if (A==B){ //親が同じだったらくっつけない
      return false;
    }
    
    //Aが必ず大きい数にする
    if (size(A) < size(B)) swap(A,B);
    
    //AにBのグループをくっつける。
    Parent[A] += Parent[B];
    //Bの親をAにする。
    Parent[B] = A;
    
    return true;
  }
};

int main(){
  int n,k,l; cin >> n >> k >> l;
  UnionFind road(n),train(n);
  rep(i,k){
    int p,q; cin >> p >> q;
    p--,q--;
    road.connect(p,q);
  }
  rep(i,l){
    int p,q; cin >> p >> q;
    p--,q--;
    train.connect(p,q);
  }
  
  map<pair<int,int>,int> mp;
  
  rep(i,n) mp[{road.root(i),train.root(i)}]++;
  rep(i,n) cout << mp[{road.root(i),train.root(i)}] << " ";

  return 0;
}

Measured memory_bytes: 13568
from fractions import gcd
N, X = map(int, input().split())
kotae = list(map(int, input().split()))
kotae.append(X)
kotae.sort()
t = kotae[1]-kotae[0]
for i in range(len(kotae)-1):
    t = gcd(t, abs(kotae[i + 1] - kotae[i]))
print(t)

Measured memory_bytes: 16280