akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

#define PI 3.14159265359

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int a, b, x; scanf("%d%d%d", &a, &b, &x);
	double ret;
	if (x * 2 > a*a*b){
		double d = (double)(2 * x) / (double)(a*a) - (double)b;
		ret = atan((double)a / ((double)b - d));
	}
	else{
		double d = (double)(2 * x) / (double)(a*b);
		ret = atan(d / (double)b);
	}

	printf("%lf",90.0f -  ret / PI*180.0f);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

int main(){
  int a=0,b=0,len;
  string S;
  cin>>S;
  
  len = S.size();

for(int i=0;i<len;i++){

if(S.at(i)=='0')
a++;
else //(S.at(i)=='1')
b++;
}
  if(a<b) cout<<2*a<<endl;
  else cout<<2*b<<endl;
}


Measured memory_bytes: 512
#include <cstdio>

const int N=100005;

int fst[N],tot=0;
struct Edge{
	int to,nxt;
}e[N*2];

void addedge(int x,int y){
	e[++tot].to=y;e[tot].nxt=fst[x];fst[x]=tot;
}

int dfs(int x,int father){
	int v=0;
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to;
		if (y!=father) v+=dfs(y,x);
	}
	return v>1?v:v^1;
}

int main(){
	int n;
	scanf("%d\n",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d\n",&x,&y);
		addedge(x,y);
		addedge(y,x);
	}
	if (!dfs(1,0)) printf("Second\n");
		else printf("First\n");
}

Measured memory_bytes: 2176
N, K = map(int, input().split())
d = [0]*K
A = []
for i in range(K):
    d[i] = int(input())
    A.append(list(map(int, input().split())))
ans = 0
for i in range(1,N+1):
    got = False
    for j in A:
        for k in j:
            if i == k:
                got = True
    if not got:
        ans += 1
print(ans)

Measured memory_bytes: 9080
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,a,b,f,ans=0;
  bool g[10][10]={};
  cin >> n >> m;
  int p[n];
  for(int i=0; i<n; i++) {
    p[i]=i;
  }
  for(int i=0; i<m; i++) {
    cin >> a >> b;
    a--,b--;
    g[a][b]=g[b][a]=true;
  }
  do{
    if(p[0]==0) {
      f=1;
      for(int i=0; i<n-1; i++) {
        if(!g[p[i]][p[i+1]]) {
          f=0;
        }
      }
      ans+=f;
    }
  }while(next_permutation(p,p+n));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

bool f(string s, string t){
    ll ptr1 = 0, ptr2 = 0;
    while(ptr1 < s.len() && ptr2 < t.len()){
        // if(t == "022") trace(ptr1, ptr2, s[ptr1], t[ptr2]);
        if(t[ptr2] == s[ptr1]){
            ptr1++, ptr2++;
        }
        else {
            ptr1++;
        }
        if(ptr2 == 3){
            return 1;
        }
    }
    ret0;
}

