akhauriyash/Code-Regression huggingface dataset:
using System;

class Program
{
    static void Main(string[] args) {
        String ret;
        ret = process(new System.IO.StreamReader(Console.OpenStandardInput()));

        //Console.WriteLine(ret);
        //Console.ReadLine();
    }

    static string process(System.IO.TextReader input) {
        int n   = int.Parse(input.ReadLine());
        int[] a = new int[n];
        

        int max = 0;
        int second = 0;

        for(int i=0; i<n; i++) {
            a[i] = int.Parse(input.ReadLine());
            if(max < a[i]) {
                second = max;
                max = a[i];
            }else if(second < a[i]) {
                second = a[i];
            }
        }
        
        for(int i=0; i<n; i++) {
            if(a[i] == max) {
                Console.WriteLine(second);
            } else {
                Console.WriteLine(max);
            }
        }
        return null;
    }

    static string process(string input) {
        return process(new System.IO.StringReader(input));
    }
}

Measured memory_bytes: 16980
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <chrono>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <cassert>
# include <array>
# include <tuple>
# include <cctype>
# include <unistd.h>
# include <unordered_map>
# include <unordered_set>
using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fast_work {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

const ll INF = 1e9 + 5, NMAX = 1e6 + 5, MOD = 1000000007, N = 1e9 + 5, LOG = 25;
const ld EPS = 1e-8, pi = 3.14159265358979323846;

int a[NMAX];

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

int d[NMAX];

signed main() {
    fast_work

    d[1] = 1;
    for(ll i = 2; i < NMAX; ++i) {
        if(d[i] != 0) continue;
        d[i] = i;

        for(ll j = i * i; j < NMAX; j += i) {
            d[j] = i;
        }
    }


    int n;
    cin >> n;

    int g = 0;

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        g = gcd(a[i], g);
    }

    if(g != 1) {
        cout << "not coprime";
        return 0;
    }

    set<int> s;
    for(int i = 0; i < n; ++i) {
        set<int> ss;
        while (a[i] > 1) {
            if(s.count(d[a[i]])) {
                cout << "setwise coprime";
                return 0;
            }
            ss.insert(d[a[i]]);
            a[i] /= d[a[i]];
        }

        s.insert(ss.begin(), ss.end());
    }

    cout << "pairwise coprime";

}


Measured memory_bytes: 11492
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll = long long;
const ll maxn=3e5+5;
ll n,a[maxn];
string s,t;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		if(s[i]!=t[i])n++;
	}
	cout<<n;
}


Measured memory_bytes: 3816
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>

using namespace std;
int main(){
    string S;
    cin >> S;
    
    int takahashi = 0;
    
    for(int i=0;i<S.length();i++){
        if(S[i] == '+'){
            takahashi++;
        }else{
            takahashi--;
        }
    }
    
    cout << takahashi << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
using namespace std;

long long int pow2_(int n){
	long long int ret = 1;
	for(int i = 0; i < n; i++){
		ret *= 2;
	}
	return ret;
}

int main() {
	
	int a[100], b[100];
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < N; i++){
		cin >> b[i];
	}
	
	long long int ans = 0;
	
	for(int i = 0; i < N; i++){
		bool DP[100] = {};
		DP[a[i]] = true;
		for(int j = 50; j >= 1; j--){
			for(int k = 0; k <= 50; k++){
				if(DP[k]){
					DP[k % j] = true;
				}
			}
		}
		if(!DP[b[i]]){
			cout << "-1" << endl;
			return 0;
		}
	}
	
	vector<int> v;
	
	for(int loop = 50; loop >= 1; loop--){
		bool flag = false;
		for(int i = 0; i < N; i++){
			bool DP[100] = {};
			DP[a[i]] = true;
			for(int j = 0; j < v.size(); j++){
				for(int k = 0; k <= 50; k++){
					if(DP[k]){
						DP[k % v[j]] = true;
					}
				}
			}
			for(int j = loop - 1; j >= 1; j--){
				for(int k = 0; k <= 50; k++){
					if(DP[k]){
						DP[k % j] = true;
					}
				}
			}
			if(!DP[b[i]]){
				flag = true;
			}
		}
		if(flag){
			v.push_back(loop);
			ans += pow2_(loop);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)

@map = Array.new(h+2).map{Array.new(w+2)}

@map[0] = "."*(w+2)
for i in 1..h
  cp = gets.chomp
  @map[i] = "." + cp + "."
end
@map[h+1] = "."*(w+2)

def puttable?(y, x)
  return true if @map[y-1][x] == "#"
  return true if @map[y][x-1] == "#"
  return true if @map[y][x+1] == "#"
  return true if @map[y+1][x] == "#"
  return false
end

for i in 1..h
  for j in 1..w
    next if @map[i][j] == '.'
    unless puttable?(i, j)
      puts "No"
      exit
    end
  end
end

puts "Yes"


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>

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

int main(){
    int H, W;
    std::cin >> H >> W;
    std::vector<std::string> pix(H);
    for(int i = 0; i < H; i++) std::cin >> pix[i];

    // -1 correspond to bomb
    std::vector<std::vector<int>> out(H, std::vector<int>(W, -1));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(pix[i][j] == '#') continue;
            int cnt = 0;
            for(int k = 0; k < 8; k++){
                int x = i + dx[k];
                int y = j + dy[k];
                if(x < 0 || x >= H) continue;
                if(y < 0 || y >= W) continue;
                if(pix[x][y] == '#') cnt++;
            }
            out[i][j] = cnt;
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(out[i][j] == -1) std::cout << '#';
            else std::cout << out[i][j];
        }
        std::cout << std::endl;
    }

    return 0;
}


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

