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

using namespace std;

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

    int N, M;
    cin >> N >> M;
    vector<int> distance(N-1); // distance of town_i between town_{i+1}
    vector<int> accum(N-1, 0);
    for(int i = 0; i < N-1; ++i) {
        cin >> distance[i];
        if(i > 0) accum[i] = accum[i-1];
        accum[i] += distance[i];
    }
    int ans = 0;
    int cur = 0;
    for(int i = 0; i < M; ++i) {
        int d;
        cin >> d;
        int next = cur+d;
        if(d > 0) {
            int cur_acc = cur==0 ? 0 : accum[cur-1];
            ans += accum[next-1] - cur_acc;
        }
        else {
            int next_acc = next==0 ? 0 : accum[next-1];
            ans += accum[cur-1] - next_acc;
        }
        ans %= 100000;
        cur = next;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1676
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int h, w;
string s[410];
bool bl[410][410];
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 };
long long ans;

void bfs(int x, int y) {
	queue<P> que;
	que.push({ x,y });
	bl[x][y] = true;
	long long cnt1 = 0, cnt2 = 0;
	if (s[x][y] == '#')cnt1++;
	else cnt2++;
	while (!que.empty()) {
		P p = que.front(); que.pop();
		for (int i = 0; i < 4; i++) {
			int tx = p.first + dx[i], ty = p.second + dy[i];
			if (tx < 0 || h <= tx || ty < 0 || w <= ty || s[p.first][p.second] == s[tx][ty] || bl[tx][ty])continue;
			if (s[tx][ty] == '#')cnt1++;
			else cnt2++;
			bl[tx][ty] = true;
			que.push({ tx,ty });
		}
	}
	ans += cnt1 * cnt2;
}

signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++)cin >> s[i];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!bl[i][j])bfs(i, j);
		}
	}
	cout << ans << endl;
}

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

char matrix[6][6];
int totalBlack = 0;
int h, w, k;
map<pair<vector<int>, vector<int>>, bool> memo;

int dp(vector<int> r, vector<int> c, int ir, int ic)
{
    if (memo[make_pair(r, c)])
        return 0;
    int res = 0;
    if (ir == r.size() && ic == c.size())
    {
        res = totalBlack;

        for (int i = 0; i < h; i++)
        {
            for (int k = 0; k < w; k++)
            {
                if ((r[i] || c[k]) && matrix[i][k] == '#')
                {
                    res--;
                }
            }
        }

        memo[make_pair(r, c)] = true;
        res == k ? res = 1 : res = 0;
        return res;
    }
    for (int i = 0; i < 2; i++)
    {
        for (int k = 0; k < 2; k++)
        {
            int rsum = 0, csum = 0;
            if (ir < r.size())
            {
                r[ir] = i;
                rsum++;
            }
            if (ic < c.size())
            {
                c[ic] = k;
                csum++;
            }
            res += dp(r, c, ir + rsum, ic + csum);
        }
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++)
    {
        for (int k = 0; k < w; k++)
        {
            cin >> matrix[i][k];
            if (matrix[i][k] == '#')
            {
                totalBlack++;
            }
        }
    }
    vector<int> r(h, -1);
    vector<int> c(w, -1);
    int ans = dp(r, c, 0, 0);
    cout << ans;
    cin >> h;
}

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

int main(){
	string s;
	cin>>s;
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R'){
		cout<<3<<"\n";
	}else if(s[0]=='R'&&s[1]=='R'||s[2]=='R'&&s[1]=='R'){
		cout<<2<<"\n";
	}else if(s[0]=='R'||s[1]=='R'||s[2]=='R'){
		cout<<1<<"\n";
	}else{
		cout<<0;
	}
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
struct iofix
{
   ios_base::Init i;
   iofix() {
      cin.sync_with_stdio(0);
      cin.tie(0);
      cout.sync_with_stdio(0);
      cout.tie(0);
      cout.precision(10);
      cout << fixed;
   }
} iofix;
 
