akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
using namespace std;

int A[300][300] = {0};
set<int> removedSet;

int main()
{
    // 整数の入力
    long long R,G,B,N;
    long long counter = 0;
    cin >> R >> G >> B >> N;
    for (int i = 0;N - R * i >=0;i++){
        // cout << i << endl;
        for (int j = 0;N - R * i - G * j >= 0;j++){
            // cout << j << endl;
            if((N - R * i - G * j) % B == 0 ){
                counter++;
            }
        }
    }
    cout << counter << endl;
    return 0;
}

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

int gcd(int a, int b) {
    if (a > b) {
        swap(a, b);
    }
    while (a) {
        b %= a;
        swap(a, b);
    }
    return b;
}
int main(){
    ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    int n, x;
    cin >> n >> x;
    int g = 0;
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        g = gcd(g, abs(k - x));
    }
    cout << g << endl;

}


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  map<char, vector<int>> list;
  for (int i = 0; i < s.size() * 2; ++i) list[s[i % s.size()]].push_back(i);
  int pos = -1;
  long long ans = 0;
  for (char c : t) {
    if (list[c].empty()) {
      ans = -1;
      break;
    }
    int next = *upper_bound(list[c].begin(), list[c].end(), pos);
    ans += next - pos;
    pos = next % s.size();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1724
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    int n; cin >> n;
    REP(i, (1 << n)){
        cout << i << ":";
        int ii = i, bit = 0;
        while(ii){
            if(ii % 2){
                cout << " " << bit;
            }
            ++bit; ii /= 2;
        }
        cout << "\n";
    }
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>

#define pi 3.14159265358979
#define mod 1000000007

using namespace std;

int main(void) {
	long long int a, b, l, m, n;
	int x[100000], y[100000];
	double r;
	string s, t;
	char u;
	int i, j, k;
	bool flag = true;
	cin >> r;
		
	cout << fixed << setprecision(15) << r * 2 * pi<< endl;
		/*if(flag)cout << "Yes" << endl;
			else cout << "No" << endl;*/
	return 0;
}

Measured memory_bytes: 3812
def main():
    n, maxW, weight, value = getInputs()

    accumulatedValue = [0] * (maxW + 1)

    possible = [False] * (maxW + 1)
    possible[0] = True

    used = []
    for i in range(maxW + 1):
        used.append([0] * n)

    for x in range(min(weight), maxW + 1):
        for w in range(n):
            weightW = weight[w]

            if (x - weightW >= 0) and possible[x - weightW] and used[x - weightW][w] == 0:
                newValue = accumulatedValue[x - weightW] + value[w]

                if newValue > accumulatedValue[x]:
                    accumulatedValue[x] = newValue
                    used[x] = used[x - weightW].copy()
                    used[x][w] = 1
                    possible[x] = True

    print(max(accumulatedValue))

def getInputs():
    n, maxW = map(lambda x: int(x), input().split())

    weight, value = [], []
    for i in range(n):
        w, v = map(lambda x: int(x), input().split())
        weight.append(w)
        value.append(v)

    return n, maxW, weight, value

main()


Measured memory_bytes: 239320
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)

int N;
int a[101];

int main() {
  
  cin>>N;
  rep(i, N)cin>>a[i];
  
  sort(a, a+N);
  
  cout<<(a[N-1]-a[0])<<endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int n, k;
int a[505];

vector<ll> divisor(ll n) {
    vector<ll> div;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            div.push_back(i);
            if (i != n / i) div.push_back(n / i);
        }
    }
    return div;
}

bool f(ll x) {
    if (x == 1) return true;
    vector<ll> vec;
    for (int i = 0; i < n; i++) {
        vec.push_back(a[i] % x);
    }
    sort(vec.begin(), vec.end());
    ll l[n + 1], r[n + 1];
    l[0] = r[n] = 0;
    for (int i = 0; i < n; i++) l[i + 1] = l[i] + vec[i];
    for (int i = n - 1; i >= 0; i--) r[i] = (x - vec[i]) + r[i + 1];
    for (int i = 0; i < n; i++) {
        if (l[i] == r[i] && l[i] <= k) return true;
    }
    return false;
}

