akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    if (c == 'A') cout << 'T';
    else if (c == 'C') cout << 'G';
    else if (c == 'G') cout << 'C';
    else cout << 'A';
}


Measured memory_bytes: 256
s = input()
ans1 = 0
ans2 = 0
ideal1 = []
ideal2 = []
for x in range(len(s)):
    if x % 2 == 0:
        ideal1.append('1')
        ideal2.append('0')
    else:
        ideal1.append('0')
        ideal2.append('1')
for inp,i1,i2 in zip(s,ideal1,ideal2):
    if inp == i1:
        pass
    else :
        ans1 += 1
    if inp == i2:
        pass
    else:
        ans2 += 1

print(min(ans1,ans2))

Measured memory_bytes: 4852
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };



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

    Vl A(n);
    rep(i, n) cin >> A[i];

    ll ans = 0;

    ll ttsum = 0;
    for (int i = 0; i < n; i++) ttsum += A[i];

    for (int i = 0; i < n - 1; i++) {
        ttsum -= A[i];
        ll tsum = ttsum;
        ll t = tsum % Mod;
        t = (t * A[i]) % Mod;
        ans += t;

    }
    cout << ans % Mod << endl;

}


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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	string s, p;
	bool ans = false;

	cin >> s >> p;
	int slen = s.length();
	int plen = p.length();

	rep(i, slen) {
		bool b = true;

		rep(j, plen) {
			int si = (i + j) % slen;
			if (s[si] != p[j]) b = false;
		}

		if (b) {
			ans = true;
			break;
		}
	}

	cout << (ans ? "Yes" : "No") << endl;


	return 0;
}



Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		    Scanner scanner = new Scanner(System.in);
		    
		    int H = scanner.nextInt();
		    int A = scanner.nextInt();
		    int i = 0;
		    
		    while(true){
		    	if(H-A*i<=0) {
		    		break;
		    	}
		      i++;
		    }
		    System.out.println(i);
		  }
}


