akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>

int main(int argc, char **argv)
{
    long long X, Y;
    std::cin >> X >> Y;

    if(std::abs(X-Y) <= 1){
        std::cout << "Brown" << std::endl;
    }else{
        std::cout << "Alice" << std::endl;
    }

    
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

#define NIL -1
#define MAX 100000

struct Node {
    int parent = NIL;
    ll depth = 0; // 親との距離
    vector<int> children = vector<int>();
    int s = 0;
};

int main(void) {
    Node tree[MAX + 1];
    int N;
    cin >> N;

    rep(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        tree[b].parent = a;
        tree[b].depth = c;
        tree[a].children.push_back(b);
    }

    int Q, K;
    cin >> Q >> K;

    // 木をK基点でDFSする
    stack<int> S;
    int searched[N + 1] = {}; 
    ll toK[N + 1] = {};

    S.push(K);
    searched[K] = 1;
    toK[K] = 0;
    
    while (!S.empty()) {
        int u = S.top();

        bool flag = false;
        for (int i = tree[u].s; i < tree[u].children.size(); ++i) {
            int child = tree[u].children[i];
            if (searched[child] == 0) {
                searched[child] = 1;

                ll parent_depth = tree[child].parent != NIL ? toK[tree[child].parent] : 0;
                toK[child] = parent_depth + tree[child].depth;
                S.push(child);
                flag = true;
                tree[u].s = i;
                break;
            }
        }

        if (!flag) {
            ll parent = tree[u].parent;
            if (parent != NIL && searched[parent] == 0) {
                searched[parent] = 1;

                toK[parent] = toK[u] + tree[u].depth;
                S.push(parent);
                flag = true;
            }
        }

        if (!flag) {
            searched[u] = 2;
            S.pop();
        }

    }

    // 距離を求める
    rep(i, Q) {
        int x, y;
        cin >> x >> y;
        cout << toK[x] + toK[y] << endl;
    }

    return 0;
}

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

const int MAX = 2000010;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}


int main() {
    COMinit();
    ll k;
    std::cin >> k;
    string s;
    std::cin >> s;
    
    ll n = s.size();
    ll ans = 0;
    for (int i = 0; i <= k; i++) {
        ans += COM(n+i-1,n-1)*mod_pow((ll)26,(ll)k-i,MOD)%MOD*mod_pow((ll)25,(ll)i,MOD)%MOD;
        ans %= MOD;
    }
    
    std::cout << ans << std::endl;
}


Measured memory_bytes: 52188
h,w=map(int,raw_input().split())
l=[]
#l=map(int,raw_input().split())
for i in range(h):
    l.append(list(raw_input()))
l[0][0]='.'
x=y=0
while 1:
    if x+1<w and l[y][x+1]=='#':
        x+=1
        l[y][x]='.'
    elif y+1<h and l[y+1][x]=='#':
        y+=1
        l[y][x]='.'
    else:
        break
for i in l:
    if '#' in i:
        print 'Impossible'
        exit()
print 'Possible'


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

using namespace std;

#define PB push_back
#define f first
#define s second

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

const ll MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)1e5+2;

ll n, K, num[MAXN], p[MAXN];

ll powMod(ll n, ll p, ll mod)
{
    ll res = 1;
    while (p)
    {
        if (p & 1)
            (res *= n) %= mod;
        (n *= n) %= mod;
        p >>= 1;
    }
    return res;
}


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

    cin >> n >> K;
    p[1] = 1;
    for(int i=2; i<=K; i++)
    {
        p[i] = powMod(i, n, MOD);
    }

    for(int i=K; i>=1; i--)
    {
        num[i] = p[K/i];
        for(int j=2*i; j <= K; j+=i)
        {
            num[i] = (MOD + num[i] -num[j])%MOD;
        }
    }
    ll ans = 0;
    for(ll i=1; i<=K; i++)
    {
        ans = (ans + (i*num[i])%MOD)%MOD;
    }

    cout << ans;
    return 0;
}


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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n, a, b;
    cin >> n >> a >> b;
    
    if (a % 2 == b % 2) {
        cout << "Alice";
    } else {
        cout << "Borys";
    }

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    final int modder=1000000007;
    int n=sc.nextInt();
    int m=sc.nextInt();
    int dp[]=new int[n+1];
    Arrays.fill(dp,0);
    for(int i=0;i<m;i++){
      dp[sc.nextInt()]=-1;
    }
    dp[0]=1;
    dp[1]=dp[1]==-1?0:1;
    for(int i=2;i<=n;i++){
      if(dp[i]!=-1){
        dp[i]=(dp[i-1]+dp[i-2])%modder;
      }else{
        dp[i]=0;
      }
    }
    System.out.println(dp[n]);
  }
}


