akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define MAX (12)

int search_seq(int *seq, int len, int num);
int numcmp(int *seq_s, int *seq_c, int len);

int main(void)
{
	int now_seq[MAX];
	int af_seq[MAX];
	int count;
	int len;
	int i;
	
	while (1){
		scanf("%d", &len);
		if (len == 0){
			break;
		}
		
		for (i = 0; i < len; i++){
			scanf("%d", &now_seq[i]);
		}
		
		for (i = 0; i < len; i++){
			af_seq[i] = search_seq(now_seq, len, now_seq[i]);
		}
		
		for (count = 0; numcmp(now_seq, af_seq, len) == 0; count++){
			for (i = 0; i < len; i++){
				now_seq[i] = af_seq[i];
			}
			
			for (i = 0; i < len; i++){
				af_seq[i] = search_seq(now_seq, len, now_seq[i]);
			}
		}
		
		printf("%d\n", count);
		for (i = 0; i < len; i++){
			printf("%d%c", now_seq[i], (i == len - 1) ? '\n' : ' ');
		}
	}
	
	return (0);
}

int search_seq(int *seq, int len, int num)
{
	int i;
	int count;
	
	count = 0;
	for (i = 0; i < len; i++){
		if (seq[i] == num){
			count++;
		}
	}
	
	return (count);
}

int numcmp(int *seq_s, int *seq_c, int len)
{
	int i;
	
	for (i = 0; seq_s[i] == seq_c[i] && i < len; i++);
	
	if (i == len){
		return (1);
	}
	
	return (0);
}

Measured memory_bytes: 0
<?php
    $R = fgets(STDIN);
    $S = fgets(STDIN);
	$ans = 0;
	if($R[0] ==$S[0]){
    	$ans += 1;
    }
	if($R[1] ==$S[1]){
    	$ans += 1;
    }
	if($R[2] ==$S[2]){
    	$ans += 1;
    }
	echo $ans;

?>

Measured memory_bytes: 4604
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    int temp;
    cin >> a;
    cin >> b;
    cin >> c;
    while (!(a <= b && b <= c)) {
        if (a > b) {
            temp = a;
            a = b;
            b = temp;
        }
        if (b > c) {
            temp = b;
            b = c;
            c = temp;
        }
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	while (true) {
		string S;
		cin >> S;
		if (S == "-") break;

		int n;
		cin >> n;

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

			string tmp = S.substr(0, h);
			S.erase(0, h);
			S += tmp;
		}
		cout << S << endl;
	}

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast
    string s;
    cin >> s;
    for(int i=0;i<3;i++) cout << s[i];
    return 0;
}


Measured memory_bytes: 3652
/*
  AtCoder Beginner Contest 104
  B - AcCepted
*/

#include<iostream>
using namespace std;

string S;

