akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int dis(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int n;
    long long int ans = 0;
    long long int a[10][10] = {};
    scanf("%d", &n);
    for (int l = 1; l <= 9; l++)
    {
        for (int r = 1; r <= 9; r++)
        {
            if (l == r && l <= n)
            {
                a[l][r]++;
            }
            int o;
            for (o = 10; (l + 1) * o <= n; o *= 10)
            {
                a[l][r] += o / 10;
            }
            if (n + 10 > l * o + r)
            {
                a[l][r] += (n + 10 - (l * o + r)) / 10;
            }
        }
    }
    for (int l = 1; l <= 9; l++)
    {
        for (int r = 1; r <= 9; r++)
        {
            ans += a[l][r] * a[r][l];
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x,y;
    cin>>x>>y;
    if(y%2==1){
            cout<<"No"<<endl;
    }
    else if(x*2<=y&&x*4>=y){
            cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
ll a[200000], dp[200000];

int main()
{
    IO;

    ll j, n, m, k, m1, m2, a1, a2, l, t, cnt=0, mn, h=0, mod=1e9+7, ans=0; int tc=0; ll i;

        cin>>n;
        for(i=1; i<=n; i++) cin>>a[i];
        dp[2]=abs(a[2]-a[1]);
        for(i=3; i<=n; i++)
            dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
        cout<<dp[n]<<endl;

    return 0;
}


Measured memory_bytes: 1792
# ABC130E

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))


M = 10**9+7
n,m = map(int, input().split())
s = input().split()
t = input().split()
n = len(s)
m = len(t)
dp = [[0] * (m+2) for _ in range(n+2)] # i-1, j-1で終わる部分列の組の個数
ss = [[0] * (m+2) for _ in range(n+2)] # sum(dp[0][0]+...+ dp[i-1][j-1])

for i in range(n+2):
    dp[i][0] = 0
    ss[i][0] = 0
for j in range(m+2):
    dp[0][j] = 0
    ss[0][j] = 0

for i in range(1, n+1):
    for j in range(1, m+1):
        if s[i-1]==t[j-1]:
            dp[i][j] += (ss[i][j] + 1)
            dp[i][j] %= M
        ss[i+1][j+1] = (-ss[i][j]+ss[i+1][j]+ss[i][j+1]+dp[i][j]) % M
print(ss[n+1][m+1]+1)

Measured memory_bytes: 104540
<?php

fscanf(STDIN, "%s", $String);
$StringPiece = array("","","","");
$Result = "No";
for($i = 0; $i < 4; $i++)
	{
		$StringPiece[$i] = substr($String, $i, 1);
	}

if($StringPiece[0] == $StringPiece[1] && $StringPiece[2] == $StringPiece[3] && $StringPiece[1] != $StringPiece[2]) $Result = "Yes";
if($StringPiece[0] == $StringPiece[2] && $StringPiece[1] == $StringPiece[3] && $StringPiece[2] != $StringPiece[1]) $Result = "Yes";
if($StringPiece[0] == $StringPiece[3] && $StringPiece[1] == $StringPiece[2] && $StringPiece[3] != $StringPiece[1]) $Result = "Yes";

echo $Result;

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n, k; cin >> n >> k;
   V<int> a(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }

   V<int> s(n+1);
   for (int i = 0; i < n; i++) {
      s[i+1] = s[i] + a[i];
   }
   V<int> s2(n+1);
   for (int i = 0; i < n; i++) {
      s2[i+1] = s2[i] + max(a[i], 0LL);
   }

   int maxsum = -INF;
   for (int i = 0; i+k <= n; i++) {
      chmax(maxsum, max(s[i+k] - s[i], 0LL) + (s2[i] + s2[n] - s2[i+k]));
   }
   cout << maxsum << endl;

   return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int counter=0;
    for(int i=0;i<s.size();i++)
    {
        if(i%2==0&&s[i]!='R'&&s[i]!='U'&&s[i]!='D')
        {
            counter++;
            break;
        }
        else         if(i%2==1&&s[i]!='L'&&s[i]!='U'&&s[i]!='D')
        {
            counter++;
            break;
        }

    }
    if(counter==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


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

int a1, a2, a3, b1, b2, b3, c11, c12, c13, c21, c22, c23, c31, c32, c33;

int main(){
  cin >> c11 >> c12 >> c13;
  cin >> c21 >> c22 >> c23;
  cin >> c31 >> c32 >> c33;
  bool flag = false;
  for(int i = 0; i <= c11; i++){
    b1 = c11 - i;
    b2 = c12 - i;
    b3 = c13 - i;
    if(c21 - b1 == c22 - b2 && c22 - b2 == c23 - b3 && c31 - b1 == c32 - b2 && c32 - b2 == c33 - b3) flag = true;
  }
    
  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

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

int main() {
    int H, W;
    cin >> H >> W;

    string a[H], b[H];
    for (int i = 0; i < H; i++) {
        cin >> a[i];
        b[i] = a[i];
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (a[i][j] == '#') continue;

            int bombs = 0;
            for (int k = 0; k < 8; k++) {
                int x = i + dx[k];
                int y = j + dy[k];
                if (x < 0 || x >= H || y < 0 || y >= W) continue;
                if (a[x][y] == '#') bombs++;
            }
            b[i][j] = '0' + bombs;
        }
    }

    for (int i = 0; i < H; i++) {
        cout << b[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
K = int(input().split()[0])

s = [[0 for _ in range(10)] for _ in range(20)]

for i in range(10):
    s[0][i] = 1

for n in range(1,20):
    for i in range(10):
        if i == 0:
            s[n][i] = s[n-1][i]+s[n-1][i+1]
        elif i == 9:
            s[n][i] = s[n-1][i-1]+s[n-1][i]
        else:
            s[n][i] = s[n-1][i-1]+s[n-1][i]+s[n-1][i+1]

i = -1
Sm = 0
SmOld = 0
while True:
    i += 1
    Sm += sum(s[i][1:])
    if Sm > K:
        Sm = SmOld
        break
    SmOld = Sm

k = 10**i
while True:
    a = list(map(int,str(k)))
    flag = True
    for h in range(i,0,-1):
        if abs(a[h-1]-a[h]) < 2:
            continue
        else:
            flag = False
            k = k-k%(10**(i-h))+10**(i-h)
            break
    if not flag:
        continue
    Sm += 1
    if Sm == K:
        print(k)
        break
    k += 1



Measured memory_bytes: 9280
n = int(input())
H = list(map(int,input().split()))

def grouping(v):
    #隣接する人同士のグルーピング
    groups = []
    tmp = 0
    zeros = 0
    for n in v:
        if n == 1:
            if zeros != 0:#直前まで０だったとき
                groups.append(zeros)
                zeros = 0#リセット
            tmp += 1
        elif n == 0:
            if tmp != 0:#直前まで１だったとき
                groups.append(tmp)
                tmp = 0#リセット
            zeros -= 1
    
    #終端の処理
    if tmp != 0:
        groups.append(tmp)
    if zeros != 0:
        groups.append(zeros)
    
    groups = [1 if x > 0 else 0 for x in groups]
    return groups

ans = 0
for i in range(max(H)):
    H = list(map(lambda x:x-1, H))
    vector = [1 if x >= 0 else 0 for x in H]
    ans += sum(grouping(vector))
print(ans)
    

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

/*****All definitions*******/
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int>
#define vs vector<string>
#define mp make_pair
/***************************/

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	set<string> s;
	for (int i = 0; i < n; i++)
	{
		string a;
		cin >> a;
		s.insert(a);
	}
	cout << s.size();
	return 0;
}


Measured memory_bytes: 19184
#include<bits/stdc++.h>
#define filename "task name"
#define fi first
#define se second
using namespace std;
const int N = 1e5+5 ;
const int mod = 1e9+7 ;
#define int long long
int n,m,t,ans[N] ;
pair<int , long long> a[N] ; 
void fre(){
	if (fopen(filename".INP", "r")) {
   	   	freopen(filename".INP", "r", stdin);
   		freopen(filename".OUT", "w", stdout);
   	}
}
main(){
	fre();
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>a[i].fi;
		a[i].se=i; 
	}
	sort(a+1,a+n+1) ;
	a[0].fi = 0 ; 
	a[0].se = 0 ;
	int j=n, idx=a[n].se; 
	while(j>0) {
		int i ; 
		for(i = j ; i > 0 && a[i].fi == a[j].fi ; i-- ) {
			idx = min(idx,a[i].se) ;  
		}
		int cnt = n-i ; 
		ans[idx] += cnt*(a[i+1].fi-a[i].fi) ;
		j = i ; 
	} 
	for(int i=1; i<=n; i++) cout << ans[i] << endl ; 
}


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "H"
#define FALSE__ "D"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

ll n;

signed main()
{
	init();
	solve();
}

void init()
{
	cin >> n;
}

void solve()
{
	ll res = 1;
	for(ll i = 1; i <= n; i++) {
		res = (res * i) % MOD;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void set(int i, char str[], int count[]);
void pull3(int count[]);

int main(void) {
	char str[14];
	int count[9];
	int i, j, k, l, m;
	_Bool comp;
	_Bool first;
	while (scanf("%s", str) != EOF) {
		first = 0;
		for (i = 0; i < 9; i++) {
			comp = 0;
			
			for (j = 0; j < 9 && !comp; j++) {
				set(i, str, count);
				for (k = 0; k < 9; k++)
					if (count[k] > 4)
						break;
				if (k != 9)
					continue;
				if (count[j] >= 2) {
					for (m = 0; m < 2; m++) {
						set(i, str, count);
						count[j] -= 2;
						if (m == 0)
							pull3(count);
						for (k = 0; k < 9; k++) {
							for (l = count[k]; l > 0; l--) {
								if ( k < 7 && count[k] > 0 && count[k+1] && count[k+2]) {
									count[k]--;count[k+1]--;count[k+2]--;
								}
							}
							if (count[k] > 0)
								break;
						}
						if (m == 1)
							pull3(count);
						
						for (k = 0; k < 9; k++) {
							if (count[k] > 0)
								break;
						}
						if (k == 9)
							comp = 1;
					}
				}
			}
			
			if (comp) {
				if (first)
					printf(" ");
				printf("%d", i+1);
				first = 1;
			}
		}
		if (!first)
			printf("0");
		printf("\n");
	}
	return 0;
}

void set(int i, char str[], int count[]) {
	int j;
	for (j = 0; j < 9; j++)
		count[j] = 0;
	for (j = 0; j < 13; j++)
		count[str[j]-'1']++;
	count[i]++;
}

void pull3(int count[]) {
	int k;
	for (k = 0; k < 9; k++) {
		if (count[k] >= 3)
			count[k] -= 3;
	}
}

Measured memory_bytes: 544
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
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; }
typedef long long ll;
int main()
{
  int n,m; cin >> n >> m;
  ll k; cin >> k;
  vector<ll> a(n),b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];

  vector<ll> asum(n+1);
  asum[0] = 0;
  rep(i,n) asum[i+1] = asum[i] + a[i];
  vector<ll> bsum(m+1);
  bsum[0] = 0;
  rep(i,m) bsum[i+1] = bsum[i] + b[i];

  ll res = 0;
  rep(i,n+1) {
    ll x = k - asum[i];
    if(x < 0) continue;
    ll lb = -1, ub = m + 1;
    while(ub - lb > 1) {
      ll mid = (ub + lb) / 2;
      (bsum[mid] <= x ? lb : ub) = mid;
    }
    chmax(res, i + lb);
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 9596
#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>;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y) { return root(x) == root(y); }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);  // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

int main() {
    long long N, M, K;
    cin >> N >> M >> K;

    vector<vector<int>> connection(N), rejection(N);
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        --A, --B;
        uf.merge(A, B);
        connection[A].push_back(B);
        connection[B].push_back(A);
    }
    for (int i = 0; i < K; ++i) {
        int C, D;
        cin >> C >> D;
        --C, --D;
        rejection[C].push_back(D);
        rejection[D].push_back(C);
    }

    rep(i, N) {
        ll res = uf.size(i) - connection[i].size() - 1;
        for (auto x : rejection[i]) {
            if (uf.issame(i, x)) --res;
        }
        cout << res << " ";
    }
    cout << endl;
}

Measured memory_bytes: 14632
#include<iostream>
#include<stdio.h>
#include<stack> 
using namespace std;
int main()
{
	stack<char> st;
	char a;
	while(cin>>a)
	{
		if(st.size()>0&&st.top()=='S'&&a=='T')
		st.pop();
		else
		{
			st.push(a);
		}
	}
	cout<<st.size()<<endl;
}

Measured memory_bytes: 512
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int MAXN = (int) 1e2 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int n;
int a[MAXN],b[MAXN];
int f[MAXN][MAXN];

void work(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
    for(int len=2;len<=n;len++){
        for(int i=1;i+len-1<=n;i++){
            int j=i+len-1;
            for(int k=i;k<j;k++){
                if(f[i][j]==0) f[i][j]=f[i][k]+f[k+1][j]+a[i]*b[k]*b[j];
                else f[i][j]=min(f[i][j],f[i][k]+f[k+1][j]+a[i]*b[k]*b[j]);
            }
        }
    }
    printf("%d\n",f[1][n]);
}

int main(){
    work();
    return 0;
}




Measured memory_bytes: 2748
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (int)(n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

int a[6666][6666];

int main(void) {
	int n, m, A, B;
	read(n); read(m); read(A); read(B);
	// if (n * A != m * B) cout << -1 << "\n";
	rep (i, B) rep (j, A) a[i][j] = 1;
	for (int i = B + 1; i <= n; i++)
		for (int j = A + 1; j <= m; j++)
			a[i][j] = 1;
	rep (i, n) {
		rep (j, m) cout << a[i][j];
		cout << "\n";
	}
}


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

int main()
{
  int n;
  string s, t;
  vector<int> v;
  cin >> n >> s >> t;
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    if(s.at(i) == t.at(0)) v.push_back(i);
  }
  for (int i = 0; i < v.size(); i++)
  {
    if(s.substr(v.at(i)) == t.substr(0, n - v.at(i))) cnt = max(cnt, n - v.at(i));
  }
  cout << 2 * n - cnt << endl;
  return 0;
}


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

int main(){
    double const pi = acos(-1.0);
    double r,area,cir;
    cin >> r;
    area = pi*r*r;
    cir = 2.0*r*pi;
    
    cout<<fixed<<setprecision(20)<<area << " " <<fixed<<setprecision(20)<<cir<< endl;
    
    return 0;
}




Measured memory_bytes: 3244
#!/usr/bin/env python
# -*- coding: utf-8 -*-

left = 'qwertasdfgzxcvb'
while True:
    s = list(input())
    if s[0] == '#':
        break
    t = True if s[0] in left else False
    count = 0
    for c in s:
        if c in left:
            if t!=True:
                t = True
                count += 1
        else:
            if t:
                t = False
                count += 1
    print(count)

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

int a[100000005], b[100000005];

int main()
{
	int n, c, d, s = 0;
	cin >> n >> c >> d;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];
	for (int i = 1; i <= n; i++)
		if (a[i] >= c && b[i] >= d) s++;
	cout << s << endl;
	return 0;
}

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

int main()
{
    int n;
    string s;

    cin >> n >> s;
    int ans = 0;

    for (int i = 0; i < 1000; i++)
    {
        int num[] = {i / 100, (i / 10) % 10, i % 10, -1};
        int k = 0;
        for (int j = 0; j < n; j++)
        {
            if(num[k] == s[j] - '0')
            {
                k++;
            }
        }
        if(k == 3)
        {
            ans ++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

def get_score(c):
    if c == 'r':
        return p
    elif c == 's':
        return r
    else:
        return s

ans = 0
dp = [0] * n
for i in range(k):
    ans += get_score(t[i])
    dp[i] = 1

for i in range(k, n):
    if t[i] == t[i-k]:
        if dp[i-k] == 0:
            dp[i] = 1
            ans += get_score(t[i])
        else:
            dp[i] = 0
    else:
        ans += get_score(t[i])
        dp[i] = 1

print(ans)

Measured memory_bytes: 4792
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int v = int.Parse(input[0]);
		int e = int.Parse(input[1]);
    long[,] distance = new long[v,v];
    long[,] dp = new long[1<<v, v];//dp[スタートを除く訪問した頂点,今いる頂点] := 通った距離
    long answer = long.MaxValue/2;

    for(int i = 0; i < v; i++)
    {
      for(int j = 0; j < v; j++)
      {
        distance[i,j] = -1;
      }
    }

    for(int i = 0; i < e; i++)
    {
      string[] inputa = Console.ReadLine().Split(' ');
      distance[int.Parse(inputa[0]), int.Parse(inputa[1])] = long.Parse(inputa[2]);
    }

    for(int i = 0; i < 1<<v; i++)
    {
      for(int j = 0; j < v; j++)
      {
        dp[i,j] = long.MaxValue/2;
      }
    }
    dp[1,0] = 0;//初期化

    for(int i = 2; i < 1<<v; i++)
    {
      for(int next = 0; next < v; next++)
      {
        if(((i>>next)&1) == 1)
        {
          for(int back = 0; back < v; back++)
          {
            if(distance[back, next] != -1 && dp[i^(1<<next),back] != long.MaxValue/2)
            {
              dp[i,next] = Math.Min(dp[i,next], dp[i^(1<<next),back]+distance[back,next]);
              //Console.WriteLine(i+" "+next+" "+dp[i,next]);
            }
          }
        }
      }
    }

    for(int i = 1; i < v; i++)
    {
      //Console.WriteLine(dp[(1<<v)-1, i]+" "+((1<<v)-1)+" "+v);
      if(dp[(1<<v)-1, i] != long.MaxValue/2 && distance[i,0] != -1)
      {
        answer = Math.Min(answer, dp[(1<<v)-1, i] + distance[i,0]);
      }
    }
		
		Console.WriteLine(answer == long.MaxValue/2 ? -1 : answer);
	}
}


Measured memory_bytes: 19140
N, M = map(int, input().split())

ac = [False] * (N+1)
wa = [0] * (N+1)

for _ in range(M):
  p, s = input().split()
  p, s = int(p), str(s)
  if ac[p]: continue

  if s == 'AC': ac[p] = True
  else: wa[p] += 1

ans1, ans2 = 0, 0
for i in range(N+1):
  if ac[i]:
    ans1 += 1
    ans2 += wa[i]

print(ans1, ans2)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  rep(i,N)cin >> v[i];
  int count = 0;
  rep(i,N){
    if(v[i] == i+1){
      ++count;
      if(i!=N-1)swap(v[i],v[i+1]);
    }
  }
  cout << count << endl;
  return 0;
}


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

#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i = (int)(begin), i##_end = (int)(end); i < i##_end; ++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x

int main(void){
	int N;
	int K;
	cin >> N;
	cin >> K;

	int ans = 0;
	rep(i, N){
		int x;
		cin >> x;
		ans += min(x, abs(x - K)) * 2;
	}
	printf("%d\n", ans);
	return 0;
}


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

#define S 10000

typedef struct COST{
	int cost;
	int nodenum;
}Cost;
typedef struct EDGE{
	int target;
	int cost;
	struct EDGE *next;
}Edge;

int graph[S][S];
int n;
int cost[S];
Cost heap[S]; //minimum heap.
int N;  //number of elements in heap.
Edge *edge[S];
Edge *lastEdge[S];

void setCost(Cost *dst, const Cost *src){
	dst->cost = src->cost;
	dst->nodenum = src->nodenum;
	return;
}
 
//e1->cost < e2->cost:-1
//e1->cost == e2->cost:0
//e1->cost > e2->cost:1
int cmpCost(Cost *e1, Cost *e2){
	return (e1->cost < e2->cost?-1:0) + (e1->cost > e2->cost?1:0);
}
 
void swapCost(Cost *e1, Cost *e2){
	int temp;
	temp = e1->cost; e1->cost = e2->cost; e2->cost = temp;
	temp = e1->nodenum; e1->nodenum = e2->nodenum; e2->nodenum = temp;
	return;
}
 
void up(int i){
	if( i <= 1 ){ return; }
	if( cmpCost(&heap[i], &heap[i/2]) == -1 ){
		swapCost(&heap[i], &heap[i/2]);
		up(i/2);
	}
	return;
}
 
void down(int i){
	int j;
	if( 2*i > N ){ return; }
	if( cmpCost(&heap[2*i], &heap[2*i+1]) == -1 ){
		j = 2*i;
	}else{
		j = 2*i+1;
	}
	if( cmpCost(&heap[i], &heap[j]) == 1 ){
		swapCost(&heap[i], &heap[j]);
		down(j);
	}
	return;
}
 
void delete(int i){
	if( i < 1 ){ return; }
	heap[i] = heap[N];
	N--;
	down(i);
	return;
}

int isInCost(int num){
	int i;
	for( i = 0; i < N; i++ ){
		if( heap[i].nodenum == num ){ return i; }
	}
	return -1;
}

void add(Cost *e){
	int re;
	if( (re = isInCost(e->nodenum)) >= 0 ){
		if( heap[re].cost < e->cost ){ return; }
		delete(re);
	}
	N++;
	setCost(&heap[N], e);
	up(N);
	return;
}
 
void init(){
	int i, j;
	for( i = 0; i < S; i++ ){
		cost[i] = -1;
		edge[i] = NULL;
		lastEdge[i] = NULL;
	}
}

void input(){
	int i, j;
	int u, k, v, c;
	Edge *e;
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){
		scanf("%d %d", &u, &k);
		for( j = 0; j < k; j++ ){
			scanf("%d %d", &v, &c);
			e = (Edge*)malloc(sizeof(Edge));
			e->cost = c;
			e->target = v;
			e->next = NULL;
			if( edge[u] == NULL ){
				edge[u] = e;
			}else{
				lastEdge[u]->next = e;
			}
			lastEdge[u] = e;
		}
	}
}

int getMinCost(int start){
	int i, j;
	Cost c, next;
	Edge *e;
	next.cost = 0;
	next.nodenum = start;
	add(&next);
	while( N > 0 ){
		setCost(&c, &heap[1]);
		delete(1);
		i = c.nodenum;
		e = edge[i];
		while( e != NULL ){
			j = e->target;
			next.cost = c.cost + e->cost;
			next.nodenum = j;
			if( cost[j] == -1 || next.cost < cost[j] ){
				cost[j] = next.cost;
				add(&next);
			}
			e = e->next;
		}
	}
	return 0;
}

void get(int s){
	cost[s] = 0;
	getMinCost(s);
}

void print(){
	int i;
	for( i = 0; i < n; i++ ){ printf("%d %d\n", i, cost[i]); }
	return;
}

int main(){
	init();
	input();
	get(0);
	print();
	return 0;
}

Measured memory_bytes: 16400
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int mini=1e8;
    for(int i=0;i<s.size()-t.size()+1;i++){
        int count=0;
        for(int j=0;j<t.size();j++){
            if(s[j+i]!=t[j]) count++;
        }
    mini=min(mini,count);
    }
    cout<<mini<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[55];
int b[55];
int l[55];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
        {
            scanf("%d%d",&a[i],&b[i]);
            l[a[i]]++;
            l[b[i]]++;
        }
        for(int i=1;i<=n;i++)
            printf("%d\n",l[i]);

}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		i, _ := strconv.Atoi(scanner.Text())
		fmt.Println(i * i * i)
	}
}