void solve(){
     int64_t N; cin >> N;
     cout << ( (N % 1000 == 0) ? 0 : (1000 - N % 1000) );
}
 
int main(){
// #ifndef Judge
//     freopen("in.txt","r",stdin);
//     freopen("out.txt","w",stdout);
// #endif
   	solve();
 
 #ifndef Time
     cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
 #endif
   return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    string s;
    cin >> s;
    if(s.size() == 3){
        reverse(s.begin(), s.end());
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, m;
vector<lli> e[100001];

lli color[100001];
bool isBipartite(lli v, lli c) {
  color[v] = c;
  for (lli u : e[v]) {
    if (color[u] == 0) {
      bool r = isBipartite(u, -c);
      if (!r) return r;
    } else if (color[u] == c) {
      return false;
    }
  }
  return true;
}

int main() {
  cin >> n >> m;
  for (lli i=0; i<m; ++i) {
    lli a, b; cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  bool bip = isBipartite(1, 1);

  if (bip) {
    lli w=0, b=0;
    for (lli i=1; i<=n; ++i) {
      if (color[i]==1) w++;
      else b++;
    }
    cout << w*b - m << '\n';
  } else {
    cout << n*(n-1)/2 - m << '\n';
  }
  return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
string N;
cin >> N;

if(N.size() == 1){
  print(N);
  return 0;
}

if(N.size() == 2){
  print(9);
  return 0;
}
int ans;
if(N.size() == 3) ans = (stoi(N) - 99) + 9;
if(N.size() == 4) ans =  909;
if(N.size() == 5) ans = (stoi(N) - 9999) + 909;
if(N.size() == 6) ans = 90909;
print(ans);
 }

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

struct UnionFind {
  std::vector<ll> data;

  UnionFind(ll n) { data.assign(n, -1); }

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

  int find(int k) {
    if (data[k] < 0) return k;
    return data[k] = find(data[k]);
  }

  ll size(int k) { return -data[find(k)]; }

  bool same(int x, int y) { return find(x) == find(y); }
};

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c[ohara], d[ohara], tmp, m, h, w, x, y, sum,
    k, q;
ll dp[ohara];
V g[ohara];

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

  cin >> n >> m >> k;
  UnionFind uf(n + 10);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    uf.unite(a[i], b[i]);
    g[a[i]].p_b(b[i]);
    g[b[i]].p_b(a[i]);
  }
  rep(i, k) {
    cin >> c[i] >> d[i];
    c[i]--;
    d[i]--;
    if (uf.same(c[i], d[i])) {
      dp[c[i]]++;
      dp[d[i]]++;
    }
  }
  rep(i, n) {
    ans = uf.size(i) - Size(g[i]) - dp[i] - 1;
    if (i == n - 1)
      Cout(ans);
    else
      cout << ans << " ";
  }
  return 0;
}

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

int conv(char c){
    if(c == 'A') return 10;
    else if(c == 'B') return 11;
    else if(c == 'C') return 12;
    else if(c == 'D') return 13;
    else if(c == 'E') return 14;
    else return 15;
}

int main(){
    char x, y;
    cin >> x >> y;
    int xn = conv(x);
    int yn = conv(y);

    if(xn > yn) cout << ">" << endl;
    else if(xn == yn) cout << "=" << endl;
    else cout << "<" << endl;

}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int c[3][3];
    string ans = "Yes";
    inc(i, 0, 3){
        inc(j, 0, 3){
            cin >> c[i][j];
        }
    }
    inc(i, 1, 3){
        inc(j, 1, 3){
            if(c[i][j-1]-c[i-1][j-1] != c[i][j]-c[i-1][j]) ans = "No";
            if(c[i-1][j]-c[i-1][j-1] != c[i][j]-c[i][j-1]) ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

long
fanc (long n, long buf)
{
  if (n != 1)
    buf = fanc (n - 1, buf * n);
  return buf;
}

int
main (void)
{
  long n;
  scanf ("%ld", &n);
  printf ("%ld\n", fanc (n, 1));
  return 0;
}

Measured memory_bytes: 592
i = list(map(int,input().split()))

if(i[0] < i[1]):
    if(i[0] < i[2] and i[2] < i[1]):
        print("Yes")
    else:
        print("No")

elif(i[0] > i[1]):
    if(i[1] < i[2] and i[2] < i[0]):
        print("Yes")
    else:
        print("No")

else:
    print("No")

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

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n,0);
    for(ll i=0;i<n;i++){
        cin >> p[i];
    }
    ll ans = n;
    ll memo = n+1;//min
    for(ll i=0;i<n;i++){//全部に全探索9
        memo = min(memo,p[i]);
        if(p[i] != memo)ans--;
    }
    
    cout << ans << endl;

    return 0;
}

//if(*min_element(p.begin(),p.begin()+i-1) <= p[i])ans--;
        /*for(ll j=0;j<=i;j++){//その数について他と比較
            if(p[j] < p[i]){
                ans--;
                break;
            }
        }*/
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    if((y-2*x)%2==0 && (4*x-y)%2==0)
    {
        if((y-2*x)/2>=0 && (4*x-y)/2>=0)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else
        printf("No\n");
    return 0;
}


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

int main(){
  int i=0;
  while(true){
    int X,Y;
    cin >> X >> Y;
    if(X==0 && Y==0){
      break;
    }
    else{
      cout << min(X,Y) << " " << max(X,Y) << endl;
      i++;
    }
  }
}
      
    


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
typedef long long ll;
const int N=100005;
int n,a[N];
using namespace std;

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	cin>>n;
	int i;
	for (i=1;i<=n;i++) cin>>a[i];
	int j,ans=0;
	for (i=2,j=1;i<=n;i++)
	{
		if (a[i]!=a[i-1])
		{
			int len=i-j;
			ans+=(len/2);
			j=i;
		}
	}
	int len=i-j;
	ans+=(len/2);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 764
k = int(input())

letsu = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(letsu[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>

using namespace std;


int main() {
 long long int a,b,c=0,d[100010],e[100010];
  
  cin >> a ;
  for(int i=0;i<a;i++)
   cin >> d[i];
  
  sort(d,d+a);
  
  for(int i=0;i<a-2;i++){
    for(int j = i+1;j<a-1;j++){
      
      for(int k=j+1;k<a;k++){
        
        if(d[i]+d[j] > d[k]){
          c++;
        }
        
        else{
          break;
        }
        
      }
    }
  }
  cout << c << endl;
}
      
      


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

int bubble_sort(int A[], int N) {
    bool flag = true;
    int i = 0;
    int count = 0;
    while (flag) {
        flag = false; 
        for (int j = N - 1; j > i; j--) {
            if (A[j] < A[j-1]) {
                int temp = A[j];
                A[j] = A[j-1];
                A[j-1] = temp;
                flag = true;
                count++;
            }
        }
        i++;
    }

    return count;
}

int main() {
    int N;
    int A[100];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int count = bubble_sort(A, N);
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll=long long;
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll c=a+b;
    if(n%c>a)cout<<((n/c)+1)*a<<endl;
    else cout<<((n/c)*a)+(n%c)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;

//void solve(){
//	long long n, cnt = 0;
//	cin >> n;
//	vector<int> a(n), b(n);
//	for (int i = 0; i < n; i++) cin >> a[i];
//	b = a;
//	sort(b.begin(), b.end());
//	for (int i = n - 1; i >= 0; i--){
//		vector<int>::iterator iter = find(a.begin(), a.end(), b[i]);
//		int index = distance(a.begin(), iter);
//		a.erase(iter);
//		cnt += i - index;
//	}
//	cout << cnt << endl;
//}

long long merge(vector<int> &A, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1 + 1), R(n2 + 1);
	for (int i = 0; i < n1; i++) L[i] = A[left + i];
	for (int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = 1000000001;
	long long i = 0, j = 0, cnt = 0;
	for (int k = left; k < right; k++){
		//cnt++;
		if (L[i] <= R[j]) A[k] = L[i++];
		else {
			cnt += n1 - i;
			A[k] = R[j++];
		}
	}
	return cnt;
}

long long merge_sort(vector<int> &A, int left, int right){
	long long sum = 0;
	if (left + 1 < right){
		int mid = (left + right) / 2;
		sum = merge_sort(A, left, mid) + merge_sort(A, mid, right);
		sum += merge(A, left, mid, right);
	}
	return sum;
}

void solve(){
	long long n, sum;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];
	cout << merge_sort(A, 0, n) << endl;
}

signed main(){
	solve();
}

Measured memory_bytes: 4336
import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

K = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))


def solve():
    if A[-1] == 1:
        lo = 2
        hi = 2
    elif A[-1] == 2:
        lo = 2
        hi = 3
    else:
        return None

    for a in reversed(A[:-1]):
        l = math.ceil(lo / a) * a
        h = math.floor(hi / a) * a
        if not lo <= l <= hi or not lo <= h <= hi:
            return None
        lo = l
        hi = h + a - 1
    return lo, hi


ans = solve()
if ans:
    print(*ans)
else:
    print(-1)


Measured memory_bytes: 13036
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  1000005
ll spf[N];
void sieve()
{
	for(int i=2;i<=1000000;i++)
	{
		  if(spf[i]==i)
		  {
		  	 for(int j=2*i;j<=1000000;j+=i)
		  	 {
		  	 	 if(spf[j]==j)
		  	 	 {
		  	 	 	 spf[j]=i;
		  	 	 }
		  	 }
		  }
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
  // cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        for(int i=1;i<=1000000;i++)
        {
        	spf[i]=i;
        }
        sieve();
        ll n;
        cin>>n;
        ll a[n+3];
        for(int i=1;i<=n;i++)
        {
        	cin>>a[i];
        }
        ll op=a[1];
        for(int i=1;i<=n;i++)
        {
        	op=__gcd(op,a[i]);
        }
        map<ll,ll>lol;
        ll w=0;
        for(int i=1;i<=n;i++)
        {
        	ll x=a[i];
        	while(x>1)
        	{
        		ll oi=spf[x];
        		if(lol[oi])
        		{
        			w=1;
        			break;
        		}
        		lol[oi]=1;
        		while(x%oi==0&&x>1)
        		{
        			  x/=oi;
        		}

        	}
        	if(w)
        		{
        			//cout<<i;
        			break;
        		}
        }
        if(!w)
        {
        	cout<<"pairwise coprime";
        }
        else if(op==1)
        {
           cout<<"setwise coprime";
        }
        else
        	cout<<"not coprime";

     
    }
    return 0;
}

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

int main () {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i=0; i<N; i++) {
    cin >> A[i];
    int C = A[i]-1;
    B[C] = i+1;
  }
  
  for (int i=0; i<N; i++) {
    
    cout << B[i] << " ";
  }
}