int main() {
  cin >> S;

  int cnt = 0;
  bool check = true;

  if (S[0] == 'A') {
    for (int i = 1; i < S.length(); ++i) {
      if ('a' <= S[i] && S[i] <= 'z') continue;
      
      if (2 <= i && i <= S.length() - 2 && S[i] == 'C') ++cnt;
      else check = false; // 範囲内にあるC以外の大文字
    }
  }

  if (check && cnt == 1) printf("AC\n");
  else printf("WA\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int a, b, c;
    cin >> a >> b >> c;
    
    cout << max(a, max(b, c)) -  min(a, min(b, c)) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

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

	for (ll i = 0; i < N; i++) {
		//i回は大きくなり,N - 1 - i回は小さくなる
		ll max = A + i * D - (N - 1 - i) * C;
		ll min = A + i * C - (N - 1 - i) * D;
		if (min <= B && B <= max) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const ll INF = 1001001001;
const double pi = acos(-1);

int main()
{
    int n, r;
    cin >> n >> r;
    if (n >= 10)
    {
        cout << r << endl;
    }
    else
    {
        cout << r + 100 * (10 - n) << endl;
    }

    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 100000000

using namespace std;

int main() {
   string a,b,c;
   cin >> a >> b >> c;
   if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0])
   cout << "YES" << endl;
   else 
   cout << "NO" << endl;
 }

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);

	if(a > b) {
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else if(a = b){
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    map<long long, long long> t;
    long long res = 0;
    long long ans = 0;
    t[0]++;
    long long ten = 1;
    for(int i = s.size() - 1; i >= 0; i--){
        res = (res + ten*(s[i] - '0')) % 2019;
        if(t.count(res)) ans += t[res];
        t[res]++;
        ten = ten * 10 % 2019;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
ll const MOD = 1e9 + 7;
double pi = 3.141592653589793238;

ll mod_pow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (mod_pow(a, 1, p) * mod_pow(a, n-1, p)) % p;
  ll t = mod_pow(a, n / 2, p);
  return (t * t) % p;
}

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

  ll ans = mod_pow(10, n, MOD) - 2 * mod_pow(9, n, MOD) + mod_pow(8, n, MOD);
  ans %= MOD;
  if (ans < 0) ans += MOD;
  cout << ans << endl;

  return 0;
}


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

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

    int P[N] = {};
    for (int i = 1; i < N; i++) {
        int A;
        cin >> A;
        P[A-1]++;
    }

    // 出力
    for (int i = 0; i < N; i++) cout << P[i] << endl;
    return 0;
}


Measured memory_bytes: 4412
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int H = scan.nextInt();
			int W = scan.nextInt();

			String []s = new String[H];
			char[][]a = new char[H][W];
			for(int i = 0;i<H;i++) {
				s[i] = scan.next();
				a[i] = s[i].toCharArray();
			}

			for(int i = 0;i<H;i++) {
				boolean ok = true;
				for(int j = 0;j<W;j++) {
					if(a[i][j]=='#')ok = false;
				}
				if(ok==true) {
					Arrays.fill(a[i],'+');
				}
			}


			for(int i = 0;i<W;i++) {
				boolean ok = true;
				for(int j = 0;j<H;j++) {
					if(a[j][i]=='#')ok = false;
				}
				if(ok==true) {
					for(int j = 0;j<H;j++) {
						a[j][i]='+';
					}
				}
			}


			for(int i =0;i<H;i++) {
				int count = 0;
				for(int j = 0;j<W;j++) {

					if(a[i][j]!='+') {
						System.out.print(a[i][j]);
						count++;
					}
				}
				if(count!=0)
					System.out.println();
			}



		}


	}


}


Measured memory_bytes: 38784
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n--){
		string s,ss;
		cin>>s>>ss;
		for(int i=s.size()-1;i>=0;i--){
			if(s[i]=='P')
				for(int j=0;j<ss.size();j++)
					if(ss[j]>='0'&&ss[j]<='9')
						ss[j]=(ss[j]-'0'+9)%10+'0';
			if(s[i]=='M')
				for(int j=0;j<ss.size();j++)
					if(ss[j]>='0'&&ss[j]<='9')
						ss[j]=(ss[j]-'0'+1)%10+'0';
			if(s[i]=='A')reverse(ss.begin(),ss.end());
			if(s[i]=='E')for(int k=0;k<ss.size()/2;k++)swap(ss[k],ss[(ss.size()+1)/2+k]);
			if(s[i]=='J')ss=ss[ss.size()-1]+ss.substr(0,ss.size()-1);
			if(s[i]=='C')ss=ss.substr(1,ss.size()-1)+ss[0];
		}
		cout<<ss<<endl;
	}
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=0;i--)
#define p(s) cout<<(s)<<endl
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;

int H,W;
char a[110][110];
//set<int> s;
map<char,int> m;
string ans;
int key;
int main() {
	cin>>H>>W;
	REP(i,0,H){
		REP(j,0,W){
			cin>>a[i][j];
			m[a[i][j]]++;
		}
	}

	if(H%2) key=W/2;
	if(W%2) key+=H/2;

	int cnt=0;
	int one=0;
	for(char i='a';i<='z';i++){
		if(m[i]%4==0) continue;
		else if(m[i]%4==2) cnt++;
		else if (m[i]%4==1) one++;
		else {
			cnt++;
			one++;
		}
	}

	if(one>1||((H*W)%2==0&&one==1)||cnt>key) ans="No";
	else ans="Yes";
	p(ans);

	return 0;
}


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