Measured memory_bytes: 22612
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
long int a[100000][3],n;
long int max(long int a,long int b){return a>b?a:b;}
long int maximum(long int a,long int b,long int c)
{
    if(a>=b && a>=c){return a;}
    else if(b>=c && b>=a){return b;}
    else{return c;}
}
void function()
{
    long int dp[n][3],i,j,p[3];
    dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2]; 
    for(i=1;i<n;i++)
    {
        dp[i][0]=max(a[i][0]+dp[i-1][1],a[i][0]+dp[i-1][2]);
        dp[i][1]=max(a[i][1]+dp[i-1][0],a[i][1]+dp[i-1][2]);
        dp[i][2]=max(a[i][2]+dp[i-1][0],a[i][2]+dp[i-1][1]);
    }
    p[0]=dp[n-1][0];p[1]=dp[n-1][1];p[2]=dp[n-1][2];
    printf("%ld",maximum(p[0],p[1],p[2]));
}
int main()
{
    long int i;
    scanf("%ld",&n);
    for(i=0;i<n;i++)
    {scanf("%ld%ld%ld",&a[i][0],&a[i][1],&a[i][2]);}
    function();
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

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

	if (n < 10) {
		cout << r + 100 * (10 - n) << endl;
	}
	else {
		cout << r << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n;
  cin >> n;
  cout << n/3 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define uLL unsigned long long

using namespace std;
const int N=2e5+10,inf=1e9;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
int to[N<<1],nt[N<<1],hd[N],tot=1;
void adde(int x,int y)
{
    ++tot,to[tot]=y,nt[tot]=hd[x],hd[x]=tot;
    ++tot,to[tot]=x,nt[tot]=hd[y],hd[y]=tot;
}
char co[2]={'W','B'};
int n,m,a[N],sq[N],a1[N],a2[N];
bool cmp(int aa,int bb){return a[aa]<a[bb];}

int main()
{
//orz itst
    n=rd(),m=rd();
    for(int i=1;i<=n;++i) a[i]=rd();
    for(int i=1;i<=m;++i) adde(rd(),rd());
    for(int i=1;i<=max(n,m);++i) a1[i]=-1,a2[i]=inf+1;
    for(int i=1;i<=n;++i) sq[i]=i;
    sort(sq+1,sq+n+1,cmp);
    for(int i=1;i<=n;++i)
    {
	int x=sq[i];
	for(int j=hd[x];j;j=nt[j])
	{
	    int y=to[j];
	    if(a[y]>a[x]||((~a1[x])&&(~a1[y]))) continue;
	    if(a[x]==a[y])
	    {
		a2[j>>1]=a[x];
		if(a1[x]<0)
		{
		    if(a1[y]<0) a1[y]=0;
		    a1[x]=a1[y]^1;
		}
		else a1[y]=a1[x]^1;
	    }
	    else if(~a1[y])
		a2[j>>1]=a[x]-a[y],a1[x]=a1[y];
	}
    }
    for(int i=1;i<=n;++i)
	if(a1[i]<0){puts("-1");return 0;}
    for(int i=1;i<=n;++i) putchar(co[a1[i]]);
    puts("");
    for(int i=1;i<=m;++i) printf("%d\n",min(a2[i],inf));
    return 0;
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
//Rohit Sharma, jammu. make aarsh proud.
#define int long long int
#define pb push_back
#define M 1000000007
#define gcd(a,b)  __gcd(a,b)
#define rep(k,n) for(int i=k;i<n;i++)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define MOD 1000000007
using namespace std;
using std::numeric_limits;
//cout.precision(numeric_limits<double>::digits10 + 1);
const int N= 1e5+1;
int n,m,k,p,l,q,r,t,cnt=1,ans=1,x,y,c=0,z;
//---------------------------------------
int a[N];
int32_t main()
{
	//https://codeforces.com/contest/1099/problem/F
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int dp[n];
	dp[0]=0,dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)dp[i]=min(dp[i-2]+ abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
	cout<<dp[n-1];

return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
int main()
{
	char s[100];
	int i=0;
	char ch;
	while(scanf("%c",&ch)!=EOF)
	{
		if(ch=='0')
		{
			s[i]='0';
			i++;
		}
		else if(ch=='1')
		{
			s[i]='1';
			i++;
		}
		else if(ch=='B')
		{
			if(i)
			i--;
		}
	}
	if(i)
	for(int j=0;j<i;j++)
	{
		printf("%c",s[j]);
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.FileInputStream;
import java.util.Scanner;


public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception{
        while(hasNext()){
            StringBuilder s = new StringBuilder(NLine());
            StringBuilder ans=new StringBuilder();
            if(s.length()==0)return;
            for (int i = 0; i < s.length(); i++) {
                if(s.charAt(i)=='@'){
                    i++;
                    int len = s.charAt(i)-'0';
                    i++;
                    for (int j = 0; j < len; j++) {
                        ans.append(s.charAt(i));
                    }
                } else {
                    ans.append(s.charAt(i));
                }
            }
            System.out.println(ans);
        }
    }

    
    static int c=-2;
    static int NI(){
        return (int)NL();
    }
    
    static long NL(){
        try {
            long r = 0;
            skip();
            if(c=='-') return -NL();
            for(;'0'<=c&&c<='9';c=System.in.read())
                r = r * 10 + c - '0';
            return r;
        } catch (Exception e) {
            return -1;
        }
    }
    
    static char NC(){
        try {
            skip();
            return (char)c;
        } catch (Exception e) {
            return 0;
        }
    }
    
    static String NS(){
        StringBuilder sb=new StringBuilder();
        try {
            skip();
            for(;!isSkip();){
                sb.append((char)c);
                c=System.in.read();
            }
            return sb.toString();
        } catch (Exception e) {
            return "";
        }
    }
    
    static String NLine(){
        StringBuilder sb=new StringBuilder();
        try {
            if(c==-2){
                c=System.in.read();
            }
            for(;c!='\n'&&c!='\r';){
                sb.append((char)c);
                c=System.in.read();
//                System.out.println(c);
            }
//            c=System.in.read();
            skip();
            return sb.toString();
        } catch (Exception e) {
            return "";
        }
    }
    
    static void skip(){
        try{
            while(isSkip()){
                c=System.in.read();
            }
        } catch (Exception e){}
        
    }
    
    static boolean hasNext(){
        skip();
        return c!=-1;
    }
    
    static boolean isSkip(){
        return 0 <= c && c <= ' ' || c == -2;
    }
}

Measured memory_bytes: 17020
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int i,sum=0,flag=0,maxx=0;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='R')
		{
			sum++;
		}
		else sum=0;
		maxx=max(sum,maxx);
	}
	printf("%d\n",maxx);
}

Measured memory_bytes: 3704
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = min (b-1, n);
    cout << a*x / b;
    
    return 0;
}



Measured memory_bytes: 3616
inp = input()
q = int(input())

answer = []

for i in range(q):
    line = input().split()

    if line[0] == "print":
        a = int(line[1])
        b = int(line[2])
        answer.append(inp[a:(b + 1)])
    elif line[0] == "reverse":
        a = int(line[1])
        b = int(line[2])
        reverseStr = inp[a:(b + 1)]
        inp = inp[:a] + reverseStr[::-1] + inp[(b + 1):]
    elif line[0] == "replace":
        a = int(line[1])
        b = int(line[2])
        p = line[3]
        inp = inp[:a] + p + inp[(b + 1):]

[print(answer[i]) for i in range(len(answer))]


Measured memory_bytes: 5624
from collections import defaultdict, Counter
from string import ascii_lowercase
n = int(input())
S = [input() for _ in range(n)]
counter = defaultdict(lambda: 50)
for s in S:
    c = Counter(s)
    for t in ascii_lowercase:
        counter[t] = min(counter[t], c[t])
print(''.join(sorted(k * v for k, v in counter.items())))

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

class Program
{
    public static void Main()
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var H = input[0];
        var R = input[1];
        if (-H < R)
        {
            Console.WriteLine(1);
        }
        else if (-H == R)
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(-1);
        }
    }
}


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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