void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans = 0;
    loop(i,0,10){
        loop(j,0,10){
            loop(k,0,10){
                string t;
                t.pb(char(i+'0'));
                t.pb(char(j+'0'));
                t.pb(char(k+'0'));
                // if(t == "022"){
                //     print(f(s,t));
                // }
                if(f(s, t)) ans++;
            }
        }
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

//ここから編集 

vector<vector<int>> g(100010);
bool used[100010];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n, m; cin >> n >> m;
  REP(i,m){
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> ans;
  int st = 0;
  while(!g[st].size()) st++;

  used[st] = true;
  ans.push_back(st);
  for(int now=st, bf = -1; now != bf;){
    bf = now;
    for(auto u: g[now]){
      if(used[u]) continue;
      used[u] = true;
      ans.push_back(u);
      now = u;
      break;
    }
  }
  reverse(all(ans));
  for(int now = st, bf = -1; now != bf;){
    bf = now;
    for(auto u: g[now]){
      if(used[u]) continue;
      used[u] = true;
      ans.push_back(u);
      now = u;
      break;
    }
  }

  cout << ans.size() << endl;
  for(int i=0; i<ans.size(); i++){
    if(i) cout << " ";
    cout << ans[i]+1;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 9252
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<vector>
#define INF 100000000

#define MAX_N 10000
#define MAX_M 100

typedef long long int ll;
using namespace std;



int main(){

	int x;

	scanf("%d", &x);

	printf("%d\n", x*x*x);

	return 0;

}

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

int main() {
    int R;
    cin >> R;
    cout << (long double)R * (long double)2 * (long double)(M_PI) << endl;

    return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

ll gcd(ll a,ll b){while(a^=b^=a^=b%=a);return b;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

void solve() {
  VAR(int, N);
  VEC(ll, T, N);
  ll ans = T[0];
  rep(i, 1, N) {
    ans = lcm(ans, T[i]);
  }
  print(ans);
}


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;
typedef pair<int, int> P;
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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n, w, d;
	int b, c;
	cin >> n >> w >> d;
	while(n != 0 || w != 0 || d != 0){
		vector<P> v;
		P x, a1, a2;
		v.push_back(P(w, d));
		rep(i,n){
			cin >> b >> c;
			x = v[b-1];
			v.erase(v.begin()+b-1);
			int k = c % (x.first + x.second);
			if(k < x.first){
				if(k <= x.first / 2){
					a1 = P(k, x.second);
					a2 = P(x.first - k, x.second);
				}
				else{
					a1 = P(x.first - k, x.second);
					a2 = P(k, x.second);
				}
			}
			else{
				k -= x.first;
				if(k <= x.second / 2){
					a1 = P(x.first, k);
					a2 = P(x.first, x.second - k);
				}
				else{
					a1 = P(x.first, x.second - k);
					a2 = P(x.first, k);
				}
			}
			v.push_back(a1);
			v.push_back(a2);
		}
		vector<int> ans;
		rep(i,v.size()) ans.push_back(v[i].first * v[i].second);
		sort(ans.begin(), ans.end());
		std::cout << ans[0];
		rep(i,ans.size()-1) std::cout << " " << ans[i+1];
		std::cout << endl;
		cin >> n >> w >> d;
	}
    return 0;
}


Measured memory_bytes: 3120
#include<cstdio>
using namespace std;

int main()
{
	char a,b,c,d;
	scanf("%c%c%c%c",&a,&b,&c,&d);
	if(a==b||b==c||c==d)
	{
		printf("Bad");
	}
	else
	{
		printf("Good");
	}
	return 0;
} 

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
ll dp[100001];
int q(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int a[3][101];
int main(void) {
  int n,x,b,cnt=0;
  scanf("%d",&n);
  FOR(3){
    scanf("%d",&x);
    FORJ(x){
      scanf("%d",&b);
      a[i][b]=1;
    }
  }
  FOR(101){
    if(a[2][i]){
      cnt+=1-a[0][i];
      cnt+=a[0][i]*a[1][i];
    }
  }
  PRN(cnt);
  return 0;
}


Measured memory_bytes: 2140
#include <stdio.h>

void print_list(int a[], int n)
{
    int i;
    for (i = 0; i < n; i++){
        printf("%d", a[i]);
        if (i < n-1)
            printf(" ");
    }
    printf("\n");
}


void bubble_sort(int a[], int n)
{
	int i, j, cnt, tmp;
	cnt = 0;
	for (i = 1; i < n; i++){
		for (j = 0; j < n-i; j++){
			if (a[j] > a[j+1]){
				tmp = a[j];  a[j] = a[j+1];  a[j+1] = tmp;
				cnt++;
			}
		}
	}
	print_list(a, n);
	printf("%d\n", cnt);
}

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


Measured memory_bytes: 2704
import Control.Monad
import Data.Array
import Data.List
import Data.Maybe

data RefBook = RefBook Int (Array Int Int)

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

readRefBook :: Int -> IO RefBook
readRefBook m = do
  (c:as) <- readInts
  return $ RefBook c (listArray (1, m) as)

main :: IO ()
main = do
  [n, m, x] <- readInts
  as <- replicateM n $ readRefBook m
  print $ fromMaybe (-1) $ solve m x as

solve :: Int -> Int -> [RefBook] -> Maybe Int
solve m x = foldr f Nothing . map (calc m x) . subsequences
  where
    f Nothing  Nothing  = Nothing
    f (Just x) Nothing  = Just x
    f Nothing  (Just y) = Just y
    f (Just x) (Just y) = Just $ x `min` y


calc :: Int -> Int -> [RefBook] -> Maybe Int
calc m x rbs = if reach then Just cost else Nothing
  where
    reach = and [ sum [ rb ! i | RefBook _ rb <- rbs ] >= x | i <- [1 .. m] ]
    cost  = sum [ c | RefBook c _ <- rbs ]


Measured memory_bytes: 5240
#include <iostream>
#include <vector>

using namespace std;

struct node {
    int parent;
    int depth;
    vector<int> children;

    node() : parent(-1), children() {}
};

int main() {
    int N;
    cin >> N;
    vector<node> node_list(N, node());
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;

        for (int j = 0; j < b; ++j) {
            int x;
            cin >> x;
            node_list[a].children.push_back(x);
            node_list[x].parent = a;
        }
    }

    for (int i = 0; i < N; ++i) {
        int depth = 0;
        auto it = &node_list[i];
        while (it->parent != -1) {
            it = &node_list[it->parent];
            ++depth;
        }
        node_list[i].depth = depth;
    }

    for (int i = 0; i < N; ++i) {
        auto& node = node_list[i];
        cout << "node " << i;
        cout << ": parent = " << node.parent;
        cout << ", depth = " << node.depth << ", ";
        if (node.parent == -1) {
            cout << "root";
        } else if (node.children.size() > 0) {
            cout << "internal node";
        } else {
            cout << "leaf";
        }
        cout << ", [";
        auto& children = node.children;
        if (children.size() > 0) {
            auto it = children.begin();
            for (; it != children.end()-1; ++it) {
                cout << *it << ", ";
            }
            cout << *it;
        }
        cout << "]" << endl;
    }

    return 0;
}

Measured memory_bytes: 6676
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int l = sc.nextInt();
        UnionFind load = new UnionFind(n);
        for (int i = 0; i < k; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            load.unite(x, y);
        }

        UnionFind rail = new UnionFind(n);
        for (int i = 0; i < l; i++) {
            int x = sc.nextInt() - 1;
            int y = sc.nextInt() - 1;
            rail.unite(x, y);
        }

        Map<Pair, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            Pair p = new Pair(load.root(i), rail.root(i));
            if (!map.containsKey(p)) {
                map.put(p, 0);
            }
            map.put(p, map.get(p) + 1);
        }

        for (int i = 0; i < n; i++) {
            Pair p = new Pair(load.root(i), rail.root(i));
            System.out.print(map.get(p));
            if (i == n - 1) {
                break;
            }
            System.out.print(" ");
        }
        System.out.println();
    }
}
class UnionFind {
    int[] par;
    public UnionFind(int n) {
        this.par = new int[n];
        for (int i = 0; i < n; i++) {
            par[i] = i;
        }
    }

    public int root(int x) {
        if (par[x] == x) {
            return x;
        }
        return par[x] = root(par[x]);
    }
    public void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) {
            return;
        }
        par[rx] = ry;
    }
    public boolean isSame(int x, int y) {
        return root(x) == root(y);
    }
}
class Pair {
    int x;
    int y;
    public Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }
    public int compareTo(Pair p) {
        return this.x - p.x;
    }
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Pair p = (Pair) o;
        return this.x == p.x && this.y == p.y;
    }
    public int hashCode() {
        return Objects.hash(x, y);
    }
    public String toString() {
        return String.format("x: %d y: %d ", this.x, this.y);
    }
}