int main() {
    cin >> n >> k;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    vector<ll> div = divisor(sum);
    sort(div.begin(), div.end(), greater<ll>());
    for (auto x : div) {
        if (f(x)) {
            cout << x << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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 ans;
    ans = (n+k-3)/(k-1);
    cout << ans;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
from collections import *

def judge(x):
    cnt = 0
    
    for hi in h:
        cnt += max(0, (hi-B*x+A-B-1)//(A-B))
    
    return cnt<=x

def binary_search():
    l, r = 0, 10**10
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            r = m-1
        else:
            l = m+1
    
    return l

N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
print(binary_search())

Measured memory_bytes: 77136
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;
string S;

const LL MOD = 1000000007;

int main() {
	cin >> N;
	cin >> S;
	int num = 0;
	LL ans = 1;
	for (int i = 0; i < N * 2; ++i) {
		if ((num % 2) == (S[i] == 'W' ? 1 : 0)) {
			++num;
		}
		else {
			if (num == 0) {
				cout << 0 << endl;
				return 0;
			}
			ans *= num;
			ans %= MOD;
			--num;
		}
	}
	if (num != 0) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i <= N; ++i) {
		ans *= i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    int N;

    cin>>N;

    if(N>999){
        cout<<"ABD"<<endl;
    }
    else{
        cout<<"ABC"<<endl;
    }

    return 0;
}

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

int main(){
    int n,a,b,c,d;
    cin >> n;

    a = n/1000;
    b = (n - a*1000)/100;
    c = (n - (a*1000 + b*100))/10;
    d = n - (a*1000 + b*100 + c*10);

    if(a+b+c+d == 7){
        cout<< a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    }else if(a+b+c-d == 7){
        cout<< a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    }else if(a+b-c+d == 7){
        cout<< a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    }else if(a+b-c-d == 7){
        cout<< a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    }else if(a-b+c+d == 7){
        cout<< a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    }else if(a-b+c-d == 7){
        cout<< a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    }else if(a-b-c+d == 7){
        cout<< a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    }else if(a-b-c-d == 7){
        cout<< a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,a[3000];
ll k;

void solve(){
    cin >> n >> k;
    rep(i,n){
        cin >> a[i];
    }
    ll ans=0;
    rep(i,n){
        int s=0,t=0;
        rep(j,n){
            if (a[i]>a[j]){
                t+=1;
                if (i<j) s+=1;
            }
        }
        ans+=t*((k*(k-1)/2)%mod)%mod+s*k%mod;
        ans%=mod;
    }

    cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int n, i;
  cin >> n >> i;

  cout << n - i + 1 << endl;
}


Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main( void )
{
	char map[21][21];
	int n, m;
	while(cin >> n, n) {
		for(int y=0; y < 21; ++y)
			for(int x=0; x < 21; ++x) {
				map[y][x] = 0;
			}
		for(int i=0; i < n; ++i) {
			int x, y;
			cin >> x >> y;
			map[y][x] = 1;
		}
		cin >> m;
		int dx[] = { 0, 0, -1, 1 };
		int dy[] = { -1, 1, 0, 0 };
		int mx, my, count;
		mx = my = 10;
		count = 0;
		for(int i=0; i < m; ++i) {
			char d;
			int l;
			cin >> d >> l;
			switch(d) {
			case 'N':
				d = 1;
				break;
			case 'S':
				d = 0;
				break;
			case 'E':
				d = 3;
				break;
			case 'W':
				d = 2;
				break;
			}
			for(int j=0; j < l; ++j) {
				mx += dx[d];
				my += dy[d];
				if(map[my][mx]) {
					map[my][mx] = 0;
					++count;
				}
			}
		}
		if(count == n)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
matrix = [[0]*n for i in range(n)]
for _ in range(n):
    lis = list(map(int,input().split()))
    if lis[1] > 0:
        for i in lis[2:]:
            matrix[lis[0]-1][i-1] = 1

for lis in matrix:
    x = list(map(str,lis))
    print(" ".join(x))



Measured memory_bytes: 5676
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
int N,M;
int l[200000],r[200000];
signed main(){
    cin>>N;
    rep(i,N)l[i]=i,r[i]=i+1;
 
    cin>>M;
    vpint vec;
    rep(i,M){
        int x,y;
        cin>>x>>y;
        y--;
        vec.pb(pint(x,y));
    }
    sort(all(vec));
    rep(i,vec.size()){
        int a=vec[i].se;
        int b=vec[i].se+1;
        l[b]=l[a];
        r[a]=r[b];
    }
 
    rep(i,N){
        if(i)printf(" ");
        printf("%lld",r[i]-l[i]);
    }
    puts("");
 
    return 0;
}

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

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

map<string, int> h;

int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

int main(){
  h["N"]=0; h["E"]=1; h["S"]=2; h["W"]=3;

  while(true){
    int N;
    cin>>N;
    if(N==0)break;
    int mp[21][21];
    memset(mp, 0, sizeof(mp));
    rep(i,N){
      int x, y;
      cin>>x>>y;
      mp[x][y]=1;
    }

    int M, nx=10, ny=10;
    int cn=0;
    cin>>M;
    rep(i,M){
      string d;
      int l;
      cin>>d>>l;
      int dd=h[d];
      rep(j,l){
        nx+=dir[dd][0]; ny+=dir[dd][1];
        if(mp[nx][ny]==1){cn++; mp[nx][ny]=0;}
      }
    }
    if(N==cn)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
main(){
	int N,i,j;
	cin>>N;
	string W[N];
	for(i=0;i<N;i++)cin>>W[i];
	for(i=0;i<N;i++){
		int c=0;
		for(j=0;j<N;j++){
			if(W[i] == W[j])c++;
			if(c>1){
				cout<<"No";
				return 0;
			}
		}
	}
	for(i=0;i<N-1;i++){
		if(W[i][W[i].size() - 1] != W[i+1][0]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,n,a[200010],ans,min;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	min=a[0];
	ans=a[1]-a[0];
	for(i=1;i<n;i++){
		if(a[i]<min) min=a[i];
		else if(a[i]-min>ans) ans=a[i]-min;
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    int tmp;
    vector<double> a;

    
    cin >> n;
    while(cin >> tmp){
        a.push_back((double)tmp);
    }
    
    
    
    sort(a.begin(),a.end());
    
    for(int i=0;i<n;i++){
        double x = 0.0;
        double y = 0.0;
        
        if(a.size()>=2){
            x = a[0];
            y = a[1];
    
            // cout << x <<", "<<y<<endl;
        }else{
            break;
        }
        
        
        a.erase(a.begin());
        a.erase(a.begin());
               
                
        double gousei = (x+y)/2.0;
        
        a.push_back(gousei);
        
        // cout << a[0] <<endl;
        
        sort(a.begin(),a.end());
    }
    
    cout << a[0] << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/
int sigma(LL x){
  LL ans = (x-1)*x/2;
  ans%=MOD;
  return ans;
}

int main() {
LL n;
LL k, ans=0;
bool flg=false;
cin >> n >> k;
VI a(n);
LL cnt=0;
REP(i, n){
  cin >> a[i];
}
LL cnt0=0;
REP(i,n-1){
  FOR(j,i+1, n){
    if(a[i]>a[j]){
      cnt++;
    }
  }
}
REP(i,n){
  REP(j,n){
    if(a[i]>a[j]){
      cnt0++;
    }
  }
}

//cout << cnt << endl;
ans+=(cnt0%MOD)*(sigma(k)%MOD)%MOD+((cnt%MOD)*k)%MOD;
/*LL cnt0 = 0;
REP(i,n){
if(a[0]<a[i]) cnt0++;
}
cout << cnt0 << endl;
ans+=((cnt0%MOD)*(sigma(k-1)))%MOD;*/
cout << ans%MOD << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double a[10005];
int main() {
	int n;
	int m;
	cin>>n;
	double sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&m);
		sum+=m;
		a[i]=m*n;
	}
	double ave = sum/n;
	//if((sum/n*n)!=sum)
	//	cout<<"0"<<endl;
//	else{
	int minn=1000000000;
	int temp;
		for(int i=0;i<n;i++){
			if(abs(a[i]-sum)<minn){
				minn=abs(a[i]-sum);
				temp=i;
			}
		}
	cout<<temp<<endl;
//	}
	
}

Measured memory_bytes: 256
#include<stdio.h>

#include <iostream>
#include <algorithm>
#include<string.h>
#include<math.h>

using namespace std;



int a[30], ax = 0;
int b[30], bx = 0;
char cs[105];
int  main()
{
	int n;
    char c;
	while(scanf("%d",&n)!=EOF)
	{
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		ax = 0;
		bx = 0;


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

			cin>>c;
			cs[i] = c;
			if (b[c - 'a'] == 0)
			{
				bx++;
			}
			b[c - 'a']++;
		}
		int maxx = -1;
		for (int i = 0; i < n - 1; i++)
		{
			b[cs[i] - 'a']--;
			if (a[cs[i] - 'a'] == 0)ax++;
			if (b[cs[i] - 'a'] == 0)
			{
				ax--;
				if (ax < 0)ax = 0;
			}
			a[cs[i] - 'a']++;

			maxx = max(maxx, ax);
		}

		printf("%d", maxx);
	}
	return 0;
}

Measured memory_bytes: 256
// 問題の URL を書いておく
// https://atcoder.jp/contests/abc088/tasks/abc088_d

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
#include <queue>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

int main(int argc, const char* argv[])
{
    int h, w;
    cin >> h >> w;
    vector<vector<int>> dist(h, vector<int>(w, 0));
    vector<vector<int>> grid(h, vector<int>(w, 0));
    int wall = 0;
    for(int i = 0; i < h; ++i)
    {
        string s;
        cin >> s;
        for(int j = 0; j < s.size(); ++j)
        {
            auto c = s[j];
            if(c == '#')
            {
                grid[i][j] = 1;
                wall++;
            }
        }
    }

    struct  Point
    {
        int x;
        int y;
        int d;
    };

    queue<Point> q;
    q.push({0, 0, 1});
    while(!q.empty())
    {
        auto p = q.front();
        q.pop();

        int x = p.x;
        int y = p.y;
        int d = p.d;
        if(!(x >= 0 && x < w && y >= 0 && y < h))
        {
            continue;
        }
        if(grid[y][x] != 0)
        {
            continue;
        }
        if(dist[y][x] != 0)
        {
            continue;
        }

        dist[y][x] = d;
        q.push({x + 1, y, d + 1});
        q.push({x - 1, y, d + 1});
        q.push({x, y + 1, d + 1});
        q.push({x, y - 1, d + 1});
    }
    int ld = dist[h - 1][w - 1];
    if(ld == 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << w * h - ld - wall << endl;
    }
}


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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
#define fs first
#define sc second
#define pb push_back
#define sz size()

using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

const D EPS = 1e-8;

inline pair<P,P> normal(P p){return make_pair(p*P(0,1),p*P(0,-1));}
inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

inline Poly convex_cut(Poly p,L l){
  Poly res;
  rep(i,p.sz){
    int nxt = (i+1)%p.sz;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

inline vector<Poly> voronoi_partition(Poly p, vector<P> vp){
  vector<Poly> res(vp.sz);
  rep(i,vp.sz){
    res[i] = p;
    rep(j,vp.sz){
      if(i!=j){
	P mid = (vp[i] + vp[j])/2.0;
	L b = L(mid, mid + normal(vp[j]-vp[i]).fs);
	res[i] = convex_cut(res[i],b);
      }
    }
  }
  return res;
}

inline D area(Poly p){
  if(p.sz<3)return 0;
  D res = cross(p[p.sz-1],p[0]);
  rep(i,p.sz-1)res += cross(p[i],p[i+1]);
  return res/2;
}

int main(){
  int n,m;
  while(cin >> n >> m){
    if(n==0 && m==0)break;

    Poly island(n);
    rep(i,n){
      int x,y;
      cin >> x >> y;
      island[i] = P(x,y);
    }

    vector<P> castle(m);
    rep(i,m){
      int x,y;
      cin >> x >> y;
      castle[i] = P(x,y);
    }

    vector<Poly> ans = voronoi_partition(island,castle);
    rep(i,ans.sz){
      cout << fixed << setprecision(9) << area(ans[i]) << endl;
    }
  }
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n + 1);
    vector<ll> b(n);
    rep(i, n + 1) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll cnt = 0;

    rep(i, n) {
        ll left = min(a.at(i), b.at(i));
        a.at(i) -= left;
        b.at(i) -= left;
        cnt += left;

        ll right = min(b.at(i), a.at(i + 1));
        a.at(i + 1) -= right;
        b.at(i) -= right;
        cnt += right;
    }
    cout << cnt;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> a(26);
    rep(i, n)a[s[i]-'a'].insert(i);
    rep(j, q){
        int t;
        cin >> t;
        if(t == 1){
            int i;
            char c;
            cin >> i >> c;
            a[s[i-1]-'a'].erase(i-1);
            s[i-1] = c;
            a[c - 'a'].insert(i-1);
        }
        else{
            int l, r, ans = 0;
            cin >> l >> r;
            l--;
            rep(i, 26){
                auto it = a[i].lower_bound(l);
                if(it != a[i].end() && *it < r)ans++;
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 24196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

#define MAX_V 100001


int V;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];

void add_edge(int from, int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v){
    used[v] = true;
    rep(i,G[v].size()){
        if(!used[G[v][i]])dfs(G[v][i]);
    }
    vs.push_back(v);
}

void rdfs(int v,int k,vector<int> &sccs){
    used[v] = true;
    sccs.pb(v);
    cmp[v] = k;
    rep(i,rG[v].size()){
        if(!used[rG[v][i]])rdfs(rG[v][i],k,sccs);
    }
}

int scc(vector< vector<int> > &each_scc){
    rep(i,MAX_V)used[i] = false;
    vs.clear();
    rep(v,V){
        if(!used[v])dfs(v);
    }
    rep(i,MAX_V)used[i] = false;
    int k=0;
    
    for(int i=vs.size()-1;i>=0;i--){
        vector<int> sccs;
        if(!used[vs[i]]){
            rdfs(vs[i], k++, sccs);
            each_scc.pb(sccs);
        }
    }
    return k;
}

int main(){
    int e;
    cin>>V>>e;
    rep(i,e){
        int s,t;
        cin>>s>>t;
        add_edge(s,t);
    }
    vector< vector<int> > each_scc;
    scc(each_scc);
    int q;
    cin>>q;
    rep(i,q){
        int a,b;
        cin>>a>>b;
        if(cmp[a]==cmp[b])cout<<1<<endl;
        else cout<<0<<endl;
    }
}

Measured memory_bytes: 9008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
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<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#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())
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 P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

int n;
string s;
cin >> n >> s;
auto len = s.length();
rep(i,len){
    s[i] += n;
    if(s[i]>'Z')s[i] -= 'Z' - 'A' + 1;
}
fin(s);

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
use std::collections::VecDeque;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut vis = vec![false; n];
    let mut path = VecDeque::new();
    path.push_back(0);
    path.push_back(graph[0][0]);
    vis[0] = true;
    vis[graph[0][0]] = true;
    loop {
        let head = path.pop_front().unwrap();
        path.push_front(head);

        let mut ok = true;
        for &v in &graph[head] {
            if !vis[v] {
                path.push_front(v);
                ok = false;
                vis[v] = true;
                break;
            }
        }

        let tail = path.pop_back().unwrap();
        path.push_back(tail);
        for &v in &graph[tail] {
            if !vis[v] {
                path.push_back(v);
                ok = false;
                vis[v] = true;
                break;
            }
        }

        if ok {
            println!("{}", path.len());
            while !path.is_empty() {
                print!("{} ", path.pop_front().unwrap() + 1);
            }
            println!();
            return;
        }
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 13052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long K,A,B;
  long long N=1;
  cin>>K>>A>>B;
  for(long long X=0;X<K;X++){
    if(A+2<B){
      if(N<A){
        N++;
      }
      else{
        if(X+1<K){
          N+=B-A;
          X++;
        }
        else{
          N++;
        }
      }
    }
    else{
      N++;
    }
  }
  cout<<N<<endl;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long 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 dx[4] = {-1,1,0,0};
const int dy[4] = {0,0,-1,1};
const int INF = 1001001001;
int main() {
    int w,h;
    while(1) {
        cin >> w >> h;
        if(w == 0 && h == 0) break;
            bool board[50][50][4];
            rep(i,h) rep(j,w) rep(k,4) board[i][j][k] = true;

            rep(i,w) board[0][i][0] = false; // up
            rep(i,w) board[h-1][i][1] = false; // down
            rep(i,h) board[i][0][2] = false; //left
            rep(i,h) board[i][w-1][3] = false; // right

            rep(i,2*h-1) {
                if(i%2 == 0) {
                    rep(j,w-1) {
                        int a;
                        cin >> a;
                        if(a == 1) {
                            board[i/2][j][3] = false;
                            board[i/2][j+1][2] = false;
                        }
                    }
                } else {
                    rep(j,w) {
                        int a;
                        cin >> a;
                        if(a==1) {
                            board[i/2][j][1] = false;
                            board[i/2+1][j][0] = false;
                        }
                    }
                }
            }
            queue<P>q;
            q.push({0,0});
            int dist[50][50];
            rep(i,h) rep(j,w) dist[i][j] = INF;
            dist[0][0] = 1;
            while(!q.empty()) {
                P p = q.front();q.pop();
                int x, y;
                x = p.first; y = p.second;
                rep(i,4) {
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if(!board[x][y][i]) continue;
                    if(dist[nx][ny] == INF) {
                        dist[nx][ny] = dist[x][y] + 1;
                        q.push({nx,ny});
                    } 
                }
            }
            if(dist[h-1][w-1] == INF) cout << 0 << endl;
            else cout << dist[h-1][w-1] << endl;
    }        
}


Measured memory_bytes: 3112
#include<iostream>
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  if(a == 5 && b == 5 && c == 7){
    cout << "YES" << endl;
  }
  else if(a == 7 && b == 5 && c ==5){
    cout << "YES" << endl;
  }
  else if(a == 5 && b ==7 && c == 5){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int num;
	char str[3];
	int cnt[4]={0};
	
	while( scanf("%d,%s", &num, &str)!=EOF ) {
		// AB?
		if ( (str[0]=='A')&&(str[1]=='B') ) {
			cnt[2]++;
			continue;
		}
		// A?
		if ( str[0]=='A' ) {
			cnt[0]++;
			continue;
		}
		// B?
		if ( str[0]=='B' ) {
			cnt[1]++;
			continue;
		}
		// O?
		if ( str[0]=='O' ) {
			cnt[3]++;
			continue;
		}
	}
	printf("%d\n%d\n%d\n%d\n", cnt[0], cnt[1], cnt[2], cnt[3]);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,pair<int,int>> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
ll gcd(ll a,ll b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}
int main(){
    int q;cin>>q;
    while(q--){
        ll a,b,c,d;cin>>a>>b>>c>>d;
        if(a<b){
            cout<<"No"<<endl;
            continue;
        }
        if(d<b){
            cout<<"No"<<endl;
            continue;
        }
        if(c>=b-1){
            cout<<"Yes"<<endl;
            continue;
        }
        ll g=gcd(d,b);
        if(b+a%g-g>c){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int n,ans=0;
	cin>>n;
	const int N=n;
	string s[N];
	for(int i=0;i<N;i++){
		cin>>s[i];
	}
	sort(&s[0],&s[N]);
	for(int i=0;i<N-1;i++){
		if(s[i]!=s[i+1])ans++;
	}
	ans++;
cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7924
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
using namespace std;

int main(void){
    string s, t;
    int ans = 0;
    cin >> s;
    t = "CODEFESTIVAL2016";
    for (int i = 0; i <= 15; i++) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
a_list = list(map(int, input().split()))

cnt = 0
for i in range(n-1):
    total = a_list[i] + a_list[i+1]
    if total > x:
        diff = total - x
        cnt += diff

        if a_list[i+1] >= diff:
            a_list[i+1] -= diff
        else:
            a_list[i] = diff - a_list[i+1]
            a_list[i+1] = 0
print(cnt)

Measured memory_bytes: 63984
N, M = map(int,input().split())
A = set([int(input()) for _ in range(M)])
MOD = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1
for i in range(1, N + 1):
    dp[i] = (dp[i - 1] + dp[i - 2]) % MOD
    if i in A:
        dp[i] = 0
print(dp[N])

Measured memory_bytes: 13216
#include <bits/stdc++.h>
using namespace std;
#define int long long
int N,X;
int A[100001];
int32_t main(){
	cin>>N>>X;
    int ans = 0;
  	for (int i=0;i<N;i++) cin>>A[i];
    
    for (int i=1;i<N;i++){
		if (A[i] + A[i-1] > X){
        	ans += A[i] - max((int)0,X-A[i-1]);
			A[i] = max((int)0,X-A[i-1]);
		}
        if (A[i-1] > X){
        	ans += A[i-1] - X;
			A[i-1] = X;
        }
	}
	
	//for (int i=0;i<N;i++) cout<<A[i]<<' ';
    cout<<ans;
}



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

int main(){
  int64_t n,a,b;
  cin >> n >> a >> b;
  int64_t x= n / (a+b);
  int64_t y= n % (a+b);
  int64_t z= min(y,a);
  cout << x*a+z << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int N; cin>>N;
  ll L[100];
  L[0]=2; L[1]=1;

  for(int i=2;i<=86;i++){
    L[i]=L[i-1]+L[i-2];
  }
  cout<<L[N]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
  int a; //cin>>a;
  string s; cin>>s;
  a=s.length();
  cout<<s;
  cout<< ( s[a-1]=='s'? "es":"s")<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[]){
	long double a,b,C360;
	cin >> a >> b >> C360;
	long double C = C360 / 360 * 2 * 3.1415926535897932384626;
	long double h = b * sin(C);
	long double x = sqrt(b * b + a * a -  2 * a * b * cos(C));
	long double L = a + b + x;
	long double S = a * h / 2;
	cout << fixed << setprecision(8) << S << endl;
	cout << fixed << setprecision(8) << L << endl;
	cout << fixed << setprecision(8) << h << endl;
	return 0;
}

Measured memory_bytes: 3520
#include <cstdio>
#include <set>
#include <queue>
#include <algorithm>

typedef std::set<int>::iterator Iter;
const int Inf = 0x3f3f3f3f;
const int MN = 100005;

int N, M, Q;
char Str1[MN], Str2[MN];
std::set<int> se, sw, ss, sn;

int dx[10], dy[10], cx, cy;
inline void Add(std::set<int> &st, int id, int *dw, int &cw) {
	if (st.empty()) return ;
	Iter It = st.lower_bound(id);
	if (It != st.end()) dw[++cw] = *It;
	if (It != st.begin()) --It, dw[++cw] = *It;
}

int Id[10][10], Cnt, S, T;
int h[40], nxt[65], to[65], w[65], tot;
inline void Ins(int x, int y, int z) { nxt[++tot] = h[x], to[tot] = y, w[tot] = z, h[x] = tot; }

struct nde {
	int d, u;
	nde() {}
	nde(int d, int u) : d(d), u(u) {}
	inline friend bool operator <(nde i, nde j) {
		return i.d == j.d ? i.u < j.u : i.d > j.d;
	}
};

std::priority_queue<nde> pq;
int Vis[40], Dis[40];
inline int Dijkstra() {
	for (int i = 1; i <= Cnt; ++i) Vis[i] = 0, Dis[i] = Inf;
	Dis[S] = 0, pq.push(nde(0, S));
	while (!pq.empty()) {
		nde p = pq.top(); pq.pop();
		int d = p.d, u = p.u;
		if (Vis[u]) continue;
		Vis[u] = 1;
		for (int i = h[u]; i; i = nxt[i])
			if (Dis[to[i]] > d + w[i])
				Dis[to[i]] = d + w[i],
				pq.push(nde(Dis[to[i]], to[i]));
	}
	return Dis[T] == Inf ? -1 : Dis[T];
}

int main() {
	scanf("%d%d%d", &N, &M, &Q);
	scanf("%s%s", Str1 + 1, Str2 + 1);
	for (int i = 1; i <= N; ++i) (Str1[i] == 'E' ? se : sw).insert(i);
	for (int i = 1; i <= M; ++i) (Str2[i] == 'S' ? ss : sn).insert(i);
	while (Q--) {
		int sx, sy, tx, ty;
		scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
		dx[1] = sx, dx[2] = tx;
		dy[1] = sy, dy[2] = ty;
		cx = cy = 2;
		Add(Str1[sx] == 'E' ? sw : se, sx, dx, cx);
		Add(Str1[tx] == 'E' ? sw : se, tx, dx, cx);
		Add(Str2[sy] == 'S' ? sn : ss, sy, dy, cy);
		Add(Str2[ty] == 'S' ? sn : ss, ty, dy, cy);
		std::sort(dx + 1, dx + cx + 1);
		cx = std::unique(dx + 1, dx + cx + 1) - dx - 1;
		std::sort(dy + 1, dy + cy + 1);
		cy = std::unique(dy + 1, dy + cy + 1) - dy - 1;
		Cnt = tot = 0;
		for (int i = 1; i <= cx; ++i)
			for (int j = 1; j <= cy; ++j) {
				Id[i][j] = ++Cnt;
				if (dx[i] == sx && dy[j] == sy) S = Cnt;
				if (dx[i] == tx && dy[j] == ty) T = Cnt;
			}
		for (int i = 1; i <= Cnt; ++i) h[i] = 0;
		for (int i = 1; i <= cx; ++i) {
			int dir = Str1[dx[i]] == 'E';
			for (int j = 1; j < cy; ++j)
				Ins(Id[i][j + !dir], Id[i][j + dir], dy[j + 1] - dy[j]);
		}
		for (int j = 1; j <= cy; ++j) {
			int dir = Str2[dy[j]] == 'S';
			for (int i = 1; i < cx; ++i)
				Ins(Id[i + !dir][j], Id[i + dir][j], dx[i + 1] - dx[i]);
		}
		printf("%d\n", Dijkstra());
	}
	return 0;
}

// Source : AtCoder ExaWizards 2019 F

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

signed main(){
	int A, B;
	scanf("%d%d", &A, &B);
	if(B % A == 0){
		printf("%d\n", A + B);
	}
	else{
		printf("%d\n", B - A);
	}
	return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <limits.h>
#include <vector>
using namespace std;

void print(vector<int> arr) {
  for(int i=0;i<arr.size();++i) {
    cout << arr[i] << " " ;
  }
  cout << "\n";
}

int main() {
  int n;
  cin >> n;
  vector<int> dp(3, 0);
  vector<int> dp_new(3, 0);
  for(int k=0;k<n;++k) {

    int arr[3];
    for(int j=0;j<3;++j) {
      cin >> arr[j];
    }

    for(int i=0;i<3;++i) {
      for(int j=0;j<3;++j) {
	if(i!=j) {
	  dp_new[j] = max(dp_new[j], dp[i]+arr[j]);
	}
      }
    }
    dp = dp_new;
  }

    cout << max(max(dp[0], dp[1]),dp[2]) << "\n";
}


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

int main()
{
   int N;
   int A[200005],B[200005];
   int answer[20005];
   int vm = 0;
   int vs = 0;
   cin >> N;
   for(int i = 0; i < N; i++){
       cin >> A[i];
       B[i] = A[i];
   }
   
   sort(B,B+N);
   vm = B[N - 1];
   vs = B[N - 2];
   for(int i = 0; i < N; i++){
       if(A[i] < vm) answer[i] = vm;
       else if(A[i] == vm)  answer[i] = vs;      
   }
   for(int i = 0; i < N; i++) cout << answer[i] << endl;
   return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+7
#define MOD 1000000007
using namespace std;



int main(){
    int D;
    cin >> D;
    
    cout<<"Christmas";
    for(int i=0; i<25-D; i++){
        cout<<" Eve";
    }
    cout<<endl;
    return 0;
}


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


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n+5][n+5];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];

    int x=(1<<n);
    int dp[x+10]={0};
    for(int mask=0;mask<x;mask++)
        for(int i=0;i<n;i++)
            for(int j=i+1;j<n;j++)
                if((mask & (1<<i)) && (mask & (1<<j)))
                    dp[mask]+=a[i][j];

    for(int mask=0;mask<x;mask++)
    {
        int submask=mask;
        while(submask)
        {
            dp[mask]=max(dp[mask],dp[submask] + dp[submask ^ mask]);
            submask=(submask-1)&mask;
        }
    }
    cout<<dp[x-1];
}


Measured memory_bytes: 4176
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(){

    ll A,B; cin>>A>>B;
    ll Gcd = __gcd(A,B);
    ll ans = A*B/Gcd;
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
typedef pair<string, int> p;

void solve()
{
	vector<p> data;
	set<string> word;
	string str;
	while(cin >> str)
	{
		int num;
		cin >> num;
		p object(str, num);
		data.push_back(object);
		word.insert(str);
	}
	sort(data.begin(), data.end());
	set<string>::iterator it = word.begin();
	int pos = 0;
	while(it != word.end())
	{
		cout << *it << endl;
		bool flag = false;
		while(pos < data.size() && *it == data[pos].first)
		{
			if(flag)
			{
				cout << " ";
			}
			cout << data[pos].second;
			++pos;
			flag = true;
		}
		cout << endl;
		++it;
	}
}

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

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

void solve()
{
	int n;
	string a,b;
	char c[201];
	cin>>n;
	cin>>a>>b;
	int ind = 0;
	rep(i,n) 
	{
		c[ind++]=a[i];
		c[ind++]=b[i];
	}
	rep(i,2*n)
	cout<<c[i];
	cout<<endl;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;

}
    

Measured memory_bytes: 256
extern crate proconio;

use proconio::*;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars,
        t: Chars,
    }
    let n = s.len();
    for i in 0..n {
        if s[i] != t[i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 2172