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

template <typename T>
class DisjointSet {
   public:
    map<T, T> p;
    map<T, int> rank;
    DisjointSet() {
        p.clear();
        rank.clear();
    }
    DisjointSet(vector<T> elements) {
        p.clear();
        rank.clear();
        for (int i = 0; i < elements.size(); i++) {
            makeSet(elements[i]);
        }
    }
    void makeSet(T x) {
        p[x] = x;
        rank[x] = 0;
    }
    bool same(T x, T y) { return findSet(x) == findSet(y); }
    void unite(T x, T y) { link(findSet(x), findSet(y)); }
    T findSet(T x) {
        if (x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }

   private:
    void link(T x, T y) {
        if (rank[x] > rank[y]) {
            p[y] = x;
        } else {
            p[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> elem;
    for (int i = 1; i <= N; i++) elem.push_back(i);
    DisjointSet<int> DS(elem);
    for (int i = 0; i < M; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        DS.unite(x, y);
    }
    set<int> p;
    for (int i = 1; i <= N; i++) {
        p.insert(DS.findSet(i));
    }
    int ans = p.size();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 17680
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,h,w, a,b,cnt = 0;
  cin >> n >> h >> w;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(a>=h && b>=w) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(n => Number(n));

  const d = s[0];
  const n = (s[1] === 100) ? 101 : s[1];

  const ans = Math.pow(100, d) * n;

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#2019/10/22
#S = open(0).read()
S = input()
# print(S)
set_S=set(S)
# print(set_S)
alpha = "abcdefghijklmnopqrstuvwxyz"
# print(alpha)
productSet = sorted(set_S^set(alpha))
#print(productSet)
print("None" if len(productSet)==0 else productSet[0])


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

int main() {
  string N;
  cin >> N;
  for(int i=0; i<3; i++){
    if(N.at(i) == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3632
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

e = Counter(v[::2]).most_common()
o = Counter(v[1::2]).most_common()

if len(set(v)) == 1:
    ans = n // 2
elif e[0][0] != o[0][0]:
    ans = n - e[0][1] - o[0][1]
else:
    ans = min(n - e[0][1] - o[1][1],
              n - e[1][1] - o[0][1])
print(ans)

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<ll> a(n+1,0);
    a[0]=2,a[1]=1;
    for(int i=2;i<=n;i++){
        a[i]=a[i-1]+a[i-2];
    }
    cout<<a[n]<<endl;
    return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

signed main() {
    int L, R;
    cin >> L >> R;
    if (R - L >= 2018) {
        cout << 0 << endl;
        return 0;
    }
    L %= 2019;
    R %= 2019;
    if (R < L)R += 2019;
    int ans = INF;
    for (int i = L; i < R; ++i) {
        for (int j = i + 1; j <= R; ++j) {
            ans = min(ans, i * j % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N, M] = nextIntArray()
    const ac = new Set()
    const judge = {}
    const cnt = {}
    let wa = 0
    while (hasNext()) {
        let [p, s] = nextStrArray()
        if(judge[p] && judge[p] == "AC") continue
        else {
            if (s == "WA") {
                cnt[p] ? cnt[p]++ : cnt[p] = 1
                judge[p] = "WA"
            }
            if (s == "AC") {
                ac.add(p)
                judge[p] = "AC"
                if(cnt[p]) wa += cnt[p]
            }
        }

    }
    console.log(ac.size, wa)
}
Main()

Measured memory_bytes: 52304
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
#define sort(v) sort(v.begin(), v.end())
#define rev(r) reverse(r.begin(), r.end())
#define cout(cc) cout << cc << endl
#define shousu(ss)   cout << fixed << setprecision(ss)

int main() {
  int N,mas=0;
  cin >> N;
  vll A(N);
  vll C(N-1);
  rep(i,N) cin >> A[i];
  rep(i,N){
  	int B;
    cin >> B;
    mas+=B;
  }
  rep(i,N-1) cin >> C[i];
  for(int i=0;i<N-1;i++){
  	if(A[i+1]-A[i]==1){
      mas+=C[A[i]-1];
    }
  }
  cout(mas);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT

#define sz(x) ((int)x.size())

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int maxn = 2*1000005;
const int mod = 1000000007;

#define FILENAME ""
    
int dp[100000 + 10];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m;
    cin >> n >> m;
    vector <ll> a;
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        dp[x] = 1;
        a.pb(x);
    }
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j < n; j++) {
            if (dp[i] == 1) break;
            if (i < a[j]) continue;
            else {
                if (dp[i - a[j]] == 0) {
                    dp[i] = 1;
                    break;
                }
            }
        }
    }
    (dp[m] == 1 ? cout << "First" : cout << "Second");
    return 0;
}

Measured memory_bytes: 640
use std::io::*;

fn main(){
    let mut input = String::new();
    stdin().read_line(&mut input);
    let mut line = input.split_whitespace().map(|e| e.parse::<f32>().unwrap());
    let a = line.next().unwrap();
    let b = line.next().unwrap();

    for i in 1..1001 {
        let n = i as f32;
        if (n * 0.08).floor() == a && (n * 0.1).floor() == b {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void)
{
	string a, b, c; cin >> a >> b >> c;
	if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
}


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

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b;
	if (b % a == 0) {
		cout << a + b;
	}
	else {
		cout << b - a;
	}
}

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

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String target = "ATGC";
        int max = 0;
        
        for (int l = 1; l <= str.length(); l++) {
            for (int s = 0; s <= str.length() - l; s++) {
                boolean success = true;
                for (int j = s; j < s + l; j++) {
                    char c = str.charAt(j);
                    //System.out.print(c + " ");
                    if (target.indexOf(c) < 0) {
                        //System.out.print("failed");
                        success = false;
                        break;
                    }
                }
                if (success) {
                    max = l;
                    break;
                }
                //System.out.println();
            }
            //System.out.println("max=" + max);
            //System.out.println();
        }
        
        System.out.println(max);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define int long long 
using namespace std;
 
signed main() {
  int N;
  cin >> N;
  set<int> kazu;
  for( int i = 0; i < N; i++ ){
    int A;
    cin >> A;
    if( kazu.count(A) ){
      cout << "NO" << endl;
      return 0;
    }else kazu.insert(A);
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 9600
#ABC057C_DigitsMultiplication.rb
n = gets.to_i
count = []
m = Math.sqrt(n).to_i
for i in 1 .. m
  if n % i == 0
    #puts "#{n}/#{i}=#{n/i}...#{n%i}"
    if (n/i).to_s.size > i.to_s.size
      count << (n/i).to_s.size
    else
      count << i.to_s.size
    end
  end
end
p count.min


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

// gcd(a, b) * lcm(a, b) = ab
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    long long div_by_c = b / c - (a - 1) / c;
    long long div_by_d = b / d - (a - 1) / d;
    long long l = lcm(c, d);
    long long div_by_cd = b / l - (a - 1) / l;

    long long ans = (b - a + 1) - div_by_c - div_by_d + div_by_cd;
    cout << ans << '\n';
}


Measured memory_bytes: 256
(let ((n (read))
    (s-read (read))
    (t-read (read)))

    (dotimes (i n)
        (format t "~(~A~)" (subseq (string s-read) i (+ i 1)))
        (format t "~(~A~)" (subseq (string t-read) i (+ i 1)))
    )
)

Measured memory_bytes: 23696
import sys
# N,M = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())

S = str(input())
K = int(input())
numplace = 0

for i in range(len(S)):
    if (S[i] == "1"):
        numplace+=1
    else:
        numplace+= 5000000000000000**int(S[i])
    if(numplace>=K):
        print(S[i])
        sys.exit()


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

int int_compare(const int* a, const int* b)
{
    if (*a < *b) {
        return 1;
    }
    if (*a > *b) {
        return -1;
    }
    return 0;
}

int main(void)
{
    int n;
    scanf("%d", &n);

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

    qsort(sorted, n, sizeof(int), (int (*)(const void*, const void*))(*int_compare));

    int max = sorted[0];
    int second_max = sorted[1];

    for (int i = 0; i < n; i++) {
        printf("%d\n", a[i] == max ? second_max : max);
    }
    return 0;
}


Measured memory_bytes: 3120
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class APayment {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    cout << 1000 * CEIL(N, 1000) - N << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  APayment solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
	int n, p, s;
	int i;

	while (1) {
		s = 0;
		scanf("%d", &n);
		if (n == 0) break;
		for (i = 0; i < n / 4; i++) {
			scanf("%d", &p); s += p;
		}
		printf("%d\n", s);
	}

	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String circle = sc.next();
		String str = sc.next();
		sc.close();
		circle+=circle;
		if(circle.contains(str)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


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

  int X,Y,A,B,C;

  cin >> X >> Y >> A >> B >> C ;

  vector<int> p(A),q(B),r(C); 

  rep(i,A) cin >> p.at(i);
  rep(i,B) cin >> q.at(i);
  rep(i,C) cin >> r.at(i);//入力終了

  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());//A,Bを降順に

  vector<int> s(X+Y+C,0);//採用リンゴ

  rep(i,X) s.at(i)=p.at(i);//pの大きいものからX個
  for(int i;i<Y;i++) s.at(i+X)=q.at(i);//qの大きいものからY個
  for(int i;i<C;i++) s.at(i+X+Y)=r.at(i);//rすべて
  
  sort(s.begin(),s.end());
  reverse(s.begin(),s.end());//sを降順に直す

  int64_t ans=0;

  rep(i,X+Y){
    ans+=s.at(i);
  }
  
  cout << ans << endl;

}

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

using namespace std;

int main(void){
  string S;
  cin >> S;
  int y,m;
  y=(S[0]-'0')*1000+(S[1]-'0')*100+(S[2]-'0')*10+(S[3]-'0');
  m=(S[5]-'0')*10+(S[6]-'0');
  int ans=y*12+m;
  if(ans>2019*12+4){
    cout << "TBD" << endl;
  }
  else{
    cout <<"Heisei" << endl;
  }
}

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

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

    n %= 1000;

    if (n == 0){
        cout << n << endl;
    } else {
        cout << 1000 - n << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
struct RMQ {
  static const int MAX_N = 1 << 17;
  int n,dat[2*MAX_N-1];
  // RMQ(){}
  RMQ(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<2*n-1;i++) dat[i]=INT_MAX;
  }
  void update(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
      k=(k-1)/2;
      dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
  }
  int query(int a,int b,int k,int l,int r){
    if(r<=a||b<=l) return INT_MAX;
    if(a<=l&&r<=b) return dat[k];
    else{
      int vl=query(a,b,k*2+1,l,(l+r)/2);
      int vr=query(a,b,k*2+2,(l+r)/2,r);
      return min(vl,vr);
    }
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};
int main(){
  int n,q;
  cin>>n>>q;
  RMQ rmq(n);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<rmq.query(x,y+1)<<endl;
    else rmq.update(x,y);
  }
  return 0;
}

Measured memory_bytes: 4124
#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>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ret = 0;
    char curr = s[0];
    for (int i = 1; i < n; ++i) {
        if (k == 0)
            break;
        if (s[i] == s[i - 1]) {
            // ret++;
        } else {
            k--;
            for (int j = i; j < n; ++j) {
                if (s[j] != s[i - 1])
                    s[j] = s[i - 1];
                // ret++;
                else {
                    i = j;
                    break;
                }
            }
        }
    }
    for (int i = 1; i < n; ++i) {
        if (s[i] == s[i - 1])
            ret++;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 512
def main(str)
  lines = str.split("\n").map { |x| x.split(' ').map(&:to_i) }
  _n = lines[0][0]
  as = lines[1]
  counts = as.each_with_object(Hash.new(0)) { |x, m| m[x] += 1 }
  counts_sum = counts.values.map { |x| (x * (x-1))/ 2 }.sum
  as.map do |a|
    val = counts[a]
    counts_sum - (val * (val - 1)) / 2 + ((val - 1) * (val - 2)) / 2
  end.join("\n")
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal("2
2
3
2
3", main("5
1 1 2 1 2"))
    assert_equal("0
0
0
0", main("4
1 2 3 4"))
    assert_equal("6
6
6
6
6", main("5
3 3 3 3 3"))
    assert_equal("5
7
5
7
7
5
7
5", main("8
1 2 1 4 2 1 4 1"))
  end
end




Measured memory_bytes: 39872
n,k,q=map(int,input().split())
i=0
a=[]
j=0
tm=0
while i!=q:
    a.append(int(input()))
    i+=1
a.sort()
if k>q:
    i=0
    while i!=n:
        print("Yes")
        i+=1
else:
    i=0
    while i!=n:
        while j!=q:
            if a[j]==(i+1):
         
                tm+=1
                j+=1
            else:
                break

        if q-tm<k:
            print ("Yes")
        else:
            print("No")
        tm=0
        i+=1

Measured memory_bytes: 7840
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b] <- getInts
  ; putInts [a*b,2*(a+b)]
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

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

class DisjointSet{
public:
    vector<int> rank,p;

    DisjointSet(){}
    DisjointSet(unsigned long size){
        rank.resize(size,0);
        p.resize(size,0);
        for(int i=0;i<size;i++)
            makeSet(i);
    }

    void makeSet(int x){
        p[x]=x;
        rank[x]=0;
    }

    bool same(int x,int y){
        return findSet(x)==findSet(y);
    }

    void unite(int x,int y){
        link(findSet(x),findSet(y));
    }

    void link(int x,int y){
        if(rank[x]>rank[y])
            p[y]=x;
        else{
            p[x]=y;
            if(rank[x]==rank[y])
                rank[y]++;
        }
    }

    int findSet(int x){
        if(x!=p[x])
            p[x]=findSet(p[x]);
        return p[x];
    }
};

int main(){
    int n,a,b,q,t;

    cin>>n>>q;
    DisjointSet ds(n);

    for(int i=0;i<q;i++){
        cin>>t>>a>>b;
        if(t==0)
            ds.unite(a,b);
        else if(t==1){
            if(ds.same(a,b))
                cout<<1<<endl;
            else
                cout<<0<<endl;
        }
    }
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    string S;
    ll mod = 1e9+7;
    cin >> N >> S;
    vector<ll> c(26,1);
    for(auto ss : S){
        c[ss-'a']++;
        c[ss-'a'] %= mod;
    }
    ll ans = 1;
    for(auto cc : c){
        ans *= cc;
        ans %= mod;
    }
    ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
n,m = map( int, input().split() )
l = [0 for i in range(m)]
r = [0 for i in range(m)]

for i in range(m):
    l[i],r[i] = map( int, input().split() )

l_max = 1
r_min = 100000
for i in range(m):
    if l_max < l[i]:
        l_max = l[i]
    if r_min > r[i]:
        r_min = r[i]

if r_min - l_max < 0:
    print(0)
else:
    print(r_min-l_max+1)

Measured memory_bytes: 48388
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

const int MAX_VALUE = 30000;

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

bool validate(int n, vector<int> v)
{
	if(len(v) != n)
		return false;

	for(auto& x: v)
	{
		if(x < 1 || x > MAX_VALUE)
			return false;
	}

	sort(v.begin(), v.end());

	for(int i = 0; i + 1 < len(v); ++i)
	{
		if(v[i + 1] == v[i])
			return false;
	}

	int common_gcd = v.front();	

	for(auto& x: v)
		common_gcd = GCD(common_gcd, x);

	if(common_gcd != 1)
		return false;

	int fsum = 0;

	for(auto& x: v)
		fsum += x;

	for(auto& x: v)
	{
		if(GCD(x, fsum - x) == 1)
			return false;
	}

	DBG("ok");
	return true;
}

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

	if(n == 3)
	{
		cout << "2 5 63" << endl;
		return;
	}

	vector<int> answ;
	int fsum = 0;

	for(int c = 1; c <= MAX_VALUE; ++c)
	{
		if(c % 2 == 0 || c % 3 == 0)
		{
			answ.push_back(c);
			fsum += c;
		}

		if(len(answ) == n)
			break;
	}

	if(fsum % 6 != 0)
	{
		int last = answ.back();
		answ.pop_back();
		fsum -= last;

		int last2 = answ.back();
		answ.pop_back();
		fsum -= last2;

		for(int i = last;; ++i)
		{
			for(int j = last2; j < i; ++j)
			{
				bool ok = true;

				ok &= (fsum + i + j) % 6 == 0;
				ok &= (i % 2 == 0 || i % 3 == 0);
				ok &= (j % 2 == 0 || j % 3 == 0);

				if(ok)
				{
					answ.push_back(j);
					answ.push_back(i);

					goto end;
				}
			}
		}
	}

end:
	cout << answ << endl;

#ifdef __LOCAL
	assert(validate(n, answ));
#endif
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_TestCode
{
    class Program
    {
        static void Main(string[] args)
        {
            string S;
            S = Console.ReadLine();
            List<char> cList = new List<char>();

            foreach(char c in S)
            {
                cList.Add(c);
            }

            if (cList.Count != cList.Distinct().ToList().Count()) Console.WriteLine("no");
            else Console.WriteLine("yes");

        }

    }
}


Measured memory_bytes: 11604
#include <iostream>
#include <cstdio>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m,cnt1=0,a;
    cin>>n>>m;
    For(i,1,m)
    {
        cin>>a;
        cnt1+=a;
    }
    if(n-cnt1>=0)cout<<n-cnt1<<endl;
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
  void neko(int N,int Y){
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      for(int k=0;k<=N-i-j;k++){
        if(i+j+k==N&&(i*10000+j*5000+k*1000)==Y){
          cout<<i<<" "<<j<<" "<<k;
          return;
        }
        if(i==N){
          cout<<-1<<" "<<-1<<" "<<-1;
          return;
        }
      }
    }
  }
}
int main()
{
    // 整数の入力
  int N,Y;
  cin>>N>>Y;
  neko(N,Y);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(i=l;i<n;i++)
using namespace std;

int main(){
	int data[15]={},i=0,n;

	while(scanf("%d",&n)!=EOF){
		if(n!=0){
			data[i]=n;
			i++;
		}else if(n==0){
			cout<<data[i-1]<<endl;
			i--;
		}
	}
}

Measured memory_bytes: 1208
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n,a,b,c;
	cin >> n;
	vector<vector<int>>vec(n+1, vector<int>(3));
	for (int i = 1; i <= n; i++) {
		cin >> a >> b >> c;
		vec[i][0] = max(vec[i - 1][1] + a, vec[i - 1][2] + a);
		vec[i][1] = max(vec[i - 1][0] + b, vec[i - 1][2] + b);
		vec[i][2] = max(vec[i - 1][0] + c, vec[i - 1][1] + c);
	}
	cout << max(vec[n][0], max(vec[n][1], vec[n][2])) << endl;
}


Measured memory_bytes: 8720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int ans=0;
  int N,D;
  cin>>N>>D;
  for(int i=0;i<N;i++){
    double a,b;
    cin>>a>>b;
    if(sqrt(a*a+b*b)<=D){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
//#include"functions.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define INF 0x7fffffff
#define LLINF 0x7fffffffffffffff
#define EPS 1e-5
#define LDEPS 1e-9
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define FOR(a,b) for(int a=0;a<b;a++)
#define FORN(a,m,n) for(int a=m;a<n;a++)
#define REP(a,m,n) for(int a=0;a<m;a+=n)
#define REPN(a,m,n,p) for(int a=m;a<n;a+=p)
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdfopen(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define ifopen(a) freopen(a,"r",stdin);
#define ofopen(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int a[51];
int main(){
	int n;
	int cnt=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]!=i+1)cnt++;
	}
	if(cnt>2){
		cout<<"NO\n";
	}
	else cout<<"YES\n";
	return 0;
}

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

using namespace std;
const int maxn=3005;

int n,m,dp[maxn][maxn],prex[maxn][maxn],prey[maxn][maxn];
char s[maxn],t[maxn];
vector<char> vec;

int main()
{
	scanf("%s %s",s+1,t+1);
	n=strlen(s+1);m=strlen(t+1);
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i]==t[j]){
				dp[i][j]=dp[i-1][j-1]+1;
				prex[i][j]=i-1;prey[i][j]=j-1;
				
			}else{
				if(dp[i-1][j]>dp[i][j-1]){
					prex[i][j]=i-1;prey[i][j]=j;
					dp[i][j]=dp[i-1][j];
				}else{
					prex[i][j]=i,prey[i][j]=j-1;
					dp[i][j]=dp[i][j-1];
				}
			}
		}
	}
	for(int x=n,y=m;x&&y;){
		
		int memorx=x,memory=y;
		if(prex[x][y]==x-1&&prey[x][y]==y-1) vec.push_back(s[x]);
		x=prex[memorx][memory];y=prey[memorx][memory];
	}
	for(int i=vec.size()-1;i>=0;i--) printf("%c",vec[i]);
	printf("\n");
}

Measured memory_bytes: 105984
N = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    B[i] = B[i-1]+A[0][i-1]
C = [0 for _ in range(N+1)]
for i in range(1,N+1):
    C[i] = C[i-1]+A[1][i-1]
cmax = 0
for i in range(N):
    a = B[i+1]+C[N]-C[i]
    cmax = max(cmax,a)
print(cmax)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int ans = -1;
		for (int i = 1; i <= 5; i++) {
			int x = sc.nextInt();
			
			if (x == 0) {
				ans = i;
				break;
			}
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}




Measured memory_bytes: 26980
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;


int main(){
int n;
  cin>>n;
  vector<string> s(n);
  rep(i,n) cin>>s.at(i);
  sort(all(s));
  vector<int> cnt(n);
  rep(i,n) cnt[i]=0;
  rep(i,n-1){
    if(s[i]==s[i+1]) cnt[i+1]=cnt[i]+1;
  }
  vector<int> copy(n);
  rep(i,n) copy[i]=cnt[i];
  sort(all(cnt));
  int m=cnt[n-1];
  rep(i,n){
    if(copy[i]==m) cout<<s[i]<<endl;
  }
}

Measured memory_bytes: 15872
//AtCoder Beginner Contest 174
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2e6 + 5;
const double E = 1e-9;

//------------------------------------------------------------------------------

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ifstream cin("input.txt");
	ofstream cout("output.txt");*/
	int n, d, ans = 0;
	cin >> n >> d;
	for (int i = 0; i < n; i++)
	{
		double x, y;
		cin >> x >> y;
		double sqt = sqrt(x * x + y * y);
		//cout<<sqt<<"\n";
		if (sqt <= d)
			++ans;
	}
	cout << ans;
	return 0;
}
//02-08-2020 17:36:04
//------------------------------------------------------------------------------

Measured memory_bytes: 3820
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
int main() {
	ll n, k;
	cin >> n >> k;
	hei(ll) a(n);
	hei(ll) S;
	map<ll, ll> x,y;
	rep(i, 0, n) {
		cin >> a[i];
	}
	ll z = 0;
	rep(i, 0, k+1) {
		if (x[z]) {
			ll p = i - y[z];
			ll d = ((k - i) % p)+y[z];
			cout << S[d] << endl;
			return 0;
		}
		else {
			x[z] = 1;
			y[z] = i;
			S.push_back(z + 1);
			z = a[z] - 1;
		}
	}
	cout << S[k] << endl;
	return 0;
}

Measured memory_bytes: 25908
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int ss = 0, nn = 0, w = 0, e = 0;

  for (int i = 0; i < n; i++){
    if(s[i] == 'S'){
      ss++;
    }else if(s[i] == 'W'){
      w++;
    }else if(s[i] == 'N'){
      nn++;
    }else{
      e++;
    }
  }
  if(ss >0 && nn > 0 || ss == 0 && nn == 0){
    if(w>0 && e>0 || w == 0 && e == 0){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const ll llinf = LLONG_MAX;
const ull ullinf = ULLONG_MAX;

int n;
const int maxn = 200001;
ll a[maxn];
const ll inf = 1000000000;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;
#endif
  cin >> n;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 1; i < n; i++) {
    a[i] = a[i - 1] + a[i];
  }
  ll ans = inf;
  for (int cut = 1; cut < n - 2; cut++) {
    ll before = a[cut];
    ll after = sum - a[cut];
    ll be_half = before / 2;
    auto ite = lower_bound(a, a + n, be_half);
    ll b1 = *ite;
    ll c1 = a[cut] - b1;
    ll b2 = -1;
    ll c2 = 1000000010;
    if (ite != a) {
      b2 = *(ite - 1);
      c2 = a[cut] - b2;
    }
    ll B, C;
    if (abs(c1 - b1) >= abs(c2 - b2)) {
      B = b2;
      C = c2;
    } else {
      B = b1;
      C = c1;
    }
    ll af_half = after / 2;
    auto ite2 = lower_bound(a, a + n, af_half + a[cut]);
    ll d1 = *ite2 - a[cut];
    ll e1 = sum - d1 - a[cut];
    ll d2 = -1;
    ll e2 = 1000000010;
    if (ite2 != a + cut + 1) {
      d2 = *(ite2 - 1) - a[cut];
      e2 = sum - d2 - a[cut];
    }
    ll D, E;
    if (abs(e1 - d1) >= abs(e2 - d2)) {
      D = d2;
      E = e2;
    } else {
      D = d1;
      E = e1;
    }
    //cerr << B << ", " << C << ", " << D << ", " << E << endl;
    ll max_ = max({B, C, D, E});
    ll min_ = min({B, C, D, E});
    ans = min(ans, max_ - min_);
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


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

int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    cout << "A"
         << B.at(0)
         << "C" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define MOD (1000000007LL)
#define PI (3.1415926535897932384)
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }



// 1次元vectorの出力
template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(void){
	cout << fixed << setprecision(20);
	int r; cin >> r;
	cout << 2 * PI * r << endl;
}

Measured memory_bytes: 3764
# R = int(input())
# a, b = map(int, input().split())
# c = list(map(int, input().split()))
# d = [list(map(int, input().split())) for _ in range(n)]
s = input()

ans = "AC"

if s[0] != "A":
    ans = "WA"

count = 0

for i in range(len(s)):
    if i == 0:
        continue
    if i >= 2 and i != len(s)-1:
        if s[i] == "C":
            count += 1
        else:
            if s[i].isupper():
                ans = "WA"
    else:
        if s[i].isupper():
            ans = "WA"

if count != 1:
    ans = "WA"

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll mod=1e9+7;
int N,a[100000],b[100000];
int main(){
	cin>>N;
	rep(i,N) cin>>a[i];
	rep(i,N) cin>>b[i];
	sort(a,a+N);
	sort(b,b+N);
	ll ans=1;
	int j=0;
	rep(i,N-1){
		while(j!=N&&b[j]<a[i]) j++;
		ans=ans*(max(1,j-i))%mod;
	}
	j=0;
	rep(i,N-1){
		while(j!=N&&a[j]<b[i]) j++;
		ans=ans*(max(1,j-i))%mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
n,k = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
i = k
min_h = 10000000000
while i < n +1:
    min_h = min(h[i-1]-h[i-k],min_h)
    i += 1
print(min_h)

Measured memory_bytes: 7492
# mod 5で1の素数を集める
# 素数220個程度作ればよい
# 1000までで168個なので2000もあれば十分

import numpy as np

is_prime = np.ones(2000,dtype = np.int64)
is_prime[:2] = 0

for p in range(2,2000):
  if p > 150:
    break
  if is_prime[p]:
    is_prime[p*p::p] = 0

primes = is_prime.nonzero()[0]
primes = primes[primes%5 == 1]

n = int(input())

ans = ' '.join([str(x) for x in primes[:n]])
print(ans)


Measured memory_bytes: 12436
#include <stdio.h>
#define Max 100000

int A[Max];
int partition(int,int);


int main(){
  int n,q;
  int i;
  
  scanf("%d",&n);
  for(i=0; i < n; i++){
    scanf("%d",&A[i]);
  }
  q=partition(0,n-1);
  
  for(i=0; i < n; i++){
    if(i==q) printf("[");
    
    printf("%d",A[i]);
    
    if(i==q) printf("]");
    
    if(i != n-1) printf(" ");
  }
  printf("\n");
  
  return 0;
}

int partition(int p,int r){
  int x;
  int i,j;
  int s;
  
  x=A[r];
  i=p-1;
  for(j=p; j < r; j++){
    if(A[j]<= x){
      i++;
      s=A[i];
      A[i]=A[j];
      A[j]=s;
    }
  }
  s=A[i+1];
  A[i+1]=A[r];
  A[r]=s;
  
  return i+1;
}

Measured memory_bytes: 992
if __name__ == '__main__':
    n = int(input())

    if n >= 400 and n <= 599:
        print(8)
    elif n >= 600 and n <= 799:
        print(7)
    elif n >= 800 and n <= 999:
        print(6)
    elif n >= 1000 and n <= 1199:
        print(5)
    elif n >= 1200 and n <= 1399:
        print(4)
    elif n >= 1400 and n <= 1599:
        print(3)
    elif n >= 1600 and n <= 1799:
        print(2)
    elif n >= 1800 and n <= 1999:
        print(1)


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

const int mod=1000000007,N=17,M=(1<<N)+5;
typedef long long ll;
int ksm(ll a,int b,int c=1){
	for(;b;b/=2,a=a*a%mod)
		if(b&1)c=c*a%mod;
	return c;
}
int T,dp[2][M],n,m,jc[M],jc2[M],a[N],ans;
void init(){
	jc[0]=1;
	for(int i=1;i<=(1<<n);++i)jc[i]=(ll)jc[i-1]*i%mod;
	jc2[1<<n]=ksm(jc[1<<n],mod-2);
	for(int i=(1<<n);i;--i)jc2[i-1]=(ll)jc2[i]*i%mod;
}
int A(int n,int k){
	if(n<k||k<0)return 0;
	return (ll)jc[n]*jc2[n-k]%mod;
}
inline void upd(int&x,const int&y){
	x+=y-mod;x+=x>>31&mod;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;init();
	for(int i=1;i<=m;++i)cin>>a[i],a[i]=(1<<n)-a[i]+1;
	dp[0][0]=1;
	for(int i=m;i;--i){
		T^=1;memset(dp[T],0,sizeof dp[T]);
		for(int j=0;j<(1<<n);++j)if(dp[!T][j]){
			upd(dp[T][j],dp[!T][j]);
			for(int k=0;k<n;++k)if(!(j>>k&1))
				dp[T][j|(1<<k)]=(dp[T][j|(1<<k)]-(ll)dp[!T][j]*(A(a[i]-j,1<<k)-A(a[i]-j-1,1<<k)))%mod,
				dp[T][j|(1<<k)]+=dp[T][j|(1<<k)]>>31&mod;
		}
	}
	for(int i=0;i<(1<<n);++i)ans=(ans+(ll)jc[(1<<n)-i-1]*dp[T][i])%mod;
	ans=((ll)ans<<n)%mod;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

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


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

int main() {

  long n;
  vector<long> t(5);
  cin >> n;
  for (int i=0; i<5; i++) {
    cin >> t.at(i);
  }
  sort(t.begin(), t.end());
  cout << (n + t.at(0) - 1)/t.at(0) + 4 << endl;

}


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

int main() {
    // insert code here...
    int a,b;
    string x,y,c,d;
    cin >> a >> b;
    d=to_string(b) ;
    c=to_string(a) ;
    for(int i=0;i<b;i++){
        
        x+=c ;
    }
    
    for(int i=0;i<a;i++){
        
        y+=d ;
    }
    
    cout << min(x,y)<<endl;
    
    
}


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

#define ll long long
#define mx  100005
#define mod 1000000009
#define lim 10000000
#define inf 1e9
#define N 18
using namespace std;
ll psum[mx];

int main(){
	ios_base::sync_with_stdio(false);
     int n,k,pp=0;
     cin>>n>>k;
     int x[n+5];
     psum[0]=x[0]=0;

     for(int i=1;i<=n;i++)
	    cin>>x[i],psum[i]=psum[i-1]+abs(x[i]-x[i-1]);

     ll ans=INT_MAX;
     for(int i=1;i+k-1<=n;i++)
	{
		ll im=psum[i+k-1]-psum[i]+abs(x[i]);
		ll im1=psum[i+k-1]-psum[i]+abs(x[i+k-1]);
		ans=min(ans,min(im,im1));

	}

	cout<<ans<<"\n";
     return 0;
}


Measured memory_bytes: 1408