akhauriyash/Code-Regression huggingface dataset:
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000000007

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))
#define mx 6e5 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//#include<bits/stdc++.h>
#define ll long long
const int maxn = 20005;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    fast;
    int a,b;
    cin>>a>>b;
    if(a==b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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 long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	ll dp[87];
	int n,i;
	cin>>n;
	dp[0]=2;
	dp[1]=1;
	for(i=2;i<87;i++)dp[i]=dp[i-1]+dp[i-2];
	cout<<dp[n]<<endl;
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a+b+1)/2<<endl;
    return 0;
}

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

int main(){
    string a, b;
    cin >> a >> b;
    if(a.length() >  b.length()) cout << "GREATER" << endl;
    if(a.length() <  b.length()) cout << "LESS" << endl;
    if(a.length() == b.length()){
        if(a >  b) cout << "GREATER" << endl;
        if(a <  b) cout << "LESS" << endl;
        if(a == b) cout << "EQUAL" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//lover~ crazy~
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main() {
    cin>>s>>t;
    for(int i=0;i<s.length();i++) {
    	char k=s[0];
    	for(int j=1;j<s.length();j++) s[j-1]=s[j];
    	s[s.length()-1]=k;
    	if(s==t) {cout<<"Yes";return 0;}
	}
	cout<<"No";
	return 0;
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int a, b, c;
	cin >> a >> b >> c;
	cout << max({a, b, c})*9 + a + b + c << endl;
	
	rtn 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
double a,b,c,d,e,f,x,y;
while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f) != EOF){ 
x=0;
y=0;
y = (c * d - a * f) / (b * d - e * a);
		x = (c - (b * y)) / a;

printf("%.3lf %.3lf\n",x,y);
}
return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <cstdint>
#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>
#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 mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#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 rSort(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(void)
{    
    ll n, m, k;
    cin >> n >> m >> k;
    bool r = false;
    
    rep(i, n+1) {
        rep(j, m+1) {
            if(i*(m-j) + j*(n-i) == k) r = true;
        }
    }
    
    r ? mes("Yes") : mes("No");
	
    
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 3612
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

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


int main() {
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> city(r);
    rep(i, 0, r) {
        cin >> city[i];
        city[i]--;
    }

    vector<vector<long long>> edges(n, vector<long long>(n, INF));
    rep(i, 0, n)
        edges[i][i] = 0;


    
    rep(i, 0, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edges[a][b] = c;
        edges[b][a] = c;
    }
    rep(k, 0, n) {
        rep(i, 0, n) {
            rep(j, 0, n){
                edges[i][j] = min(edges[i][j], edges[i][k] + edges[k][j]);
            }
        }
    }
    vector<int> city_copy(city);
    long long minx = INF;
    do {
        long long sumx = 0;
        rep(i, 0, r - 1) {
            int from = city[i], to = city[i + 1];
            sumx += edges[from][to];
        }
        minx = min(minx, sumx);
        
        next_permutation(city.begin(), city.end());
    } while (city != city_copy);

    cout << minx << endl;
    return 0;
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> s(N+1, 0);
    for(int i = 0; i < N; i++) {
        if(i+1 < N && S[i] == 'A' && S[i+1] == 'C') {
            s[i+1] = s[i] + 1;
        } else {
            s[i+1] = s[i];
        }
    }
    for(int q = 0; q < Q; q++) {
        int l, r;
        cin >> l >> r;
        r--;
        l--;
        cout << s[r] - s[l] << endl; 
    }
    return 0;
}

Measured memory_bytes: 1408
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N = I()
S = []
for i in range(N):
    S.append(input())
#  N = 10**5
#  S = []
#  for i in range(N):
#      S.append(random.choice(string.ascii_letters))

# count?
"""
countして、かけていく
"""
M, A, R, C, H  = 0,0,0,0,0

for s in S:
    if s[0] == "M":
        M += 1
    elif s[0] == "A":
        A += 1
    elif s[0] == "R":
        R += 1
    elif s[0] == "C":
        C += 1
    elif s[0] == "H":
        H += 1

l = [M,A,R,C,H]
result = 0
for i in range(len(l)-2):
    for j in range(i+1, len(l)-1):
        for k in range(j+1, len(l)):
            result += l[i]*l[j]*l[k]
print(result)


Measured memory_bytes: 12228
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
p = list(c.items())
p.sort(reverse = True)
tate = 0
yoko = 0
for k , v in p:
    if tate == 0 and v >= 4:
        tate = k
        yoko = k
        break
    elif tate == 0 and 2 <= v <= 3:
        tate = k
    elif tate != 0 and v >= 2:
        yoko = k
        break
    
print(tate*yoko)

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

typedef long long ll;

int h[100008];
int flag[100008];
int a[100008];
int b[100008];

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

  scanf("%d %d", &n, &m);
  for(i = 1;i <= n;i++){
    scanf("%d", &h[i]);
    flag[i] = 1;
  }

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

    if(h[a[i]] == h[b[i]]) flag[a[i]] = flag[b[i]] = 0;

    else if(h[a[i]] > h[b[i]]) flag[b[i]] = 0;

    else flag[a[i]] = 0;
  }

  for(i = 1;i <= n;i++){
    if(flag[i] == 1) cnt++;
  }

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

  return 0;
}