struct Person {
    ll H;
    ll P;
    bool operator<(const Person& p) const
    {
        return (p.P + p.H) > (P + H);
    }
};


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<Person> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i].H >> P[i].P;
    }
    sort(P.begin(), P.end());
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, INF<ll>));  //n人まででm人が積んだときの最小高さ
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= i; j++) {
            if (dp[i - 1][j] != INF<ll>) {
                if (dp[i - 1][j] <= P[i - 1].H) {
                    dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + P[i - 1].P);
                }
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            }
        }
    }
    for (int i = N; i >= 0; i--) {
        if (dp[N][i] != INF<ll>) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 195968
var i,j,n,k,s:longint;
	a:array[-5..100050]of longint;

procedure kp(l,r:longint);
var c,d,e,f:longint;
begin
	c:=l;d:=r;e:=a[(l+r) div 2];
	repeat
		while a[c]<e do inc(c);
		while a[d]>e do dec(d);
		if c<=d then begin
			f:=a[c];a[c]:=a[d];a[d]:=f;
			inc(c);
			dec(d);
		end;
	until c>d;
	if c<r then kp(c,r);
	if l<d then kp(l,d);
end;
begin
	readln(n);
	for i:=1 to n do readln(a[i]);
	kp(1,n);
	s:=0;i:=0;
	repeat
		inc(i);k:=a[i];j:=1;
		while a[i+1]=k do begin
			inc(j);inc(i);
		end;
		if j mod 2=0 then else inc(s);
	until i=n;
	writeln(s);
end.


Measured memory_bytes: 512
def inv(x):
    return pow(x, MOD-2, MOD)


MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))

primes = {}

for val in A:
    p = 2
    while val >= p * p:
        if val % p == 0:
            # 割り切れるならそこから話が始まる
            cnt = 0
            while val % p == 0:
                cnt += 1
                val //= p
            if p not in primes:
                primes[p] = cnt
            else:
                primes[p] = max(cnt, primes[p])
        p += 1
    if val != 1:
        if val not in primes:
            primes[val] = 1

lcm = 1
for p in primes:
    lcm *= p ** primes[p]
    lcm %= MOD
# print(lcm)
ans = 0

for val in A:
    ans += lcm * inv(val)
    ans %= MOD
print(ans)


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

int main(){
  int N=0;
  int D=0;
  cin>>N>>D;
  vector<double> x(N);
  vector<double> y(N);
  int count=0;
  for(int i=0; i<N; i++){
    cin>>x.at(i);
    cin>>y.at(i);
  }
  vector<double> X(N);
  vector<double> Y(N);
  vector<double> K(N);
  for(int i=0; i<N; i++){
    X.at(i)=x.at(i)*x.at(i);
    Y.at(i)=y.at(i)*y.at(i);
    K.at(i)=sqrt(X.at(i)+Y.at(i));
  if(K.at(i)<=D){
      count++;
  }
  }
    
    cout<<count<<endl;
}
 
    
  

Measured memory_bytes: 11248
/*
 * Problem Description: Connected Components
 * Category: Graph I
 * Author: Khan
 * Date: 21th October, 2017
 */

#include <iostream>
#include <vector>
#include <stack>

using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void DFS(int r, int c)
{
    stack<int> s;
    s.push(r);
    color[r] = c;
    while(!s.empty())
    {
        int u = s.top(); s.pop();
        for (int i = 0; i < G[u].size(); ++i)
        {
            int v = G[u][i];
            if(color[v] == NIL)
            {
                color[v] = c;
                s.push(v);
            }
        }
    }
}