Measured memory_bytes: 163660
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define LiangJiaJun main
using namespace std;
int n,now=1,ans=0;
int a[100004];
bool vis[100004];
int LiangJiaJun(){
	memset(vis,0,sizeof(vis));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	while(1){
		if(vis[now]) return puts("-1"),0;
		if(a[now] == 2) break;
		vis[now] = 1; now = a[now]; ++ans; 
	}
	printf("%d\n",ans+1);
	return 0;
}

Measured memory_bytes: 768
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
res = -float('inf')
for i in range(1,1<<10):
    cnt = [0 for _ in range(n)]
    for j in range(10):
        for k in range(n):
            if (i>>j)&1 and f[k][10-j-1]:
                cnt[k] += 1
    total = 0
    for k in range(n):
        total += p[k][cnt[k]]
    res = max(res,total)
print(res)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, q;

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

  cin >> n >> q;

  vector<vector<int>> g(n + 1, vector<int>());
  vector<int> c(n + 1, 0);

  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    g[b].push_back(a);
    g[a].push_back(b);
  }

  REP(i, q) {
    int a, b;
    cin >> a >> b;
    c[a] += b;
  }

  queue<tuple<int, int, int>> que;
  que.push(make_tuple(1, -1, 0));
  while(!que.empty()) {
    tuple<int, int, int> t = que.front(); que.pop();
    int now = get<0>(t);
    int from = get<1>(t);
    int sum = get<2>(t);

    int suma = sum + c[now];
    c[now] = suma;
    REP(i, g[now].size()) {
      if(g[now][i] != from) {
        que.push(make_tuple(g[now][i], now, suma));
      }
    }
  }
  FOR(i, 1, n + 1) {
    cout << c[i] << endl;
  }
}


Measured memory_bytes: 17140
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
  A[i]*=-1