Measured memory_bytes: 51048
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
int i,j,k,l;
static const int MAX_N=10e5;
long A[MAX_N+1];//,dp[][];
long mini=10e10,maxs=0;
int main(void){
	int N;cin >> N;
	rep_(i,1,N){
		cin >> A[i];
	}int ans=0,take=0;
	rep_(i,1,N-1){
		if(A[i]>=A[i+1]){
			take++;
		}
		else{
			ans=max(take,ans);
			take=0;
		}
	}ans=max(take,ans);
	puts(ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    int sum = 0;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        sum += arr[i];
    }
    int make = sum/n;
    int ans1 = 0;
    int ans2 = 0;
    for (int i = 0; i <  n; i++) {
        ans1 += pow(abs(arr[i] - make) , 2);
    }
    make++;
    for (int i = 0; i < n; i++) {
        ans2 += pow(abs(arr[i] - make) , 2);
    }
    cout << min(ans1 , ans2) << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>

void gc(int* x){
    *x = 0;
    for(;;){
        int c=getchar();
        if('0'<= c && c <='9'){
            *x = *x*10 + c-'0';
        }else{
            break;
        }
    }
}

int main(void){
    using namespace std;
    constexpr int KMAX = 10000;
    static int s[KMAX+1][2*KMAX+1];
    char c;
    int n, k, x, y;
    /*
       cin.sync_with_stdio(false);
       cout.sync_with_stdio(false);
       cin.tie(nullptr);
       cout.tie(nullptr);
       cin >> n >> k;
       */
    scanf("%d %d\n", &n, &k);
    for(int i=0; i<n; i++){
        //cin >> x >> y >> c;
        gc(&x);
        gc(&y);
        c=getchar();
        getchar();
        //scanf("%d %d %c", &x, &y, &c);
        y %= 2*k;
        if(c=='W'){
            if(y>=k){
                y-=k;
            }else{
                x+=k;
            }
        }else{
            if(y>=k){
                y-=k;
                x+=k;
            }
        }
        x %= 2*k;
        s[y+1][x+1]++;
    }
    for(int y=0; y<k; y++){
        for(int x=0; x<2*k; x++){
            s[y+1][x+1] += s[y][x+1] + s[y+1][x] - s[y][x];
        }
    }
    int max = 0;
    int v = s[0][0] - s[0][2*k];
    for(int y=0; y<k; y++){
        int u = v - s[y][0] + s[y][2*k];
        for(int x=0; x<k; x++){
            int t = u - s[0][x] - s[k][x] + s[0][x+k] + s[k][x+k] + 2*s[y][x] - 2*s[y][x+k];
            t = t<n/2 ? n-t : t;
            max = t>max ? t : max;
        }
    }
    //cout << max;
    printf("%d", max);
    return 0;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (500006)
ll n,A[MAXN],mod=1e9+7,sum[MAXN],ans,zero[MAXN];
vector<int> v[1<<20|6];
int main(){
	cin>>n;
	FOR(i,1,n)cin>>A[i];
	FOR(i,1,n)sum[i]=sum[i-1]^A[i];
	FOR(i,1,n)zero[i]=zero[i-1]+(sum[i]==0);
	FOR(i,1,n)v[sum[i]].eb(i);
	ans=1;
	if(sum[n]==0) FOR(i,1,zero[n]-1)ans*=2,ans%=mod;
	// FOR(i,1,n)cerr<<sum[i]<<' ';cerr<<'\n'; // FOR(i,1,n)cerr<<zero[i]<<' '; cerr<<'\n'; // cerr<<ans<<'\n';
	FOR(val,1,(1<<20)-1)if(siz(v[val]))if(sum[n]==0||sum[n]==val){
		// must -1 if this includes the whole thing
		// can only start with x
		vector<ll> num(siz(v[val])+1,0);
		FOR(j,1,siz(v[val])-1){
			num[j]=zero[v[val][j]]-zero[v[val][j-1]];
		}
		DEC(i,siz(num)-2,0)num[i]+=num[i+1];
		ll add=1, grad=0;
		FOR(j,0,siz(v[val])-1){
			ll dp=add-num[j+1]*grad%mod+mod;dp%=mod;
			if(sum[n]==0||v[val][j]==n) ans += dp, ans %= mod;
			add += dp * num[j+1] % mod, add %= mod;
			grad += dp, grad %= mod;
		}
		if(sum[n]==val) { -- ans, ans += mod, ans %= mod; }
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 49156
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    G = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = LI_()
        G[a].append((b, i))
        G[b].append((a, i))

    ans = [0] * (N - 1)
    visited = [False] * N

    def dfs(c, color_p):
        visited[c] = True
        color = 0
        for n, i in G[c]:
            if not visited[n]:
                if color == color_p:
                    color += 1
                ans[i] = color
                dfs(n, color)
                color += 1

    dfs(0, -1)

    print(max(ans) + 1)
    for i in ans:
        print(i + 1)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 96164
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<assert.h>
#define INF 0x3f3f3f3f//3f3f3f3f
#define ll long long
#define ull unsigned long long
#define lowbit(a) ((a)&(-(a)))
using namespace std;
bool vis[100005];
int a[100005],b[100005];
int main() {
    int n;
    while(~scanf("%d",&n)){
        typedef pair<int,int> P;
        priority_queue<P> queA,queB;
        for(int i = 1;i<=n;i++){
            scanf("%d%d",&a[i],&b[i]);
            vis[i] = 0;
            queA.push(P(a[i]+b[i],i));
            queB.push(P(b[i]+a[i],i));
        }
        ll ans = 0;
        for(int i = 1;i<=n;i++){
            if(i&1){
                while(vis[queA.top().second])queA.pop();
                P d = queA.top();queA.pop();
                vis[d.second] = 1;
                ans += a[d.second];
            }else{
                while(vis[queB.top().second])queB.pop();
                P d = queB.top();queB.pop();
                vis[d.second] = 1;
                ans -= b[d.second];
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2924
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n,k,i;
  cin>>n>>k;

  vector<int> e;
  e.resize(n);

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

  int max=0;
  int tmp=0;
  for(i=0;i<k;i++){
    tmp+=e[i];
  }
  max=tmp;

  for(;i<n;i++){
    tmp-=e[i-k];
    tmp+=e[i];

    if(max<tmp){
      max=tmp;
    }
  }

  printf("%lf\n",max/2.0+double(k));
  //cout<<max/2.0+double(k)<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

int main()
{
    int n, l;
    string s[111];
    cin >> n >> l;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    sort(s, s + n);
    for (int i = 0; i < n; i++)
    {
        cout << s[i];
    }
    cout << endl;
}

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

int32_t main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int k, n=3, res=0;
    vector<int> cards(n);
    vector<int> mul = {-1, 0, 1};
    cin >> cards[2] >> cards[1] >> cards[0] >> k;
    while(n--){
        if(k <= cards[n]){
            res += k*mul[n];
            break;
        } else {
            res += cards[n]*mul[n];
            k = k - cards[n];
        }
    }
    cout << res << "\n";
}

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

#define int long long int
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
bool sortbysecdesc(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second>b.second; 
} 
 
/*
Mistakes
 
- while using pairs make sure you comparator datatype it's int by default change it as per the need
- Modify comparator if you want to
*/
#define f first
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll64 int64_t
#define pb push_back
#define pll pair<long long int,long long int>
#define pi pair<int,int>
#define mi map<int,int>
#define mll map<long long int,long long int>
#define umi unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define vpi vector<pair<int,int>>
#define vpll vector<pair<long long int,long long int>>
#define mod 1000000007
#define fp(i,x,n) for(int i=x;i<n;i++)
#define fn(i,x,n) for(int i=x;i>n;i--)
#define fpm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define asort_vp_second(vect) sort(vect.begin(), vect.end(), sortbysec)
#define asort_vp_first(vect) sort(vect.begin(), vect.end())
#define dsort_vp_first(vect) sort(vect.begin(), vect.end(), sortinrev) 
#define dsort_vp_second(vect) sort(vect.begin(), vect.end(), sortbysecdesc)
#define vi vector<int>
#define vll vector<long long int>
#define c(x) cout<<x<<endl;
#define M 1000000007
using namespace std; 

signed main()
{
    int n;
    cin>>n;
    int a[n];
    
    fp(i,0,n)
    cin>>a[i];
    
    int mx=a[0];
    int ans=0;
    fp(i,0,n-1)
    {
        if(a[i+1]-a[i]<0){
        ans+=abs(a[i]-a[i+1]);
        a[i+1]=a[i];}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5168
@cache = {}

def count(x)
  return 0 if x == 0 || x.odd?
  return @cache[x] if @cache.key?(x)
  @cache[x] = count(x / 2) + 1
end

n = gets.to_i
digits = gets.split.map(&:to_i)

puts digits.reduce(0){|sum, digit| sum + count(digit)}

Measured memory_bytes: 8700
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

struct Edge
{
    int to;
    int cap;
    int rev;
};

void add_edge(map<int, vector<Edge>> &g, int from, int to, int cap)
{
    g[from].push_back((Edge){to, cap, (int)g[to].size()});
    g[to].push_back((Edge){from, 0, (int)g[from].size() - 1});
}

int dfs(map<int, vector<Edge>> &g, map<int, bool> &visited, int cur, int dst, int f)
{
    if (cur == dst)
        return f;
    visited[cur] = true;
    for (auto &e : g[cur])
    {
        //cerr << e.cap << endl;

        assert(e.cap == 0 || e.cap == 1);

        if (!visited[e.to] && e.cap > 0)
        {
            int tmp = dfs(g, visited, e.to, dst, min(f, e.cap));
            if (tmp > 0)
            {
                e.cap -= tmp;
                g[e.to][e.rev].cap += tmp;
                return tmp;
            }
        }
    }
    return 0;
}
int maxFlow(map<int, vector<Edge>> &g, int s, int t)
{
    map<int, bool> visited;
    int ret = 0, tmp = 0;
    do
    {
        visited.clear();
        tmp = dfs(g, visited, s, t, IINF);
        ret += tmp;
        // cerr << tmp << endl;
    } while (tmp != 0);
    return ret;
}

int main(int argc, char const *argv[])
{
    map<int, vector<Edge>> g;
    int n;
    cin >> n;
    vector<pair<int, int>> blue, red;
    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        red.push_back({x, y});
    }
    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        blue.push_back({x, y});
    }
    rep(i, n) rep(j, n)
    {
        if (red[i].first < blue[j].first && red[i].second < blue[j].second)
        {
            add_edge(g, i, n + j, 1);
            // cerr << i << " -> " << n + j << endl;
        }
    }
    rep(i, n)
    {
        add_edge(g, 2 * n, i, 1);
        //  cerr << 2 * n << " -> " << i << endl;
    }
    rep(i, n)
    {
        add_edge(g, n + i, 2 * n + 1, 1);
        //  cerr << n + i << " -> " << 2 * n + 1 << endl;
    }

    // cerr << "go" << endl;
    cout << maxFlow(g, 2 * n, 2 * n + 1) << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

ll to_id(ll x, ll y) {
    return 21 * x + y;
}

void Main() {
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    rep(i, H) cin >> grid[i];

    Graph graph(450, vector<ll>(450, INF));
    rep(i, H) {
        rep(j, W) {
            if (grid[i][j] == '#') continue;
            rep(k, 4) {
                int x = dx[k];
                int y = dy[k];
                if (0 <= j + x && j + x < W && 0 <= i + y && i + y < H && grid[i + y][j + x] != '#') {
                    ll from = to_id(i, j);
                    ll to = to_id(i + y, j + x);
                    graph[from][to] = 1;
                    graph[to][from] = 1;
                }
            }
        }
    }
    warshall_floyd(graph);
    ll ans = 0;
    rep(i, H) {
        rep(j, W) {
            ll start = to_id(i, j);
            rep(i2, H) {
                rep(j2, W) {
                    ll goal = to_id(i2, j2);
                    ll tmp = graph[start][goal];
                    // print(tmp);
                    if (start == goal) continue;
                    if (tmp < INF) {
                        ans = max(tmp, ans);
                    }
                }
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int n,m;cin>>n>>m;
    vector<int> d(n,-1);
    rep(i,m){
        int s,c;cin>>s>>c;
        s--;
        if(s==0&&c==0){
            if(n!=1){cout<<-1<<endl;
            return 0;
            }
        }
        if(d[s]==-1||d[s]==c)d[s]=c;
        else{
            cout<<-1<<endl;
            return 0;
        }
    }
    rep(i,n){
        int x=d[i];
        if(x==-1){
            if(i==0&&n!=1)x=1;
            else x=0;
        }
        cout<<x;
    }
    cout<<endl;
}


Measured memory_bytes: 256
import math
n=int(input())
l=0

xi=[]
yi=[]

for i in range(n):
    x,y=map(int,input().split())
    xi.append(x)
    yi.append(y)

for j in range(n):
    for k in range(n):
        if j>=k:
            continue
        l+=math.sqrt((xi[j]-xi[k])**2+(yi[j]-yi[k])**2)

print(l*2/n)

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

using namespace std;

int main()
{
	int n, t, a, h;
	cin >> n >> t >> a;
	int ans = -1;
	double def = 1000000;
	for (int i = 0; i < n; i++)
	{
		cin >> h;
		if (def > abs((double)t - h * 0.006 - a))
		{
			ans = i + 1;
			def = abs((double)t - h * 0.006 - a);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
<?php
$RL=str_split(trim(fgets(STDIN)));
$ans=array_fill(0, count($RL), 0);
$i=0;
$j='R';
$RLKey_L=0;
foreach($RL as $k=>$v){
  if($v==$j){
      $i++;
  }else{
    if($v=='R'){
      //** L **
      $ans[$RLKey_L-1]+=floor($i/2);
      $ans[$RLKey_L]+=ceil($i/2);
    }else{
      //** R **
      $ans[$k-1]+=ceil($i/2);
      $ans[$k]+=floor($i/2);
      $RLKey_L=$k;
    }
    $i=1;
    $j=$v;
  }
}
//最後のL
$ans[$RLKey_L-1]+=floor($i/2);
$ans[$RLKey_L]+=ceil($i/2);

echo implode(" ",$ans);

Measured memory_bytes: 35724
n,m = map(int,input().split())
ab = [[-1] for i in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    if ab[a-1][-1] == -1:
        ab[a-1][-1] = b-1
    else:
        ab[a-1].append(b-1)
flg = False
for i, mid in enumerate(ab[0]):
    if n-1 in ab[mid]:
        flg = True
        break

if flg :print('POSSIBLE')
else:print('IMPOSSIBLE')


Measured memory_bytes: 70504
#include <iostream>
using namespace std;
#define DEBT 100000
#define INTEREST 5 //%
int main()
{
	int n;
	int sumdebt=DEBT;
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		sumdebt = sumdebt + (int)sumdebt*((float)INTEREST/100);
		if(sumdebt % 1000 != 0)
		{
			sumdebt = sumdebt + (1000-(sumdebt%1000));
		}
	}

	cout << sumdebt << endl;
	return(0);
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstring>
using namespace std;

string mkzero(int len) {
    char str[80];
    sprintf(str, "%0*d", len, 0);
    return string(str);
}

int main() {
    const char * fromA = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    const char * toA[] = {
        "101",
        "000000",
        "000011",
        "10010001",
        "010001",
        "000001",
        "100101",
        "10011010",
        "0101",
        "0001",
        "110",
        "01001",
        "10011011",
        "010000",
        "0111",
        "10011000",
        "0110",
        "00100",
        "10011001",
        "10011110",
        "00101",
        "111",
        "10011111",
        "1000",
        "00110",
        "00111",
        "10011100",
        "10011101",
        "000010",
        "10010010",
        "10010011",
        "10010000",
        ""
    };

    const char * fromB[] = {
        "00000",
        "00001",
        "00010",
        "00011",
        "00100",
        "00101",
        "00110",
        "00111",
        "01000",
        "01001",
        "01010",
        "01011",
        "01100",
        "01101",
        "01110",
        "01111",
        "10000",
        "10001",
        "10010",
        "10011",
        "10100",
        "10101",
        "10110",
        "10111",
        "11000",
        "11001",
        "11010",
        "11011",
        "11100",
        "11101",
        "11110",
        "11111",
        ""
    };

    const char * toB = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

    map<char, string> enc;
    for(int i = 0, len = strlen(fromA); i < len; i++) {
        enc.insert(make_pair(fromA[i], string(toA[i])));
    }

    map<string, char> dec;
    for(int i = 0, len = strlen(toB); i < len; i++) {
        dec.insert(make_pair(string(fromB[i]), toB[i]));
    }

#if 0
    for(map<char, string>::const_iterator it = enc.begin(); it != enc.end(); ++it) {
        cerr << it->first << " -> " << it->second << endl;
    }

    for(map<string, char>::const_iterator it = dec.begin(); it != dec.end(); ++it) {
        cerr << it->first << " -> " << it->second << endl;
    }
#endif

    for(string line; getline(cin, line); ) {
        ostringstream ss;
        for(int i = 0; i < (int)line.length(); i++)
            ss << enc[line[i]];
        if(ss.str().size() % 5 > 0) ss << mkzero(5 - ss.str().size() % 5);
        for(int i = 0; i < (int)ss.str().size() / 5; i++) {
            cout << dec[ss.str().substr(5*i, 5)];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1252
/* 

И пусть меня погубит, то к чему я
Бегу, не жалея ног.
И если мне суждено сгореть на восходе,
Я буду идти вперёд.

*/

#include <bits/stdc++.h>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()

using namespace std;

const bool dbg_flg = 0;
#define debug(x) if (dbg_flg) cerr << #x << ' ' << x << '\n'
#define debug_pair(x) if (dbg_flg) cerr << #x << ' ' << x.F << ' ' << x.S << '\n' 

const int inf = 1e9 + 7;
const int MAXN = 1e5 + 5;

int n, s[MAXN];
bool dp[MAXN];

void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
	}

	dp[0] = 1;

	int m = 10000 * 2;

	for (int i = 1; i <= n; i++) {
		for (int j = m - s[i]; j >= 0; j--) {
			if (!dp[j]) continue;

			dp[j + s[i]] = 1;
		}		
	}

	for (int i = m; i >= 0; i--) {
		if (i % 10 == 0) continue;

		if (dp[i]) {
			cout << i;
			
			return;
		}
	}

	cout << 0;
}

int main() {
	
	//~ freopen(".in", "r", stdin);
	//~ freopen(".out", "w", stdout);
	
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);

	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
	}

	return 0;
}

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

immutable int INF = 1 << 29;
int[][] adj;


void main() {
    auto N = readln.chomp.to!int;
    int E = 0;
    auto uf = new UnionFind(N);
    auto used = new bool[][](N, N);
    auto black = new string[](N);
    foreach (i; 0..N) black[i] = "0";
    string[] ans = ["!"];

    while (E < N - 1) {
        int a = uniform(0, N);
        int b = uniform(0, N);
        if (a == b) continue;
        if (used[a][b]) continue;
        if (uf.find(a) == uf.find(b)) continue;

        black[a] = black[b] = "1";
        writeln("? " ~ black.join(""));
        stdout.flush;
        auto radius = readln.chomp.to!int;
        if (radius == 1) {
            ans ~= ("(" ~ a.to!string ~ "," ~ b.to!string ~ ")");
            uf.unite(a, b);
        }
        E += radius;

        black[a] = black[b] = "0";
        used[a][b] = true;
        used[b][a] = true;
    }

    ans.join(" ").writeln;
    stdout.flush;

}


class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] < table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}


Measured memory_bytes: 2000
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String tmp[] = new String[10];
		String tmpStr;
		Map<String, Integer> map = new HashMap<String, Integer>();
		long answer = 0;

		for (int i = 0; i < N; i++) {
			tmpStr = sc.next();
			tmp = tmpStr.split("");
			Arrays.sort(tmp);

			if (map.containsKey(Arrays.toString(tmp))) {
				map.put(Arrays.toString(tmp), (int)map.get(Arrays.toString(tmp)) + 1);
			} else {
				map.put(Arrays.toString(tmp), 1);
			}
		}

		for (String key : map.keySet()) {
			long n = map.get(key);
			answer += (n * (n - 1)) / 2;
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 109040
#include <iostream>

using namespace std;

static const int N = 100;
static const int INF = 2001;

struct Vertex {
    bool is_visit;
    int min_w;
    int parent;
};

class MST {
private:
    int matrix[N][N];
    Vertex vertex[N];
    int n;

public:
    MST()
    {
        cin >> n;
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n; j++)
            {
                cin >> matrix[i][j];
                if(matrix[i][j] == -1)
                    matrix[i][j] = INF;
            }
        }
    }

    void prim()
    {
        for(int i = 0; i < n; i++)
        {
            vertex[i].is_visit = false;
            vertex[i].min_w = INF;
        }
        vertex[0].min_w = 0;
        vertex[0].parent = -1;

        while(true)
        {
            int u = -1;
            int mincost = INF;
            for(int i = 0; i < n; i++)
            {
                if(!vertex[i].is_visit && vertex[i].min_w < mincost)
                {
                    mincost = vertex[i].min_w;
                    u = i;
                }
            }

            if(mincost == INF)
                break;

            vertex[u].is_visit = true;

            for(int v = 0; v < n; v++)
            {
                if(!vertex[v].is_visit && matrix[u][v] != INF)
                {
                    if(matrix[u][v] < vertex[v].min_w)
                    {
                        vertex[v].min_w = matrix[u][v];
                        vertex[v].parent = u;
                    }
                }
            }
        }
    }

    void print()
    {
        int sum = 0;
        for(int i = 0; i < n; i++)
            if(vertex[i].parent != -1)
                sum += matrix[i][vertex[i].parent];
        cout << sum << endl;
    }
};

int main()
{
    MST mst;
    mst.prim();
    mst.print();
}


Measured memory_bytes: 3120
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
b = 1

for i in range(n):
    b *= a[i]
    if b > 10 ** 18:
        b = -1
        break

for i in range(n):
    if a[i] == 0:
        b = 0

print(b)

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

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<int, vector<int>, greater<int>> A;
    int a;
    for(int i = 0; i < N; i++) {
        cin >> a;
        A.push(a);
    }

    vector<pair<int, int>> bc(M);
    for(int i = 0; i < M; i++) {
        cin >> bc.at(i).second >> bc.at(i).first;
    }

    sort(bc.begin(), bc.end(), greater<pair<int, int>>());

    for(int i = 0; i < M; i++) {
        int b = bc.at(i).second;
        int c = bc.at(i).first;
        for(int i = 0; i < b; i++) {
            if(A.top() < c) {
                A.pop();
                A.push(c);
            } else {
                break;
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ans += A.top();
        A.pop();
    }

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

Measured memory_bytes: 1528
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll gcd(ll x, ll y) {
    if(y == 0) {
        return x;
    }
    else {
        return gcd(y, x%y);
    }
}

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

    cout << 3LL*(n - gcd(n, x)) << endl;
    return 0;
}

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

int main() {
  long long A, B;
  int K;
  cin >> A >> B >> K;
  if(A+K-1 >= B-K+1) {
    for(long long i = A; i <= B; i++) {
      cout << i << endl;
    }
  }
  else {
    for(long long i = A; i < A+K; i++) {
      cout << i << endl;
    }
    for(long long i = B-K+1; i <= B; i++) {
      cout << i << endl;
    }
  }
}


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

int main() {
	int a,b,c,d,e;
  	char s;
    cin>>s;
  if(s=='A')
    cout<<'T';
  else if(s=='C')
    cout<<'G';
  else if(s=='T')
    cout<<'A';
  else if(s=='G')
    cout<<'C';
  
  cout<<endl;
 
    
  return 0;
}

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

#define MAX 100

int main() {

  while(1) {
    int a=-1, b;
    int V = 0;
    int edge[MAX]={};
    while(cin>>a>>b&&(a+b)) {
      V = max(V, max(a, b));
      a--, b--;
      edge[a]++, edge[b]++;
    }
    
    if(a==-1) break;
    
    bool flag = false;
    
    if( edge[0]%2==0 || edge[1]%2==0 ) flag = true;
    
    for( int i=2; i<V; i++ ) if( edge[i] % 2 == 1 ) flag = true;
    
    cout << ( flag ? "NG" : "OK" ) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55;
int n,a[N],b[N],m=0;bool v[N][N],f[N][N];
ll bin[N],ans=0;
inline bool check(int x){
	for(int i=0;i<=m;i++)for(int j=0;j<=m;j++)f[i][j]=v[i][j];
	for(int i=0;i<=m;i++)
		for(int j=1;j<=x;j++)f[i][i%j]=1;
	for(int k=0;k<=m;k++)
		for(int i=0;i<=m;i++)
		     if(f[i][k]) 
				for(int j=0;j<=m;j++)f[i][j]|=f[i][k]&f[k][j];
	for(int i=0;i<=n;i++)if(!f[a[i]][b[i]])return true;
	return false;
}
int main(){
	scanf("%d",&n);
	bin[0]=1;
	for(int i=1;i<=50;i++)bin[i]=bin[i-1]<<1;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),m=max(m,a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]);
	for(int i=0;i<=m;i++)v[i][i]=1;
	for(int i=m;i>=1;i--)
		if(check(i-1)){
			for(int j=0;j<=m;j++)v[j][j%i]=1;
			ans+=bin[i];
		}	
	for(int k=0;k<=m;k++)
		for(int i=0;i<=m;i++)
			for(int j=0;j<=m;j++)v[i][j]|=v[i][k]&v[k][j];
	for(int i=1;i<=n;i++)
		if(!v[a[i]][b[i]])puts("-1"),exit(0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
using namespace std;

int main(int argc, char const *argv[])
{
	int n, m, l=0;
	cin >> n >> m >> l;
	long int  A[n][m],B[m][l],C[n][l];
	int i,j,k=0;
	int a,b=0;



	for (i = 0; i < n; ++i)
	{
		for (j = 0; j < m; ++j)
		{
			cin >> A[i][j];
		}
	}

	for (i = 0; i < m; ++i)
	{
		for (j = 0; j < l; ++j)
		{
			cin >> B[i][j];
		}
	}

	for (i = 0; i < n; ++i)
	{
		for (j = 0; j < l; ++j)
		{
			C[i][j] = 0;
		}
	}

	for (i = 0; i < n; ++i)
	{
		for (j = 0; j < l ; ++j)
		{
			for(k = 0; k < m; k++)
			{
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}

 	for (i=0;i<n;i++)
 	{
 		for (j=0;j<l;j++)
 		{
 			if(j!=l-1)
 			{
 				cout << C[i][j] << " ";
 			}
 			else
 			{
 				cout << C[i][j];
 			}
 		}
 		cout << endl;
 	}

	return 0;
}


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

using namespace std;

bool is_prime(int x) {
  for (int i = 2; i < x; i ++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

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

  int x;
  cin >> x;
  while (!is_prime(x)) {
    x += 1;
  }
  cout << x << endl;
}

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

typedef long long ll;

int main() {
    ll A,B,K;
    cin >> A >> B >> K;
    
    bool flag=true;
    for(ll i=0; i<K; i++){
        if(flag){
            if(A%2!=0){
                A--;
            }
            B += A/2;
            A /= 2;
            flag=false;
        }
        else {
            if(B%2!=0){
                B--;
            }
            A += B/2;
            B /= 2;
            flag = true;
        }
    }
    cout << A <<" "<< B << endl;
}


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

int main(){
    int n;
    cin>>n;
    vector<pair<pair<string,int>,int>> book(n);

    rep(i,n){
        string s;
        int p;
        cin>>s>>p;
        book[i].first.first=s;
        book[i].first.second=p*-1;
        book[i].second=i+1;
    }
    sort(book.begin(),book.end());
    rep(i,n) cout<<book[i].second<<"\n";
    return 0;
}

Measured memory_bytes: 3588
use std::io;

fn main() {
	let s = read::<String>();
	let k = read::<i64>();
	let mut count: i64 = 0;
	let (num_1, last_char) = ret_char_num(&s);
	let first_s: String = format!("{}{}", last_char, s);
	let (num_2, last_char) = ret_char_num(&first_s);

	let mids_s: String = format!("{}{}", last_char, s);
	let (num_3, _last_char) = ret_char_num(&mids_s);
	if k > 0{
		count = num_1 + (num_2 + num_3) * (k / 2);
		if k % 2 == 0 {
			count = count - num_3;
		}
	}
	println!("{}", count);
}

fn read<T: std::str::FromStr>() -> T {
	let mut line = String::new();
	io::stdin().read_line(&mut line).ok();
	line.trim().parse().ok().unwrap()
}

fn ret_char_num(s : &String) -> (i64, char) {
	let mut vec: Vec<char> = s.as_str().chars().collect();
	let mut count: i64 = 0;

	for i in 1..vec.len(){
		if vec[i - 1] == vec[i]{
			count = count + 1;
			vec[i] = '!';
		}
	}
	return (count, vec[vec.len() - 1]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
bool issosuu(int n){
    for(int i =2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    int q;
    cin >> q;
    vector<int> ans(100000);
    ans[1] = 0;
    ans[3] = 1;
    for(int i = 3;i<100000;i+=2){
        if(issosuu(i)&&issosuu((i+1)/2)){
            ans[i] = ans[i-2]+1;
        }
        else{
            ans[i] = ans[i-2];
        }
    }
    for(int i =0;i<q;i++){
        int l,r,hoge=0;
        cin >> l>>r;
        if(ans[l]-ans[l-2]==1){
            hoge=1;
        }
        cout<<ans[r]-ans[l]+hoge<<endl;
    }

}

Measured memory_bytes: 1024
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data',function(chunk){

var line = chunk.toString().split(' ').map(Number);
var a = Number(line[0]);
var b = Number(line[1]);
var c = Number(line[2]);
var count = 0;

for (var i = a; i < b+1 ; i++){
 if(  c % i === 0){
     count++;
  }
 }
 console.log(count);
});

Measured memory_bytes: 15572
#include <iostream>
using namespace std;
 
int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int A = X;
  int B = Y;
  int C = Z;
  
  int temp = A;
  A = B;
  B = temp;
  
  temp = A;
  A = C;
  C = temp;
  
  cout << A << " " << B << " " << C;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e18;
const int inf=2e9;
const ll MOD=1000000007;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

int main(){
    ll N,M;cin>>N>>M;
    ll info[N];
    rep(i,N)info[i]=0;
    ll pena=0,ans=0;
    rep(i,M){
        ll p;string s;cin>>p>>s;
        p--;
        if(info[p]<1000000){
            if(s=="WA")info[p]++;
            else{
                pena+=info[p];
                ans++;
                info[p]=1000000;
            }
        }
    }
    cout<<ans<<" "<<pena<<endl;
    return 0;
}

Measured memory_bytes: 1024
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
  
N,X = [ int(it) for it in input().split() ]
li = [ abs(int(it)-X) for it in input().split() ]


gc = li[0]
for v in li[1:]:
  if ( v != 0 ):
    gc = gcd(gc,v)
print ( gc )


Measured memory_bytes: 14252
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	int n, a, b;
	int ac=0, bc=0;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int ct = 0;
	for(auto& i:s) {
		if (i == 'c')cout << "No" << endl;
		if (i == 'a') {
			if (ac + bc < a + b) { cout << "Yes" << endl; ++ac; }
			else cout << "No" << endl;
		}
		if (i == 'b') {
			if (ac + bc < a + b&&bc < b) { cout << "Yes" << endl; ++bc; }
			else cout << "No" << endl;
		}
		++ct;
	}
	return 0;
}

Measured memory_bytes: 896
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    int l, r, d, cnt = 0;
    cin >> l >> r >> d;
    for (int i = l; i <= r; i++)
        if (i % d == 0)
            cnt++;
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
  
    string s[100];
    int p[100];
    for (int i = 0; i < n; i++) cin >> s[i] >> p[i];

    vector<int> index(n);
    iota(index.begin(), index.end(), 0);
    sort(index.begin(), index.end(), [&](int x, int y)
         { return s[x] == s[y] ? p[x] > p[y] : s[x] < s[y]; } );
  
    for (int x : index) cout << x+1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main { 
  public static void main(String[] args){
	  long max = -1000000;
	  long min = 1000000;
	  long sum=0;
	  Scanner sc = new Scanner(System.in);
	  int n = sc.nextInt();
	  for(int i=0;i<n;i++) {
	  int a = sc.nextInt();
	  if(a<=min) {
		  min=a;
	  }
	  if(a>max) {
		  max=a;
	  }
	  sum+=a;
	  
	  }
	  System.out.printf("%d %d %d\n",min,max,sum);
  }
}



Measured memory_bytes: 42132
N,T = map(int,input().split())
l = [list(map(int,input().split())) for i in range(N)]
##print(l)
a = []
for i in range(N):
  if l[i][1] <= T:
    a.append(l[i][0])
if a != []:
  t = min(a) 
  print(t)
else:
  print("TLE")

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

/**
 * 選択ソート
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B&lang=ja">ALDS1_2_B</a>
 */
public class Main {

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

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int count = selectionSort(a, n);

		System.out.println(Arrays.toString(a).replace("[", "").replace("]", "").replace(",", ""));
		System.out.println(count);

		sc.close();
	}

	private static int selectionSort(int[] a, int n) {
		int count = 0;
		for (int i = 0; i < n; i++) {
			int minj = i;
			for (int j = i; j < n; j++) {
				if (a[j] < a[minj]) {
					minj = j;
				}
			}
			int tmp = a[minj];
			a[minj] = a[i];
			a[i] = tmp;
			if (i != minj) count++;
		}
		return count;
	}

}



Measured memory_bytes: 26456
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		//出力
		Console.WriteLine(a * b);
	}
}

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

long d;
long c[26];
long s[365][26];
long t[365];
long last[26];
long tmpAdd[26];

long nowAns = -1<<30;

long calcMinus(int day,long* last);
long calcScore();

int main(){
    long time = clock();
    
    nowAns = 0;
    cin >> d;
    for(int i=0;i<26;i++)cin >> c[i];
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    srand(4);

    


    for(int i=0;i<365;i++){
        t[i] = rand()%26 + 1;
    }
    nowAns = calcScore();

    for(int i=0;i<26;i++){
        last[i] = tmpAdd[i];
    }

   do{
        
        int qq = 1;
        int qqbef = 1;
        int dd = 0;
        
            do{
                dd = rand()%365;
                qqbef = t[dd];
                qq = rand()%26 + 1;
                if(s[dd][qq-1] > s[dd][qqbef-1]){
                    if(rand()%100 == 0)qq = qqbef;
                }else{
                    if(rand()%10 > 0)qq = qqbef;
                }
            }while(qq == qqbef);
        
        t[dd] = qq;
        long tmp = calcScore();
        bool chk = true;
        if(tmp > nowAns){

        }else{
            if(rand()%100 > 1){
                chk = false;
            }
        }

        if(chk){
            for(int i=0;i<26;i++){
                last[i] = tmpAdd[i];
            }
            nowAns = tmp;
        }else{
            t[dd] = qqbef;
        }
    }while(clock() - time  < 2*CLOCKS_PER_SEC-19600);

    for(int i=0;i<d;i++){
        cout << t[i]<<endl;
    }
    
}


long calcMinus(int day,long* tmplast){

    long ans = 0;
    for(int i=0;i<26;i++){
        ans -= c[i] * (day - tmplast[i]);
    }

    return ans;
}

long calcScore(){
    long ans = 0;

    long tmplast[26];
    for(int i=0;i<26;i++){
        tmplast[i] = -1;
    }

    for(int i=0;i<d;i++){
        tmplast[t[i]-1] = i;
        ans += s[i][t[i]-1];
        ans += calcMinus(i,tmplast);
    }

    for(int i=0;i<26;i++){
        tmpAdd[i] = tmplast[i];
    }

    return ans;
    
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main(){
   long a,b,c,k;
   cin>>a>>b>>c>>k;
   long ans=0;
    if(a>=k) cout<<k<<endl;
    else if (a<k) {
        ans+=a;
        k=k-a;
        if(b>=k) cout<<ans<<endl;
        else if(b<k){
            k=k-b;
            ans=ans-k;
            cout<<ans<<endl;
        
        }
    }   

}

Measured memory_bytes: 3636