int getcoin(int A,int B){
    int sum=0;
    if(A>B){
        sum += A;
        A--;
    }
    else {
        sum += B;
        B--;
    }
    return sum += max(A,B);
}
int main(){
    int A,B;
    cin >> A >> B;
    cout << getcoin(A,B) << endl;
    return 0;
    
}

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

using namespace std;

typedef long long ll;

#define int long long

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    vector <ll> d;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            d.push_back(i);
            if (n / i != i) {
                d.push_back(n / i);
            }
        }
    }
    // x * (i + 1) = n
    set <int> have;
    ll ans = 0;
    for (ll x : d) {
        ll y = n / x;
        y--;
        if (y > 0 && !have.count(y) && (n / y == n % y)) {
            ans += y;
        }
        have.insert(y);
    }
    cout << ans << '\n';
    return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    for(int i = a; i <= b; ++i) if(c%i == 0) ++cnt;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

char a,b;
int main()
{
	cin>>a>>b;
	if(a<b)
		cout<<"<"<<endl;
	else if(a==b)
		cout<<"="<<endl;
	else
		cout<<">"<<endl;
 return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;++i) cin>>s[i];
  for(int i=0;i<n;++i) sort(s[i].begin(),s[i].end());
  sort(s.begin(),s.end());
  
  int i=0;
  int64_t ans=0;
  while(i<n){
    int64_t j=0;
    while(i+j<n && s[i+j]==s[i]) ++j;
    ans += j*(j-1);
    i = i+j;
  }
  cout<<ans/2<<endl;
}

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

int main() {
  long long N;
  cin>>N;
  long long X=1;
  vector<long long> A(N);
  
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    if(A.at(i)==0){
      X=0;
      break;
    }
  }
  if(X!=0){
   for(int i=0;i<N;i++){ 
      if(A.at(i)<=1000000000000000000/X){
        X*=A.at(i);
      }else{
        X=-1;
        break;
        }
   }
  }
  cout<<X;
}


Measured memory_bytes: 4060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1e9 + 7
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int x;
    cin >> x;
    cout << 10 - x / 200 << endl;
}

Measured memory_bytes: 3632
N = int(input())
cnt = [0]*4
judge = ["AC","WA","TLE","RE"]
for i in range(N):
    s = input()
    if s=="AC":
        cnt[0]+=1
    elif s=="WA":
        cnt[1]+=1
    elif s=="TLE":
        cnt[2]+=1
    else:
        cnt[3]+=1
for i in range(4):
    print(judge[i],"x",cnt[i])

Measured memory_bytes: 9156
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());

ll n,m,q,a[51],b[51],c[51],d[51],v[10],f=-1;

void dfs(ll x,ll p=1)
{
	if(x==n)
	{
		ll k=0;
		rep(i,q)
		{
			if(v[b[i]]-v[a[i]]==c[i])
				k+=d[i];
		}
		f=max(f,k);
		return;
	}
	repe(i,p,m+1)
	{
		v[x]=i;
		dfs(x+1,i);
	}
}

int main()
{
	IOS;
	ll i,j,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>m>>q;
		// n=s.length();
		// ll a[n];
		rep(i,q)
		{
			cin>>a[i]>>b[i]>>c[i]>>d[i];
			a[i]--; b[i]--;
		}
		dfs(0);
		cout<<f;

		
		cout<<"\n";
	}
	return 0;
}

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

ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

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

ll fact(ll n){
	ll res = 1;
	rep(i, n){
		res *= i + 1;
		res =  res%((ll)(1e9 + 7));
	}
	return res;
}


int main(){
	ll n;
	cin >> n;
	cout << fact(n) << endl;
}

Measured memory_bytes: 256
n,v,s;char*S="?\x06[Ofm}'\x7fo";main(b,i){for(;~scanf("%d",&n);)for(s=0;n-->0;puts(""),s^=b)for(scanf("%d",&v),b=S[v]^s,i=7;i--;)putchar(48|b>>i&1);}