import heapq
heapq.heapify(A)
import math
for i in range(M):
  maxi=heapq.heappop(A)
  maxi=math.ceil(maxi/2)
  heapq.heappush(A,maxi)
  
ans=sum(A)*(-1)
print(ans)
    

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int n,q; cin>>n>>q;
    string s; cin>>s;
    vector<int>ss(n,0);

    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C'){
            ss[i+1]++;
        }
        ss[i+1]+=ss[i];
    }

    rep(i,q){
        int l,r;cin>>l>>r;
        cout<<ss[r-1]-ss[l-1]<<endl;
    }

}



Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    static List<int> GetCycle(int n, List<int>[] edges)
    {
        for (int i = 1; i <= n; i++)
        {
            var cycle = GetCycle(n, edges, i);
            if (cycle != null)
            {
                return cycle;
            }
        }
        return null;
    }

    static List<int> GetCycle(int n, List<int>[] edges, int start)
    {
        var prev = new int[n + 1];
        var currents = new List<int>() { start };

        do
        {
            var nexts = new List<int>();
            foreach (var cur in currents)
            {
                foreach (var next in edges[cur].Where(v => prev[v] == 0))
                {
                    nexts.Add(next);
                    prev[next] = cur;
                }
            }

            currents = nexts;
        } while (currents.Count > 0 && prev[start] == 0);
        if (prev[start] == 0)
        {
            return null;
        }

        var way = new Stack<int>();
        for (int v = prev[start]; v != start; v = prev[v])
        {
            way.Push(v);
        }
        way.Push(start);
        return way.ToList();
    }

    static void DeleteExtraEdge(List<int>[] edges, List<int> cycle)
    {
        var vertex = new HashSet<int>(cycle);
        foreach (var v in cycle)
        {
            edges[v] = edges[v].Where(x => vertex.Contains(x)).ToList();
        }
    }

    static List<int> GetInducedSubgraph(int n, List<int>[] edges, List<int> cycle)
    {
        while (true)
        {
            DeleteExtraEdge(edges, cycle);
            var ex = 0;
            for (int i = 0; i < cycle.Count; i++)
            {
                var cur = cycle[i];
                if (edges[cur].Count > 1)
                {
                    var next = cycle[(i + 1) % cycle.Count];
                    ex = edges[cur].First(v => v != next);
                    break;
                }
            }
            if (ex == 0)
            {
                return cycle;
            }
            cycle = GetCycle(n, edges, ex);
        }
    }

    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var N = vals[0];
        var M = vals[1];
        var edges = Enumerable.Range(0, N + 1).Select(_ => new List<int>()).ToArray();
        for (int i = 0; i < M; i++)
        {
            vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            edges[vals[0]].Add(vals[1]);
        }

        var cycle = GetCycle(N, edges);
        if (cycle == null)
        {
            Console.WriteLine(-1);
            return;
        }
        cycle = GetInducedSubgraph(N, edges, cycle);
        Console.WriteLine(cycle.Count);
        Console.WriteLine(string.Join(Environment.NewLine, cycle));
    }
}

Measured memory_bytes: 19764
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
// #include <atcoder/all>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vvll xy(2);
    for (int i = 0; i < n; i++) {
        ll x, y; cin >> x >> y;
        xy[0].emplace_back(x + y);
        xy[1].emplace_back(x - y);
    }
    sort(ALL(xy[0])), sort(ALL(xy[1]));
    cout << max(xy[0].back() - xy[0][0], xy[1].back() - xy[1][0]) << '\n';
    return 0;
}


Measured memory_bytes: 6692
import java.util.Scanner;
public class Main {
	    public static void main(String[] args){
	        Scanner sc=new Scanner(System.in);
	        int i=0,j=0;
	        while(true){
	            int H=sc.nextInt();
	            int W=sc.nextInt();
	            if(H==0&&W==0)break;
	            else for(i=0;i<H;i++){
	                for(j=0;j<W;j++){
	                	if(i%2==1&&j%2==1){
	                    System.out.print("#");
	                	}
	                	else if(i%2==1&&j%2==0)System.out.print(".");
	                	else if(i%2==0&&j%2==1)System.out.print(".");
	                	else System.out.print("#");
	                }
	                System.out.print("\n");
	        }
	            System.out.print("\n");
	    }
	}
	
}


Measured memory_bytes: 37480
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

type Tree struct {
	key   int
	left  *Tree
	right *Tree
}

func (t *Tree) insert(n int) *Tree {
	if t == nil {
		return &Tree{key: n}
	}

	if n < t.key {
		t.left = t.left.insert(n)
	} else {
		t.right = t.right.insert(n)
	}
	return t
}