Measured memory_bytes: 1088
import java.util.*;
import java.math.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    BigDecimal A = sc.nextBigDecimal();
    BigDecimal B = sc.nextBigDecimal();
    System.out.println(A.multiply(B).setScale(0, BigDecimal.ROUND_DOWN));
  }
}

Measured memory_bytes: 28940
#include <bits/stdc++.h>
using namespace std;
//useful 
#define rep(i,n) for(int i = 0; i < (n); i++)
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数
int long long GetDigitSum(int long long n){
    if(n < 10){
       return n;
    }
    return GetDigitSum(n/10) + n%10;
} //十進数の桁和
unsigned int long long unsignedGetDigitSum(unsigned int long long n){
    if(n < 10){
       return n;
    }
    return unsignedGetDigitSum(n/10) + n%10;
} //十進数の桁和unsigned
int long long divisorcount(int long long n){
	int long long ans = 1;
	vector<int> x(n + 1);
	int long long num = n; // 素因数分解する変数num 
	for (int long long i = 2; i <= n; i++) {
		while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
			x.at(i)++; //割った個数を配列に足す
			num /= i;
		}
	}
	for (int i = 2; i <= n; i++){
		ans *= x.at(i) + 1; //それぞれを+1して掛けていく
	}
    return ans;
} //約数カウント