void assignColor()
{
    int id = 1;
    for (int i = 0; i < n; ++i)
        color[i] = NIL;
    for (int i = 0; i < n; ++i)
        if(color[i] == NIL)
            DFS(i, id++);
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int s, t, m, q;

    cin >> n >>m;

    for (int i = 0; i < m; ++i)
    {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;

    for (int i = 0; i < q; ++i)
    {
        cin >> s >> t;
        if(color[s] == color[t])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 8984
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<long long,long long>
#define ppii pair<long long,pair<long long,long long>>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<vector<long long>> vii;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
//int dx[4] = { 1,0,-1,0 };
//int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;
const int MAX_N = 1 << 17;
const int cf = 100010;
///////////////////////////////////////////////////////////////////////////////

template<class T>
vector<pair<T,int>> runlength(vector<T> arr) {
	int i = 0;
	int n = arr.size();
	vector<pair<T, int>> run;
	while (i < arr.size()) {
		T t = arr[i];
		int k = 0;
		while (i + k < n && arr[i + k] == t) k++;
		run.push_back(pair<T, int>(t, k));
		i += k;
	}
	return run;
}

template<class T>
int freq(vector<T> arr,int k) {
	vector<T> vec = arr;
	int n = arr.size();
	sort(all(vec));
	int i = 0;
	vector<pair<int, T>> run;
	while (i < arr.size()) {
	    T t = arr[i];
		int k = 0;
		while (i + k < n && arr[i + k] == t) k++;
		run.push_back(pair<int, T>(k, t));
		i += k;
	}
	sort(all(run));
	int lyn = run.size();
	lint sum = 0;
	for (int i = 0; i < lyn - k; i++) sum += run[i].first;
	return sum;
}

int main(void) {
	int n, k; cin >> n >> k;
	vector<int> a(n); rep(n)cin >> a[i];
	sort(all(a));
	cout << freq(a, k) << endl;
	return 0;

}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
using namespace std;

int main() {
  unsigned long long a, b, x;
  cin >> a >> b >> x;
  cout << ((unsigned long long)(b / x - a / x + !(a % x))) << endl;
  getchar();
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int a,b;
    cin>>a>>b;
  	b/=2;
  	int ans=0;
    if(a>=6)ans+=b;
  	if(a>=13)ans+=b;
  
    cout<<ans<<"\n";

    return 0;

}


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

int main() {
  int N, M, c, max=0;
  string s;
  cin >> N;
  vector<string> blue(N);
  
  for(int i=0;i<N;i++){
    cin >> blue.at(i);
  }
  
  cin >> M;
  vector<string> red(M);
  
  for(int i=0;i<M;i++){
    cin >> red.at(i);
  }
  
  for(int i=0;i<N;i++){
    s=blue.at(i);
    c=0;
    for(int j=0;j<N;j++){
      if(blue.at(j) == s)
        c++;
    }
    for(int j=0;j<M;j++){
      if(red.at(j) == s)
        c--;
    }
    if(max < c)
      max = c;
  }
  
  cout << max << endl;
  
}


Measured memory_bytes: 3608
# https://atcoder.jp/contests/abc098/tasks/arc098_a

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
rr = range


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret

# 要は各地点で向きが揃っている人数をカウントすれば良い
# 0番目がリーダーのとき、向きが揃っている人はWのカウントとなる(あとはリーダーの文字次第)
# i番目を++するとき、[0,i)は向きが揃っているひとをカウントできる、[i+1,N)で向きが揃っているのはWが登場するたび引けば良い


N = read_a_int()
S = read()[:-1]
W = 'W'
E = 'E'

l = 0  # iの左側でEを向いている人数
r = S.count(W)  # iの右側でWを向いている人数

ans = 10**9
for s in S:
    if s == W:  # 右を更新
        r -= 1

    # 答えを更新
    ans = min(ans, N - 1 - (r + l))  # -1は自分のコストを考えない分

    if s == E:  # 左を更新
        l += 1

print(ans)


Measured memory_bytes: 3784
import java.util.Scanner;
import java.util.Set;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // Scanner sc = new Scanner("5\n10 4 8 7 3");
        int n = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for(int i=0;i<n;i++){
            h[i] = Integer.parseInt(sc.next());
        }
        int max = 0;
        int cnt = 0;
        int prev = h[0];
        for(int i=1;i<n;i++){
            if(h[i]>prev){
                max = Math.max(cnt, max);
                cnt = 0;
            }else{
                cnt++;
            }
            prev = h[i];
        }
        max = Math.max(cnt, max);
        System.out.println(max);
    }
}

Measured memory_bytes: 47128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    return (int)(*(int*)b - *(int*)a);
}