func (t *Tree) find(n int) bool {
	switch {
	case t == nil:
		return false
	case t.key == n:
		return true
	case n < t.key:
		return t.left.find(n)
	default:
		return t.right.find(n)
	}
}

func (t *Tree) delete(n int) *Tree {
	if t == nil {
		return nil
	}

	if t.key == n {
		switch {
		case t.left == nil && t.right == nil:
			return nil
		case t.left != nil && t.right != nil:
			t.right, t.key = t.right.deleteFirst()
			return t
		case t.left == nil:
			return t.right
		default:
			return t.left
		}
	}

	if n < t.key {
		t.left = t.left.delete(n)
	} else {
		t.right = t.right.delete(n)
	}
	return t
}

// deleteFirst deletes the first node as in-ordered.
// t should not be nil.
func (t *Tree) deleteFirst() (*Tree, int) {
	if t.left == nil {
		return nil, t.key
	}
	left, key := t.left.deleteFirst()
	t.left = left
	return t, key
}

func main() {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	nextInt := func() int { scn.Scan(); r, _ := strconv.Atoi(scn.Text()); return r }
	w := bufio.NewWriter(os.Stdout)

	m := nextInt()
	var t *Tree

	for i := 0; i < m; i++ {
		switch scn.Scan(); scn.Text() {
		case "insert":
			t = t.insert(nextInt())
		case "find":
			if t.find(nextInt()) {
				fmt.Fprintln(w, "yes")
			} else {
				fmt.Fprintln(w, "no")
			}
		case "delete":
			t = t.delete(nextInt())
		case "print":
			inorder(w, t)
			fmt.Fprintln(w)
			preorder(w, t)
			fmt.Fprintln(w)
		}
	}

	w.Flush()
}

func preorder(w io.Writer, t *Tree) {
	if t == nil {
		return
	}
	print(w, t.key)
	preorder(w, t.left)
	preorder(w, t.right)
}

func inorder(w io.Writer, t *Tree) {
	if t == nil {
		return
	}
	inorder(w, t.left)
	print(w, t.key)
	inorder(w, t.right)
}

func print(w io.Writer, n int) {
	fmt.Fprintf(w, " %d", n)
}


Measured memory_bytes: 22208
#include <stdio.h>

int main(void)
{
	int s[200000],N,i,a;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		s[i]=0;
	}
	for(i=0;i<N-1;i++){
		scanf("%d",&a);
		s[a-1]++;
	}
	for(i=0;i<N;i++)printf("%d\n",s[i]);
	return 0;
}

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

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

const int INF = 1000000007;

int main(void){
	int n; cin>>n;
	int c[n] = {0}, s[n] = {0}, f[n] = {0};
	for(int i=0;i<n-1;i++) cin>>c[i]>>s[i]>>f[i];

	for(int i=0;i<n;i++) {
		int ans = 0;
		for(int j=i;j<n-1;j++) {
			if(ans < s[j]) ans = s[j];
			else if(ans % f[j] == 0);
			else ans = ans + f[j] - (ans % f[j]);
			ans += c[j];
		}

		cout<< ans <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))

sousa = []

for i in range(N,0,-1):
  for j in range(i,0,-1):
    if B[j-1] == j:
      sousa.append(j)
      del B[j-1]
      break
      
  if j <= 0:
    break
    
if len(B) > 0:
  print(-1)
  exit(0)
#print(sousa)

for i in range(N-1,-1,-1):
  print(sousa[i])

Measured memory_bytes: 38512
n, x = map(int, input().split())
xarr =list(map(int, input().split()))

xarr.append(x)

xarr.sort()

arr2 = []
for i in range(len(xarr)-1):
	arr2.append(xarr[i+1]-xarr[i])

def gcb(a, b):
	while b:
		a, b = b, a % b
	return a

gc = 0

if len(arr2) > 1:
	gc = gcb(arr2[0],arr2[1])
	for y in range(len(arr2)-1):
		gc = gcb(gc,arr2[y+1])
else:
	gc = arr2[0]
	