Measured memory_bytes: 0
// ABC_171_B

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

  int sum = 0;
  vector<int> v(n);
  for(int i = 0; i < n; ++i) {
    cin >> v[i];
}

  sort(v.begin(), v.end());
  //  for(int i = 0; i < n; ++i) cout << v[i] << "\n";

  for(int i = 0; i < k; ++i) {
    sum = sum + v[i];
    //cout << sum << "\n";
  }

  cout << sum << "\n";

  return 0;
}


Measured memory_bytes: 3632
while True:
    i = input()
    a, op, b = i.split()
    if op == '?':
        break
    a, b = int(a), int(b)

    if op == '*':
        print(a * b)
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '/':
        print(a // b)




Measured memory_bytes: 5600
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

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

void f(ll rest,string s){
    if(rest==0){
        cout<<s<<endl;
    }else{
        for(char c='a';c<='c';c++){
            f(rest -1,s+c);
        }
    }
}


int main(){
    double w,h,x,y;
    ll c=0;
    cin>>w>>h>>x>>y;
    if(x==w/2 && y==h/2) c=1;
    cout<<fixed<<w*h/2<<" "<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
require 'pp'

K,A,B = readline.chomp.split.map(&:to_i)

if B-A <= 2
  puts 1+K
else
  if K < A-1
    puts 1+K
  else
    k = K - (A-1)
    sum = A + (B-A) * (k/2)
    if k % 2 == 1
      sum += 1
    end
    puts sum
  end
end



Measured memory_bytes: 2172
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

OFS=20
KK = 41
n = inn()
d = [[0]*KK for i in range(KK)]
for i in range(n):
    a = ins()
    p = a.find('.')
    if p<0:
        v = int(a)
        k = 0
    else:
        b = a[:p]+a[p+1:]
        v = int(b)
        k = len(a)-1-p
    x2 = 0
    while v%2==0:
        x2 += 1
        v //= 2
    x2 = min(x2,OFS)
    x5 = 0
    while v%5==0:
        x5 += 1
        v //= 5
    x5 = min(x5,OFS)
    d[x2-k+OFS][x5-k+OFS] += 1

#if DBG:
#    for i in range(KK):
#        for j in range(KK):
#            if d[i][j]!=0:
#                ddprint(f"i {i-OFS} j {j-OFS} {d[i][j]}")

ans = 0
h = {}
for p in range(KK):
    for q in range(KK):
        sm = 0 if p<OFS or q<OFS else (d[p][q]*(d[p][q]-1)//2)
        #if sm>0:
        #ddprint(f"p {p-OFS} q {q-OFS} d {d[p][q]} {sm=}")
        for r in range(-p+2*OFS,KK):
            #if r==p:
            #    continue
            for s in range(-q+2*OFS,KK):
                if (r,s)==(p,q) or (r,s,p,q) in h:
                    continue
                h[(p,q,r,s)] = 1
                sm += d[p][q]*d[r][s]
                #if d[p][q]*d[r][s]>0:
                #    ddprint(f"p {p-OFS} q {q-OFS} r {r-OFS} s {s-OFS} d {d[p][q]} {d[r][s]}")
        ans += sm
print(ans)


Measured memory_bytes: 180488
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using ll = long long;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using ld = long double;
using ui = unsigned int;
using ull = unsigned long long;
using ui128 = __uint128_t;
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define lc ind<<1
#define rc ind<<1|1
const int MN = 1e5 + 2, LOG = 17, INF = 1e8;
char s[MN];
int wot[MN];
int main () { 
	int n;
	scanf ("%d",&n);
	auto nxt = [&] (int a) {int x = a + 1; return x > n ? 1 : x;};
	auto lst = [&] (int a) {int x = a - 1; return x < 1 ? n : x;};
	scanf ("%s",s+1);
	for (int a = 0; a < 2; a++) {
		for (int b = 0; b < 2; b++) {
			wot[1] = a; wot[2] = b;
			for (int i = 3; i <= n; i++) {
				if ((s[i-1] == 'o' && wot[i-1] == 0) || (s[i-1] == 'x' && wot[i-1] == 1)) wot[i] = wot[i-2];
				else wot[i] = wot[i-2] ^ 1;
			}
			bool ok = 1;
			for (int i = 1; i <= n; i++) {
				if ((s[i] == 'o' && wot[i] == 0) || (s[i] == 'x' && wot[i] == 1)) ok &= wot[nxt(i)] == wot[lst(i)];
				else ok &= wot[nxt(i)] != wot[lst(i)];
			}
			if (ok) {
				for (int i = 1; i <= n; i++) putchar(wot[i]?'W':'S');
				return 0;
			}
		}
	}
	printf ("-1\n");
    return 0;
}


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

using namespace std;

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

    vector<int> dp(k + 1, 0);
    for (int i = 1; i <= k; ++i) {
        for (auto x : a) {
            if (x <= i && dp[i - x] == 0)
                dp[i] = 1;
        }
    }
    
    if (dp[k] == 1) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }

     
    return 0;
}


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

int n, a, b;

bool cal_sum(int x){
  int sum = 0;
  while(x != 0){
    sum += x % 10;
    x /= 10;
  }
  if(a <= sum && sum <= b){
    return true;
  }else{
    return false;
  }
}

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

  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(cal_sum(i)) ans += i;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000
vector<int>e[N];
bool used1[N];
bool used2[N];
bool used[N];
int ans[N];
queue<int>q;

void dfs(int k, int x,int y) {
	f(i, e[k].size()) {
		if (x == 1) {
			if (!used1[e[k][i]]) {
				used1[e[k][i]] = true;
				dfs(e[k][i], x + 1,y);
			}
		}
		else if (x == 2) {
			if (!used2[e[k][i]]) {
				used2[e[k][i]] = true;
				dfs(e[k][i], x + 1,y);
			}
		}
		else{
			if (!used[e[k][i]]) {
				used[e[k][i]] = true;
				ans[e[k][i]] = y + 1;
				q.push(e[k][i]);
			}
		}
	}
	return;
}


int main() {
	int n, k, m;
	int x, y, z;
	int s, t;
	scanf("%d %d", &n, &m);
	f(i, m) {
		scanf("%d %d", &x,&y);
		x--;
		y--;
		e[x].push_back(y);
	}
	scanf("%d %d", &s, &t);
	s--;
	t--;
	f(i, N) {
		used1[i] = false;
		used2[i] = false;
		used[i] = false;
		ans[i] = -1;
	}
	used[s] = true;
	ans[s] = 0;
	q.push(s);
	while (!q.empty()) {
		x = q.front();
		q.pop();
		dfs(x, 1, ans[x]);
		if (used[t])break;
	}
	printf("%d\n", ans[t]);


	return 0;
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
    int n = in();
    int sum = 0;
    int m = 0;
    while (sum < n) {
        ++m;
        sum += m;
    }

    while (sum > n) {
        if (sum - m >= n) {
            sum -= m;
        } else {
            cout << m << endl;
        }
        --m;
    }

    while (m) {
        cout << m << endl;
        --m;
    }


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<vector<int>> matricies(n, vector<int>(n, 0));
	while(n--) {
		int u, k;
		cin >> u >> k;
		while(k--) {
			int v;
			cin >> v;
			matricies.at(u-1).at(v-1) = 1;
		}
	}

	for (int i = 0; i < matricies.size(); i++) {
		for (int j = 0; j < matricies.at(0).size(); j++) {
			if (j == matricies.at(0).size() - 1) cout << matricies.at(i).at(j) << endl;
			else cout << matricies.at(i).at(j) << " ";
		}
	}
}



Measured memory_bytes: 3140
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  ll ans = 1;
  repeat(i,N){
    ans = ans*(i+1)%MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int H, W, dp[2][10946][2][2], bits[10946], nxts[10946], conv[1 << 19], maxbits;

char M[20][21];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	int maxbit = 1 << (W - 1);

	for (int i = 0; i < maxbit; i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok)
		{
			conv[i] = maxbits; bits[maxbits++] = i;
		}
	}

	for (int i = 0; i < maxbits; i++)
	{
		nxts[i] = conv[(bits[i] << 1) & (maxbit - 1)];
	}

	for (int i = 0; i < H * W - 1; i++)
	{
		int s = i % 2;
		int t = (i + 1) % 2;

		for (int j = 0; j < maxbits; j++)
		{
			dp[t][j][0][0] = 0;
			dp[t][j][0][1] = 0;
			dp[t][j][1][0] = 0;
			dp[t][j][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		for (int j = 0; j < maxbits; j++)
		{
			int sum0 = dp[s][j][0][0] + dp[s][j][1][0];
			int sum1 = dp[s][j][0][1] + dp[s][j][1][1];

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[t][nxts[j]][0][0] += sum0;
				dp[t][nxts[j]][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[t][nxts[j] + 1][1][0] += dp[s][j][0][0];
					dp[t][nxts[j] + 1][1][1] += dp[s][j][0][1];

					dp[t][nxts[j] + 1][1][0] %= 100000;
					dp[t][nxts[j] + 1][1][1] %= 100000;

					dp[t][nxts[j]][1][0] += dp[s][j][1][0];
					dp[t][nxts[j]][1][1] += dp[s][j][1][1];
				}
				else
				{
					dp[t][nxts[j]][1][0] += sum0;
					dp[t][nxts[j]][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[t][nxts[j]][1][1] += sum0;
				}
				else
				{
					dp[t][nxts[j]][1][0] += sum0;
				}

				dp[t][nxts[j]][1][1] += sum1;
			}

			dp[t][nxts[j]][0][0] %= 100000;
			dp[t][nxts[j]][0][1] %= 100000;
			dp[t][nxts[j]][1][0] %= 100000;
			dp[t][nxts[j]][1][1] %= 100000;
		}
	}

	int ret = 0;

	int last = (H * W + 1) % 2;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[last][i][0][1];
		ret += dp[last][i][1][1];

		ret %= 100000;
	}

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

	return 0;
}

Measured memory_bytes: 3396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){
  int n;
  cin >> n;
  set<int> st;
  rep(i,n){
      int tmp;
      cin >> tmp;
      st.insert(tmp);
  }
  cout << st.size() << endl;
}

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

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