int ascending_compare(const void *a, const void *b){
    return (int)*(int*)a - *(int*)b;
}




int main(void){
    int n;
    int *a;
    int cnt = 0;
    int answer = 0;
    int i;

    scanf("%d", &n);

    a = malloc(sizeof(int) * n+1);

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

    qsort(a, n, sizeof(int), ascending_compare);

    a[n] = 0;


    for (i = 0; i < n+1; i++){
        cnt++;
        if (a[i] != a[i-1] && i != 0){
            cnt--;
            if (cnt > a[i-1]){
                answer += (cnt - a[i-1]);
            }else if(cnt < a[i-1]){
                answer += cnt;
            }
            cnt = 1;
        }
    }

    printf("%d\n", answer);







    return 0;
}

Measured memory_bytes: 892
A, B = map(int, input().split())
S = input()
flag = True
for i in range(len(S)):
    if i == A:
        if S[i] != '-':
            flag = False
            break
    else:
        if S[i] < '0' or S[i] > '9':
            flag = False
            break
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <stdio.h>
int main(){
    int a,b,c;
    char ans;
    while(1){
        scanf("%d%d%d",&a,&b,&c);
        if(a+b<30)ans='F';
        if(a+b>=30){
            ans='D';
            if(c>=50)ans='C';
        }
        if(a+b>=50)ans='C';
        if(a+b>=65)ans='B';
        if(a+b>=80)ans='A';
        if(a==-1||b==-1){
            if(a==b&&c==b)return 0;
            ans='F';
        }
        printf("%c\n",ans);
    }
}

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

#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  ll n; cin>>n;
  vector<ll> a(5, 0);
  for (int i=0; i<5; i++) {
    cin >> a[i];
  }
  SORT(a);
  ll b = (n+(a[0]-1))/a[0];
  cout << b+4 << endl;
}

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


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int m,n,c;


int main(){
  int ans=0;
  cin >> n >> m>>c;
  vector<int> b(m);
  int a;
  REP(j,m) cin>>b[j];
  REP(i,n){
    int sm=0;
    REP(j,m){
      cin>>a;
      sm+=a*b[j];
    }
    if ((sm+c)>0)ans++;
  }



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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define vi vector<int>
#define pb emplace_back
ll poww(ll n,ll x)
{
    ll res=1;
    
    while(x>0)
    {
        if(x&1)
          res*=n;
        
        x=x>>1;
        n*=n;
    }
    return res;
}





int main() 
{
	   ios::sync_with_stdio(0);
	   cin.tie(0);
	   cout.tie(0);
       
       int d,t,s;
       cin>>d>>t>>s;
       
       if(t*s>=d)
        cout<<"Yes";
       else
        cout<<"No";       
       
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
#define debug(a) cout<<a<<endl
#define pii pair<ll,ll>
#define maxn 1000009
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    int n,c;
    cin>>n>>c;
    c+=n*3;
    cout<<c/2<<endl;
    return 0;
}
///usar double sempre ou long double
///pensar em casos que coisas dao negativas
///N esquecer de limpar as coisas em quest de varios testes
///OLHAR A COMPLEXIDADE PRA VER SE N PASSA POR BRUTE FORCE OU BRUTE FORCE COM ALGUMAS OTIMIZACOES

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  ll n, k,ans;
  vector<pair<int, int>> num;
  cin >> n >> k;

  REP(i, n){
      int a, b;
      cin >> a >> b;
      num.pb(make_pair(a,b));
    }

    sort(num.begin(), num.end());

    ll count = 0;

    for(int i = 0;count < k; i++){
        ans = num[i].first;
        count += num[i].second;
      }
      cout << ans << endl;
      return 0;
}


Measured memory_bytes: 1400
<?php
$div = 1000000000+7;
fscanf(STDIN, "%d %d", $n, $m);

if(abs($n-$m) > 1){
  echo "0\n";
  return;
}else if(abs($n-$m) == 1){
  echo factorial($n) * factorial($m) % $div;
  echo "\n";
}else{
  echo factorial($n) * factorial($m) % $div * 2 % $div;
  echo "\n";
}

function factorial($x){
  $div = 1000000000+7;
  $a = 1;
  for($i = 1; $i <= $x; $i++){
    $a *= $i;
    $a %= $div;
  }
  return $a;
}
?>


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

const int N = 100050;
int dp[N];

int main () {
  ios_base::sync_with_stdio(0);
  
  for (int i = 0; i < 100; i++) dp[i] = 0;
  for (int i = 0; i < 6; i++) dp[i+100] = 1;
  
  for (int i = 106; i < N; i++) {
    for (int j = 0; j < 6; j++) {
      if (dp[i-100-j]) {
        dp[i] = 1;
      }
    }
  }

  int x;
  cin >> x;
  cout << dp[x];

  return 0;
}