Measured memory_bytes: 4000
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    int k = 0, ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if(x == 1) k++;
        else k = 0;
        ans = max(ans, k+1);
    }
    cout << ans << "\n";
    return 0;
}



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

struct UF{
    int n;
    vector<int> par;
    UF(int n) : n(n) {
        for(int i = 0; i < n; i++) par.push_back(i);
    }
    int find(int a){
        if(a != par[a]) par[a] = find(par[a]);
        return par[a];
    }
    void join(int a, int b){
        par[find(a)] = find(b);
    }
};

vector<vector<int> > tree;
vector<pair<int,int> > ans;
vector<int> deg;

void dfs(int v, int p){
	for(int w : tree[v]){
		if(w == p) continue;
		dfs(w, v);
	}
	if(p >= 0){
		if(deg[v] & 1){
			deg[v] ^= 1;
			ans.push_back({v, p});
		} else {
			deg[p] ^= 1;
			ans.push_back({p, v});
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	UF uf(n);
	if(m & 1){
		cout << -1 << '\n';
		return 0;
	}
	tree.resize(n);
	deg.resize(n, 0);
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		if(uf.find(a) == uf.find(b)){
			ans.emplace_back(a, b);
			deg[a]++;
		} else {
			uf.join(a, b);
			tree[a].push_back(b);
			tree[b].push_back(a);
		}
	}
	dfs(0, -1);
	for(auto g : ans){
		cout << g.first + 1 << " " << g.second + 1 << '\n';
	}
}

Measured memory_bytes: 13940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {
    string s;
    cin >> s;
    int len = s.size();

    int r = 0;
    int b = 0;
    REP(i, len){
        if (s[i] == '0') r++;
        else b++;
    }

    cout << (2 *min(b, r)) << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int A = 1; A < N; A++) {
    ans += N / A;
    if (N % A == 0) ans--;
  }
  cout << ans << endl;
}

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