Measured memory_bytes: 3292
# https://atcoder.jp/contests/hitachi2020/submissions/10704509
# PyPyなら通る

def main():
    import sys
    input = sys.stdin.readline

    inf = 1 << 30
    L = 30

    N, T = map(int, input().split())

    ps = []
    coef_0 = []
    for _ in range(N):
        a, b = map(int, input().split())
        if a == 0:
            coef_0.append(b + 1)
        else:
            ps.append((a, b))  # namedtupleやめた,coef,const

    ps.sort(key=lambda p: p[0] / (p[1] + 1), reverse=True)
    coef_0.sort()

    dp = [inf] * (L + 1)
    dp[0] = 0
    for coef, const in ps:
        for visited in reversed(range(L)):
            dp[visited + 1] = min(
                dp[visited + 1],
                (dp[visited] + 1) * (coef + 1) + const
            )

    def accumulate(a):
        s = 0
        yield s  # start=x->0
        for x in a:
            s += x
            yield s

    *acc, = accumulate(coef_0)

    ans = 0
    cnt = len(acc) - 1
    for visited, consumption_time in enumerate(dp):
        rest = T - consumption_time
        if rest < 0: break  # le->lt,continue->break,restは狭義単調減少
        while cnt > 0 and acc[cnt] > rest:  # bisect_right->しゃくとり
            cnt -= 1
        ans = max(ans, visited + cnt)
    print(ans) # setのminと逐次minどちらが速い


if __name__ == '__main__':
    main()


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;

  int m;
  cin >> m;

  ii s, e;
  cin >> s.ff >> s.ss;
  --s.ff, --s.ss;
  cin >> e.ff >> e.ss;
  --e.ff, --e.ss;

  int mat[n][m];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      char x;
      cin >> x;
      mat[i][j] = (x == '.');
    }
  }

  int dx[] = {-1, 1, 0, 0};
  int dy[] = {0, 0, -1, 1};
  priority_queue<tt, vector<tt>, greater<tt>> q;
  q.emplace(0, s.ff, s.ss);
  int vis[n][m];
  memset(vis, 0, sizeof vis);

  while (!q.empty()) {
    auto [d, x, y] = q.top();
    q.pop();
    // debug(x);
    // debug(y);

    if (vis[x][y])
      continue;
    vis[x][y] = true;

    if (ii(x, y) == e) {
      cout << d << endl;
      return;
    }

    for (int k = 0; k < 4; ++k) {
      int nx = x + dx[k], ny = y + dy[k];
      if (0 <= nx && nx < n && 0 <= ny && ny < m) {
        if (mat[nx][ny]) {
          q.emplace(d, nx, ny);
        }
      }
    }

    for (int i = x - 2; i <= x + 2; ++i) {
      for (int j = y - 2; j <= y + 2; ++j) {
        if (0 <= i && i < n && 0 <= j && j < m) {
          if (mat[i][j]) {
            q.emplace(d + 1, i, j);
          }
        }
      }
    }
  }

  cout << -1 << endl;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 25000