Measured memory_bytes: 640
// 2019/05/04 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	string s;
	getline(cin, s);

	for(int i=0; i<s.size(); i++){
		if(s[i]=='.' || s[i]==','){
			s[i] = ' ';
		}
	}

	istringstream is(s);

	bool flg = false;

	while(true){
		string ss;
		is >> ss;

		if(is.eof())
			break;

		if(ss.size()>=3 && ss.size()<=6){
			if(flg)
				cout << ' ';

			cout << ss;

			flg = true;
		}
	}

	cout << endl;

	return 0;
}



Measured memory_bytes: 3140
#include <stdio.h>

int main(void)
{
	int n, i, a, cnt = 0;

	scanf("%d" ,&n);
	for (i = 1; i <= n; i++)
	{
		scanf("%d" ,&a);
		if (a != i)
			++cnt;
	}

	if (cnt <= 2)
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

void solve(){
    int n, ans=0;
    string s;
    cin >> n >> s;
    for(int i=0; i<n-2; i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            ans++;
    }
    cout << ans << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


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

int main(void)
{
    int N, T, i;
    cin >> N >> T;
    vector<int> t(N);
    for (i = 0; i < N; i++)
    {
        cin >> t[i];
    }
    int deltaTime = 0;
    int time = 0;
    for (i = 1; i < N; i++)
    {
        deltaTime = t[i - 1];
        if (t[i] - deltaTime < T)
        {
            time += t[i] - deltaTime;
        }
        else
        {
            time += T;
        }
    }
    cout << time + T << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
    int a,b;
	scanf("%d %d",&a,&b);
	if(a<b) printf("a < b\n");
	else if(a>b) printf("a > b\n");
	else if(a==b) printf("a == b\n");
	return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

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

const llong inf=100000000;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> b(n,0);
    REP(i,n) {cin>>b[i], --b[i];}

    vector<int> ans;

    for(int j=0; j<n; j++)
    {
        int cnt=-1;
        for(int i=(int)b.size()-1; i>=0; --i) //b.size()が毎回切り替わる
        {
            if (b[i] == i)
            {
                cnt = i;
                break;
            }
        }

        if(cnt==-1)
        {
            cout<<-1<<endl;
            return 0;
        }
        ans.push_back(cnt+1);
        b.erase(b.begin()+cnt);
    }
    reverse(ans.begin(),ans.end());
    for(auto v:ans) cout<<v<<endl;
    return  0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main ()
{
    char S[100];
    scanf ("%s",S);
    if (strcmp("Sunny",S)==0)
        printf ("Cloudy\n");
    if (strcmp("Cloudy",S)==0)
        printf ("Rainy\n");
    if (strcmp("Rainy",S)==0)
        printf ("Sunny\n");
        return 0;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int L, H;
  while(cin>>L>>H,L){
    int S = (1<<L)-1;
    vector<int> ans;
    bool used[1000][10] = {};
    vector<string> vs(H);
    vector<int> hit(H);
    vector<int> brow(H);
    REP(i,H){
      cin>>vs[i]>>hit[i]>>brow[i];
      REP(j,vs[i].size())used[i][vs[i][j]-'0'] = true;
    }
    while(S < 1<<10){
      vector<int> digit;
      REP(i,H){
        int hb = 0;
        REP(j,10)if(used[i][j] && S >> j & 1)hb++;
        if(hit[i] + brow[i] != hb){
          goto NEXT;
        }
      }
      REP(i,10)if(S >> i & 1)digit.push_back(i);
      do{
        bool ok = true;
        REP(i,H){
          int h = 0;
          REP(j,L)if((vs[i][j]-'0') == digit[j])h++;
          if(hit[i] != h){
            ok = false;
            break;
          }
        }
        if(ok){
          if(ans.size() > 0){
            ans = vector<int>();
            goto OUTPUT;
          }else{
            ans = digit;
          }
        }
      }while(next_permutation(digit.begin(), digit.end()));
      NEXT:
      int x = S & -S, y = S + x;
      S = ((S & ~y) / x >> 1) | y;
    }
OUTPUT:
    if(ans.size() > 0) { REP(i,ans.size()){cout<<ans[i];} cout<<endl; }
    else cout<<"NO"<<endl;
  }
  return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (S != "Y" && i == N-1) {
      cout << "Three" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

const int MN = 188;

int N, M, J;
char a[MN][MN];
int f[MN][MN][MN], g[MN][MN][MN];

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; ++i) scanf("%s", a[i] + 1);
	int tN = N - 1, tM = M - 1;
	while (tN) ++J, tN >>= 1;
	while (tM) ++J, tM >>= 1;
	for (int l = 1; l <= N; ++l)
		for (int r = l; r <= N; ++r) {
			f[l][r][M + 1] = M;
			for (int j = M; j >= 1; --j) {
				int o = l == r || (a[l][j] == a[r][j] && f[l][r - 1][j] >= j);
				if (!o) f[l][r][j] = j - 1;
				else f[l][r][j] = a[l][j] == a[l][j + 1] ? f[l][r][j + 1] : j;
			}
		}
	for (int l = 1; l <= M; ++l)
		for (int r = l; r <= M; ++r) {
			g[l][r][N + 1] = N;
			for (int i = N; i >= 1; --i) {
				int o = l == r || (a[i][l] == a[i][r] && g[l][r - 1][i] >= i);
				if (!o) g[l][r][i] = i - 1;
				else g[l][r][i] = a[i][l] == a[i + 1][l] ? g[l][r][i + 1] : i;
			}
		}
	if (f[1][N][1] == M) return puts("0"), 0;
	for (int k = 1; k <= J; ++k) {
		for (int l = 1; l <= N; ++l)
			for (int r = l; r <= N; ++r)
				for (int j = 1; j <= M; ++j)
					f[l][r][j] = f[l][r][f[l][r][j] + 1];
		for (int l = 1; l <= M; ++l)
			for (int r = l; r <= M; ++r)
				for (int i = 1; i <= N; ++i)
					g[l][r][i] = g[l][r][g[l][r][i] + 1];
		for (int i = 1; i <= N; ++i)
			for (int j = 1; j <= M; ++j) {
				static int A[MN], B[MN];
				for (int z = i; z <= N; ++z) A[z] = f[i][z][j];
				for (int z = j; z <= M; ++z) B[z] = g[j][z][i];
				A[N + 1] = j - 1, B[M + 1] = i - 1;
				for (int z = i; z <= N; ++z)
					for (int w = A[z]; w > A[z + 1]; --w)
						g[j][w][i] = std::max(g[j][w][i], z);
				for (int z = j; z <= M; ++z)
					for (int w = B[z]; w > B[z + 1]; --w)
						f[i][w][j] = std::max(f[i][w][j], z);
			}
		if (f[1][N][1] == M) return printf("%d\n", k), 0;
	}
	return 0;
}

Measured memory_bytes: 51200
N,A,B,C,D = map(int,input().split())
S = input()
rock = []
for i in range(N):
	if S[i] == '#':
		rock.append(i+1)

nRock = len(rock)

# renzoku
for i in range(nRock-1):
	if rock[i+1] - rock[i] == 1:
		if A < rock[i] or B < rock[i]:
			if C > rock[i] or D > rock[i]:
				print("No")
				exit()

# A ... B ... C ... D
if C < D:
	print("Yes")
	exit()

# A ... B ...#.....#... D ... C
for i in range(nRock):
	if i == 0:
		if rock[i] >= 4:
			if B < rock[i]-1:
				print("Yes")
				exit()
		continue
	if rock[i] - rock[i-1] > 3:
		if B < rock[i]-1:
			if D == rock[i-1]+1:
				print("No")
				exit()
			else:
				print("Yes")
				exit()
print("No")

Measured memory_bytes: 6416
#C
import math
a,b,h,m = map(int,input().split())
#時間t(hour)
t = h + m/60
#a,bの角度
a_theta = t * 30
b_theta = (t * 360) % 360

theta = abs(a_theta - b_theta)

c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(theta)))

print(c)

Measured memory_bytes: 9440
N = int(input())
A = list(map(int,input().split()))
s = 0
s2 = 0
P = 10**9 + 7
for i in range(N):
    s = ( s + A[i] )%P
    s2 = (s2 + (A[i]**2) % P ) % P
r2 = pow(2, P-2, P)
print( ( (  ( s**2 % P - s2 ) % P ) * r2 ) % P)

Measured memory_bytes: 31436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		char a[][]=new char[h][w];
		for(int i=0;i<h;i++) {
			String s = scan.next();
			a[i]=s.toCharArray();
		}
		scan.close();

		for(int i=-1;i<=h;i++) {
			for(int j=-1;j<=w;j++) {
				if(0<=i && i<h && 0<=j&&j<w){
					System.out.print(a[i][j]);
				}else {
					System.out.print("#");
				}
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 23228
#include <iostream>
#include <queue>
#include <climits>
#include <vector>
using namespace std;
typedef pair<pair<int,int>,int> NODE;
#define cost first.first
#define ticket first.second 
#define pos second
#define ppp(a,b,c) make_pair(make_pair(a,b),c)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)

int info[100][100];
int n;

int dijk(int a,int b,int c){
	priority_queue<NODE,vector<NODE>,greater<NODE> >  Q;
	int memo[100][11];
	rep(i,100)rep(j,11)memo[i][j] = INF;
	rep(j,11)memo[a][j] = 0;
	
	Q.push(ppp(0,c,a));
	while( !Q.empty() ){
		NODE q = Q.top();Q.pop();
		for(int i=0;i<n;i++){
			if( info[q.pos][i]+q.cost < memo[i][q.ticket]){
				 memo[i][q.ticket] = info[q.pos][i]+q.cost;
				Q.push(ppp(info[q.pos][i]+q.cost ,q.ticket,i));
			}
			if( q.ticket && info[q.pos][i]/2+q.cost < memo[i][q.ticket-1] ){
					Q.push( ppp( info[q.pos][i]/2+q.cost , q.ticket-1, i));
				 memo[i][q.ticket-1] = info[q.pos][i]/2+q.cost;
			}
		}
	}
	int mi = (1<<21);
	rep(j,11)mi = min(memo[b][j],mi);
	return mi;
}
int main(){
	int c,m,s,d,a,b,f;
	while(cin >> c >> n >> m >> s >> d ,c ){
		s--;d--;
		rep(i,100)rep(j,100)info[i][j]=INF*2;
		
		for(int i=0;i<m;i++){
			cin >> a >> b >> f;
			a--;b--;
			info[a][b] = info[b][a] = f;
		}
		cout << dijk(s,d,c) << endl;
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    vector<ll> dp(w + 1);
    rep(i, w) { dp[i] = -1; }
    dp[w] = 0;

    rep(i, n) {
        int weight, value;
        cin >> weight >> value;
        for (int j = 0; j < w + 1; j++) {
            if (j + weight <= w && dp[j + weight] >= 0) {
                dp[j] = max(dp[j], dp[j + weight] + value);
            }
        }
    }

    vector<ll>::iterator it = max_element(dp.begin(), dp.end());
    cout << *it << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char a[105][105];
int b[26];

int func(int val)
{
    for(int i=-0; i<26; i++)
    {
        if(b[i]>=val)
        {
            b[i]-=val;
            return 1;
        }
    }
    return 0;
}
int main()
{
    int i,j,m,n,k;
    cin>>n>>m;
    memset(b,0,sizeof(b));
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0; i<n; i++)
        for(j=0; j<m; j++)
        {
            b[a[i][j]-'a']++;
        }
    for(i=0; i<n/2; i++)
        for(j=0; j<m/2; j++)
        {
            if(!func(4))
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    if(n%2==1)
    {
        for(i=0; i<m/2; i++)
            if(!func(2))
            {
                cout<<"No"<<endl;
                return 0;
            }
    }
    if(m%2==1)
    {
        for(i=0; i<n/2; i++)
            if(!func(2))
            {
                cout<<"No"<<endl;
                return 0;
            }
    }
    if(m%2==1&&n%2==1)
    {
        if(!func(1))
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  n, _ := strconv.Atoi(sc.Text())

  a := make([]int, n + 1)
  for i := 0; i <= n; i++ {
    sc.Scan()
    a[i], _ = strconv.Atoi(sc.Text())
  }

  cnt := 0
  for i := 0; i < n; i++ {
    sc.Scan()
    b, _ := strconv.Atoi(sc.Text())
    if b > a[i] {
      cnt += a[i]
      if b - a[i] > a[i + 1] {
        cnt += a[i + 1]
        a[i + 1] = 0
      } else {
        cnt += b - a[i]
        a[i + 1] -= b - a[i]
      }
    } else {
      cnt += b
    }
  }
  fmt.Println(cnt)

}



Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;++i) cin>>a[i];
    
    int c[200001]={0};
    for(int i=0;i<n;++i){
        ++c[a[i]-1];
    }
    sort(c,c+200001,greater<int>());
    int s=0;
    for(int i=k;i<n;++i){
        s+=c[i];
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int x;cin>>x;
    int ans=x/500;
    int xx=x-ans*500;
    ans=ans*1000+xx/5*5;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b;
    cin >> a >> b;
    if(a > b+1){
        cout << 2*a-1 << endl;
    }else if(a+1 < b){
        cout << 2*b -1 << endl;
    }else{
        cout << a + b << endl;
    }
}


Measured memory_bytes: 256