int main() {
int A,B,T ;
cin >> A >> B >> T;
int t = 0;
int sum = 0;

for (int i = 1; i < 23;i++){
  t += A ;
  if (t > T){
    cout << sum << endl;
    break;
  }
  else {
    sum += B ;
  }
  
}

}






Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int[] a = new int[6];
	double x, y, p, q;
	while(sc.hasNext()){
	    for(int i=0; i<6; i++)
		a[i]=sc.nextInt();
	    p = (double)(a[2]*a[4]-a[1]*a[5]);
	    q = (double)(a[2]*a[3]-a[0]*a[5]);
	    if(p==0)
		x = 0;
	    else
		x = p/(a[0]*a[4]-a[1]*a[3]);
	    if(q==0)
		y = 0;
	    else
		y = q/(a[1]*a[3]-a[0]*a[4]);
	    System.out.printf("%.3f %.3f\n", x, y);
	}
    }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    if(s=="AAA" || s=="BBB") cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 256
DBG = !true
DBG2 = !true
m,n = gets.split.map{|x| x.to_i}
a = []
for i in 0...n
  a << gets.to_i
end

def sum(p,q)
  puts "sum(#{p},#{q}) called b[q] #{$b[q]}" if DBG
  if p > q
    v = 0
  elsif p == 0
    v = $b[q]
  else
    v = $b[q] - $b[p-1]
  end
  puts "sum returns #{v}" if DBG
  return v