print(gc)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
typedef long long ll;
int n,rt=1,tot=1,ch[N][2];
bool lev[N],vis[N];
ll l;
int sg;
char s[N];
void Insert()
{
    int now=rt;
    for(int i=1;s[i];i++)
    {
        int p=s[i]-'0';
        if(!ch[now][p]) ch[now][p]=++tot;
        now=ch[now][p];
    }
    lev[now]=true;
}
int getsg(ll x)
{
    if(x==0) return 0;
    ll ans=1;
    while(x%4==0)
    {
        x/=4;ans+=2;
    }
    if(x%4==1||x%4==3) return ans;
    return ans+1;
}
void dfs(int u,int dep)
{
    if(lev[u]) return;
    if(!ch[u][0]||!ch[u][1])
    {
        int x=getsg(l-dep);
        if(x!=0)
        {
            vis[x]^=1;
            if(vis[x]) sg++;
            else sg--;
        }
    }
    if(ch[u][0]) dfs(ch[u][0],dep+1);
    if(ch[u][1]) dfs(ch[u][1],dep+1);
}
int main()
{
    scanf("%d%lld",&n,&l);
    while(n--)
    {
        scanf("%s",s+1);
        Insert();
    }
    dfs(rt,0);
    if(sg) printf("Alice\n");
    else printf("Bob\n");
}


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

int main()
{
	#define int long long int
	int n,w;
	cin>>n>>w;
	vector<pair<int,int> >v;
	int dp[103][100003];
	v.push_back({0,0});
	for(int i=0;i<n;i++)
		{
			int a,b;
			cin>>a>>b;
			v.push_back(make_pair(a,b));
		}
	for(int i=0;i<=n;i++)
		dp[i][0]=0;
	for(int i=0;i<=w;i++)
		dp[0][i]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=w;j++)
		{   if(v[i].first>j)
            dp[i][j]=dp[i-1][j];
            else
			dp[i][j]=max(dp[i-1][j],v[i].second+dp[i-1][j-v[i].first]);

		}
	}
	cout<<dp[n][w]<<endl;
	return 0;


}


Measured memory_bytes: 80640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
using namespace std;
int main() {
  int x, y;
  cin >> x >> y;
  cout << x * y << ' ' << 2 * (x + y) << endl;
  return 0;
}

Measured memory_bytes: 3044
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll, ll>;
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, K;
	cin >> N >> K;
	if (K == 1)
		cout << 0 << endl;
	else
		cout << N - K << endl;
	return 0;
}






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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = (ll) (80 * 80 * 10);
pll G[85][85];
bool dp[85][85][MAX];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H, W;
    cin >> H >> W;
    REP(i, H) {
        REP(j, W) {
            cin >> G[i][j].first;
        }
    }
    REP(i, H) {
        REP(j, W) {
            cin >> G[i][j].second;
        }
    }

    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = dp[1][0][0] = dp[0][1][0] = true;
    REP(i, H) {
        REP(j, W) {
            ll d = abs(G[i][j].first - G[i][j].second);
            REP(n, MAX) {
                if (dp[i + 1][j][n] || dp[i][j + 1][n]) {
                    dp[i + 1][j + 1][n + d] = dp[i + 1][j + 1][abs(n - d)] = true;
                }
            }
        }
    }

    REP(i, MAX) {
        if (dp[H][W][i]) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  int n;
  cin >> n;
  int a[n];
  REP(i, n) cin >> a[i];
  sort(a, a+n);
  int dif = INF, ans = 0;
  REP(i, n-1){
    if(a[n-1]%2 == 0){
      if(dif > abs(a[n-1]/2 - a[i])){
        dif = abs(a[n-1]/2 - a[i]);
        ans = a[i];
      }
    }
    else{
      if(dif > abs(a[n-1]/2 - a[i])){
        dif = abs(a[n-1]/2 - a[i]);
        ans = a[i];
      }
      if(dif > abs(a[n-1]/2 + 1 - a[i])){
        dif = abs(a[n-1]/2 + 1 - a[i]);
        ans = a[i];
      }
    }
  }
  cout << a[n-1] << " " << ans << endl;
  return 0;
}


Measured memory_bytes: 640
from collections import Counter
N,K=map(int,input().split())
A=list(map(int,input().split()))
l=[]
c=Counter(A)
value=list(c.values())
key=list(c.keys())
count=0
for i in range(len(key)):
    l.append([key[i],value[i]])
l.sort(key=lambda x:x[1])
#print(l)
for i in range(len(key)-K):
    count=count+l[i][1]
print(count)

Measured memory_bytes: 118088
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean flg = false;
        for (int i = 0 ; i < N ; i++) {
            String s = sc.next();
            if (s.equals("Y")) {
                flg = true;
            }
        }
        if (flg) {
            System.out.println("Four");
        } else {
            System.out.println("Three");
        }
    }

}

