akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t X;
    cin >> X;
    
    if (X == 2 || X == 3) {
        cout << X << endl;
        return 0;
    }
    for (int64_t i = X; true; i++) {
        bool T = false;
        for (int j = 2; j * j <= i; j++){
            if (i % j == 0) {
                T = true;
                break;
            }
        }
        if (!T) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x11111111
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};//URDL
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int main(){
  int total_cities;
  int total_roads;

  while(~scanf("%d %d",&total_cities,&total_roads)){
    if(total_cities == 0 && total_roads == 0) break;

    int sea[201][201];
    int land[201][201];
    memset(sea,0x11,sizeof(sea));
    memset(land,0x11,sizeof(land));

    for(int road_idx = 0; road_idx < total_roads; road_idx++){
      int src,dst,time;
      char type[2];
      scanf("%d %d %d %s",&src,&dst,&time,type);
      if(type[0] == 'S'){
	sea[src][dst] = min(sea[src][dst],time);
	sea[dst][src] = min(sea[dst][src],time);
      }
      else if(type[0] == 'L'){
	land[src][dst] = min(land[src][dst],time);
	land[dst][src] = min(land[dst][src],time);
      }
    }
    for(int src=1;src<=total_cities;src++){
      int dst = src;
      sea[src][dst] = 0;
      land[src][dst] = 0;
    }
    int total_routes;
    int routes[1001];
    scanf("%d",&total_routes);
    for(int route_idx = 0; route_idx < total_routes; route_idx++){
      int route;
      scanf("%d",&route);
      routes[route_idx] = route;
    }

    int dp[201][201];
    memset(dp,0x11,sizeof(dp));

    for(int mid=1;mid<=total_cities;mid++){
      for(int src=1;src<=total_cities;src++){
	for(int dst=1;dst<=total_cities;dst++){
	  land[src][dst] = min(land[src][dst],land[src][mid] + land[mid][dst]);
	  sea[src][dst] = min(sea[src][dst],sea[src][mid] + sea[mid][dst]);
	}
      }
    }
    
    int ship[1001][201]; // ship[route_idx][city] = cost
    memset(ship,0x11,sizeof(ship));
    ship[0][routes[0]] = 0;

    for(int route_idx = 1; route_idx < total_routes; route_idx++){
      int prev_target = routes[route_idx - 1];
      int target = routes[route_idx];

      for(int mid1 = 1; mid1 <= total_cities; mid1++){
	ship[route_idx][mid1] = min(ship[route_idx][mid1],ship[route_idx-1][mid1] + land[prev_target][target]);

	for(int mid2 = 1; mid2 <= total_cities; mid2++){
	  ship[route_idx][mid2] = min(ship[route_idx][mid2],
				      ship[route_idx-1][mid1] + land[prev_target][mid1] + sea[mid1][mid2] + land[mid2][target]);
	}
      }
    }
    int res = INF;
    for(int city=1;city<=total_cities;city++){
      res = min(ship[total_routes-1][city],res);
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 2464
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	string S;
	cin >> S;
	int month;
	month = 10 * (S[5] - '0') + (S[6] - '0');

	if (month <= 4) cout << "Heisei" << endl;
	else cout << "TBD" << endl;


	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N;
ll i, j, k,ans;

int main(){
    scanf("%lld",&N);
    fornum(i,0,9){
        fornum(j,0,9){
            if((i+1)*(j+1)==N){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

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

using namespace std;

typedef long long ll;

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

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

  rep(i, n) { cin >> l[i]; }
  sort(l.begin(), l.end());

  ll ans = 0;
  for (int s = 0; s < n-2; s++) {
    for (int mid = s+1; mid < n-1; mid++) {
      int t = l.end()-lower_bound(l.begin(), l.end(), l[s]+l[mid]);
      int add = n-mid-1-t;
      ans += add;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();

        int result = 0;
        for (int i = 0; i < 6; i++) {
            result += N % 10;
            N = (N - (N % 10)) / 10;
        }
        if (result == 1) result = 10;
        System.out.println(result);
    }
}


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

int main(void) {
	using namespace std;
	string A;
	cin >> A;
	long long l = A.length();
	long long res = 1 + l * (l - 1) / 2; // (i, j)の選び方の総数(何もしない場合含む)
	//A[i] == A[j] となる(i, j)の組をすべて求める
	sort(A.begin(), A.end());
	long long mult = 1; //multiplicity
	char pre = A[0];
	for(int i = 1; i < l; ++i) {
		if(pre != A[i]) {
			pre = A[i];
			res -= mult * (mult - 1) / 2;
			mult = 1;
		} else {
			++mult;
		}
	}
	res -= mult * (mult - 1) / 2;
	cout << res << '\n';
	return 0;
}



Measured memory_bytes: 640
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a

    n = ni()
    divisor = [0 for _ in range(101)]

    ans = 0
    for i in range(1, n + 1):
        a = prime_factorize(i)
        for ai in a:
            divisor[ai] += 1

    over75 = 0
    over25 = 0
    over15 = 0
    over5 = 0
    over3 = 0
    for di in divisor:
        tmp = di + 1
        if tmp >= 75:
            over75 += 1
        if tmp >= 25:
            over25 += 1
        if tmp >= 15:
            over15 += 1
        if tmp >= 5:
            over5 += 1
        if tmp >= 3:
            over3 += 1

    ans = over75 + over25 * (over3 - 1) + over15 * (over5 - 1) + over5 * (over5 - 1) // 2 * (over3 - 2)

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
  char s[101][11],t[101][11];
  int i,j,m,n,max=0,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%s",s[i]);
  scanf("%d",&m);
  for(i=0;i<m;i++)
    scanf("%s",t[i]);
  for(i=0;i<n;i++){
    cnt=0;
    for(j=0;j<n;j++){
      if(strcmp(s[i],s[j])==0)
        cnt++;
    }
    for(j=0;j<m;j++){
      if(strcmp(s[i],t[j])==0)
        cnt--;
    }
    if(max<cnt)
      max=cnt;
  }
  printf("%d\n",max);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int w, h; cin >> w >> h;
	vector<vi> v(h, vi(w));
	vector<vi> yoko(h + 1, vi(w + 1));
	vector<vi> tate(h + 1, vi(w + 1));
	vector<vi> dp(h + 1, vi(w + 1));
	
	rep(i, h) rep(j, w) cin >> v[i][j];
	for(int i = h - 1; i >= 0; i--) for(int j = w - 1; j >= 0; j--){
		yoko[i][j] = yoko[i][j + 1] + v[i][j];
		tate[i][j] = tate[i + 1][j] + v[i][j];
	}
	for(int i = h; i >= 0; i--) for(int j = w; j >= 0; j--){
		if(i == h && j == w) continue;
		
		int mx = -inf, mn = inf;
		if(i + 1 <= h){
			mx = max(mx, dp[i + 1][j] + yoko[i][j]);
			mn = min(mn, dp[i + 1][j] + yoko[i][j]);
		}
		if(j + 1 <= w){
			mx = max(mx, dp[i][j + 1] - tate[i][j]);
			mn = min(mn, dp[i][j + 1] - tate[i][j]);
		}
		dp[i][j] = i + j & 1 ? mn : mx;
	}
	cout << abs(dp[0][0]) << endl;
	return 0;
}


Measured memory_bytes: 18724
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
    
using namespace std;
using ll = long long;
using pii = pair<int, int>;
    
const int oo = 1e9 + 7;
const int mod = 1e9 + 7;
const double PI = acos(-1);

int main(){
   ll a, b, op = 0;

   cin >> a >> b;

   cout << (abs(a - b) <= 1? "Brown" : "Alice") << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N,K = map(int,input().split())
t_d = []
for _ in range(N):
    t,d = map(int,input().split())
    t_d.append([t,d])
t_d = sorted(t_d, key=lambda x:-x[1])
kiso = 0
neta = Counter()
stack = []
for t,d in t_d[:K]:
    kiso += d
    neta[t] += 1
    stack.append((t,d))
ans = kiso + len(neta)**2
tmp = ans
for t,d in t_d[K:]:
    if t in neta : continue
    while(stack):
        t0,d0 = stack.pop()
        if neta[t0] > 1:
            tmp += d - d0 + 2*len(neta) + 1
            ans = max(ans,tmp)
            neta[t0] -= 1
            neta[t] += 1
            break
    else:
        break
print(ans)

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

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

int main(void) {
    const int INF = 1 << 30;
    int n, x, m, sum = 0, min_m = INF;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> x;
    REP(i, n) {
        cin >> m;
        sum += m;
        min_m = min(min_m, m);
    }
    
    cout << n + (x - sum) / min_m << "\n";
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn gcd(a: usize, b:usize) -> usize {
    let mut ans = 0;
    let mut tmp = 0;
    let mut x = a;
    let mut y = b;
    if x<y {
        //std::mem::swap(&mut x,&mut y);
        tmp = y;
        y = x;
        x = tmp;
    }
    if x==0 {
        ans = y;
        return ans;
    }
    if y==0 {
        ans = x;
        return ans;
    }
    let mut r = x % y;
    loop {
        if r==0 {
            break;
        }
        x = y;
        y = r;
        r = x % y;
    }
    ans = y;
    ans
}
fn main(){

    input!{
        n: usize,
        a: [usize;n],
    }

    let mut m: Vec<usize> = vec![0;n+2];
    let mut l_tmp: Vec<usize> = vec![0;n+2];
    let mut r_tmp: Vec<usize> = vec![0;n+2];
    
    l_tmp[1] = a[0];
    for i in 1..n {
        l_tmp[i+1] = gcd(l_tmp[i],a[i]);
    }
    r_tmp[n] = a[n-1];
    for i in (0..n-1).rev() {
        r_tmp[i+1] = gcd(r_tmp[i+2], a[i]);
    }

    // for i in 0..n {
    //     println!("{}", l_tmp[i]);
    //     println!("{}", r_tmp[n-1-i]);
    // }

    let mut ans = 1;
    for i in 0..n {
        let res = gcd(l_tmp[i], r_tmp[i+2]);
        ans = std::cmp::max(ans,res);
    }

    println!("{}", ans);

}

Measured memory_bytes: 4400
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;



void main() {
    long a, b, k;
    scan(a, b, k);
    auto ra = a - min(a, k);
    auto rb = b - max(0, min(k - a, b));
    writefln("%s %s", ra, rb);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}

Measured memory_bytes: 368
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


const int N = 2e5 + 100;

ll A[N];

int main(){
	fio; cout<<fixed<<setprecision(25);	
	ll k , n;
	cin >> k >> n;
	for(int i = 0;i < n ; ++i){
		cin >> A[i];
	}
	A[n] = k+A[0];
	ll shot = 0;
	for(int i = 0;i < n ; ++i){
		shot = max(shot , A[i+1] - A[i]);
	}
	cout << k-shot << endl;









	return 0;
}


Measured memory_bytes: 1792
H,W = gets.split.map(&:to_i)
MAP = $<.map(&:chomp)
RST = Marshal.load(Marshal.dump(MAP))

def check(x,y)
  count = 0
  [ [-1,-1], [ 0,-1], [ 1,-1], [-1, 0], [ 1, 0], [-1, 1], [ 0, 1], [ 1, 1] ].each do |dx, dy|
    nx = x + dx
    ny = y + dy
    if nx>=0 && nx<W && ny>=0 && ny<H
      count += 1if MAP[ny][nx]=="#"
    end
  end
  count
end

H.times do |y|
  W.times do |x|
    if MAP[y][x]!="#"
      print check(x,y)
    else
      print "#"
    end
  end
  puts
end

Measured memory_bytes: 1788
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long int i,n,ans=1,diff,fin;
	cin>>n;
	for(i=1;i<=sqrt(n);i++)
	{
		ans=i*i;
		
		if(i==1||(n-ans)<diff)
		{
			diff=n-ans;	
			fin=ans;
		}
		
	}
	cout<<fin;
	return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if (A <= 8 && B <= 8)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<int> w(n + 1), r(n+1);
	for (int i = 0; i < n; ++i) {
		w[i+1] = w[i];
		if (s[i] == 'W') w[i+1]++;
	}
	for (int i = n-1; i >= 0; --i) {
		r[i] = r[i+1];
		if (s[i] == 'R') r[i]++;
	}
	int res = 1e9;
	for (int i = 0; i <= n; ++i) {
		int tmp = min(w[i], r[i]) + abs(w[i] - r[i]);
		res = min(res, tmp);
	}
	cout << res;
}

Measured memory_bytes: 5240
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (
	(a == 7 and b == 5 and c == 5) or
	(a == 5 and b == 7 and c == 5) or 
	(a == 5 and b == 5 and c == 7)) {
		printf("YES");
		return 0;
	}
	printf("NO");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <functional>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N = (int)2e5+77;
const int mod = (int)1e9+7;

ll n,m,k,x,y;

int main() {
    fast;
    cin>>n>>m>>x>>y;
    fore(i,n,m) fore(j,x,y) if(i==j) k++;
    if(k) k--;
    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 256
n=gets.to_i
s=$<.map {|si|si.chomp.split("").map &:to_s}
s.map! {|si|si.sort}
s = s.group_by {|si|si.join}
ans=0
s.each do |si|
  t=si[1].length
  ans+=t*(t-1)/2 if t>1
end
puts ans

Measured memory_bytes: 127100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;
vector<int> enum_div(int n){
	vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    vector<ll> b(N);
    bool push[N];
    for(int i=0;i<N;i++){
        b[i]=0;
      	push[i]=false;
    }
    ll sum=0;
    for(int i=N-1;i>=0;i--){
        if(b[i]%2!=a[i]){
          	cerr << '!';
            b[i]++;
            push[i]=true;
            sum++;
            vector<int> p=enum_div(i+1);
            for(auto x:p){
                b[x-1]++;
            }
        }
    }
    cout << sum << endl;
    for(int i=0;i<N;i++){
        if(push[i])cout << i+1 << ' ';
    }


}

/*



 */



Measured memory_bytes: 4224
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int len[50002];
int res[50002];
int main(void){
	scanf("%d",&n);
	memset(len,0,sizeof(len));
	memset(res,0,sizeof(res));
	int maxi=0;
	int one=0;
	for(int i=2;i<=n;i++){
		printf("? %d %d\n",1,i);
		fflush(stdout);
		scanf("%d",&len[i]);
		maxi=max(maxi,len[i]);
		if(maxi==len[i])one=i;
	}
	res[maxi]=1;
	if(n!=1)res[0]=one;
	for(int i=2;i<=n;i++){
		if(i==one)continue;
		printf("? %d %d\n",one,i);
		fflush(stdout);
		int g;
		scanf("%d",&g);
		res[g]=i;
	}
	printf("! ");
	for(int i=0;i<n;i++){
		printf("%d%c",res[i],i+1==n?'\n':' ');
	}
	fflush(stdout);
	return 0;
}

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

int main() {
  	int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++){
    	cin >> A[i];
    }
  	vector<bool> B(N,0);
    B[0] = 1;
    int x = A[0];
    int count = 0;
    while(true){
    	if (B[x-1] == 0){
        	B[x-1] = 1;
            count++;
            x = A[x-1];
        }
        else if (B[x-1] == 1){
        	cout << -1 << endl;
          	break;
        }
        if (B[1] == 1){
        	cout << count << endl;
            break;
        }
    }
} 

Measured memory_bytes: 3716
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    l=[list(map(int, input().split())) for i in range(m)]
    a=10**5
    b=0
    for i in range(m):
        a=min(a,l[i][1])
    for i in range(m):
        b=max(b,l[i][0])
    print(max(0,a-b+1))
resolve()

Measured memory_bytes: 27368
N,X=map(int,input().split())
M,P=[1],[1]
for i in range(1,N+1):
    M.append(M[-1]*2+3)
    P.append(P[-1]*2+1)

def counter(N,X):
    if N==0:
        if X<=0:
            return 0
        else:
            return 1
    elif X==1:
        return 0
    elif X<=1+M[N-1]:
        return counter(N-1,X-1)
    else:
        return P[N-1]+1+counter(N-1,X-2-M[N-1])

print(counter(N,X))

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

#define INF 1000050000

int dp[3002][3002];

int main()
{
	string s, t;
	cin >> s >> t;
	int fl[3003];
	memset(fl, 0, sizeof(fl));
	stack<char> st;
	int len1 = s.size();
	int len2 = t.size();
	for(int i = 0; i < len1; i++) {
		for(int j = 0; j < len2; j++) {
			if(s[i] == t[j]) {
				dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j]);
			} else {
				dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
			}
		}
	}
	int len = dp[s.size()][t.size()];
	for(int i = s.size(); i > 0; i--) {
		for(int j = t.size(); j > 0; j--) {
			if(dp[i][j] == len && dp[i][j] == dp[i-1][j-1]+1 && s[i-1] == t[j-1]) {
				len--;
				st.push(t[j-1]);
				break;
			}
		}
	}
	while(!st.empty()) {
		printf("%c", st.top());
		st.pop();
	}
	printf("\n");
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N=256;
const int maxn=2e5+5;
int a[maxn];
int main()
{
    int n,x,t;
    scanf("%d%d%d",&n,&x,&t);
    int c=ceil(1.0*n/x);
    printf("%d\n",c*t);
    return 0;
}


Measured memory_bytes: 3812
#include<iostream>

using namespace std;

int main(){
    int N,x,y,flag;
    cin >> N;
    x = 0;
    y = 0;
    flag = 0;
    for(x = 0; x <= 25; x++){
        for(y = 0; y < 15; y++){
            if(4*x + 7*y > N){
                continue;
            }
            if(4*x + 7*y == N){
                flag = 1;
            }
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
S = str(input())
ans = 0
if S[1]=="R":
    ans+=1
    if S[0]=="R" or S[2]=="R":
        ans+=1
        if S[0]=="R" and S[2]=="R":
            ans+=1
elif S[0]=="R" or S[2]=="R":
    ans+=1
print(ans)

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for(int i = 0; i < tx - sx; i++)
    cout << 'R';
  for(int i = 0; i < ty - sy; i++)
    cout << 'U';
  for(int i = 0; i < tx - sx; i++)
    cout << 'L';
  for(int i = 0; i < ty - sy; i++)
    cout << 'D';
  cout << 'D';
  for(int i = 0; i < tx - sx + 1; i++)
    cout << 'R';
  for(int i = 0; i < ty - sy + 1; i++)
    cout << 'U';
  cout << 'L' << 'U';
  for(int i = 0; i < tx - sx + 1; i++)
    cout << 'L';
  for(int i = 0; i < ty - sy + 1; i++)
    cout << 'D';
  cout << 'R' << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String array[] = str.split("");
        List<Integer> list = new ArrayList<Integer>();
        for(int i=0; i<array.length; i++){
            list.add(Integer.parseInt(array[i]));
        }
        int min = 1000;
        for(int i=2; i<list.size(); i++){
            int sum = 0;
            sum += list.get(i-2) * 100;
            sum += list.get(i-1) * 10;
            sum += list.get(i);
            if(Math.abs(sum-753) < min) min = Math.abs(sum-753);
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 21844
/*
  Contest 117
  B - Polygon
  Rakesh Kumar --> 28/09/2020
 */

#include <bits/stdc++.h>

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

    int n = 0;
    std::cin >> n;
    int total = 0;
    int max = 0;
    while (n--) {
        int s = 0;
        std::cin >> s;
        max = std::max(s, max);
        total += s;
    }
    total -= max;
    if (max < total)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}


Measured memory_bytes: 3604
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i
    integer(int32), allocatable:: a(:), josi(:)

    read*, n
    allocate(a(n),josi(0:n))
    read*, a(2:)

    josi(:) = 0
    do i=1,n
        josi(a(i)) = josi(a(i)) + 1
    end do

    do i=1,n
        print'(i0)', josi(i)
    end do

end program name

Measured memory_bytes: 4604
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


int dp[301][301][301];
void solve(std::string S, long long K){
	for(int w=1;w<=S.size();w++){
		for(int i=0;i+w<=S.size();i++){
			for(int k=0;k<=K;k++){
				dp[i][i+w][k]=max(dp[i][i+w-1][k],dp[i+1][i+w][k]);
				if(k>0){
					dp[i][i+w][k]=max(dp[i][i+w][k],dp[i][i+w][k-1]);
				}
				if(S[i]==S[i+w-1]){
					int d=(w==1?1:2);
					dp[i][i+w][k]=max(dp[i][i+w][k],dp[i+1][i+w-1][k]+d);
				}
				else{
					if(k>0){
						dp[i][i+w][k]=max(dp[i][i+w][k],dp[i+1][i+w-1][k-1]+2);
					}
				}
			}
		}
	}
	cout << dp[0][S.size()][K] << endl;

}

int main(){
    std::string S;
    std::cin >> S;
    long long K;
    scanf("%lld",&K);
    solve(S, K);
    return 0;
}


Measured memory_bytes: 57912
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];

    ll ans=0;
    rep(i,h)rep(j,w){
        if(s[i][j]=='#')continue;
        queue<pl> q;
        vvl d(h,vl(w,INF));
        d[i][j]=0;
        q.emplace(i,j);
        while(q.size()){
            pl p=q.front();q.pop();
            rep(k,4){
                ll ty=p.first+D4[k],tx=p.second+D4[k+1];
                if(ty<0||ty>=h||tx<0||tx>=w||s[ty][tx]=='#'||d[ty][tx]!=INF)continue;
                d[ty][tx]=d[p.first][p.second]+1;
                chmax(ans,d[ty][tx]);
                q.emplace(ty,tx);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string a;
	cin >> a;
	int e = a.size();
	if (e == 2) { cout << a << endl; }
	else { cout << a[2] << a[1] << a[0] << endl; }
}
	

Measured memory_bytes: 256
mod = 10**9 + 7
 
def C(n, r, mod):
    x=y=1
    for i in range(r):
        x *= n; y *= r
        x %= mod; y %= mod
        n -= 1; r -= 1
    return x * pow(y, mod - 2, mod) % mod
 
 
n, a, b = map(int, input().split())
 
print((pow(2, n, mod) - 1 - C(n, a, mod) - C(n, b, mod)) % mod)

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else
      x=x->right;
  }

  z->parent=y;

  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left=z;
  else
    y->right=z;


}

void inorder(Node x){
  if(x!=NIL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  }
}

void preorder(Node x){
  if(x!=NIL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
  
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
     if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

Measured memory_bytes: 24040
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-04-30(Thu)
   note   
**********************************************************************/

#include <bits/stdc++.h>
using namespace std;

int main() {
   string s;
   cin >> s;
   if(s == "ABC"){
       cout << "ARC" << endl;
   }
   else if(s == "ARC"){
       cout << "ABC" << endl;
   }
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	string S; cin >> S;
	ll N = S.size();
	
	REP(i, N-1)
	{
		if (i != N-2)
		{
			if (S[i] == S[i+2])
			{
				std::cout << i+1 << " " << i+3 << std::endl;
				return 0;
			}
		}

		if (S[i] == S[i+1])
		{
			std::cout << i+1 << " " << i+2 << std::endl;
			return 0;
		}
	}

	std::cout << "-1 -1" << std::endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

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

    int a,b;
    cin >> a >> b;
    if (a<10&&b<10) cout << a*b <<endl;
    else            cout << -1 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		HashMap<String,Integer> map = new HashMap<>();
		int n = sc.nextInt();
		String s;
		for (int i=0; i<n; i++) {
			s = sc.next();
			map.put(s,map.getOrDefault(s,0));
			map.put(s,map.get(s)+1);
		}
		int m = sc.nextInt();
		for (int i=0; i<m; i++) {
			s = sc.next();
			map.put(s,map.getOrDefault(s,0));
			map.put(s,map.get(s)-1);
		}
		int max = 0;
		for (Map.Entry<String,Integer> e : map.entrySet()) {
			max = Math.max(max,e.getValue());
		}
		out.println(max);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    k--;
    cout << A[k];
    return 0;
}

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

int main(void){
    // Your code here!
   char a;
   
   cin >> a;
   if( a == 'a' || a == 'i'|| a == 'u' || a == 'e' || a == 'o' ){
       cout << "vowel" << endl;
   }else {
       cout << "consonant" << endl;
   }
}


Measured memory_bytes: 256
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int main()
{
    ll n,m,i,j,k=0,l;
    cin>>n>>m;
    rep(i,0,m-1)cin>>l,k+=l;
    if(k>n)cout<<-1;
    else cout<<(n-k);
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

// https://atcoder.jp/contests/dp/tasks/dp_a
public class Main {
    public static void main(String args[]) {
        try (Scanner scan = new Scanner(System.in)) {
            int n = scan.nextInt();
            int[] h = new int[n];
            for (int i = 0; i < n; i++) {
                h[i] = scan.nextInt();
            }
            System.out.println(new UsingDP().minCost(h));
        }
    }

    public interface Solution {
        int minCost(int[] heights);
    }

    public static class UsingDP implements Solution {
        public int minCost(int[] heights) {
            if (heights.length < 2) return 0;
            if (heights.length == 2) return Math.abs(heights[1] - heights[0]);
            int[] costs = new int[heights.length];
            Arrays.fill(costs, 1, costs.length, Integer.MAX_VALUE);
            for (int i = 0; i < heights.length; i++) {
                for (int j = i + 1, jl = Math.min(j + 2, heights.length); j < jl; j++) {
                    costs[j] = Math.min(costs[j], costs[i] + Math.abs(heights[j] - heights[i]));
                }
            }
            return costs[costs.length - 1];
        }
    }
}


Measured memory_bytes: 51084
data class Point(val x: Double, val y: Double)

fun main(args: Array<String>) {
    val depth = readLine()?.toInt() ?: 0
    val begin = Point(0.0, 0.0)
    val end = Point(100.0, 0.0)
    println(begin.toStr())
    koch(begin, end, depth)
    println(end.toStr())
}

fun koch(begin: Point, end: Point, depth: Int) {
    if (depth == 0) {
        return
    }
    val s = (begin * 2 + end) / 3
    val t = (begin + end * 2) / 3
    val u = Point((t - s).x * Math.cos(Math.PI / 3) - (t - s).y * Math.sin(Math.PI / 3) + s.x,
        (t - s).x * Math.sin(Math.PI / 3) + (t - s).y * Math.cos(Math.PI / 3) + s.y)
    koch(begin, s, depth - 1)
    println(s.toStr())
    koch(s, u, depth - 1)
    println(u.toStr())
    koch(u, t, depth - 1)
    println(t.toStr())
    koch(t, end, depth - 1)
}

operator fun Point.plus(other: Point): Point {
    return Point(this.x + other.x, this.y + other.y)
}

operator fun Point.minus(other: Point): Point {
    return Point(this.x -  other.x, this.y - other.y)
}

operator fun Point.times(num: Int): Point {
    return Point(this.x * num, this.y * num)
}

operator fun Point.div(num: Int): Point {
    return Point(this.x / num, this.y / num)
}

fun Point.toStr(): String {
    return "${this.x} ${this.y}"
}


Measured memory_bytes: 32416
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let mut adj = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let u = sc.ne::<usize>() - 1;
        let v = sc.ne::<usize>() - 1;
        adj[u].push(v);
        adj[v].push(u);
    }
    fn dfs(cur: usize, par: usize, adj: &Vec<Vec<usize>>, mut used: &mut Vec<bool>) {
        for &nxt in &adj[cur] {
            if nxt != par {
                dfs(nxt, cur, adj, used);
            }
        }
        if used[cur] || used[par] {
            return;
        }
        if cur != par {
            used[cur] = true;
            used[par] = true;
        }
    }
    let mut used = vec![false; n];
    dfs(0, 0, &adj, &mut used);
    // println!("{:?}", used);
    println!("{}",
             if used.iter().any(|&x| x == false) {
                 "First"
             } else {
                 "Second"
             });
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r])
                  .ok()
                  .unwrap()
                  .parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


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

index=0
sum=0
minF=100
while index < n:
    s = int(input())
    if s%10!=0 and s<minF:
        minF=s
    sum+=s
    index+=1

if sum%10!=0:
    print(sum)
else:
    if minF!=100:
        print(sum-minF)
    else:
        print(0)

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



int main()
{
	ll N,A,B,C;cin >>N>> A >> B >> C;
	vector<string> input(N);
	string method;
	bool can=true;
	for (int i=0;i<N;i++)
	{
		cin >> input[i];
	}
	for (int i=0;i<N;i++)
	{
		if (input[i]=="AB")
		{
			if (A==1 && B==1)
			{
				if (i+1<N)
				{
					if (input[i+1]=="BC")
					{
						B++;
						A--;
						method+="B";
						continue;
					}
					if (input[i+1]=="AC")
					{
						B--;
						A++;
						method+="A";
						continue;
					}
				}
			}
			if (A==0 && B==0)
			{
				can=false;
				break;
			}
			if (A>=B)
			{
				A--;
				B++;
				method+="B";
			}
			else
			{
				A++;
				B--;
				method+="A";
			}
			
		}
		if (input[i]=="BC")
		{
			if (C==0 && B==0)
			{
				can=false;
				break;
			}
			if (C==1 && B==1)
			{
				if (i+1<N)
				{
					if (input[i+1]=="AC")
					{
						C++;
						B--;
						method+="C";
						continue;
					}
					if (input[i+1]=="AB")
					{
						C--;
						B++;
						method+="B";
						continue;
					}
				}
				
			}
			if (C>=B)
			{
				C--;
				B++;
				method+="B";
			}
			else
			{
				C++;
				B--;
				method+="C";
			}
		}
		if (input[i]=="AC")
		{
			if (A==1 && C==1)
			{
				if (i+1<N)
				{
					if (input[i+1]=="BC")
					{
						C++;
						A--;
						method+="C";
						continue;
					}
					if (input[i+1]=="AB")
					{
						C--;
						A++;
						method+="A";
						continue;
					}
				}
			}
			if (A==0 && C==0)
			{
				can=false;
				break;
			}
			if (A>=C)
			{
				A--;
				C++;
				method+="C";
			}
			else
			{
				A++;
				C--;
				method+="A";
			}
		}
	}
	if (can)
	{
		cout << "Yes" << endl;
		for (int i=0;i<method.size();i++) cout << method[i] << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 6692
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, k;
	while (cin >> n >> k, n, k) {
		int s[114514] = {};
		for (int i = 1; i <= n; i++) {
			int a; cin >> a;
			s[i] = s[i - 1] + a;
		}
		long long ans = 0;
		for (int i = 1; i <= n - k; i++) {
			ans = max(ans, (long long)(s[i + k] - s[i]));
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin >> x;
    if (x)
        cout << 0 << endl;
    else
        cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

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

  ll n = 0, k = 0;

  cin >> n >> k;

  vector<ll> p(n), c(n);

  vector<pair<ll, ll> > cycle; //len, gain

  for(int i = 0; i < n; i++) { cin >> p[i]; p[i]--; }

  for(int i = 0; i < n; i++) cin >> c[i];

  for(int i = 0; i < n; i++) {
    ll clen = 0, cgain = 0, cur = i;
    while(clen == 0 || cur != i) {
      cgain += c[cur];
      cur = p[cur];
      clen++;
      if(clen > n) break;
    }
    if(clen > n) clen = -1;
    cycle.pb(mp(clen, cgain));
    //cout << clen << ' ' << cgain << endl;
    //cycle always exist huh
  }

  ll ans = -774342;

  for(int i = 0; i < n; i++) {
    if(cycle[i].se <= 0) {
      ll cur = i, gain = 0;
      for(int j = 0; j < min(k, 2 * cycle[i].fi); j++) {
        gain += c[cur];
        cur = p[cur];
        if(ans == -774342) ans = gain;
        ans = max(ans, gain);
      }
    } else {
      ll use = max(0ll, (k / cycle[i].fi) - 1);
      ll cur = i, gain = use * cycle[i].se;
      ll left = k - use * cycle[i].fi;
      while(left--) {
        gain += c[cur];
        cur = p[cur];
        if(ans == -774342) ans = gain;
        ans = max(ans, gain);
      }
    }
  }

  cout << ans << endl;

  return 0;
}
/*

*/


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

using namespace std;

using ll = long long;

int main(){
  ll N;
  cin >> N;
  bool ok = false;
  for(int i=0;i<100;i++)
    for(int j=0;j<100;j++)
      if(i * 4 + 7 * j == N)
	ok = true;
  if(ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    // Point 文字列をchar1文字に変更する
    // 奇数だけ処理
    val str = readLine()!!
    val array = str.toCharArray()

    var result = ""
    for ((index, value) in array.withIndex()) {
        if (index % 2 == 0) {
            // indexから始まるので、1文字目は通常1で奇数だが、0始まりであれば
            // 偶数が奇数部になる
            // 文字連結の表記を確認
            result += value
        }
    }
    println(result)
}

Measured memory_bytes: 118016