inline int F(int x)
{
	return x*x;
}

int main()
{
	int d;
	while(cin >> d)
	{
		int n=600/d;
		int area=0;

		for(int i=0; i<n; ++i)
		{
			area += F(i*d)*d;
		}

		cout << area << '\n';
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = (s.size() - 1) / 2;
	for (; n >= 1; --n) {
		if (s.substr(0, n) == s.substr(n, n)) {
			break;
		}
	}
	cout << n * 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll a, b, k;
    cin >> a >> b >> k;
    ll c = min(a, k);
    k -= c;
    a -= c;
    if(k > 0) {
        b -= min(b, k);
    }

    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i=0,j,n[100000];

		for(i=0;i<100000;i++)
		{
			scanf("%d",&n[i]);
			if(n[i]==0){
					break;
			}
		}
		
		for(j=1;j<i+1;j++){
			printf("Case %d: %d\n",j,n[j-1]);
		}

	return 0;
}

Measured memory_bytes: 644
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

int dp[1000][1000];
char d[1000][1000];

main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)cin>>d[i][j];

		int smax=0;
		for(int i=0;i<n;i++){
			if(d[i][0]=='*')dp[i][0]=0;
			else smax=dp[i][0]=1;
			
			if(d[0][i]=='*')dp[0][i]=0;
			else smax=dp[0][i]=1;
		}

		for(int i=1;i<n;i++){
			for(int j=1;j<n;j++){
				if(d[i][j]=='*')dp[i][j]=0;
				else dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
				
				smax=max(smax,dp[i][j]);
			}
		}
		cout<<smax<<endl;
	}
}

Measured memory_bytes: 1964
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define mk make_pair
#define se second
#define fi first
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  r(i,n)cin>>a[i];
  sort(a,a+n);
  cout<<a[n-1]-a[0]<<endl;
}

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

// macros
#define overload_rep(va_0, va_1, va_2, name, ...) name
#define rep_0(i, n) for(int i = 0; i < (n); ++i)
#define rep_1(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// libraries

// declarations
typedef long long lint;
constexpr int inf = 1 << 30;

// solve
int main(){

    int N, Q;
    cin >> N >> Q;
    vector<lint> A(N);
    rep(i, N)cin >> A[i];

    vector<lint> even(N + 1, 0), odd(N + 1, 0);
    rep(i, N){
        even[i + 1] += even[i];
        odd[i + 1] += odd[i];
        if(i & 1)even[i + 1] += A[i];
        else odd[i + 1] += A[i];
    }

    int sz = (N + 1) / 2;
    vector<int> judge(sz);
    judge[sz - 1] = inf;
    rep(i, 1, sz - 1){
        judge[sz - i - 1] = (A[N - i - 1] + A[N - i - i - 1]) / 2;
    }

    while(Q--){
        int X;
        cin >> X;
        int pos = judge.end() - lower_bound(all(judge), X);
        lint ans = even[N] - even[N - pos] + odd[N] - odd[N - pos];
        if(N & 1)ans += odd[N - pos - pos + 1] - odd[0];
        else ans += even[N - pos - pos + 1] - even[0];
        cout << ans << '\n';
    }

}


Measured memory_bytes: 4224
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll N, M, ans = 0, k;