Measured memory_bytes: 20820
N = int(input())
H = list(map(int,input().split()))
a = []
cnt = 0
for i in range(N-1):
  if cnt-H[i]>1:
    print("No")
    exit() 
  elif H[i]>H[i+1] and H[i]-H[i+1]==1:
    a.append(H[i]-1)
    cnt = max(cnt,H[i])
  elif H[i]<=H[i+1]:
    a.append(H[i])
    cnt = max(cnt,H[i])
  else:
    print("No")
    exit()
if cnt-H[N-1]>1:
  print("No")
  exit()
print("Yes")


Measured memory_bytes: 14704
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<vector<vector<ll>>> f(n, vector<vector<ll>>(5, vector<ll>(2)));
    REP(i, n) REP(j, 5) REP(k, 2) cin >> f[i][j][k];
    vector<vector<ll>> p(n, vector<ll>(11));
    REP(i, n) REP(j, 11) cin >> p[i][j];

    ll ans = -INF;
    REP(i, 1LL << 10) {

        if (!i) continue;

        vector<ll> c(n, 0);
        REP(j, n) REP(k, 5) REP(l, 2) {
            if (f[j][k][l] && (1LL << (k*2+l)) & i) {
                c[j]++;
            }
        }

        ll term = 0;
        REP(i, n) term += p[i][c[i]];

        chmax(ans, term);

    }

    cout << ans << endl;
    
}

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

#define Fi first
#define Se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)
typedef tuple<int, int, int> t3;

int N, A[1000010];
char buf[1000010];

int f(int x) {
	int res = 0;
	while(x >= 2) res += x / 2, x >>= 1;
	return res;
}

int C(int n, int r) {
	return f(n) - f(r) - f(n-r) == 0 ? 1 : 0;
}

int main() {
	scanf("%d", &N);
	scanf("%s", buf + 1);
	for(int i=1;i<N;i++) {
		int x = buf[i] - '0', y = buf[i+1] - '0';
		A[i] = abs(x - y);
	}
	--N;
	if(N == 1) {
		printf("%d\n", A[1]);
		return 0;
	}
	int oc = 0;
	for(int i=1;i<=N;i++) {
		oc = (oc + C(N-1, i-1) * A[i]) % 2;
	}
	if(oc) puts("1");
	else {
		int e1 = 0;
		for(int i=1;i<=N;i++) if(A[i] == 1) e1 = 1;
		if(e1) {
			puts("0");
		}
		else {
			for(int i=1;i<=N;i++) A[i] /= 2;
			oc = 0;
			for(int i=1;i<=N;i++) oc = (oc + C(N-1, i-1) * A[i]) % 2;
			if(oc) puts("2");
			else puts("0");
		}
	}
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
#define RS(a) string  a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
signed main()
{
    fastio;
    R(d);R(t);R(s);
    if(t*s>=d)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    
}


Measured memory_bytes: 3648
package main

import(
	"fmt"
	"strconv"
) 

func main(){
	var S string
	fmt.Scan(&S)
	
	var m int
	m, _ = strconv.Atoi(S[5:7])

	if m < 5 {
		fmt.Println("Heisei")
	} else{
		fmt.Println("TBD")
	}
}

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

int n, arr[100005], le[100005], ri[100005], ans;

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


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

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


	for(int i = 0; i < n; i++){
		le[i+1] = gcd(le[i], arr[i]);
	}


	for(int i = n; i >= 1; i--){
		ri[i] = gcd(ri[i+1], arr[i-1]);
	}

	ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, gcd(le[i-1],ri[i+1]));
	}
	
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	int s[105];
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sum += s[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	int min = 1e5;
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (min > s[i] && s[i] % 10 != 0) {
			min = s[i];
			count++;
		}
	}
	if (count == 0) {
		cout << "0" << endl;
	}
	else {
		cout << sum - min << endl;
		return 0;
	}
	return 0;
}

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

#define MAX_E 2005
#define MAX_V 1005
#define INF 1e15

// 頂点fromから頂点toへのコストcostの辺
struct edge {
    long long int from, to, cost;
};

edge es[MAX_E]; // 辺

long long int d[MAX_V]; // 最短距離
int V, E;     // Vは頂点数、Eは辺数