int main(){
    string S;
    cin >> S;
    if(S.back() == 's'){
        cout << S << "es" << endl;
    }
    else{
        cout << S << 's' << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
N = int(input())
A = list(map(int, input().split()))
B = []
i = 0
while i < N - 1:
    if A[i] != A[i+1]:
        B.append(A[i])
    i += 1
B.append(A[-1])

ans = 1
i = 0
while i < len(B) - 2:
    if (B[i + 1] - B[i]) * (B[i + 2] - B[i + 1]) < 0:
        ans += 1
        i += 2
    else:
        i += 1
print(ans)


Measured memory_bytes: 85108
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << endl;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

typedef complex<long double> point;
typedef pair<point,point> line;
point polar(const long double &r, const long double &th) { return point(r*cosl(th),r*sinl(th)); }
bool equal(const long double x1,const long double x2){ return abs(x1-x2)<eps; }
bool equal(const point& a,const point& b){ return equal(a.real(),b.real()) and equal(a.imag(),b.imag()); }
long double length(const point& a){ return abs(a); }
long double distance(const point& a,const point& b){ return abs(a-b); }
long double dot(const point& a,const point& b){ return a.real()*b.real()+a.imag()*b.imag(); }
long double cross(const point& a,const point& b){ return a.real()*b.imag()-a.imag()*b.real(); }
int ccw(point a,point b,point c) {
    b-=a; c-=a;
    if(cross(b, c) > 0)   return +1;       // counter clockwise
    if(cross(b, c) < 0)   return -1;       // clockwise
    if(dot(b, c) < 0)     return +2;       // c--a--b on line
    if(norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;
}
bool intersectSS(const line& s, const line& t){
    return ccw(s.first,s.second,t.first)*ccw(s.first,s.second,t.second) <= 0 &&
           ccw(t.first,t.second,s.first)*ccw(t.first,t.second,s.second) <= 0;
}

long double sub(int na,int nb,vector<point> &pa,vector<point> &pb){
    vector<long double> dist(nb,inf);
    vector<bool> done(nb);
    dist[0]=0;
    for(;;){
        int u=-1;
        rep(v,0,nb){
            if(!done[v] and (u==-1 or dist[u]>dist[v])) u=v;
        }
        if(u==-1) break;
        done[u]=true;
        rep(v,0,nb){
            if(intersectSS(line(pa[0],pa[1]),line(pb[u],pb[v]))) continue;
            long double d=dist[u]+abs(pb[u]-pb[v]);
            if(d<dist[v]) dist[v]=d;
        }
    }
    return abs(pa[0]-pa[1])+dist[1];
}

void solve(){
    int na,nb;
    cin >> na >> nb;
    vector<point> pa,pb;
    rep(i,0,na){
        long double x,y;
        cin >> x >> y;
        pa.push_back(point(x,y));
    }
    rep(i,0,nb){
        long double x,y;
        cin >> x >> y;
        pb.push_back(point(x,y));
    }
    long double ans=min(sub(na,nb,pa,pb),sub(nb,na,pb,pa));
    if(ans<inf) cout << ans << endl;
    else cout << -1 << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 3464
n=int(input())
a=[input() for _ in range(n)]
m=int(input())
b=[input() for _ in range(m)]
A=list(set(a))
ans=[0]
for i in range(len(A)):
    cnt=0
    cnt=a.count(A[i])-b.count(A[i])
    ans.append(cnt)
print(max(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll gcdExtended(ll a,ll b,ll *x,ll *y)
{
    if(a==0)
    {
        *x=0,*y=1;
        return(b);
    }
    ll x1,y1;
    ll gcd=gcdExtended(b%a,a,&x1,&y1);
    *x=y1-(b/a)*x1;
    *y=x1;
    return(gcd);
}*/
ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
/*ll modInverse(ll a, ll m)
{
    ll x,y;
    ll g = gcdExtended(a, m,&x,&y);
    return((x%m+m)%m);
}*/
/*long combi(int n,int k)
{
    long ans=1;
    k=k>n-k?n-k:k;
    int j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}*/
/*struct cmp{
    bool operator()(const pair<ll,ll>&a,const pair<ll,ll>&b)
    const{
        int lena=a.second-a.first+1;
        int lenb=b.second-b.first+1;
        if(lena==lenb) return a.first<b.first;
        return lena>lenb;
    }
};*/
void solve()
{
    ll n;
    double d;
    cin>>n>>d;
    ll c1,c2;
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        cin>>c1>>c2;
        double dist=sqrt(pow(c1,2)+pow(c2,2));
        if(dist<=d)
            ans++;
    }
    cout<<ans<<endl;
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int N;
  cin >> N;
  string s[10010];
  int cnt=0;
  int a=0,b=0,ab=0;
  rep(i,N){
    cin >> s[i];
    int size=s[i].size();
    rep(j,size-1){
      if(s[i].substr(j,2) == "AB")cnt++;
    }
    if(s[i][size-1]=='A' && s[i][0]=='B'){
      ab++;
    }else{
      if(s[i][size-1]=='A')a++;
      if(s[i][0]=='B')b++;
    }
  }

  if(ab>0){
  cnt += ab-1;//まずB...Aを全部繋げる

  //B...A鎖の始点と終点
  if(a>0){
    cnt++;
    a--;
  }
  if(b>0){
    cnt++;
    b--;
  }

  //残ったやつでペア
  cnt += min(a,b);
  }else{
    cnt += min(a,b);
  }

  cout << cnt << endl;
}


Measured memory_bytes: 768
n=int(input())
lists=[int(input())for i in range(n)]
lists.append(0)
ans=0
if lists[0]!=0:
    print(-1)
else:
    flag=True
    for i in range(n-1):
        if lists[i]+1<lists[i+1]:
            flag=False
            break
    if not flag:
        print(-1)
    else:
        for i in range(n):
            if lists[i]+1==lists[i+1]:
                ans+=1
            else:
                ans+=lists[i+1]
        print(ans)
        
        

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

int x;

int ans = -1;

int main(void){
  // Here your code !
  scanf("%d", &x);

  for (int b = 2; b < x; ++b) {
    for (int p = 2; pow(b, p) <= x; ++p) {
      int cur = pow(b, p);
      ans = max(ans, cur);
    }
  }

  if (x == 1) ans = 1;
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 512
import java.util.*;

class Main {
    public static void main(String... args) {
        int N = IN.nextInt();
		int X = IN.nextInt();
		List<Integer> xs = new ArrayList<Integer>();
		xs.add(X);
		for (int i = 0; i < N; i++) {
			xs.add(IN.nextInt());
		}
		xs.sort((i, j) -> i - j);
		int ans = xs.get(1) - xs.get(0);
		for (int i = 1; i < N; i++) {
			int tmp = xs.get(i + 1) - xs.get(i);
			ans = euclid(ans, tmp);
		}
		puts(ans);
	}

	static int euclid(int a, int b) {
		int c = a % b;
		if (c == 0) {
			return b;
		} else {
			return euclid(b, c);
		}
	}

    static final Scanner IN = new Scanner(System.in);
    static <T> void puts(T arg) { System.out.println(arg); }
}


Measured memory_bytes: 58228
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        int sum = 0;
        int tmp = i;
        while (tmp != 0)
        {
            sum += tmp % 10;
            tmp /= 10;
        }
        if ((A <= sum) && (sum <= B))
        {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

ll solve() {
    ll N, P;
    cin >> N >> P;
    auto PrimeFactor = [](ll x) {
        map<ll, ll> pr;
        for ( ll k = 2; k * k <= x; k++ ) {
            while ( x % k == 0 ) {
                pr[k]++;
                x /= k;
            }
        }
        if ( x > 1 ) pr[x]++;
        return pr;
    };
    auto fs = PrimeFactor(P);
    ll ans = 1;
    for ( auto f : fs ) {
        if ( f.second >= N ) {
            for ( int i = 0; i < f.second/N; i++ ) ans *= f.first;
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{
    std::string s;
    std::cin >> s;
    bool flag = true;
    for (std::string::const_reverse_iterator it = s.rbegin(); it != s.rend();)
    {
        if (*it == 'm')
        {
            ++it;
            if (!(std::distance(it, s.crend()) >= 4 && *it++ == 'a' && *it++ == 'e' && *it++ == 'r' && *it++ == 'd'))
            {
                flag = false;
                break;
            }
        }
        else if (*it == 'e')
        {
            ++it;
            if (!(std::distance(it, s.crend()) >= 4 && *it++ == 's' && *it++ == 'a' && *it++ == 'r' && *it++ == 'e'))
            {
                flag = false;
                break;
            }
        }
        else if (*it == 'r')
        {
            ++it;
            if (!(it != s.rend() && *it++ == 'e'))
            {
                flag = false;
                break;
            }

            if (*it == 'm')
            {
                ++it;
                if (!(std::distance(it, s.crend()) >= 4 && *it++ == 'a' && *it++ == 'e' && *it++ == 'r' && *it++ == 'd'))
                {
                    flag = false;
                    break;
                }
            }
            else if (*it == 's')
            {
                ++it;
                if (!(std::distance(it, s.crend()) >= 3 && *it++ == 'a' && *it++ == 'r' && *it++ == 'e'))
                {
                    flag = false;
                    break;
                }
            }
            else
            {
                flag = false;
                break;
            }
        }
        else
        {
            flag = false;
            break;
        }
    }

    if (flag)
    {
        std::cout << "YES";
    }
    else
    {
        std::cout << "NO";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
#include<queue>

using namespace std;

int main()
{
	char a[101] = { 0 };
	char b[101] = { 0 };
	cin >> a >> b;
	int ans = 0;
	int len_a, len_b;
	len_a = strlen(a);
	len_b = strlen(b);
	if (len_a > len_b) {
		ans = 1;
	}
	else if (len_a < len_b) {
		ans = -1;
	}
	else {
		for (int i = 0; i < len_a; i++) {
			if (a[i] > b[i]) {
				ans = 1;
				break;
			}
			else if (a[i] < b[i]) {
				ans = -1;
				break;
			}
		}
	}
	if (ans == 1) {
		cout << "GREATER" << endl;
	}
	else if (ans == -1) {
		cout << "LESS" << endl;
	}
	else {
		cout << "EQUAL" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n;
cin >> n;
vector<pair<int,int>> l(n);
for(int i = 0; i < n; i++){
    int a,b;
    cin >> a >> b;
    l[i] = make_pair(b,a);
}
sort(l.begin(),l.end());
int time = 0, ans = 0;
for(int i = 0; i < n; i++){
    time += l[i].second;
    if(l[i].first >= time)
    ans++;
}
if(ans == n)
cout << "Yes" << endl;
else
{
    cout << "No" << endl;
}

}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    vector<int> integers;
    integers.push_back(A);
    integers.push_back(B);
    integers.push_back(C);
    int count = 0;
    vector<int> evens;
    for (int i = 0; i < 3; i++) {
        if (integers[i] % 2 == 0) {
            evens.push_back(i);
        }
    }
    if (evens.size() == 3 || evens.size() == 0) {
        int max = *max_element(integers.begin(), integers.end());
        count = (max * 3 - integers[0] - integers[1] - integers[2]) / 2;
    } else if (evens.size() == 1) {
        int sum = 0;
        for (int i = 0; i < 3; i++) {
            if (i != evens[0]) {
                sum += ++integers[i];
            } else {
                sum += integers[i];
            }
        }
        count = 1;
        int max = *max_element(integers.begin(), integers.end());
        count += (max * 3 - sum) / 2;
    } else { // evens.size == 2
        int sum = 0;
        for (int i = 0; i < 3; i++) {
            if (i == evens[0] || i == evens[1]) {
                sum += ++integers[i];
            } else {
                sum += integers[i];
            }
        }
        count = 1;
        int max = *max_element(integers.begin(), integers.end());
        count += (max * 3 - sum) / 2;
    }
    cout << count << endl;
    return 0;
}


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

int main() {
  long long N;
  cin >> N;
  string s;
  unordered_map<string, int> S;
  long long answer = 0;
  for (int i = 0; i < N; i++) {
    cin >> s;
    sort(s.begin(), s.end());
    answer += S[s]++;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 10660
#include<iostream>
using namespace std;
const int MAXN=11;
char a[MAXN],b[MAXN];
bool flag;
int main(){
	for(int i=1;i<=3;i++) cin>>a[i];
	for(int i=1;i<=3;i++) cin>>b[i];
	if(a[3]==b[1]&&a[1]==b[3]&&a[2]==b[2]) flag=1;
	if(flag) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S, A;
	cin >> S;
	int N = S.size();
	A = "abcdefghijklmnopqrstuvwxyz"; // 文字と数字の対応付け
	vector<int> t(26); // 使用されている文字数を記録
	REP(i, N){
		//char'a'を引くことで'a'を０に対応させる
		t.at(S.at(i) - 'a') += 1;
	}
	if(N == 26){ // 26文字か否かで処理が異なる
		REP(i, 26){
			int tmp = S.at(25-i) - 'a'; // 最後の文字の番号
			t.at(tmp) = 0; // 最後の文字はもう使わないので0にする
			while(tmp < 25){
				tmp++; // ここで最大25('z')になる
				if(t.at(tmp) == 0){
					cout << S.substr(0,25-i) << A.at(tmp) <<endl;
					return 0;
				}
			}
		}
		cout << -1 << endl;
	}else{ // 26文字以外のときの処理
		int min_n = 26;
		REP(i, 26){
			if(t.at(i) == 0){
				// 使用していない文字のうち最も若い番号のもの
				min_n = min(min_n, i);
			}
		}
		// 最も若い番号を最後に追加する
		cout << S << A.at(min_n) << endl;
	}	
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	int A, B;
	cin >> A >> B;
	int AB = A * B;

	string result = "No";
	for (int C = 1; C <= 3; C++) {
		if ((AB * C) % 2 == 1) {
			result = "Yes";
			break;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
let inp_matrix : 'a array -> int -> int -> unit = fun a m n ->
  for i = 0 to m - 1 do
    for j = 0 to n - 1 do
      a.(i).(j) <- Scanf.scanf " %d" (fun x -> x)
    done
  done
  
let rec inp_loop : (unit -> 'a) -> int -> 'a list = fun inp_fun n ->
  if n = 0 then []
  else
    let x = inp_fun () in
    x :: inp_loop inp_fun (n - 1)

let hole a m n k =
  for i = 0 to m - 1 do
    for j = 0 to n - 1 do
      if a.(i).(j) == k then
        a.(i).(j) <- (-1)
    done
  done

let calc_ans a =
  let ans = ref "No" in
  for i = 0 to 2 do
    if (a.(i).(0) == a.(i).(1) && a.(i).(0) == a.(i).(2)) then ans := "Yes"
  done;
  for j = 0 to 2 do
    if (a.(0).(j) == a.(1).(j) && a.(0).(j) == a.(2).(j)) then ans := "Yes"
  done;
  if (a.(0).(0) == a.(1).(1) && a.(2).(2) == a.(1).(1) || a.(0).(2) == a.(1).(1) && a.(0).(2) == a.(2).(0)) then ans := "Yes";
  !ans
  
  
let () =
  let a = Array.make_matrix 3 3 0 in
  let () = inp_matrix a 3 3 in
  let n = Scanf.scanf " %d" (fun x -> x) in
  let l = inp_loop (fun () -> Scanf.scanf " %d" (fun x -> x)) n in
  List.iter  (hole a 3 3) l;
  let ans = calc_ans a
  in
  print_endline ans


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

int main() {
  int N = 0;
  cin >> N;
  
  int total = 0;
  for( int i = 0; i < N; ++i ){
    int l = 0, r = 0;
    cin >> l >> r;
    r -= l;
    total += r + 1;
  }
  cout << total;
}

Measured memory_bytes: 3640
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]);
        int h = int.Parse(input[2]);
        int m = int.Parse(input[3]);
        double r1 = 0.0;
        if(m != 0) r1 = h*30+30*((double)m/60.0);
        else r1 = h*30;
        //Console.WriteLine(r1);
        double r2 = m*6;
        double r = Math.Abs(r1-r2);
        if(r > 180) r = 360 - r;
        double rad = System.Math.PI * r / 180.0;
        double len = Math.Sqrt(Math.Pow(a,2)+Math.Pow(b,2)-(2*a*b*Math.Cos(rad)));
        Console.WriteLine(len);
	}
}

Measured memory_bytes: 18876
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
 
using namespace std;
 
typedef long long ll;
 
#define MAX_N 100010
 
int n;
string s;
int ans[MAX_N];
 
bool check() {
  rep(i,n) {
    int next = ( i + 1 ) % n;
    int prev = ( i - 1 + n ) % n;
    if( ans[i] == 0 ) {
      if( s[i] == 'o' ) {
	if( !( ans[prev] == ans[next] ) ) return false;
      } else {
	if( !( ans[prev] != ans[next] ) ) return false;
      }
    } else {
      if( s[i] == 'o' ) {
	if( !( ans[prev] != ans[next] ) ) return false;
      } else {
	if( !( ans[prev] == ans[next] ) ) return false;
      }
    }
  }
  return true;
}
 
bool calc(int a,int b) {
  memset(ans,-1,sizeof ans);
  ans[0] = a, ans[1] = b;
  REP(i,1,n-1) {
    int next = ( i + 1 ) % n;
    int prev = ( i - 1 + n ) % n;
    if( s[i] == 'o' ) {
      if( ans[i] == 0 ) {
	ans[next] = ans[prev];
      } else {
	ans[next] = (ans[prev]+1)%2;
      }
    } else {
      if( ans[i] == 0 ) {
	ans[next] = (ans[prev]+1)%2;
      } else {
	ans[next] = ans[prev];
      }
    }
  }
  return check();
}
 
void compute() {
  rep(i,2) {
    rep(j,2) {
      if( calc(i,j) ) {
	rep(k,n) {
	  if( ans[k] == 0 ) cout << "S";
	  else cout << "W";
	} puts("");
	return;
      }
    }
  }
  puts("-1");
}
 
int main() {
  cin >> n >> s;
  compute();
  return 0;
}

Measured memory_bytes: 896