end

def xl(a,m,k,r)
  v = 2*sum(k-r,k-1) + (2*r-1)*m - 2*sum(k+2,k+r) -
      a[k+1] + [ a[k+1]-a[k], m+a[k]-a[k+1] ].max
  if k+r < a.size - 1
    v += 2*(m-a[k+r+1])
  end
  puts "xl: k #{k} r #{r} returns #{v}" if DBG
  return v
end

def xr(a,m,k,r)
  v = 2*sum(k-r,k-2) + (2*r)*m - 2*sum(k+1,k+r) +
      a[k-1] + [ a[k]-a[k-1], m+a[k-1]-a[k] ].max
  if k-r > 0
    v += 2*a[k-r-1]
  end
  puts "xr: k #{k} r #{r} returns #{v}" if DBG
  return v
end

# # main # #
$b = [ a[0] ]
for i in 1...n
  $b << $b[i-1] + a[i]
end

if n==1
  mx = [ a[0], m-a[0] ].max
  print mx
  exit
end

v0 = m - a[1] + [ a[1]-a[0], m+a[0]-a[1] ].max
vn1 = a[n-2] + [ a[n-1]-a[n-2], m+a[n-2]-a[n-1] ].max
mx = [v0, vn1].max
puts "v0 #{v0} vn1 #{vn1}" if DBG2