// s番目の頂点から各頂点への最短距離を求める
bool shortest_path(int s) {
    for (int v=0;v<10*V;++v) {
        bool update = false;
        for (int i = 0; i < E; i++) {
            edge e = es[i];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if (!update)
            break;
    }
}

int main(){
    cin >> V >> E;

    for (int i = 0; i <= V; i++)
        d[i] = INF;
    d[1] = 0;

    for(int i=0;i<E;++i){
        int a, b, c;
        cin >> a >> b >> c;
        es[i] = (edge){a, b, -c};
    }

    shortest_path(1);
    long long int first = d[V];
    shortest_path(1);

    if(d[V] != first)cout << "inf" << endl;
    else cout << -d[V] << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    char X, Y;
    cin >> X >> Y;
    if(X < Y) puts("<");
    else if(X == Y) puts("=");
    else puts(">");
    return 0;
}

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

int main()
{
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;

    if(U == S){
        cout << --A;
        cout << " ";
        cout << B;
    }else{
        cout << A;
        cout << " ";
        cout << --B;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int i;
        int x;
        for(i=1;i<=n;i++){
            x=i;
            if(x%3==0)System.out.printf(" %d",i);
            else{
                while(x!=0){
                    if(x%10==3){
                        System.out.printf(" %d",i);
                        break;
                    }
                    x/=10;
                }
            }
        }
        System.out.printf("\n");
  }
}


Measured memory_bytes: 37972
#include<string.h>
char map[101*100],*M="><^v.*";
W,H,i,p;
main(){
	for(;scanf("%d%d\n",&H,&W),W;){
		for(i=0;i<(W+1)*H;i++)
			map[i]=getchar();
		for(p=0;;){
			i=strchr(M,map[p])-M;
			map[p]='*';
			if(i==0)
				p++;
			if(i==1)
				p--;
			if(i==2)
				p-=W+1;
			if(i==3)
				p+=W+1;
			if(i==4){
				printf("%d %d\n",p%(W+1),p/(W+1));
				break;
			}
			if(i==5){
				puts("LOOP");
				break;
			}
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll ans=1;
char s[200005];
int t[27];
int main (){
	scanf ("%s",s+1);
	int len=strlen(s+1),i;
	for (i=len;i>=1;i--)
	{ans+=(len-i-t[s[i]-'a']);
	t[s[i]-'a']++;
	}
	printf ("%lld\n",ans);
	return 0;
}
	

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
void init(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main()
{
  init();
  int n; cin >> n;
  vector<double> p(n); for(auto& e:p) cin >> e;
  vector<vector<double> > dp(n + 1,vector<double>(n + 1,0.0));
  dp[1][0] = 1 - p[0];
  dp[1][1] = p[0];
  for(int i = 1; i < n; i ++){
    dp[i + 1][0] = dp[i][0]*(1 - p[i]);
    for(int j = 0; j <= i; j ++){
      dp[i + 1][j + 1] = dp[i][j]*p[i] + dp[i][j + 1]*(1 - p[i]);
    }
    
  }
  double ans = 0;
  REP(i,n + 1){
    if(i > n/2){
      ans += dp[n][i];
    }
    // cout << dp[n][i] << endl;
  }
  cout << ans << endl;
}


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

int S, a, b, c;

int main() {
    cin >> S;
    a = S / 3600;
    b = (S % 3600) / 60;
    c = S % 60;
    cout << a << ":" << b << ":" << c << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> a(q);
  vector<int> ans(n);
  for(int i=0;i<q;i++){
    cin>>a.at(i);
    a.at(i)--;
    ans.at(a.at(i))++;
  }
  for(int i=0;i<n;i++){
    if(ans.at(i)>(q-k)){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
    
  return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

/**
 * Q1
 */
public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        int count = 1;
        int i = 0;
        while(true){
            if (b <= count) {
                System.out.println(i);
                break;
            }

            count += a - 1;
            i++;
        }
    }
}

Measured memory_bytes: 22612
import java.lang.String
import java.math.BigDecimal


fun main() {
    val (n, d) = readLine()!!.split(" ").map { it.toInt() }
    val x= Array(n){ readLine()!!.split(" ").map { it.toInt() }.toIntArray()}
    fun dist(a: IntArray, b: IntArray):Boolean{
        var d=0
        for (i in 0 until a.size){
            d+=(a[i]-b[i])*(a[i]-b[i])
        }

        val bigDecimal = BigDecimal(String.valueOf( Math.sqrt(d.toDouble()) ))
        val intValue: Int = bigDecimal.toInt()
        val sub=bigDecimal.subtract(
            BigDecimal(intValue)
        ).toDouble()
        if (sub==0.toDouble()){
            return true
        }
        return false
    }
    var ans=0
    for (i in 0 until n){
        for (j in i+1 until n){
            if (dist(x[i], x[j])){ans++}
        }
    }
    println(ans)
}

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

int main(){ 
    int n;
    cin>>n;
    int b=1;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
        if(a[i]!=a[i+1]){
            b++;
        }
    }
    cout<<b;
    return 0;
}


Measured memory_bytes: 256