void solve(){
    k = min(N, M/2);

    ans += k;
    M -= 2*k;
    
    ans += M/4;
    
    cout << ans << endl;
}

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

    solve();
}


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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	for (int i = 0; i < N; i++)
		cin >> p[i];

	//sort
	for (int i = 0; i < N - 1; i++) {
		for (int j = N - 1; j > i; j--) {
			if (p[j - 1] > p[j]) {
				int temp = p[j];
				p[j] = p[j - 1];
				p[j - 1] = temp;
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < K; i++) {
		sum += p[i];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3620
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll r, D, x;

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

  cin >> r >> D >> x;

  rep(i, 10) {
      cout << r*x - D << endl;
      x = r*x - D;
  }

  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(void){
	int height,width;
	int i,j;
	
	while(1){
		scanf("%d %d",&height,&width);
		if(height==0 && width==0){
			break;
		}
		for(i=0;i<height;i++){
			for(j=0;j<width;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string S;

int main(void) {

	cin >> S;

	int ans = 1;
	for (int i = 0; i <= 2; i++) {
		if (S[i] == S[i + 1]) { ans = -1; }
	}

	if (ans == -1) { cout << "Bad" << endl; }
	else { cout << "Good" << endl; }


	return 0;
}

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

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

int main() {

  int K;
  cin >> K;

  int answer = 0;

  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      for (int k = 1; k <= K; k++) {
        int gcd_ = gcd(i,j);
        answer += gcd(gcd_, k);
      }
    }
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 3632
n = int(input())
a = input()

fac2 = [0] * (n+1)
i = 2
while(i <= n ):
    for j in range(i,n+1,i):
        fac2[j] += 1
    i *= 2

for i in range(1,n+1):
    fac2[i] += fac2[i-1]

def calc(x):
    len_x = len(x)
    res = 0
    for i,xi in enumerate(x):
        if(fac2[len_x-1] - fac2[len_x-1-i] - fac2[i] > 0):
            continue
        res = res ^ xi
    return res

if(a.count('2')==0):
    x = []
    for ai in a:
        x.append(int(ai)//2)
    res = calc(x)
    if(res==0):
        print(0)
    else:
        print(2)
else:
    x = []
    for ai in a:
        x.append( (int(ai)-1) % 2)
    res = calc(x)
    print(res)

Measured memory_bytes: 158692
use std::collections::HashMap;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() -> () {
    input!{
        s: chars,
        t: chars,
    }
    let mut map1 = HashMap::<char, char>::new();
    let mut map2 = HashMap::<char, char>::new();
    for (c1, c2) in s.iter().zip(t) {
        if let Some(c) = map1.get(&c1) {
            if c != &c2 {
                println!("No");
                return;
            }
            continue;
        } else if let Some(ref c) = map2.get(&c2) {
            if *c != c1 {
                println!("No");
                return;
            }
            continue;
        }
        map1.insert(*c1, c2);
        map2.insert(c2, *c1);
    }
    println!("Yes");
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

void dfs(vector<vector<int> > &g, vector<bool> &used, int cur){
    used[cur] = true;
    for(auto nxt : g[cur]){
        if(!used[nxt]){
            dfs(g, used, nxt);
        }
    }
}

signed main(){
    
    int n, m; cin >> n >> m;
    vector<vector<int> > g(n + m);
    for(int i = 0; i < n; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int L; cin >> L;
            int from = i;
            int to = n + L - 1;
            g[from].push_back(to);
            g[to].push_back(from);
        }
    }

    vector<bool> used(n + m, false);
    dfs(g, used, 0);
    bool flag = true;
    for(int i = 0; i < n; i++){
        if(!used[i]){
            flag = false;
            break;
        }
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 8820
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	if(A < C && B > C && B < D) cout << B - C << endl;
	else if(A > C && A < D && B > D) cout << D - A << endl;
	else if(A <= C && B >= D) cout << D - C << endl;
	else if(A >= C && B <= D) cout << B - A << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		final int N = scan.nextInt();
		final int K = scan.nextInt();
		int result = 0;
		int h = 0;
		for(int i = 0; i < N; i++) {
			h = scan.nextInt();
			if(h >= K) {
				result++;
			}
		}
		System.out.println(result);
		scan.close();


	}

}


Measured memory_bytes: 48960
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  int sum = a+b;
  if (sum%2 != 0) {
    cout << sum/2+1 << endl;
  }
  else cout << sum/2 << endl;
} 
  

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  int n = 100 * r + 10 * g + b;
  if (n % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
#define mod 1000000007
ll mypower(ll a, ll b, ll p)
{
    ll ans = 1;
    a = a%p;
    while(b)
    {
        if(b%2)
            ans = ans*a % p;
        b=b/2;
        a = a*a % p;
    }
    return ans;
}
int main() {
    string s;
    cin >> s;
    if(s == "ABC")
        cout << "ARC";
    else
        cout << "ABC";
}

Measured memory_bytes: 3628
import java.util.*;

class Main {
    private final String s, t;
    private final int sLength;
    private HashMap<Character, ArrayList<Integer> > sMap, tMap;
    private HashSet<ArrayList<Integer> > sIndexSet, tIndexSet;
    private static final String YES = "Yes", NO = "No";

    Main(String s, String t) {
        this.s = s;
        this.t = t;
        this.sLength = s.length();
    }

    private void mapValuesToSet(boolean is_s) {
        HashMap<Character, ArrayList<Integer> > strMap = is_s ? sMap : tMap;
        HashSet <ArrayList<Integer> > indexSet = new HashSet<>();

        for (ArrayList<Integer> arr : strMap.values()) {
            indexSet.add(arr);
        }

        if (is_s) {
            sIndexSet = indexSet;
        } else {
            tIndexSet = indexSet;
        }
    }

    private void mapIndexesToChar(boolean is_s) {
        String str = is_s ? this.s : this.t;
        HashMap<Character, ArrayList<Integer> > strMap = new HashMap<>();

        for (int i = 0; i < sLength; i++) {
            char c = str.charAt(i);
            if (strMap.get(c) == null) {
                ArrayList<Integer> arr = new ArrayList<>();
                arr.add(i);
                strMap.put(c, arr);
            } else {
                strMap.get(c).add(i);
            }
        }

        if (is_s) {
            sMap = strMap;
        } else {
            tMap = strMap;
        }
    }

    private void judge() {
        boolean is_s = true;
        boolean reached_last_check = true;

        mapIndexesToChar(is_s);
        mapIndexesToChar(!is_s);

        mapValuesToSet(is_s);
        mapValuesToSet(!is_s);

        for (ArrayList<Integer> arr : sIndexSet) {
            if (tIndexSet.contains(arr)) {
                tIndexSet.remove(arr);
            } else {
                reached_last_check = false;
                break;
            }
        }

        if (reached_last_check && this.tIndexSet.isEmpty()) {
            System.out.println(YES);
        } else {
            System.out.println(NO);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        Main st = new Main(s, t);
        st.judge();
    }
}


Measured memory_bytes: 50692
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//エラトステネスの篩
const int Num = 1000009;
vector<bool> p(Num, true);
void Eratosthenes() {
	p[0] = false;
	p[1] = false;
	for (int i = 0; i < Num; ++i)if (p[i])
		for (int j = i * 2; j < Num; j += i)p[j] = false;
}

int main() {
	Eratosthenes();
	int n;
	while (cin >> n && n) {
		int ans = 0;
		for (int i = 3; i < n / 2; i += 2) {
			if (p[i] && p[n - i]) {
				//cout << i << ", " << n - i << endl;
				ans++;
			}
		}
		ans += (p[n / 2]);
		Cout(ans);
	}
}


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

int check_pali(string str, int l, int r)
{
    int mid = (r-l)/2;
    r--;
    for(int i=0; i<=mid; i++)
    {
        if(str[i] != str[r])
        {
            return 0;
            break;
        }
        r--;
    }
    return 1;
}

int main() 
{
    string str;
    cin>>str;
    int n = str.length();
    if(check_pali(str, 0, n) == 1)
    {
        int a = check_pali(str, 0, (n-1)/2);
        int b = check_pali(str, (n+3)/2, n);
        if(a == 1 && b == 1)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  vector<int> a(260, 0);
  rep(i, s.length()){
    int tmp = (int)s[i];
    a[tmp]++;
  }  
  rep(i, a.size()){
    if(a[i] > 1) {
      cout << "no" << endl;
      return 0;
    }
  }  
  cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll f[1000100], finv[1000100], p[1000100], pinv[1000100];

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a) {
  return modpow(a, mod - 2);
}

ll nCr(ll n, ll r) {
  if (n < 0) return 0;
  if (r < 0 || r > n) return 0;
  return f[n] * finv[n - r] % mod * finv[r] % mod;
}

ll nHr(ll n, ll r) {
  return nCr(n + r - 1, r);
}

void init() {
  f[0] = 1, finv[0] = 1, p[0] = 1, pinv[0] = 1;
  FOR(i, 1, 1000100) {
    f[i] = i * f[i - 1] % mod;
    finv[i] = modinv(f[i]);
    p[i] = p[i - 1] * 2 % mod;
    pinv[i] = pinv[i - 1] * 500000004 % mod;
  }
}

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

  init();

  ll b, w;
  cin >> b >> w;

  ll cb = 0, cw = 0;
  rep(i, b + w) {
    cb = (cb * 2 + nCr(i - 1, w - 1)) % mod;
    cw = (cw * 2 + nCr(i - 1, b - 1)) % mod;
    //cout << cb << ' ' << cw << '\n';
    ll ans = (p[i] + cb - cw + mod) % mod * pinv[i + 1] % mod;
    cout << ans << '\n';
  }

  




  
  return 0;
}

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

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

  if(x == 1 || x == 2 * n - 1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
    vector<int> ans(2 * n - 1);
    for(int i = 0;i < 2 * n - 1;i++){
      ans[i] = i + 1;
    }
    int tmp;
    tmp = ans[x - 1];
    ans[x - 1] = ans[n - 1];
    ans[n - 1] = tmp;

    tmp = ans [n];
    ans[n] = ans[0];
    ans[0] = tmp;

    tmp = ans[n - 2];
    ans[n - 2] = ans[2 * n - 2];
    ans[2 * n - 2] = tmp;
    for(int i = 0;i < 2 * n - 1;i++){
      cout << ans[i] << endl;
    }
  }
}

Measured memory_bytes: 2432
#include<stdio.h>
#include<math.h>
int main()
{
    int n;
    scanf("%d", &n);

    int arr[n];

    for(int i=0; i<n; i++)
        scanf("%d", &arr[i]);

    int count=0;

    for(int i=1; i<n-1; i++)
    {
        if((arr[i]>arr[i-1] && arr[i]<arr[i+1]) || (arr[i]<arr[i-1] && arr[i]>arr[i+1]))
            count+=1;
    }

    printf("%d", count);


    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define SIZE 101

int main(void){
  char s[SIZE * 2], p[SIZE];
  int i = 0, j, k = 0, sLength, flg = 0;

  scanf("%s", s);
  scanf("%s", p);

  // make circulated string s
  while (s[i] != '\0')
    i++;
  sLength = i;
  for (j = 0; j < sLength; j++) {
    s[i] = s[j];
    i++;
  }
  
  // compare p with s
  for (i = 0; s[i] != '\0'; i++) {
    // printf("s:%c, p:%c\n", s[i], p[k]);
    if (s[i] == p[0]) {
      for (k = 1; k < SIZE; k++) {
	if (p[k] == '\0') {
	  flg = 1;
	  break;
	}
	else if (p[k] != s[i + k]) {
	  break;
	}
    /* else if(k == 1 && s[i] == s[i - 1]) { */
    /*   if (s[i] != p[0]) */
    /* 	k = 0; */
    /* } */
    /* else */
    /*   k = 0; */
      }
    }
  }
  if (flg == 1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

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

int main() {
	int a, b;
	cin>>a>>b;
	if ((a>0 && a<21) || (a>0 && a<21)) 
		if (a>9 || b>9)
			cout<<-1;
		else
			cout<<a*b;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  int n, m;
  cin >> n >> m;
  cout << n * max(n - 1, 0) / 2 + m * max(m - 1, 0) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

h,w = inpl()
n = inp()
a = inpl()
ind = 0
now = a[0]
res = [[None]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        res[i][j] = ind+1
        now -= 1
        if now == 0 and ind < n-1:
            ind += 1
            now = a[ind]
for i in range(h):
    if i%2:
        tmp = [str(x) for x in res[i][::-1]]
    else:
        tmp = [str(x) for x in res[i]]  
    print(' '.join(tmp))

Measured memory_bytes: 5592
import java.util.Scanner;

public class Main {

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

	    String S=gs();
	    
	    int s=0;
	    int st=0;
        for(int i=0; i<S.length();i++) {
        	char c=S.charAt(i);
        	if(c=='T'&&s>0) {
        		st++;
        		s--;
        	} else if(c=='S') {
        		s++;
        	}
        }


        System.out.println(S.length() - 2*st);

		//System.out.println();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.14159265358979323846264338327950L
const int INF = 1001001001;
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

int gcd(int a, int b){ 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b)  
{  
    return (a*b)/gcd(a,b);  
}  

vector<int> adj[N];

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    double theta = abs(6*m - (h*60+m)*0.5);
    //theta = min(theta, 360 - theta);
    ld res = a*a+b*b-2*a*b*cos(theta*PI/180.0);
    cout << fixed << setprecision(15) << sqrtl(res) << endl;
    return 0;
}


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

namespace AGC046A
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            int K = 1;
            int kakudo = X;
            while (kakudo % 360 != 0)
            {
                kakudo += X;
                K += 1;
            }
            Console.WriteLine(K);
        }
    }
}


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

int main(void){
  int P,Q,R,min=10000,tmp[3];
  scanf("%d %d %d",&P,&Q,&R);
  
  tmp[0] = P+Q;
  tmp[1] = Q+R;
  tmp[2] = R+P;
  
  for(int i = 0;i<3;i++){
    if(tmp[i]<min){
      min = tmp[i]; 
    }
  }
  
  printf("%d",min);
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

ll pow2(ll a){
    ll temp = 1;
    for(int i=0;i<a;++i){
        temp *= 2;
    }
    return temp;
}

ll dfs(ll h, ll count){
    if(h == 1) return count + 1;
    count += (dfs(h / 2, count) * 2 + 1);
    return count;
}

int main()
{
    ll H;
    cin >> H;
    cout << dfs(H, 0) << endl;
}


Measured memory_bytes: 256
from itertools import combinations
X = int(input())
#X = input()
#L, R, d=map(int,input().split())
#C = []
# for i in range(N):
#    C.append((input().replace(".","0").replace("#","1")))
# S=list(map(int,input().split()))
# B=list(map(int,input().split()))

if X >= 30:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N;cin>>N;
    bool visited[N];
    REP(i,N)visited[i]=false;
    int G[N];
    REP(i,N)G[i]=INF;
    REP(i,N){
        int a;cin>>a;a--;
        G[i]=a;
    }
    int z=0;
    int count=0;
    while(!visited[z]){
      	visited[z]=true;
      	if(z==1)break;
        z=G[z];
        count++;
    }
    cout<<(visited[1]?count:-1)<<endl;
}

Measured memory_bytes: 1152
using System;
using System.Linq;

namespace B___Card_Game_for_Two
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Ai = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToArray();

            Console.WriteLine(Ai.Where((e, i) => i % 2 == 0).Sum() - Ai.Where((e, i) => i % 2 == 1).Sum());
        }
    }
}


Measured memory_bytes: 13396
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

DIV_NUM = 1000000000 + 7

INPUT_NUMS = list(map(int, input().split()))
N=int(INPUT_NUMS[0])
K=int(INPUT_NUMS[1])

A = [int(x) for x in input().split()]
AA = np.array(A)
if N==1:
    print(0)
    exit()

# https://kira000.hatenadiary.jp/entry/2019/02/23/053917
def bubble_sort(A):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(A)-1, i, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
    return cnt

answer = bubble_sort(AA)

B = sorted(A)
q=0
p=B[0]
r=0
for i in range(1,N):
    if B[i]>p:
        p=B[i]
        r=i
    q += r

# print(answer,K)
answer = answer % DIV_NUM
answer = int(answer)
answer = (answer * K) % DIV_NUM
q = q % DIV_NUM
answer = answer + q * K * (K-1) // 2
answer = answer % DIV_NUM
print(answer)



Measured memory_bytes: 14456
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<limits.h>
using namespace std;

int main() {
    string s;
    int c=0;
    cin>>s;
    for(int i=0;i<=(s.length()-1)/2;i++){
        if(s[i]!=s[s.length()-i-1]){
            //cout<<s[i]<<endl;
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
typedef long long ll;
using namespace std;
 
 
int main(){
    int n; cin >> n;
    char sa[10]={'a','b','c','d','e','f','g','h','i','j'};
    string ansstring(n,'a');
    vector<int> ans(n,0);

    int matu=n-1;
    int maxc=0;
    if(n==1) cout << 'a' << endl;
    while(matu){
        matu=n-1;
        cout << ansstring << endl;
        while(ans[matu]!=(maxc+1)){
            ans[matu]++; ansstring[matu]=sa[ans[matu]];
            cout << ansstring << endl;
        }
        matu--;
        while(matu){
        int ma=0;
        rep(i,matu) ma=max(ma,ans[i]);
        if(ans[matu]<1+ma){
        ans[matu]++; ansstring[matu]=sa[ans[matu]];
        maxc=max(ans[matu],ma);
        break;
        }
        else matu--;
        }
        for(int i=matu+1; i<n; i++){
             ans[i]=0; ansstring[i]=sa[0];
        }
    }
return 0;
}

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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	for(auto t = 1; t <= n; ++ t){
		int res = 0;
		for(auto x = 1; x * x <= t; ++ x){
			for(auto y = 1; x * x + y * y + x * y <= t; ++ y){
				for(auto z = 1; x * x + y * y + z * z + x * y + y * z + z * x <= t; ++ z){
					if(x * x + y * y + z * z + x * y + y * z + z * x == t){
						++ res;
					}
				}
			}
		}
		cout << res << "\n";
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define Fast    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sz      300005

int main(){
    Fast;
    int a,b,c, i,j,k, n,m,t, cs=1;

    cin>>a>>b>>c>>k;

    if(a>=k){
        cout<<k<<endl;
    }
    else if(a+b>=k){
        cout<<a<<endl;
    }
    else{
        k-=(a+b);
        k*=-1;
        a+=k;
        cout<<a<<endl;
    }
    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << (x) << ", "
#define de(x) cout << #x << " = " << (x) << "\n"
#define endl "\n"

//-----
const int N = 2e3 + 7;
int n, k, q, a[N];
bool ban[N];
int gao(int bas) {
	vi v, lis;
	rep(i, 0, n + 1) {
		if (ban[i]) {
			sort(all(v)); reverse(all(v));
			rep(j, k - 1, sz(v)) lis.pb(v[j]);
			v.clear();
			continue;
		}
		v.pb(a[i]);
	}
	sort(all(lis)); if (sz(lis) < q) return INT_MAX;
	return lis[q - 1] - bas;
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n >> k >> q;
	rep(i, 0, n) cin >> a[i];
	vector<pii> v; rep(i, 0, n) v.pb({a[i], i});
	sort(all(v));
	int ans = INT_MAX;
	ban[n] = true;
	rep(i, 0, sz(v)) {
		ans = min(ans, gao(v[i].fi));
		ban[v[i].se] = true;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n,k;
  cin >> n>>k;
  print(n - k + 1);
}

Measured memory_bytes: 256
import heapq  # heapqライブラリのimport
N,M=map(int,input().split())
lst=list(map(int,input().split()))
for i in range(N):
 lst[i]=(-lst[i],1)
for i in range(M):
 B,C=map(int,input().split())
 lst.append((-C,B))
heapq.heapify(lst)  # リストを優先度付きキューへ
ans=0
while N>0 :
 a=heapq.heappop(lst)
 ans+=a[0]*a[1]
 N-=a[1] 
ans+=a[0]*N
print((-1)*ans)


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

#define INF 2147483647
#define LINF 9223372036854775807
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

string s;

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

	cin>>s;
	if(s.find("AC")!=-1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

int dx,dy,dd;

bool op(int n){
  dd = (dd+n)%4;
  if(dd==0)dx++;
  if(dd==1)dy++;
  if(dd==2)dx--;
  if(dd==3)dy--;
  if(n==4)return false;
  return true;
}
    

int main(){
  int w,h;
  bool dp[540][30][30][4];
  int grid[30][30];
  int c[4];

  while(1){
    cin >> w >> h;
    if(!w && !h)break;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)cin >> grid[i][j];
    }
    for(int i=0;i<4;i++)cin >> c[i];

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	for(int k=0;k<4;k++){
	  for(int l=0;l<540;l++)dp[l][i][j][k] = false;
	}
      }
    }

    int ans = -1;

    while(1){
      ans++;
      queue<int> y,x,d;

      if(!ans){
	y.push(0);
	x.push(0);
	d.push(0);
      }else{
	for(int i=0;i<4;i++){
	  if(c[i] <= ans){
	    for(int j=0;j<h;j++){
	      for(int k=0;k<w;k++){
		for(int l=0;l<4;l++){
		  if(dp[ans-c[i]][j][k][l]){
		    dp[ans][j][k][l] = true;
		    dy = j;
		    dx = k;
		    dd = l;
		    if(op(i)){
		      if( dx<=w-1 && dy<=h-1 && dx>=0 && dy>=0){
			y.push(dy);
			x.push(dx);
			d.push(dd);
		      }
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
    
      while(!x.empty()){
	dy = y.front();
	y.pop();
	dx = x.front();
	x.pop();
	dd = d.front();
	d.pop();
	if(!dp[ans][dy][dx][dd]){
	  dp[ans][dy][dx][dd] = true;
	  if(op(grid[dy][dx])){
	    if( dx<=w-1 && dy<=h-1 && dx>=0 && dy>=0 ){
	      y.push(dy);
	      x.push(dx);
	      d.push(dd);
	    }
	  }
	}
      }

      bool f = false;
      for(int i=0;i<4;i++)f |= dp[ans][h-1][w-1][i];
      if(f)break;
    }
    cout << ans << endl;
  }
}

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

int main() {

    int N;
    long long C;
    vector<pair<long long, long long>> x;

    cin >> N >> C;
    x.resize(N);
    for(int i=0; i<N; i++) {
        cin >> x[i].first >> x[i].second;
    }
    sort(x.begin(), x.end());

    vector<long long> a, b;
    a.resize(N);
    b.resize(N);

    long long dist = 0, sum = 0;
    for(int i=0; i<N; i++) {
        dist = x[i].first;
        sum += x[i].second;
        a[i] = sum - dist;
        if(i > 0) {
            a[i] = max(a[i], a[i-1]);
        }
    }
    
    sum = 0;
    for(int i=N-1; i>=0; i--) {
        dist = C - x[i].first;
        sum += x[i].second;
        int j = N-i-1;
        b[j] = sum - dist;
        if(j > 0) {
            b[j] = max(b[j], b[j-1]);
        }
    }

    long long ans = 0, parans = 0;
    ans = max(ans, a[N-1]);
    ans = max(ans, b[N-1]);
    
    sum = 0;
    for(int i=0; i<N; i++) {
        dist = x[i].first;
        sum += x[i].second;
        if(N-i-2 >= 0) {
            parans = sum - 2*dist + b[N-i-2];
            ans = max(ans, parans);
        }
    }
    
    sum = 0;
    for(int i=N-1; i>=0; i--) {
        dist = C - x[i].first;
        sum += x[i].second;
        int j = N-i-1;
        if(N-j-2 >= 0) {
            parans = sum - 2*dist + a[N-j-2];
            ans = max(ans, parans);            
        }
    }

    cout << ans << '\n';

    return 0;
}

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

void __print(int32_t x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define debug(x...)

 

struct segtree{

    #define noop LLONG_MAX
    #define left 2*x +1
    #define right 2*x+2
    #define mid (lx+rx)/2 
    vector<int> values;
    int size;

    void init(int n)
    {
        size=1;
        while(size<n)
            size*=2;

        values.assign(2*size,noop);
    }

    void push(int x,int lx,int rx)
    {
        if(rx==lx+1||values[x]==noop)
        {
            return;
        }

        values[left]=min(values[left],values[x]);
        values[right]=min(values[right],values[x]);
        values[x]=noop;
    }

    void change(int x,int lx,int rx,int l,int r,int v)
    {
        push(x,lx,rx);
        if(lx>=r||rx<=l)
            return;
        if(l<=lx&&r>=rx)
        {
            values[x]=min(v,values[x]);
            return;
        }
        change(left,lx,mid,l,r,v);
        change(right,mid,rx,l,r,v);
    }

    void change(int l,int r ,int v)
    {
        change(0,0,size,l,r,v);
    }

    int getval(int x,int lx,int rx,int l)
    {
       // debug(x,lx,rx,values[x]);
        push(x,lx,rx);
        if(lx+1==rx)
        {
            return values[x];
        }

        if(l<mid)
        {
            return getval(left,lx,mid,l);
        }
        return getval(right,mid,rx,l);

    }

    int getval(int l)
    {
        return getval(0,0,size,l);
    }


};

int32_t main()
{
    int n,q;
    cin>>n>>q;

    segtree ri,down;

    ri.init(n);
    down.init(n);

    ri.change(0,n,n-1);
    down.change(0,n,n-1);
    //debug(ri.values);

    int ans=0;
    for(int i=0;i<q;i++)
    {
        int type,x;
        cin>>type>>x;

        if(type==1)
        {
            int v=down.getval(x-1);
            debug(v);
            down.change(x-1,x,0);
            ans+=v-1;
            ri.change(0,v,x-1);
        }

        else
        {
            int v=ri.getval(x-1);
            debug(v);
            ri.change(x-1,x,0);
            ans+=v-1;
            down.change(0,v,x-1);
        }
        debug(ans);

    }

    cout<<(n-2)*(n-2)-ans;
}

Measured memory_bytes: 11448
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String[] a = new String[n];
        Arrays.setAll(a, i -> sc.next());
        sc.close();

        // 主処理
        Set<String> set = new HashSet<>(Arrays.asList(a));
        int result = set.size();

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 75036