for k in 1..(n-2)
  r = [k, n-1-k].min
  vl = xl(a,m,k,r)
  mx = vl if vl > mx
  vr = xr(a,m,k,r)
  mx = vr if vr > mx
  puts "k #{k} xl #{vl} xr #{vr}" if DBG2
end

print mx


Measured memory_bytes: 5372
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    
    int a, b, c;
    a = N / 100;
    N %= 100;
    b = N / 10;
    N %= 10;
    c = N;

    if(a == c){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
string s, t;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s>>t;
    string ans="";
    ans+=t;
    ans+=s;
    cout << ans << "\n";
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int m[2],d[2],i,j;
    for (i = 0; i < 2; i++)
    {
        scanf("%d %d",&m[i],&d[i]);
    }
    printf("%d",m[0] == m[1] ? 0 : 1);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================


signed main() {
	string str;
	cin >> str;

	string bef = "_";
	string now = "";
	auto s = str.size();
	ll ans = 0;
	FOR(i, 0, s) {
		now += str[i];
		if (bef != now) {
			++ans;
			bef = now;
			now = "";
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;

int teleport[200005];
int step[200005];
int destination[200005];

int main()
{
    int N;
    ll K;
    scanf("%d%lld", &N, &K);
    for (int i = 0; i < N; i++) {
        scanf("%d", &teleport[i]);
        teleport[i]--;
    }
    memset(step, -1, sizeof(step));
    int number = 1;
    int position = 0;
    destination[number-1] = position+1;
    while (step[position] < 0) {
        step[position] = number++;
        position = teleport[position];
        destination[number-1] = position+1;
    }
    number--;
    int loopPoint = position;
    int nonLoopCount = step[position]-1;
    int cyclesCount = number - nonLoopCount;
    if (K > nonLoopCount) {
        K = (K - nonLoopCount) % cyclesCount + nonLoopCount;
    }
    printf("%d\n", destination[K]);
    return 0;
}


Measured memory_bytes: 5976
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    fast;
    ll n,i,j,k,l,ans,m,q;
    cin>>n;
    j=1000000000+7;
    l=1;
    k=1;
    m=1;
    for(i=1;i<=n;i++)
    {
        l=(l*10)%j;
    }
    for(i=1;i<=n;i++)
    {
        k=(k*9)%j;
    }
    k=(k*2)%j;
    for(i=1;i<=n;i++)
    {
        m=(m*8)%j;
    }
    q=(k-m+j)%j;
    ans=(l-q+j)%j;
    cout<<ans<<endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxx 100003
ll ks(ll n,ll c,ll w[],ll p[],ll dp[][maxx])
{
    if(n==0)
    {
        if(c>=w[n])
            return p[n];
        return 0;
    }
    if(dp[n][c]!=-1)
        return dp[n][c];
    ll ans1=INT_MIN;
    if(c>=w[n])
        ans1 = ks(n-1,c-w[n],w,p,dp)+p[n];
    return dp[n][c]=max(ans1,ks(n-1,c,w,p,dp));
}
int main()
{
    ll n,c;
    cin>>n>>c;
    ll w[n+1],p[n+1];
    for(ll i=0;i<n;i++)
        cin>>w[i]>>p[i];
    ll dp[n+1][maxx]={0};
    memset(dp,-1,sizeof(dp));
    cout<<ks(n-1,c,w,p,dp)<<endl;
}


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

int c[60][60];
bool visited[60][60];
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int h, w;

bool check(int x, int y){
  if(x < 0 || y < 0)return false;
  if(x >= w || y >= h)return false;
  if(visited[y][x])return false;
  if(c[y][x] == 0)return false;
  return true;
}

void dfs(int x, int y){ 
  if(!check(x, y))return;

  visited[y][x] = true;
  for(int i = 0; i < 8; i++){
    dfs(x + dx[i], y + dy[i]);
  }
}

int main(){
  while(cin >> w >> h, w || h){
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        scanf("%d", &c[i][j]);
      }
    }

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        visited[i][j] = false;
      }
    }

    int cnt = 0;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if(!visited[i][j] && c[i][j] == 1){
          dfs(j, i);
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 3136
mod = 998244353
a, b, c, d = map(int, input().split())

dp0 = [0] * (c-a+1)
dp1 = [1]
for i in range(c-a):
    dp1.append(dp1[-1] * b % mod)

for j in range(1, d-b+1):
    new_dp0 = [(dp0[0] * a + dp1[0]) % mod]
    new_dp1 = [dp1[0] * (a-1) % mod]
    for i in range(1, c-a+1):
        new_dp0.append((dp0[i] * (a+i) + dp1[i]) % mod)
        new_dp1.append((new_dp0[-2] + new_dp1[-1]) * (b+j) % mod)

    dp0 = new_dp0
    dp1 = new_dp1

print((dp0[-1] + dp1[-1]) % mod)

Measured memory_bytes: 78748
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb(x) push_back(x)

typedef pair<ll,ll> pp;
int lcm(int a, int b)
{
    int lar = max(a, b);
    int small = min(a, b);
    for (int i = lar; ; i += lar) {
        if (i % small == 0)
            return i;
    }
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b) {
    return (a.second < b.second);
}

ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;     // Initialize result
  
    x = x % p; // Update x if it is more than or
                // equal to p
   
    if (x == 0) return 0; // In case x is divisible by p;
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
  
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

struct ArrayWrapper
{
    int a[101][101];
};

bool isPowerOfTwo (ll x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
vector<vector<ll>> x;
ll n, m, q;


void dfs(vector<ll> v, ll last){
    if(last != 0) v.push_back(last);
    if(v.size() != n) for(ll i = 0;last+i <= m;i++){
        dfs(v, last+i);
    }
    if(v.size() == n) x.push_back(v);
}

void solve(){
    cin >> n >> m >> q;
    vector<vector<ll>> vv;
    while(q--){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        vector< ll > temp;
        temp.push_back(a);
        temp.push_back(b);
        temp.push_back(c);
        temp.push_back(d);
        vv.push_back(temp);
    }
    vector< ll > temp;
    dfs(temp, 1);
    ll mx = -1;
    for(ll i =  0;i < x.size();i++){
        
        ll sum = 0;
        for(ll j = 0;j < vv.size();j++){
            ll a = vv[j][0], b = vv[j][1], c = vv[j][2], d = vv[j][3];
            if(x[i][b-1] - x[i][a-1] == c) sum += d;
        }//cout << sum << endl;
        mx = max(mx, sum);
    }
    cout << mx << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //ll t; cin >> t; while(t--)
        solve();
}


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

int N, K;
main() {
  cin >> N;
  cin >> K;
  int center = ((N/2)+(N%2)-1)%3;
  for(int i = 0; i < K; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    a = a - N/2;
    b = b - N/2;
    if(N%2 == 0) {
      if(a < 0) a += 1;
      if(b < 0) b += 1;
    }
    a = abs(a);
    b = abs(b);
    int tmp;
    tmp = max(a, b);
    int c;
    cout << ((N/3)*3-tmp+center)%3+1 << endl;
  }
}

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

int main(){
  int k;
  cin >> k;
  if(k%2==0||k%5==0){
    cout << -1 << endl;
    return 0;
  }
  if(k%7==0){
    k /= 7;
  }
  k *= 9;
  int m=10,n=1;
  while(m%k!=1%k){
    m *= 10;
    m %= k;
    n++;
  }
  
  cout << n << endl;
}

Measured memory_bytes: 3632