akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
string target;
int chk(string s){
  for(int t = 1 ; t < s.size() ; ++t){
    for(int idx = 0; idx < s.size() ; ++idx){
       string ret;
      for(int j = idx ; j < s.size() ; j += t){
        ret += s[j];
      }
      if(~ret.find(target)){
       return 1;
      }
    }
  }
  return 0;
}
 
int main(){
  int ret = 0;
  int n ; 
  while(cin >> n){
  cin >> target;
  for(int i = 0 ; i < n ; ++i){
    string s ; 
    cin >> s;
    ret += chk(s);
  }
  cout << ret << endl;
  }
}

Measured memory_bytes: 1220
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


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

	if(n == k){
		cout << 1 << endl;
		return 0;
	}

	cout << ceil((n - 1) / (k - 1)) << endl;



}



Measured memory_bytes: 640
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
const bool DEBUG = 1;
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef tuple<ll, ll> P;
typedef tuple<ll, ll, ll> P3;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<P> VP;
typedef vector<string> VS;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique(ALL(a)),(a).end())
#define PB push_back
#define EACH(i,c) REP(i,(c).size())
#define REACH(i,c) RREP(i,(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

#define BR cout<<"\n"

#define dump(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)<<"\n"
#define dump2(x,y) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n"
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<<"] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n"\
  <<" , "<<#z<<"="<<(z)<<"\n"

#define SAY(x) if(DEBUG) cerr<<"["<<__LINE__<< "] "<<(x)<<"\n"

#define YES(x) cout<<((x)?"YES":"NO")<<"\n"
#define Yes(x) cout<<((x)?"Yes":"No")<<"\n"
#define yes(x) cout<<((x)?"yes":"no")<<"\n"

inline int omajinai_int_in(){omajinai;int n;cin>>n;return n;}
inline ll omajinai_ll_in(){omajinai;ll n;cin>>n;return n;}
inline string omajinai_string_in(){omajinai;string n;cin>>n;return n;}
inline int int_in(){int n;cin>>n;return n;}
inline ll ll_in(){ll n;cin>>n;return n;}
inline string string_in(){string n;cin>>n;return n;}
#define oini omajinai_int_in()
#define oinl omajinai_ll_in()
#define oins omajinai_string_in()
#define ini int_in()
#define inl ll_in()
#define ins string_in()

#define isInside(x,y) (0<=(x)&&(x)<w&&0<=(y)&&(y)<h)

#define fi(x) (get<0>(x))
#define se(x) (get<1>(x))
#define th(x) (get<2>(x))
#define fo(x) (get<3>(x))

template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; EACH(i, v) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }

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

ll ans;

int sol(){
  int a=ini,b=ini;
  string s=ins;
  if(s.size()!=a+b+1)return 0;
  EACH(i,s){
    if(i==a && s[i]!='-')return 0;
    if(i!=a && s[i]=='-')return 0;
  }
  return 1;
}
int main() {
	//#####//
  Yes(sol());
}

//


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define rep(i,a,b) for (rg int i=(a);i<=(b);i++)
#define per(i,a,b) for (rg int i=(b);i>=(a);i--)
#define pb push_back
#define lowbit(x) (x&(-x))
#define mk make_pair
#define VI vector<int>
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define fi first
#define se second
#define il inline
#define ll long long
#define db double
#define ld long double
#define inf 0x3f3f3f3f
#define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<15,stdin),p1==p2)?EOF:*p1++)
char buf[1<<15],*p1 = buf,*p2 = buf;
inline ll read(){
    #define num ch-'0'
    char ch;bool flag=0;ll res;
    while(!isdigit(ch=getc()))
    (ch=='-')&&(flag=true);
    for(res=num;isdigit(ch=getc());res=res*10ll+num);
    (flag)&&(res=-res);
    #undef num
    return res;
}
inline void write(ll x){
	if (x < 0) x = ~x + 1ll, putchar('-');
	if (x > 9) write(x / 10ll);
	putchar(x % 10ll + '0');
}
#define mid ((l + r)>>1)
#define ls (x<<1)
#define rs ((x<<1)|1)
#undef mid
#undef ls
#undef rs
#define maxn 1010
ll dp[maxn][1<<12];
void solve()
{
	int n = read(),m = read();
	rep(i,0,m) rep(j,0,(1<<n)-1) dp[i][j] = inf;
	dp[0][0] = 0;
	rep(i,1,m)
	{
		ll cost = read();
		int K = read();
		int x = 0;
		rep(i,1,K)
		{
			int v = read();
			x|=(1<<(v-1));
		}
		rep(k,0,(1<<n)-1)
		{
			dp[i][k] = min(dp[i][k],dp[i-1][k]);
			dp[i][k|x] = min(dp[i][k|x],dp[i-1][k] + cost);
		}
	}
	cout<<(dp[m][(1<<n)-1] >=inf?-1:dp[m][(1<<n)-1]);
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("data.txt","r",stdin);
	#endif
//	int T = read();
//	while(T--)
	solve();
}