object Main {
  def main(args: Array[String]): Unit = {
    val lines = Iterator.continually(scala.io.StdIn.readLine).takeWhile(_ != null).toList.foreach { line =>
      val in = line.split(" ").map(_.toDouble)
      val (x, y) = solve(in(0), in(1), in(2), in(3), in(4), in(5))
      println(f"${round(x)}%.3f ${round(y)}%.3f");
    }
  }

  def solve(a: Double, b: Double, c: Double, d: Double, e: Double, f: Double): (Double, Double) = {
    val det = a * e - b * d
    val inva = e
    val invb = -b
    val invc = -d
    val invd = a
    val x = (inva * c + invb * f) / det
    val y = (invc * c + invd * f) / det

    (x, y)
  }
  
  def round(x: Double): Double = {
    scala.math.round(x * 1000) / 1000.0;
  }
}

Measured memory_bytes: 44136
#include <stdio.h>
int main(void)
{
    int a,b,i,sum=0;
   scanf("%d%d", &a, &b);
  int z[b];
     for(i=0; i<b; i++)
        {
      scanf("%d", &z[i]);
        sum += z[i];
  }
    if(a<=sum)
    {
      printf("Yes\n");
  }
     else
   {
       printf("No\n");
   }
    return 0;
}

Measured memory_bytes: 1992
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int n;
	cin >> n;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