int main() {
	int data[] = {0,1,0,2,0,2,0,0,2,0,2,0};
	int A, B;
	cin >> A >> B;
	A--;
	B--;
	if (data[A] ==data[B]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aoj.ALDS.Chapter6A
{
    class Program
    {
        /// <summary>
        /// ?????°array????¨?????????????(?????±??????????????????)???
        /// (?????°array????????´?£????????????????????????????)???
        /// </summary>
        /// <returns></returns>
        public static List<int> CountingSort(List<int> array)
        {
            int min = array.Min();
            int max = array.Max();

            // min ~ max?????§???????´???°????????????????????????(??????????????????)???
            // ?????????array?????????????????\??????????´???????????????°????????????
            // ???????????????????????§???????????????????????????????????¢?????´????????????????????¨?????????
            // ?\?????????????????????????????????¨???????????????????????????????????????
            var counter = new Dictionary<int, int>();
            for (int i = min; i <= max; i++)
            {
                counter[i] = 0;
            }

            // array???????????????????´???????????????°????????????????????????
            foreach (var value in array)
            {
                counter[value]++;
            }

            // ??????counter??????????????????????????\??????????´?????´?????????¨????????????????????????
            // ????¶???????????´????????????°??????????´?????????????????????\?????????????????????????????????
            for (int i = min + 1; i <= max; i++)
            {
                counter[i] += counter[i - 1];
            }

            // return??¨?????????????????????????????§????????????????????????
            var bucketArray = new List<int>();
            for (int i = 0; i < array.Count(); i++)
            {
                bucketArray.Add(0);
            }

            //for (int i = array.Count() - 1; i >= 0; i--)
            for (int i = 0; i < array.Count(); i++)
            {
                int value = array[i];
                int key = counter[value];
                // Console.WriteLine("key:{0}, value{1}", key, value);

                bucketArray[key - 1] = value;

                // ????????????????´???????????????£?????´??????????????????????°???????????´???????????????\?????????????????????????????????????????????
                counter[value]--;
            }

            return bucketArray;
        }

        public static void Solve()
        {
            Console.ReadLine();
            var list = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse).ToList();

            var bucketList = CountingSort(list);

            string answer = string.Join(" ", bucketList.Select(i => i.ToString()).ToArray());
            Console.WriteLine(answer);
        }

        public static void Main()
        {
            // Console.SetIn(new System.IO.StreamReader("Aoj/AlgorithmsAndDataStructures/Input/06_Sort_A_01.txt"));
            Solve();
        }
    }
}

Measured memory_bytes: 283436
from itertools import combinations
N = int(input())

march = [0] * 5
for _ in range(N):
  S = input()
  S = S[0]
  if S == "M":
    march[0] += 1
  elif S == "A":
    march[1] += 1
  elif S == "R":
    march[2] += 1
  elif S == "C":
    march[3] += 1
  elif S == "H":
    march[4] += 1
  
ls = list(combinations(range(5),3))

ans = 0
for (i,j,k) in ls:
  ans += march[i] * march[j] * march[k]
  
print(ans)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
ll mod                = 1e9 + 7;
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll ans=1LL;
	cin >>n;
	Vi a(n);
	cin >> a;
	map<int, ll> dis;
	dis[-1] = 3LL;
	rep(i, n) {
		ans *= dis[a[i] - 1LL];
		ans %= mod;
		dis[a[i]]++;
		dis[a[i] - 1]--;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9620
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    ll m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(d1==31&&(m1==12||m1==10||m1==8||m1==7||m1==5||m1==3||m1==12||m1==1))
        cout<<1;
    else if(d1==30&&(m1==11||m1==9||m1==6||m1==4))
        cout<<1;
    else if(d1==28&&m1==2)
        cout<<1;
    else
        cout<<0;
    return 0;
}

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

long long N;
vector<long long> v[100005];

//return mini depth
long long search(long long win){
        //cout << "win = " << win << endl;
        if(v[win].size() == 0){
                return 0;
        }

        vector<long long> vec;
        for(int i = 0; i < v[win].size(); i++){
                vec.push_back(search(v[win][i]));
        }
        long long ret = 0;

        sort(vec.begin(), vec.end(), greater<long long>());
        //cout << "winwin = " << win << endl;
        //cout << "vec size = " << vec.size() << endl;
        for(int i = 0; i < vec.size(); i++){
                ret = max(ret, vec[i] + i + 1);
                //cout << "vec[" << i << "] = " << vec[i] << endl;
        }
        //cout << "return " << ret << endl;
        return ret;
}



int main(){
        cin >> N;

        for(long long i = 1; i < N; i++){
                long long tmp;
                cin >> tmp;
                tmp--;
                //i lose tmp
                v[tmp].push_back(i);
        }

        /*
        for(int i = 0; i < N; i++){
                cout << "i = " << i << endl;
                for(int j = 0; j < v[i].size(); j++){
                        cout << v[i][j] << endl;
                }
        }
        */



        cout << search(0) << endl;;
}


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

using namespace std;
typedef unsigned long long ull;

bool isLikeCoffee(string s){
	return s[2] == s[3] && s[4] == s[5];
}

int main(void){
	string s;

	cin >> s;
	if(isLikeCoffee(s)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
places = list(map(int, input().split()))

for i in range(N):
  if i == 0:
    ans = 1
    temp = abs((T - 0.006 * places[i]) - A)
  else:
    tt = abs((T - 0.006 * places[i]) - A)
    if tt < temp:
      ans = i+1
      temp = tt

print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

using P=pair<double,double>;
using Pl=pair<double,ll>;
using T=pair<double,P>;
double dist(pair<double,double>& x,pair<double,double>& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}
int main(){
  ll i,N;
  double inf=pow(2,60);
  vector<T> v(2);
  v[0].first=v[1].first=0;
  cin>>v[0].second.first>>v[0].second.second>>v[1].second.first>>v[1].second.second;
  cin>>N;N+=2;
  v.resize(N);
  v[N-1]=v[1];
  rep1(i,N-1){
    cin>>v[i].second.first>>v[i].second.second>>v[i].first;
  }

  vector<double> d(N,inf);
  priority_queue<Pl,vector<Pl>,greater<Pl>> que;
  d[0]=0;
  rep1(i,N){
    que.push(Pl(max(dist(v[i].second,v[0].second)-v[i].first,0.0),i));
  }
  while(d[N-1]==inf){
    auto x=que.top();que.pop();
    if(d[x.second]!=inf)continue;
    d[x.second]=x.first;
    rep1(i,N){
      if(d[i]==inf){
        double next=x.first+max(dist(v[i].second,v[x.second].second)-v[i].first-v[x.second].first,0.0);
        que.push(Pl(next,i));
      }
    }
  }
  printf("%.10f\n",d[N-1]);
  return 0;
}

Measured memory_bytes: 10608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define maxLen 200006
#define in insert
#define pb push_back
#define mp make_pair
#define F first
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}

int main(){
    ll n,k; cin>>n>>k;
    ll dp[k+1];
    fill(dp,dp+k+1,0);
    for(ll i=k;i>=1;i--){
        ll noOfMultiples=k/i;
        ll temp=exp(noOfMultiples,n,mod);
        temp%=mod;
        temp%=mod;
        ll extra=0;
        for(ll j=i*2;j<=k;j+=i){
            extra=(extra+dp[j])%mod;
        }
        dp[i]=(temp-extra+mod)%mod;
    }
    ll ans=0;
    for(ll i=1;i<=k;i++){
        ans+=(dp[i]%mod*i%mod)%mod;
    }
    cout<<ans%mod;
    return 0;
}


Measured memory_bytes: 4332
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int x, a, b;
    cin >> x >> a >> b;

    if(b<=a){
        cout << "delicious" << endl;
    }
    else if(b<=x+a){
        cout << "safe" << endl;
    }
    else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(2147483647)


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
X = LI()
Y = LI()
y_ret = 0
x_ret = 0
for i in range(1, n):
    x_diff = X[i] - X[i - 1]
    x_ret += x_diff * i * (n - i)
    x_ret %= mod


for j in range(1, m):
    y_diff = Y[j] - Y[j - 1]
    y_ret += y_diff * j * (m - j)
    y_ret %= mod



print(y_ret * x_ret % mod)

Measured memory_bytes: 75364
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int a,b,c;
    cin >> a >> b >> c;
    
    cout << ( b-a == c-b ? "YES" : "NO" ) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  s += s[0]; s += s[1];
  vi val(n + 2);
  rep(i, n + 2) val[i] = (s[i] == 'o') ? 1 : 0;
  rep(i, 4){
    int first = (i & 1), second = (i >> 1);
    vi check(n + 2, -1); // W = 0, S = 1
    check[0] = first; check[1] = second;
    for(int j = 1; j <= n; j++){
      check[j + 1] = (check[j - 1] ^ check[j] ^ val[j]);
    }
    if(check[0] == check[n] && check[1] == check[n + 1]){
      string ans = "";
      rep(j, n) ans += check[j] ? 'S' : 'W';
      cout << ans << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll K, A[int(2e5+5)];

bool Solve(ll num){
  ll cnt = 0;
  for (int i = 0; i < N; i++){
    cnt += (A[i] - 1) / num;
  }
  if (cnt <= K) return true;
  else return false;
}

int main(){
  cin >> N >> K;
  ll L = 0, R = 1e9;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  while (R - L > 1){
    ll now = (L + R) / 2;
    if (Solve(now)) R = now;
    else L = now;
  }
  cout << R << endl;

  return 0;
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  int N;string S;cin>>N>>S;
  int x=0,ans=0;
  rep(i,N){
    if(S[i]=='I'){
      x++;
      ans =max(x,ans);
    }
    else{
      x--;
      ans=max(x,ans);
    }
  }
  cout<<ans<<endl;
}





Measured memory_bytes: 256
import re
import functools

N = int(input())
MOD = 10 ** 9 + 7


@functools.lru_cache(maxsize=2**24)
def dfs(cur, last3):
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if not re.match('.AGC|.ACG|.GAC|A.GC|AG.C', last3 + c):
            ret += dfs(cur + 1, last3[1:] + c)
    return ret % MOD


print(dfs(0, 'TTT'))

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


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

vector<bool> kai(10001,false);
for(int i=1;i<10;i++){
kai[i]=true;
}
for(int i=1;i<10;i++){
kai[10*i+i]=true;
}
for(int i=1;i<10;i++){
	for(int j=0;j<10;j++){
	kai[101*i+10*j]=true;
	kai[1001*i+110*j]=true;
	}
}
int ans=n;
int ans2=n;
while(1){
if(kai[ans]){
cout<<ans<<endl;
break;
}
if(kai[ans2]){
cout<<ans2<<endl;
break;
}
if(ans2>=10001)ans2=n;
ans--;
ans2++;

}

return 0;
}



Measured memory_bytes: 3104
// Main maut ko takiya, aur kafan ko chadaar banakar audhta hoon!

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define len(a) ll(a.size())
#define endl "\n"

#define vll vector< ll >
#define pll pair< ll, ll >
#define vvll vector< vll >
#define vpll vector< pll >

#define umsll unordered_map<string,ll>
#define umll unordered_map<ll,ll>
#define sll set<ll>
#define minpqll priority_queue<ll,vector<ll>,greater<ll>>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " : " << arg1 << endl;
    }

    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1 << "  ";
        __f(comma + 1, args...);
    }

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

const double pi=3.141592653589793238462643383279502884197169399375105820974944;
const double e=2.71828182845904523536028747135266249775724709369995;
const ll mod=1e9+7;
const ll inf=2e18;
const ll ninf=-2e18;
const ll nax=1e6;

ll power(ll x, ll y, ll mod)
{
    ll ans=1;
    x=x%mod;
    while(y)
    {
        if(y&1)
            ans=(x*ans)%mod;

        x=(x*x)%mod;
        y>>=1;
    }
    return ans;
}

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

    int n;
    cin>>n;

    ll a[n];
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);

    bool ok = false;

    ll alice = 0;
    ll bob = 0;

    for(int i = n-1; i >= 0; i--)
    {
        if(!ok)
        {
            alice += a[i];
        }
        else
            bob += a[i];

        ok = !ok;
    }

    cout<<alice-bob;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int dfs(int, vector<int>, vector<vector<int>>, vector<int>, int);