Measured memory_bytes: 35636
#include<iostream>

#define     MAX_NUMBER              10
#define     MOUNTAIN_HEIGHT_MIN     0
#define     MOUNTAIN_HEIGHT_MAX     10000
#define     MAX_SHOW_NUMBER         3

using namespace std;

int main(){
	int i,j;
	int num[MAX_NUMBER];
	bool flag;

	// MAX_NUMBER の値をチェック (プログラマのミスを防ぐ)
	if(((int)MAX_NUMBER) <= 0){
		cerr << "エラー：MAX_NUMBERの値が0以下です" << endl;
		return -1;
	}

	// 値の入力・チェック
	for(i=0;i<((int)(MAX_NUMBER));i++){
		// 値の入力
		cin >> num[i];
		// 値のチェック
		if(num[i] < ((int)MOUNTAIN_HEIGHT_MIN)){
			cerr << "エラー：" << i <<"番目の山の高さが" << ((int)MOUNTAIN_HEIGHT_MIN) << "メートル未満です" << endl;
			return -1;
		}else if(num[i] > ((int)MOUNTAIN_HEIGHT_MAX)){
			cerr << "エラー：" << i <<"番目の山の高さが" << ((int)MOUNTAIN_HEIGHT_MAX) << "メートルより大きいです" << endl;
			return -1;
		}
	}

	// 並び替えループ
	do{
		flag = false;
		for(i=0;i < (((int)(MAX_NUMBER)) - 1);i++){
			if(num[i] < num[i+1]){
				j = num[i];
				num[i] = num[i+1];
				num[i+1] = j;
				flag = true;
			}
		}
	}while(flag == true);

	for(i=0;i<((int)(MAX_SHOW_NUMBER));i++){
		cout << num[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
//テストケース100個以下、1 <= n <= 10^8
#include<iostream>
#include<cmath>
using namespace std;

char *out[3] = {"perfect number", "deficient number", "abundant number"};

int main() {
	int n;
	while( cin >> n ) {
		if (!n) break;
		
		int i, s = 0;
		for( i = 1; i <= (int)(sqrt((double)n) + 1e-6); i++ ) {
			if ( n % i == 0 ) {
				s += i;
				if ( n/i > i )
					s += n/i;
			}
		}
		s -= n;
		//cout << s << endl;
		
		if ( n == s )
			cout << out[0] << endl;
		if ( n > s )
			cout << out[1] << endl;
		if ( n < s )
			cout << out[2] << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
# include <bits/stdc++.h>
  typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second
#define all v.begin(),v.end()
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef unsigned long long ulll;
 
using namespace std ;
int main () {

    string s;
    cin>>s;
    
    for(int i=0;i<s.length();++i)
    {
        if(s[i]==',')
         s[i] = ' ';
    }
     cout<<s;
   

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

ll saiki(ll h){
  if(h==0){
    return 0;
  }else if(h==1){
    return 1;
  }else{
    return saiki(h/2) * 2 + 1;
  }
}

int main(void){
  fast_io
  ll h;cin>>h;
  cout<<saiki(h)<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;

int N;
using pint = pair<int, int>;
vector<vector<pint>> v;

bool judge(int bit) {
    for (int i = 0; i < N; ++i) {
        if (!(bit & (1 << i))) continue;
        for (pint xy : v[i]) {
            int x = xy.first;
            int y = xy.second;
            if (y == 1 && !(bit & (1 << x))) return false;
            if (y == 0 && (bit & (1 << x))) return false;
        }
    }
    return true;
}

int main() {
    cin >> N;
    v.resize(N);
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        v[i].resize(A);
        for (int j = 0; j < A; ++j) {
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }

    int res = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        if (judge(bit)) {
            int count = 0;
            for (int i = 0; i < N; ++i) {
                if (bit & (1 << i)) ++count;
            }
            res = max(count, res);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
strr = []
i = 0
while n > 0:
    rem = n % 26
    if rem == 0:
        strr.append('z')
        n = (n // 26) - 1
    else:
        strr.append(chr((rem - 1) + ord('a')))
        n = n // 26
strr = strr[::-1]
print("".join(strr))


Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<vi> c(3,vi(3));
    rep(i,3) rep(j,3) cin >> c[i][j];
    int a = c[0][0]-c[0][1],b = c[0][1]-c[0][2];
    if(c[1][0]-c[1][1] != a || c[1][1]-c[1][2] != b) {
        cout << "No";
        return 0;
    }
    if(c[2][0]-c[2][1] != a || c[2][1]-c[2][2] != b) {
        cout << "No";
        return 0;
    }
    a = c[0][0]-c[1][0];
    b = c[1][0]-c[2][0];
    if(c[0][1]-c[1][1] != a || c[1][1]-c[2][1] != b) {
        cout << "No";
        return 0;
    }
    if(c[0][2]-c[1][2] != a || c[1][2]-c[2][2] != b) {
        cout << "No";
        return 0;
    }
    cout << "Yes";
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum

def solve():
    K = II()
    one = int(list(str(K))[-1])
    if one % 2 == 0 or one == 5:
        print(-1)
        return

    cnt = 1
    first_k = 7
    while 1:
        if first_k >= K:
            break
        first_k = first_k * 10 + 7
        cnt = cnt + 1
    # print(first_k)

    q = first_k % K
    while 1:
        if q == 0:
            print(cnt)
            return
        q = (q * 10 + 7) % K
        cnt = cnt + 1


if __name__ == '__main__':
    solve()


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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  string S;
  cin >> N >> S;
  int cnt = 0;
  FOR(i, N - 2) {
    if (S.substr(i, 3) == "ABC") {
      cnt++;
    }
  }
  print(cnt);
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <utility>
#include <algorithm>
#include <iostream>
using namespace std;
#define PB push_back
#define F first
#define S second
int main(){
    int a[60][20],t,p,r,team,prob,time;
    vector<pair<pair<int,int>,int>>v;
    string s;
    while(true){
        cin>>t>>p>>r;
        v.clear();
        if(t==0&&p==0&&r==0)return 0;
        for(int i=1;i<=t;i++){
            v.PB({{0,0},i});
            for(int j=1;j<=p;j++)a[i][j]=0;
        }
        while(r--){
            cin>>team>>prob>>time>>s;
            if(a[team][prob]==-1)continue;
            if(s[0]=='W')a[team][prob]++;
            else {
                v[team-1].F.F--;
                v[team-1].F.S+=time+a[team][prob]*1200;
                a[team][prob]=-1;
            }
        }
        sort(v.begin(),v.end());
        for(pair<pair<int,int>,int> i:v)printf("%d %d %d\n",i.S,-i.F.F,i.F.S);
    }
}


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

int cnt;
vector<int> G;
void insertionSort(vector<int>& a, int n, int g) {
	for (int i = g;i < n;i++) {
		int v = a[i];
		int j = i - g;
		while (j >= 0 && a[j] > v) {
			a[j + g] = a[j];
			j = j - g;
			cnt++;
		}
		a[j + g] = v;
	}
}
void shellSort(vector<int>& a, int n) {
	// 数列gn+1=3gn+1の生成
	for (int h = 1;;) {
		if (h > n)break;
		G.push_back(h);
		h = 3 * h + 1;
	}
	for (int i = G.size() - 1;i >= 0; i--) {
		insertionSort(a, n, G[i]);
	}
}
int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	cnt = 0;
	shellSort(a, n);
	cout << G.size() << endl;
	for (int i = G.size() - 1;i >= 0;i--) {
		cout << G[i];
		if (i)cout << " ";
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0;i < n;i++)cout << a[i] << endl;
	return 0;
}


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

typedef long long ll;

int main()
{
    ll N,A,B;
    cin>>N>>A>>B;
    vector<ll> all;
    for(ll i=0; i<N; i++){
        all.push_back(i+1);
    }
    ll sz = N;
    if(A+B > N+1)
        cout<<-1<<endl;
    else if(A*B < N)
        cout<<-1<<endl;
    else{
        while(sz>=A+B-1 && sz>0){
             for(ll i=sz-A; i<sz; i++){
                cout<<all[i]<<" ";
             }
             for(ll i=0; i<A; i++)
                all.pop_back();
             sz-=A;
             B--;
        }
        if(B>0){
            for(ll i=B-1; i<sz; i++){
                cout<<all[i]<<" ";
            }
            for(ll i=0; i<B-1; i++){
                cout<<all[B-2-i]<<" ";
            }
        }
        cout<<endl;

    }
    return 0;
}


Measured memory_bytes: 6512
from collections import Counter
l = len(S := input())
counts = Counter((n := (n + (d := d * 10 % 2019) * int(S[-i])) % 2019 if i else (n := 0 * (d := 202)) for i in range(l + 1)))
print(sum(n * (n - 1) // 2 for n in counts.values()))


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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

llong dp[100001][3];

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<llong> A(n), B(n), C(n);
    rep(i, n) cin >> A[i] >> B[i] >> C[i];

    dp[0][0] = A[0]; // dp[i][j] i日目にjを選択した場合の幸福度の最大値
    dp[0][1] = B[0];
    dp[0][2] = C[0];
    for (int i = 1; i < n; ++i) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + A[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + B[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + C[i];
    }

    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]})<< endl;

    return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b,c,d,n,x,y;
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	x=n/a;
	if(n%a!=0){
		x++;
	}
	y=n/c;
	if(n%c!=0){
		y++;
	}
	if(b*x<d*y){
		printf("%d\n",b*x);
	}
	else{
		printf("%d\n",d*y);
	}
	return 0;
}


Measured memory_bytes: 2752
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::collections::*;

//fn pf_map(x: i64) -> BTreeMap<i64, i64> {
//    fn prime_index(x: i64, divisor: i64) -> (i64, i64) {
//        match x % divisor {
//            0 => {
//                let (last_state, n) = prime_index(x / divisor, divisor);
//                (last_state, n + 1)
//            }
//            _ => (x, 0),
//        }
//    };
//    (2..)
//        .scan(x, |state, i| match *state {
//            1 => None,
//            _ => {
//                let divisor = if i * i <= *state { i } else { *state };
//                let (next_state, index) = prime_index(*state, divisor);
//                *state = next_state;
//                Some((divisor, index))
//            }
//        })
//        .filter(|&(_, num)| num > 0)
//        .collect::<BTreeMap<i64, i64>>()
//}

fn pf_map(x: i64) -> BTreeMap<i64, i64> {
    (2..)
        .scan(x, |state, i| match *state {
            1 => None,
            _ => {
                let divisor = if i * i <= *state { i } else { *state };
                let mut index = 0;
                while *state % divisor == 0 {
                    *state /= divisor;
                    index += 1;
                }
                Some((divisor, index))
            }
        })
        .filter(|&(_, index)| index > 0)
        .collect()
}

fn main() {
    input! {
        n:i64
    }
    let ans: i64 = pf_map(n)
        .iter()
        .map(|(_, &index)| {
            (1..)
                .take_while(|&i| index >= i * (i + 1) / 2)
                .last()
                .unwrap()
        })
        .sum();
    println!("{}", ans);
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

const string YES = "Yes";
const string NO = "No";

int main(){
    int n;
    cin >> n;
    vpii ab(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ab[i] = pair<int, int>(b, a);
    }
    sort(all(ab));
    int t = 0;
    bool ans = true;
    for (auto w : ab) {
        if (w.first < t + w.second) ans = false;
        t += w.second;
    }
    cout << (ans?YES:NO) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(int argc, char* argv[])
{
	int x = 0, y = 0;
	scanf("%d %d", &x, &y);

	if (x > y) {
		int tmp = x;
		x = y;
		y = tmp;
	}

	bool loop = true;
	while (loop) {
		int mod = x % y;
		if (mod == 0) {
			break;
		} else {
			x = y;
			y = mod;
		}
	}
	printf("%d\r\n", y);

	return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
vector<bool>prime_t(int n){
  vector<bool>prime(n + 1,true);
  if(n >= 0)prime[0] = false;
  if(n >= 1)prime[1] = false;
  for(int i = 2; i * i <= n; i++){
    if(!prime[i])continue;
    for(int j = i + i; j <= n; j += i)prime[j] = false;
  }
  return prime;
}
int main(){
  while(true){
    int n,x;
    cin >> n >> x;
    if(n == 0 && x == 0)return 0;
    vector<int>v(n);
    rep(i,n)cin >> v[i];
    auto P = prime_t(x);
    vector<bool>dp(x + 1,false);
    dp[0] = true;
    int ans = -1;
    rep(i,x + 1){
      if(!dp[i])continue;
      if(P[i])ans = max(ans,i);
      rep(j,n){
        if(i + v[j] > x)continue;
        dp[i + v[j]] = true;
      }
    }
    if(ans == -1)cout << "NA" << endl;
    else cout << ans << endl;
  }
  return 0;
}


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

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int maxval = -1;
	int gcd = -1;
	for(int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		if(gcd == -1) gcd = x;
		else gcd = __gcd(gcd, x);
		maxval = max(maxval, x);
	}
	if(k <= maxval && k % gcd == 0) {
		printf("POSSIBLE\n");
	} else {
		printf("IMPOSSIBLE\n");
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
	Scanner s = new Scanner(System.in);
	int a , b , sum , valLen;

	while(s.hasNext()){
		String line = s.nextLine();
		String[] array = line.split(" ",0);
		a = Integer.parseInt(array[0]);
		b = Integer.parseInt(array[1]);
		sum = a + b;
		valLen = String.valueOf( sum ).length();
		System.out.println(valLen);
	}
  }
}

Measured memory_bytes: 26368
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

int n,m;
vector<int> g[M];
int dp[M]={};
bool flag[M];
int f(int x){
	if(flag[x])return dp[x];
	flag[x]=true;
	int fans=0;
	for(auto v:g[x])fans=max(fans,f(v)+1);
	return dp[x]=fans;
}


int main(){
	int x[M],y[M];
	cin>>n>>m;
	rep(i,0,m){
		cin>>x[i]>>y[i];
		g[x[i]].push_back(y[i]);
	}
	int ans=0;
	rep(i,1,n+1)ans=max(ans,f(i));
	print(ans);
}



Measured memory_bytes: 9088
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

LL N,X;

LL calc(LL a, LL b){
    if (a==0 || b==0) return 0;
    if (a>b) swap(a,b);
    if (b%a==0) return a*(2*(b/a)-1);
    return 2*a*(b/a)+calc(a,b%a);
}

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

    cout << N+calc(X,N-X) << "\n";

    return 0;
}


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

using namespace std;


int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
    int n;
    long double sum = 0;
    cin >> n;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        sum += 1./x;
    }
    cout << setprecision(5) << fixed << 1/sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a, b;
	int i, temp;
	int count = 1;

	for(i = 0; i <= 200; i++) {
		if(scanf("%d %d", &a, &b) == EOF) break;
		temp = a + b;
		count = 1;
		while(1) {
			if((temp - 10) < 0) {
				printf("%d\n", count);
				break;
			} else {
				temp /= 10;
				count++;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n >> s;

	long long r, g, b;
	r=count(s.begin(),s.end(),'R');
	g=count(s.begin(),s.end(),'G');
	b=count(s.begin(),s.end(),'B');

	long long ans=r*g*b;
	for(int i=0; i<n-2; ++i){
		for(int j=i+1; j<n-1; ++j){
			int k=2*j-i;
			if(k>=n) break;
			if(s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k]) --ans;
		}
	}

	cout << ans << endl;
}

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

int main()
{
  	int N;
  	int K;
  	int counter=0;
	cin >> N >> K;
  	for (int i=0;i<N;i++)
    {
    	int a=0;
      	cin >> a;
      	if(a>=K)
        {
        	counter++;
        }
    }
  	cout << counter << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	int N, L;
	cin >> N >> L;
	vector<char*> words;
	for (int n = 0; n < N; n++) {
		words.push_back(new char[L+1]);
		cin >> words[n];
	}
	
	sort(words.begin(), words.end(), [](char* a, char* b) {
		int ret = strcmp(a,b);
		return ret < 0;
	});

	for (auto word : words) {
		printf("%s", word);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
    
int main(void) {
  std::string s;
  std::cin >> s;
  
  std::sort(s.begin(), s.end());
  
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == s[i+1]) {
      std::cout << "no" << std::endl;
      return 0;
    }
  }

  std::cout << "yes" << std::endl;
  return 0;
}

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

int main()
{
ll n ;
cin >> n ;
string s ;
cin >> s ;
vector<ll> v;
rep(i,n){
  v.push_back(s[i]-'1');
}
bool ok=1;
rep(i,n)if(v[i]==1)ok=0;
if(ok)rep(i,n)v[i]/=2;
ll sum=0;
rep(i,n-1){
  sum+=__builtin_ffsll(n-1-i)-__builtin_ffsll(i+1);
  if(sum==0)ans=(ans+v[i+1])%2;
}
ans=(ans+v[0])%2;
if(ok)ans*=2;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 11768
#include<cstdio>
int A[1000000], n;

int binarySearch(int key){
    int left=0;
    int right=n;
    int mid;
    while(left<right){
        mid =(left+right)/2;
        if(key==A[mid]) return 1;
        if(key > A[mid]) left = mid+1;
        else if(key <A[mid]) right =mid;
    }
    return 0;
}

int main(){
    int i, q, k, sum=0;

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

    scanf("%d", &q);
    for(i=0; i<q;i++){
        scanf("%d",&k);
        if(binarySearch(k)) sum++;
    }
    printf("%d\n", sum);

    return 0;
}



Measured memory_bytes: 2948
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  vector<ll> a(n);rep(i,n)cin>>a[i];
  
  ll mi = INFL;
  ll sum = SUM(a);
  ll add = 0;
  rep(i,n){
    add += a[i];
    chmin(mi,abs(sum-add*2)); 
  }
  print(mi);
  return 0;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}

struct Dijkstra{
	struct edge {
		ll to;
		ll cost;
		edge(int a, ll b) { to = a; cost = b; }
	};

	int V;
	vector<vector<edge>> G;
	vector<ll> d;

	Dijkstra(int v) {
		V = v;
		G = vector<vector<edge>>(V);
		d = vector<ll>(V);
	}

	void addEdge(int from, int to, ll cost) {
		G[from].emplace_back(edge(to, cost));
	}

	vector<ll>& shortest_path(int s) {
		priority_queue<
				pair<ll, int>,
				vector<pair<ll, int>>,
				greater<pair<ll, int>>
		> que;
		for (ll& i : d) i = INF;
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			auto p = que.top(); que.pop();
			int v = p.second;
			if (d[v] < p.first) continue;
			for (const edge& e : G[v]) {
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
		return d;
	}
};

void Main()
{
	ll n,m,s,t;
	ll res=0;
	string sres;
	cin>>n>>m>>s>>t;
	s--;t--;
	Dijkstra en(n),sn(n);
	REP(i,m){
		ll u,v,a,b;
		cin>>u>>v>>a>>b;
		u--;v--;
		en.addEdge(u,v,a);
		en.addEdge(v,u,a);
		sn.addEdge(u,v,b);
		sn.addEdge(v,u,b);
	}

	auto &A=en.shortest_path(s);
	auto &B=sn.shortest_path(t);
	VI AB(n);
	REP(i,n) AB[i]=A[i]+B[i];
	VI dp(n+1);
	dp[n]=INF;
	REPD(i,n){
		dp[i]=min(dp[i+1],AB[i]);
	}
	REP(i,n){
		res=1e15;
		res-=dp[i];
		COUT(res);
	}
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 19784
using System;

class Program
{
    static void Main(string[] args)
    {
        int n;

        string num = Console.ReadLine();
        n = int.Parse(num);

        for (int i = 1; i <= n ; i++)
        {
            if (i % 3 == 0 || i % 10 == 3 || i % 100 / 10 == 3 || i % 1000 / 100 == 3 || i % 10000 / 1000 == 3)
            {
                Console.Write(" " + i);
            }     
        }
        Console.WriteLine("");
    }
}



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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

const int M = 1e9 + 7;
const int N = 1e3 + 1;
int a[N][N], dp[N][N];

int main()
{
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            char c;
            cin >> c;
            if(c == '#')
                a[i][j] = 0;
            else
                a[i][j] = 1;
        }
    }

    int k = 1;
    for(int i = 0; i < h; i++)
    {
        if(!a[i][0])
            k = 0;
        dp[i][0] = k;
    }
    k = 1;
    for(int j = 0; j < w; j++)
    {
        if(!a[0][j])
            k = 0;
        dp[0][j] = k;
    }
    for(int i = 1; i < h; i++)
    {
        for(int j = 1; j < w; j++)
        {
            if(!a[i][j])
                dp[i][j] = 0;
            else
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % M;
        }
    }

    cout << dp[h - 1][w - 1];

    return 0;
}


Measured memory_bytes: 8064
def main():
    input()
    mod = 10**9 + 7
    ar = sorted(map(int, input().split()))
    ar.reverse()

    cnt = ar[0] + ar[1]
    an = ar[0] * ar[1] % mod

    for i in range(2, len(ar)):
        an += cnt * ar[i]
        cnt += ar[i]

    print(an % mod)


if __name__ == '__main__':
    main()

Measured memory_bytes: 31432
n,m = map(int,input().split())
done = [0]*(n+1)
wa = [0]*(n+1)
pen = 0
for i in range(m):
  p,q = input().split()
  p = int(p)
  if q == "WA":
    if done[p] == 0:
      wa[p] += 1
  else:
    if done[p] == 0:
      done[p] = 1
      pen += wa[p]
print(sum(done),pen)

Measured memory_bytes: 4596
#include<cstdio>
#include<iostream>

using namespace std;

int main(void){

	int l1,l2,l3;
	int ty=0,hi=0;

	while(scanf("%d,%d,%d",&l1,&l2,&l3)!=EOF){

		if(l1*l1+l2*l2==l3*l3) ty++;
		if(l1==l2) hi++;
	}

	printf("%d\n%d\n",ty,hi);

	return 0;
}

Measured memory_bytes: 1188
using System;
class game{
    public static void Main(){
        int gamenumber = int.Parse(Console.ReadLine());
        int[] point = new int[2];
        point[0] = 0; point[1] = 0;
        String[] words;
        for(int i=0; i<gamenumber; i++){
            words = Console.ReadLine().Split(' ');
            if(string.Compare(words[0], words[1]) < 0){
                point[1]+=3;
            }
            else if(string.Compare(words[0], words[1]) > 0){
                point[0]+=3;
            }
            else{
                point[0]++;
                point[1]++;
            }
        }
        Console.WriteLine("{0} {1}",point[0],point[1]);
    }
}


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

int main() {
	int N;
	cin>>N;
	string S;
	cin >> S;
	
	int num=0;
	int m=0;
	for(int i=0; i<N; i++){
		if(S[i]=='I'){
			num+=1;
			m=max(m,num);
		}else{
			num--;
		}
	}
	cout<< m << endl;
	return 0;
}

Measured memory_bytes: 256
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

let cnt = 0;

const merge = (arr, left, mid, right) => {
    const n1 = mid - left;
    const n2 = right - mid;
    const L = [];
    const R = [];

    for (let i = 0; i < n1; i++) {
        L[i] = arr[left + i];
    }
    for (let i = 0; i < n2; i++) {
        R[i] = arr[mid + i];
    }

    L[n1] = 1/0;
    R[n2] = 1/0;

    let i = 0;
    let j = 0;
    for (let k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            arr[k] = L[i];
            i++;
        } else {
            arr[k] = R[j];
            j++;
        }
    }
};

const msort = (arr, left, right) => {
    if (left + 1 < right) {
        const mid = Math.floor((left + right) / 2);
        msort(arr, left, mid);
        msort(arr, mid, right);
        merge(arr, left, mid, right);
    }
};

const data = line[1].split(' ').map(Number);
msort(data, 0, data.length);
console.log(data.join(' '));
console.log(cnt);



Measured memory_bytes: 121452
#include <iostream>
#include<vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	
	if ((a + b) % 2 == 0){
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 505;

int n, k, sum = 0;
int a[N];

int check(int x)
{
	int reqd = 0;
	vector<int> v;
	for(int i = 1; i <= n; i++)
	{
		int cur = a[i] % x;
		v.push_back(cur);
	}
	sort(v.begin(), v.end());
	int l = 0, r = v.size() - 1;
	int rem = 0;
	while(l <= r)
	{
		if(rem <= 0)
		{
			rem += v[l];
			reqd += v[l];
			l++;
		}
		else
		{
			rem -= (x - v[r]);
			reqd += (x - v[r]);
			r--;
		}
	}
	if(reqd > 2 * k)
		return 0;
	if(rem != 0)
		return 0;
	return 1;
}

int32_t main()
{
	IOS;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	int ans = 1;
	for(int i = 1; i * i <= sum; i++)
	{
		if(sum % i == 0)
		{
			if(check(i))
				ans = max(ans, i);
			if(check(sum / i))
				ans = max(ans, sum / i);
		}
	}
	cout << ans;
	return 0;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	map<int, int>a;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		a[tmp]++;
	}
	int ret = 0;
	for (auto itr = a.begin(); itr != a.end(); ++itr) {
		int key = itr->first;       // キーを表示
		int value = itr->second;
		//cout << "key= " << key << " value= " << value << endl;
		if (value < key) ret += value;
		else if (value > key) ret += (value - key);
	}
	print(ret);
}

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

int main(){
  string s;
  cin >> s;
  if(s == "keyence"){
    cout << "YES" << endl;
    return 0;
  }
  for(int i = 0; i < s.size(); i++){
    for(int j = i; j < s.size(); j++){
      string t = s;
      t.erase(i, j - i + 1);
      if(t == "keyence"){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,d,w,h,i,j,k,l,m,n,x,y,z;
	ll		ans = 0;
	string	s;
	cin >> n;
	vector<pair<ll,ll>>	aa( 100001 , make_pair(0,0) ), bb(100001 , make_pair(0,0) );

	for(i=0;i<n;i+=2){
		cin >> a >> b;
		aa[a].first++;
		bb[b].first++;
		aa[a].second = a;
		bb[b].second = b;
	}
	sort(aa.begin(),aa.end());
	sort(bb.begin(),bb.end());
	ans = n - (aa[100000].first + bb[100000].first);
	if (ans==0 && a==b) ans = n / 2;
	else {
		if (aa[100000].second == bb[100000].second) {
			c = max(aa[100000].first + bb[99999].first ,
			        aa[99999].first + bb[100000].first);
			ans = n - c;

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


Measured memory_bytes: 6432
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
 
l = [0]*(N+1)
r = [0]*(N+1)

for i in range(N):
	l[i+1] = gcd(l[i], A[i])
for i in reversed(range(N)):	
	r[i] = gcd(r[i+1],A[i])

ans = 0
for i in range(N):
	ans = max(ans, gcd(l[i], r[i+1]))
print(ans)

Measured memory_bytes: 16148
a,b,k = map(int,input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        a /= 2
        b += a
    else:
        if b % 2 == 1:
            b -= 1
        b /= 2
        a += b
print(str(int(a)) + " " + str(int(b)))


Measured memory_bytes: 2940
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] S = new char[H][W];
		for(int i = 0; i < H; i++)
			S[i] = sc.next().toCharArray();
		int ans = 0;
		int[] dx = {1, -1, 0, 0};
		int[] dy = {0, 0, 1, -1};
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(S[i][j] == '#')
					continue;
				Queue<Integer> q = new ArrayDeque<>();
				q.add(i);
				q.add(j);
				boolean[][] used = new boolean[H][W];
				int[][] dist = new int[H][W];
				int max = 0;
				while(!q.isEmpty()) {
					int x = q.poll();
					int y = q.poll();
					if(used[x][y])
						continue;
					used[x][y] = true;
					for(int k = 0; k < 4; k++) {
						int xx = x + dx[k];
						int yy = y + dy[k];
						if(xx >= H || xx < 0 || yy >= W || yy < 0)
							continue;
						if(S[xx][yy]  == '#' || used[xx][yy])
							continue;
						q.add(xx);
						q.add(yy);
						dist[xx][yy] = dist[x][y] + 1;
						max = Math.max(dist[xx][yy], max);
					}
				}
				ans = Math.max(ans, max);
			}
		}
		System.out.println(ans);

	}

}


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

int n;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    int sum = a1 + a2 + a3;
    if(sum >= 22)cout << "bust";
    else cout << "win";
    cout << '\n';
    return 0;
}







Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

namespace Tree
{
    class Rooted_Trees
    {
        struct Node
        {
            public int id;
            public int parent;
            public int depth;
            public int[] childlen;
            public int type;
            public string Type { get { switch (type) { case 0: return "root"; case 1: return "internal node"; case 2: return "leaf"; default: return null; } } }
        }
        static void Main(string[] args)
        {
            int size = int.Parse(Console.ReadLine());
            var nodes = new Node[size];

            for (int i = 0; i < size; i++)
                nodes[i].parent = -1;

            for (int i = 0; i < size; i++)
            {
                var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var id = token[0];
                nodes[id].id = id;

                var k = token[1];
                if (k == 0) nodes[id].type = 2;
                else
                {
                    nodes[id].type = 1;
                    nodes[id].childlen = new int[k];
                    for (int j = 0; j < k; j++)
                    {
                        nodes[id].childlen[j] = token[2 + j];
                        nodes[token[2 + j]].parent = id;
                        nodes[token[2 + j]].depth = nodes[id].depth + 1;
                    }
                }
            }

            for (int i = 0; i < size; i++)
                if (nodes[i].parent == -1) nodes[i].type = 0;
                else nodes[i].depth = nodes[nodes[i].parent].depth + 1;

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            for (int i = 0; i < size; i++)
            {
                Console.Write("node {0}: parent = {1}, depth = {2}, {3}, [", nodes[i].id, nodes[i].parent, nodes[i].depth, nodes[i].Type);
                if (nodes[i].childlen != null) Console.Write(string.Join(", ", nodes[i].childlen.Select(s => s.ToString()).ToArray()));
                Console.WriteLine("]");
            }

            Console.Out.Flush();

        }
    }
}

Measured memory_bytes: 22928