// constexpr long double EPS = 1e-15;
// const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> v;
    char c = s[0];
    int cnt = 1;
    int ans = 0;
    rep(i,1,n) {
        if (s[i] == c) cnt++;
        else {
            v.pb(cnt);
            ans += cnt - 1;
            cnt = 1;
            c = s[i];
        }
    }
    v.pb(cnt);
    ans += cnt - 1;
    cnt = 0;
    for (int i = 1; i < sz(v) && cnt < k; i += 2) {
        ans += (i == sz(v) - 1? 1:2);
        cnt++;
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define boost				  ios_base::sync_with_stdio(0);cin.tie(NULL);
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define all(p)                p.begin(),p.end()
#define iscn(num)             scanf("%d",&num);
#define scn(num)              scanf("%lld",&num);
#define scn2(num,num2)        scanf("%lld%lld",&num,&num2);
#define dbg(x)                cerr <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
void set_bit(int &N, int pos) { N=N | (1 << pos);}
void reset_bit(int &N, int pos) { N=N & ~(1 << pos);}
bool check_bit(int N,int pos) {return (bool)( N&(1 << pos));}
template <class T > void max_self(T &a, T b){
	a=max(a,b);
}
template <class T > void min_self(T &a, T b){
	a=min(a,b);
}
////////////////////////
const ll mod =1e9+7;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;

void ara_read(vec &v,ll n){
	ll temp;
	for(ll i=0; i< n; i++){
		scanf("%lld",&temp);
		v.emplace_back(temp);
	}
}
////////////////////////
void add_self(int &a,int b){
	a+=b;
	if(a>=MOD)
		a-=MOD ;
}
int main()
{
	 /* We can use bitmasking to solve this dp problem
	 * This is a very easy bitmasking problem */
	 int n;
	 scanf("%d",&n);
	 int compatible[n][n];
	 for(int i=0; i< n; ++i){
		 for(int j=0; j< n; ++j){
			 scanf("%d",&compatible[i][j]);
		 }
	 }
	 
	 //~ for(int i=0; i< n; ++i){
		 //~ for(int j=0; j< n; ++j){
			 //~ printf("%d ",compatible[i][j]);
		 //~ }
		 //~ puts("");
	 //~ }	 
	 
	 
	 
	 const int nax = (1<<n) ;
	 //~ dbg(nax);
	 vector <int > dp(nax);
	 dp[0]=1;
	 for(int mask=0; mask<nax-1; ++mask){
		 int curr = __builtin_popcount(mask);
		 for(int x=0; x< n; ++x){
			 if(compatible[curr][x] && !check_bit(mask,x)){
				 int temp = mask ^ (1<<x) ;
				 add_self(dp[temp],dp[mask]);
			 }
		 }
		  
	 }
	 //~ int maxi= 0;
	 //~ for(auto x : dp)
		//~ cerr << x <<" ";
	//~ cerr << endl;
		//~ maxi = max(maxi, x);
		//~ cerr << maxi << "\n" ;
	 printf("%d\n",dp[nax-1]);
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll a,b;
  cin >> a >> b;

  if(a>b) swap(a,b);

  ll ans;
  if(a==1 && b==2) ans = 3;
  if(a==1 && b==3) ans = 2;
  if(a==2 && b==3) ans = 1;
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


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

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

  string a, b, c;
  cin >> a >> b >> c;
  int x=(int)a.size(), y=(int)b.size(), z=(int)c.size(), p=0, q=0, r=0;
  char o='a';
  while(true){
    if(o=='a'){
      o=a[p];
      p++;
    }
    else if(o=='b'){
      o=b[q];
      q++;
    }
    else{
      o=c[r];
      r++;
    }
    if(x==p-1||y==q-1||z==r-1)break;
  }

  if(x==p-1)cout << "A\n";
  else if(y==q-1)cout << "B\n";
  else cout << "C\n";

  return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String m[] = s.split("");
    int ans = 0;
    for (int i = 0; i < s.length(); i++){
      if (m[i].equals("+")){
        ans++;
      }else{
        ans--;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35268
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, L = inm()
S = [ins() for _ in range(N)]
S.sort()

print("".join(S))


Measured memory_bytes: 9168
void main()
{
    string l = rdStr;

    long len = l.length;
    long[] exp = new long[len];
    exp[len-1] = 1;
    foreach_reverse (i; 0 .. len-1)
    {
        exp[i] = (3 * exp[i+1]) % mod;
    }

    long num = 1;
    long result;
    foreach (i, x; l)
    {
        if (x == '0') continue;
        result = (result + (num * exp[i]) % mod) % mod;
        num = (2 * num) % mod;
    }
    result = (result + num) % mod;

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 3224
# your code goes here
n = int(input())
a = input().split()
res = 1
zero = 0
for e in range(n):
	if int(a[e]) == 0:
		zero = 1
for e in range(n):
	res *= int(a[e])
	if res > 1000000000000000000:
		break
if zero == 1:
	print(0)
elif res > 1000000000000000000:
	print(-1)
else:
	print(res)

Measured memory_bytes: 19388
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		//入力から1つずつ値を取得する。
		Scanner scan = new Scanner(System.in);

		//B-A(D-C)を実施する。
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		//比較用のlistを準備する
		List<Integer> alice = new ArrayList<>();
		List<Integer> bob = new ArrayList<>();

		//差分だけ、for文ループを回す。
		//alice
		for(int i=a; i<=b; i++) {
			alice.add(i);
		}
		//bobの文
		for(int i=c; i<=d; i++) {
			bob.add(i);
		}

		//listの中身を比較して、重複を、新規で用意したlistに格納する。
		//比較結果用のlist
		List<Integer> resultList = new ArrayList<>();

		for(int strAlice:alice) {
			for(int strBob:bob) {
				if(strAlice==strBob) {
					resultList.add(strAlice);
				}
			}
		}

		//listのサイズを出力する。
		if(resultList.isEmpty()) {
			System.out.println("0");
		}
		else {
			System.out.println(resultList.get(resultList.size()-1)-resultList.get(0));	
		}
	}
}


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

using ll = long long;

int main() {
    ll N, X;
    cin >> N >> X;
    ll res = N;
    ll a = min(N - X, X), b = max(X, N - X);
    while(true) {
        if(b % a == 0) {
            res += 2 * a * (b / a - 1) + a;
            break;
        } else {
            res += 2 * a * (b / a);
            ll t = a;
            a = b %= a;
            b = t;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<map>
#include<cstdio>
using namespace std;
int main(){for(int T;~scanf("%d",&T)&&T;puts("")){
	map<pair<int,int>,int>m;
	char C[2];
	int n,k;
	for(;T--;){
		scanf("%s%d",C,&n);
		if(*C=='D'){
			for(auto it=m.begin();it!=m.end();)if(it->second==n)m.erase(it++);else	++it;
		}else if(*C=='R'){
			auto it=m.lower_bound(make_pair(n,2000000000));
			printf("%d\n",it==m.begin()||n<(--it)->first.first||it->first.second<n ? -1 : it->second);
		}else if(*C=='W'){
			int c=!scanf("%d",&k),d;
			for(auto it=m.begin();k&&it!=m.end();++it){
				d=it->first.first-c;
				if(d>k)d=k;
				if(d)m[make_pair(c,c+d-1)]=n;
				k-=d;
				c=it->first.second+1;
			}
			if(k)m.insert({{c,c+k-1},n});
		}
	}
}}

Measured memory_bytes: 1236
# 入力 N K
nk = list(map(int, input().split()))

# 制約条件
if nk[0] > 0 and 0 <= nk[1] < 101:
    if nk[0] >= nk[1]:
        s = int(nk[0] / 2)
        j = nk[0] % 2
        if nk[1] <= s + j:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			String s;
			String[][] a = new String[n][];
			int p;
			for(int i=0;i<n;i++){
				s = sc.next().replaceAll(":", " ").replaceAll(",", " ");
				a[i] = s.split(" ");
				p = a[i].length-1;
				a[i][p] = a[i][p].substring(0,a[i][p].length()-1);
				
			}
			
			ArrayList<String> list = new ArrayList<String>();
			for(int i=1;i<a[0].length;i++) list.add(a[0][i]);
			
			boolean flag;
			while(true){
				flag = false;
				for(int i=1;i<n;i++){
					if(list.contains(a[i][0])==true){
						flag = true;
						list.remove(list.indexOf(a[i][0]));
						for(int j=1;j<a[i].length;j++){
							if(list.contains(a[i][j])==false) list.add(a[i][j]);
						}
					}
				}
				if(flag==false) break;
			}
			
			System.out.println(list.size());
		}	
	}	
}

Measured memory_bytes: 43024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    bool hoge = false;
    for (int i = S.size()-T.size();i>=0;i--) {
        bool tmp = true;
        rep(j,0,T.size()) {
            if (S[i+j]==T[j] || S[i+j]=='?') {
                continue;
            }
            else {
                tmp = false;
                break;
            }
        }
        if (tmp) {
            rep(j,0,T.size()) {
                S[i+j] = T[j];
            }
            hoge = true;
            break;
        }
    }

    if (!hoge) {
        cout << "UNRESTORABLE" << endl;
    } 
    else {
        rep(i,0,S.size()) {
            if (S[i]=='?') {
                S[i] = 'a';
            }
        }
        cout << S << endl;
    }

 
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';
#define rep(i, begin, end) \
	for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

ll powof2(ll n)
{
	ll p = 2;
	ll ans = 1;
	while (n)
	{
		if (n & 1)
			ans = ans * p % MOD;
		p = p * p % MOD;
		n >>= 1;
	}
	return ans;
}

void solve()
{
	ll n;
	cin >> n;
	map<ll, ll> m;
	rep(i, 0, n)
	{
		ll x;
		cin >> x;
		m[x]++;
	}
	bool flag = false;
	if (n & 1)
	{
		if (m[0] > 1)
			flag = true;
		else
		{
			rep(i, 1, n)
			{
				if (m[i] == 1 || m[i] > 2)
					flag = true;
				if (flag)
					break;
			}
		}
	}
	else
	{
		if (m[0] > 0)
			flag = true;
		else
		{
			rep(i, 1, n)
			{
				if (m[i] == 1 || m[i] > 2)
					flag = true;
				if (flag)
					break;
			}
		}
	}
	if (flag)
		cout << '0' << endl;
	else
		cout << powof2(n / 2);
	cout << endl;
}

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

Measured memory_bytes: 6528
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n, k; cin >> n >> k;

	vector<LL> x(n);
	vector<LL> y(n);

	vector<LL> xb(n);
	vector<LL> yb(n);


	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];

		xb[i] = x[i];
		yb[i] = y[i];
	}

	sort(xb.begin(), xb.end());
	sort(yb.begin(), yb.end());

	LL ans = LLONG_MAX;

	for (int x1 = 0; x1 < n; x1++) {
		for (int x2 = x1+1; x2 < n; x2++) {

			for (int y1 = 0; y1 < n; y1++) {
				for (int y2 = y1+1; y2 < n; y2++) {

					LL xl = xb[x1];
					LL xr = xb[x2];

					LL ys = yb[y1];
					LL yu = yb[y2];

					LL cnt = 0;

					for (int i = 0; i < n; i++) {
						if (xl <= x[i] && x[i] <= xr) {
							if (yu >= y[i] && y[i] >= ys) {
								cnt++;
							}
						}
					}

					if (cnt >= k) {
						LL area = (LL)(xr - xl)*(LL)(yu - ys);

						ans = min(ans, area);
					}
				}

			}
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    string s;
    cin >> s;
    ll sum = 0;
    for(auto&& c :s) {
        sum += c - '0';
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << '\n';
    return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int k,s;
	cin >>k >>s;
	vector<ll> p( s+10);
	
	rep(x,k+1) rep(y,k+1){
		if(x+y <= s) p[x+y]++;
	}
	ll ans =0;
	rep(z,k+1) rep(q, 2*k+1){
		if(z + q == s){
			ans +=p[q];
		}
	}
	cout << ans <<endl;
	
	

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

struct node{
	int x, y, i;
};

auto func1 = [](const node &a, const node &b){
	if(a.x != b.x) return a.x < b.x;
	return a.y > b.y;
};

auto func2 = [](const node &a, const node &b){
	if(a.y != b.y) return a.y < b.y;
	return a.x > b.x;
};

priority_queue<node, vector<node>, decltype(func1) > pq1 (func1);
priority_queue<node, vector<node>, decltype(func2) > pq2 (func2);
priority_queue<int> lev2;

bool inque[100005];
int n, x, y, z;
pi a[100005];

int main(){
	scanf("%d %d %d",&x,&y,&z);
	n = x + y + z;
	lint ret = 0;
	for(int i=0; i<n; i++){
		int p, q, r;
		scanf("%d %d %d",&p,&q,&r);
		a[i] = pi(p - r, q - r);
		ret += r;
	}
	sort(a, a+n);
	reverse(a, a+n);
	for(int i=0; i<x; i++){
		ret += a[i].first;
		lev2.push(a[i].second - a[i].first);
	}
	for(int i=x; i<n; i++){
		inque[i] = 1;
		pq1.push({a[i].first, a[i].second, i});
		pq2.push({a[i].first, a[i].second, i});
	}
	for(int i=0; i<y; i++){
		while(!inque[pq1.top().i]) pq1.pop();
		while(!inque[pq2.top().i]) pq2.pop();
		node p1 = pq1.top(), p2 = pq2.top();
		if(p2.y >= p1.x + lev2.top()){
			ret += p2.y;
			inque[p2.i] = 0;
		}
		else{
			ret += p1.x + lev2.top();
			inque[p1.i] = 0;
			lev2.pop();
			lev2.push(p1.y - p1.x);
		}
	}
	cout << ret << endl;
}


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

int main()
{
    int n;
    cin >>n;
    set<string>s;
    for(int i = 1; i <= n; i++)
    {
        string te;
        cin >> te;
        s.insert(te);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19228
az={chr(97+i):50 for i in range(26)}
for _ in[0]*int(input()):
    cnt={chr(97+i):0 for i in range(26)}
    for c in input():
        cnt[c]+=1
    for c in az:
        az[c]=min(az[c],cnt[c])
print(''.join(c*az[c]for c in sorted(az)))

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

using namespace std;

int main(){

    int n;
    scanf("%d",&n);
    int t[n+1],x[n+1],y[n+1];
    for(int i = 0;i<=n;i++){
        if(i == 0){
            t[i] = 0;
            x[i] = 0;
            y[i] = 0;
        }
        else scanf("%d%d%d",&t[i],&x[i],&y[i]);
    }
    bool flag = false;
    for(int i = 1;i <= n;i++){
        if(t[i]%2 == abs(x[i]+y[i])%2 && t[i] - t[i-1] >= abs(x[i]-x[i-1] + y[i]-y[i-1])){
            flag = true;
        }
        else{
            flag = false;
            break;
        }
    }

    if(flag) printf("Yes\n");
    else printf("No\n");


   return 0; 
}

Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    S=list(input())
    ans=INF
    for i in range(len(S)-2):
        N=int(S[i]+S[i+1]+S[i+2])
        ans=min(abs(753-N),ans)
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

ll resolve(string &s)
{
    ll res = s.length();
    for (ll i = 1; i < (ll)s.length();)
    {
        if (s[i - 1] == s[i])
        {
            res--;
            i += 3;
        }
        else
        {
            i++;
        }
    }
    return res;
}

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    ll res1 = resolve(s);
    reverse(ALL(s));
    ll res2 = resolve(s);
    cout << max(res1, res2) << endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASheepAndWolves solver = new ASheepAndWolves();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASheepAndWolves {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            if (s.nextInt() <= s.nextInt())
                w.println("unsafe");
            else
                w.println("safe");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32428
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  int lr[100010][2] = {0};
  for (int i = 0; i < q; i++) {
    cin >> lr[i][0] >> lr[i][1];
  }
  vector<int> a(n + 1, 0);
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == 'C' && s[i - 1] == 'A') {
      a[i + 1] = a[i] + 1;
    }
    else {
      a[i + 1] = a[i];
    }
  }
  for (int i = 0; i < q; i++) {
    cout << a[lr[i][1]] - a[lr[i][0]] << endl;
  }
  return 0;
}

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

int main() {
  int H, W, K; cin >> H >> W >> K;
  const int MOD = 1000000007;
  vector<vector<long long>> dp(H+1, vector<long long>(W+2));
  dp.at(0).at(1) = 1;
  for (int i = 0; i < H; i++) {
    for (int bit = 0; bit < (1 << (W-1)); bit++) {
      vector<bool> L(W+1);
      for (int i = 0; i < W-1; i++) {
        if ((bit >> i) & 1) L.at(i+1) = true;
      }
      bool isValid = true;
      for (int i = 2; i < W; i++) {
        if (L.at(i) && L.at(i-1)) isValid = false;
      }
      if (!isValid) continue;
      for (int j = 1; j <= W; j++) {
        if (L.at(j-1)) {
          dp.at(i+1).at(j-1) = (dp.at(i+1).at(j-1) + dp.at(i).at(j)) % MOD;
        }
        else if (L.at(j)) {
          dp.at(i+1).at(j+1) = (dp.at(i+1).at(j+1) + dp.at(i).at(j)) % MOD;
        }
        else {
          dp.at(i+1).at(j) = (dp.at(i+1).at(j) + dp.at(i).at(j)) % MOD;
        }
      }
    }
  }
  cout << dp.at(H).at(K) << endl;
}

Measured memory_bytes: 3636
N = int(input())

#M[u][v]:隣接行列
M=[]
for n in range(N):
    input_temp=list(map(int,input().split()))
    M_temp=[-1]*N
    for k in range(0,2*input_temp[1],2):
        M_temp[input_temp[2+k]]=input_temp[2+k+1]
    M.append(M_temp)
    
#color:各頂点の訪問状態を示す
color=['white']*N

#d:TとV-Tを繋ぐ辺の中で重みが最小の辺の重みの値を保持
d=[10**10]*N

#p[v-1]:MSTにおけるvの親を保持
p=[-1]*N

#初期値
d[0] = 0
p[0] = -1

# ans=0
while True:
#     ans+=1
    mincost=10**10
    for i in range(N):
        if color[i] != 'BLACK' and d[i] < mincost:
            mincost = d[i]
            u = i
#     print(u,mincost)       
    if mincost == 10**10:
        break
    
    color[u] = 'BLACK'
    
    for v in range(N):
        if color[v] != 'BLACK' and M[u][v]!=-1:
#             print(u,v,color[v],M[u][v],d[v])
            if d[u]+M[u][v] < d[v]:
                d[v] = d[u] + M[u][v]
                p[v] = u
                color[v] = 'GRAY'
    # print(color,mincost,d,p)
    
for d_ in enumerate(d):
    print(d_[0],d_[1])


Measured memory_bytes: 5848
#include <stdio.h>

long long max(long long a, long long b) {
    if (a > b)
        return a;
    return b;
}

#define maxel 3007

long long dp[maxel][maxel];


int main(){
    int n;
    long long arr[maxel];

    scanf("%d", &n);

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

    for (int l=n-1; l >= 0; l--) {
        for (int r=l; r < n; r++) {
            if (l == r)
                dp[l][r] = arr[l];
            else
                dp[l][r] = max(arr[l] - dp[l+1][r], arr[r] - dp[l][r-1]);
        }
    }

    printf("%lld\n", dp[0][n-1]);

    return 0;
}


Measured memory_bytes: 47400
///Bismillahir Rahmanir Rahim
#define ll long long
#define ull unsigned long long
#define scf1(a)  scanf("%lld",&a)
#define scf2(a,b)  scanf("%lld %lld",&a,&b)
#define pf    printf
#define pb    push_back
#define rsrt(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define ff first
#define ss second
#define spd ios_base::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
vector<pair<ll,ll>>v;
ll n,bag;
ll dp[101][100005];
ll val[101];
ll wt[101];
int main()
{
    ll n,bag,i,j,k;

    cin>>n>>bag;

    for(i=1;i<=n;i++)
    {
        cin>>wt[i]>>val[i];
    }


    for(i=1;i<=n;i++)
    {
        for(j=1;j<=bag;j++)
        {
            if(wt[i]<=j)
            {
                dp[i][j] = max(dp[i-1][j],val[i]+dp[i-1][j-wt[i]]);
            }

            else
                dp[i][j] = dp[i-1][j];
        }
    }

    cout<<dp[n][bag]<<endl;
}


Measured memory_bytes: 78336
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		boolean[]flag = new boolean[26];
		int l = S.length();
		for(int i = 0; i < l; i++) {
			int k = S.charAt(i) - 'a';
			flag[k] = true;
		}
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < 26; i++) {
			if(!flag[i]) {
				char c = (char)(i + 'a');
				System.out.println(c);
				System.exit(0);
			}
		}
		System.out.println("None");
	}
}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] _n_m_l = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = _n_m_l[0];
            int m = _n_m_l[1];
            int l = _n_m_l[2];

            int[,] matrix_a = new int[n, m];
            int[,] matrix_b = new int[m, l];
            long[,] matrix_c = new long[n, l];

            int[] line;
            for (int i = 0; i < n; i++)
            {
                line = new int[m];
                line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();          
                for (int j = 0; j < m; j++)
                {
                     matrix_a[i, j] = line[j];
                }               
            }

            for (int i = 0; i < m; i++)
            {
                line = new int[l];
                line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                for (int j = 0; j < l; j++)
                {
                    matrix_b[i, j] = line[j];
                }
            }

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < l; j++)
                {
                    for (int k = 0; k < m; k++)
                    {
                        matrix_c[i, j] += matrix_a[i, k] * matrix_b[k, j];
                    }
                }
            }

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < l; j++)
                {
                    Console.Write(matrix_c[i,j]);
                    if (!(j == l-1))
                    Console.Write(" ");
                }
                Console.WriteLine();
            }

        }
    }
}


Measured memory_bytes: 20408
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if A <= 8 and B <= 8:
        print("Yay!")
    else:
        print(":(")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940