bool check(vector<int>, vector<vector<int>>, vector<int>);
 
int main() {
    int n, m;
    cin >> n >> m;

    vector<vector<int>> v(m);
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int tmp;
            cin >> tmp;
            v[i].push_back(tmp);
        }
    }
    
    vector<int> p;
    for (int i = 0; i < m; i++) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

    vector<int> s(n);
    int ans = dfs(0, s, v, p, n);

    cout << ans << endl;
}

int dfs(int pos, vector<int> s, vector<vector<int>> v, vector<int> p, int n) {
    if (pos == n) {
        if (check(s, v, p)) {
            return 1;
        } else {
            return 0;
        }
    }

    s[pos] = 0;
    int ans1 = dfs(pos + 1, s, v, p, n);
    s[pos] = 1;
    int ans2 = dfs(pos + 1, s, v, p, n);

    return ans1 + ans2;
}

bool check(vector<int> s, vector<vector<int>> v, vector<int> p) {
    int sum = 0;
    int index = 0;
    for (vector<int> i : v) {
        for (int j: i) {
            sum += s[j-1];
        }
        if (sum%2 != p[index]) {
            return false;
        }
        index++;
        sum = 0;
    }
    return true;
}

Measured memory_bytes: 256
// 10の倍数縛り

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

int main(){
  int A, B, C, D, E;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  cin >> E;

  // 最後に何を注文するかが大事
  // mod 10 を計算して最小のものが最後に届くようにする
  int last_menu = A;
  if ( (last_menu - 1) % 10 > (B - 1) % 10 ){
    last_menu = B;
  }
  if ( (last_menu - 1) % 10 > (C - 1) % 10 ){
    last_menu = C;
  }
  if ( (last_menu - 1) % 10 > (D - 1) % 10 ){
    last_menu = D;
  }
  if ( (last_menu - 1) % 10 > (E - 1) % 10 ){
    last_menu = E;
  }
  // cout << last_menu << endl;
  int totaltime = 0;
  totaltime += A + 9 - (A-1) % 10;
  totaltime += B + 9 - (B-1) % 10;
  totaltime += C + 9 - (C-1) % 10;
  totaltime += D + 9 - (D-1) % 10;
  totaltime += E + 9 - (E-1) % 10;
  totaltime -= 9 - (last_menu-1) % 10;
  cout << totaltime << endl;
  return 0;
}


Measured memory_bytes: 256