akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;

}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;

}

int min(int x, int y){
  return x < y ? x : y;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = n + 1;

  while (head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0) enqueue(u);
    else printf("%s %d\n",u.name, elaps);

  }

  return 0;
}



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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> t(N+2), v(N+2);
    for(int i=1; i<=N; i++) cin >> t[i];
    for(int i=1; i<=N; i++) cin >> v[i];
    int T = 0;
    for(int i=1; i<=N; i++) T += t[i];

    t[0] = 0; v[0] = 0;
    t[N+1] = 0; v[N+1] = 0;

    vector<int> vlim(2*T+1, 1<<30);

    int pos0 = 0, pos1;
    for(int i=0; i<N+2; i++){
        pos1 = pos0 + 2*t[i];
        for(int j=0; j<=pos0; j++)
            vlim[j] = min(vlim[j], 2*v[i] + pos0-j);
        for(int j=pos0; j<=pos1; j++)
            vlim[j] = min(vlim[j], 2*v[i]);
        for(int j=pos1; j<=2*T; j++)
            vlim[j] = min(vlim[j], 2*v[i] + j - pos1);
        pos0 = pos1;
    }
    int ans = 0;
    for(int i=0; i<2*T; i++){
        int v1 = vlim[i];
        int v2 = vlim[i+1];
        ans += v1+v2;
    }

    cout << fixed << setprecision(12) << ans / 8.0 << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
 
int main(){
	int k, a, b;
    cin >> k;
  	cin >> a >> b;
    while( a <= b ){
    	if( a++ % k == 0 ){cout << "OK"; return 0;}
    }
    cout << "NG";
  	return 0;
}

Measured memory_bytes: 3608
#define ll long long
#define MOD 1000000007 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define T long long t;cin>>t;while(t--)
#define foe(i) for(int i=1;i<=n;i++)
#define fo(i) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin>>n;
  double a[1006];
  double ans=0;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
    ans+=1/a[i];
  }
  cout<<setprecision(15)<<1/ans;
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
int t[100000];
int main(){
    int n,c,k;
    scanf("%d%d%d",&n,&c,&k);
    for(int i=0;i<n;i++)scanf("%d",&t[i]);
    std::sort(t,t+n);
    int ti,cnt=0,ans=1;
    for(int i=0;i<n;i++){
        if(cnt==0){
            ti=t[i];
            cnt=1;
        }else if(t[i]-ti>k || cnt>=c){
            ans++;
            ti=t[i];
            cnt=1;
        }else cnt++;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 512
N = int(input())
a = [int(input()) for i in range(N)]

a.sort()
ans = sum(a)

S = [ans - i for i in a]
maxtenga = 0

for i in range(len(S)):
    if S[i] % 10 != 0:
        maxtenga = S[i]
        break

flag = False
for i in range(len(a)):
    if a[i] % 10 != 0:
        flag = True

if ans % 10 != 0:
    print(ans)
elif flag is False:
    print(0)
else:
    print(maxtenga)


Measured memory_bytes: 3064
#include<stdio.h>

int main(){

  int n,h[100],i,j,count=0,yama=1;

  scanf("%d",&n);

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

  //自分より前と同じか高ければ見える
  for(i=1;i<n;++i){
    for(j=0;j<i;++j){
      if(h[i]>=h[j]){
        ++count;
      }
    }
    if(count==i){
      ++yama;
    }
    count = 0;
  }
  printf("%d\n",yama);

return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

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

	ll p = 0;
	ll t = 1;
	while( p < x ){
		p += t;
		t += 1;
	}
	
	cout << t-1 << endl;

	ret 0;
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    for(auto& c : s){
        c = (c - 'A' + n) % 26 + 'A';
    }
    cout << s << endl;
    return 0;
}


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

// Top Down DP
int frog2TopDown(int cur, int heights[], int N, int K, int dp[]) {
    // Base Case
    if(cur >= N) return 0;
    // Recursive Case
    if(dp[cur] != 0) return dp[cur]; // Look Up
    int ans = INT_MAX;
    for(int steps = 1; steps <= K; steps++) {
        ans = min(ans, (abs(heights[cur] - heights[cur + steps]) + frog2TopDown((cur + steps), heights, N, K, dp)));
    }
    return (dp[cur] = ans);
}

// Bottom Up DP
int frog2BottomUp(int heights[], int N, int K) {
    int dp[100005] = {0};
    dp[0] = 0; // Base Case
    for(int i = 1; i <= N; i++) {
        dp[i] = INT_MAX;
        for(int steps = 1; steps <= K; steps++) {
            int cur_ans = (i < steps) ? INT_MAX : (abs(heights[i] - heights[i - steps]) + dp[i - steps]);
            dp[i] = min(dp[i], cur_ans);
        }
    }
    return dp[N];
}

// Bottom Up DP (With 1 Based Indexing)
int frog2BottomUp_1(vector<int> arr, int N, int K) {
    vector<int> dp(N + 1);
    dp[1] = 0;
    for(int i = 2; i <= N; i++) {
        dp[i] = INT_MAX;
        for(int j = (i - 1); (j >= 1 && (i - j) <= K); j--) {
            dp[i] = min(dp[i], (abs(arr[i] - arr[j]) + dp[j]));
        }
    }
    return dp[N];
}

int main() {
    int N, K;
    cin >> N >> K;
    //int heights[100005];
    //for(int i = 0; i < N; i++) cin >> heights[i];
    // Top Down Approach
    //int dp[100005] = {0};
    //cout << frog2TopDown(0, heights, N - 1, K, dp) << endl;
    // Bottom Up Approach
    //cout << frog2BottomUp(heights, N - 1, K) << endl;
    // Bottom Up Approach With 1 Based Indexing
    vector<int> stones(N + 1);
    for(int i = 1; i <= N; i++) {
        cin >> stones[i];
    }
    cout << frog2BottomUp_1(stones, N, K) << endl;
    return 0;
}

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


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

	int n;
	cin >> n;
	map<string, int> m;
	rep(i, n){
		string command, value;
		cin >> command >> value;
		if (command == "insert") {
			m.insert(make_pair(value, 1));
		} else if (command == "find") { 
			if (m.find(value) != m.end()) cout << "yes" << endl;
			else cout << "no" << endl;
		} 
	}
}




Measured memory_bytes: 33264
#include<bits/stdc++.h>
#define ll long long
#define M 1000000007

using namespace std;

// Solve function here


// End Solve function

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
    //ifstream cin("input.in");
	//clock_t start, finish;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a%d) a = a/d+1;
	else a /= d;
	if(c%b) c = c/b+1;
	else c /= b;
	if(c <= a) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

vector<ll> factors;
vector<ll> factors1;


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int n;
    cin >> n;
    vector<ll> A(n);
    REP(i, n) cin >> A[i];
    factors.pb(1);
    factors.pb(A[0]);
    factors1.pb(1);
    factors1.pb(A[1]);
    for (int i = 2; i < sqrt(A[0]) + 2; i++) {
        if (A[0] % i == 0) {
            factors.pb(i);
            factors.pb(A[0] / i);
        }
    }
    for (int i = 2; i < sqrt(A[1]) + 2; i++) {
        if (A[1] % i == 0) {
            factors1.pb(i);
            factors1.pb(A[1] / i);
        }
    }
    int ans = 1;
    REP(i, SZ(factors)) {
        int ccc = 0;
        FOR(j, 1, n-1) {
            if (A[j] % factors[i]) {
                ccc++;
                if (ccc > 1) {
                    break;
                }
            }
        }
        if (ccc < 2 && factors[i] > ans) ans = factors[i];
    }
    REP(i, SZ(factors1)) {
        int ccc = 0;
        FOR(j, 0, n-1) {
            if (j == 1) continue;
            if (A[j] % factors1[i]) {
                ccc++;
                if (ccc > 1) {
                    break;
                }
            }
        }
        if (ccc < 2 && factors1[i] > ans) ans = factors1[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll a[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll sum = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        a[i] *= 2;
        if (i % 2)
            sum -= a[i];
        else
            sum += a[i];
    }
    ll x = sum / 2;
    cout << x << ' ';
    for (int i = 0; i < n - 1; ++i)
        cout << (x = (a[i] - x)) << ' ';
}


Measured memory_bytes: 2176
import math
import itertools
N = int(input())
x = [0] * N
y = [0] * N
way = [0] * N
seq = []
dis = 0

def distance(a, b):
    return ((x[way[a]] - x[way[b]]) ** 2 + (y[way[a]] - y[way[b]]) ** 2) ** 0.5

for i in range(N):
    x[i], y[i] = map(int, input().split())
    seq.append(i)

ways = list(itertools.permutations(seq))

n = len(ways)
for i in range(n):
    way = ways[i]
    for j in range(N - 1):
        dis += distance(j, j + 1)
print(dis / n)


Measured memory_bytes: 8180
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t {}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 0xde0b6b43b9aca00;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;

  vector <ll> p (n);
  rep (i, n) cin >> p [i];

  sort (ALL (p));

  ll ans = 0;
  FOR (ite, begin (p), prev (end (p)))
  {
    ans += * ite;
  }
  ans += p.back () / 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
s=input()
k=int(input())
n=len(s)

koho=set()
for i in range(n):
    for j in range(i+1, min(i+k+1, n+1)):
        c=s[i:j]
        if c not in koho:
            koho.add(c)
ans=sorted(list(koho))
print(ans[k-1])


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

int N;
int a[20000];

int main(){  
  //freopen("ABC049C_in.txt", "r", stdin);

  scanf("%d\n",&N);
  for(int i=1;i<=N;i++){
    scanf("%d",a+i);
  }

  int res=0;
  while(true){
      bool flag=false;
      for(int i=1;i<=N;i++){
        if(!flag){
          if(a[i]%2==0){a[i]/=2;flag=true;}
          /*else{a[i]*=3;}*/
        }
        else{
          break;
        }
        /*else{
          a[i]*=3;
        }*/
      }
      if(!flag){break;}
      res+=1;
  }
  printf("%d\n",res);

  return 0;
}

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

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

  if(n==1){
    cout << "Hello World";
    return 0;
  } else {
    int a, b;
    cin >> a >> b;
    cout << a+b;
    return 0;
  }
}


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

int main() {
  int64_t x;
  cin >> x;
  int64_t ans_500 = x/500;
  x = x%500;
  int64_t ans_5 = x/5;
  cout << ans_500*1000 + ans_5*5 << endl;
}

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
S = rs()
f = ''
ans = -1
for i in S:
    if f != i:
        ans += 1
    f = i
print(ans)

Measured memory_bytes: 64492
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int g[12]={0,1,0,2,0,2,0,0,2,0,2,0};
    int x,y;
    cin>>x>>y;
    x=g[x-1];
    y=g[y-1];
    if(x==y)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(int argc, char *argv[]) 
{
    std::string s;
    std::cin >> s;

    std::string divide[4] ={"dream", "dreamer", "erase", "eraser"};

    std::reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++) {
        reverse(divide[i].begin(), divide[i].end());
    }

    bool can = true;
    for (int i = 0; i < s.size();) {
        bool can2 = false;
        for (int j = 0; j < 4; j++) {
            std::string d = divide[j];
            if (s.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }

    if (can) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO"  << std::endl;
    }

    return 0;
}

Measured memory_bytes: 512
a,b,c = map (int, input().split())
if a < b:
	if a < c:
		if b < c:
			print(a, b, c)
		else:
			print(a, c, b)
	else:
		print(c, a, b)
else:
	if b < c:
		if a < c:
			print(b, a, c)
		else:
			print(b, c, a)
	else:
		print(c, b, a)
		

Measured memory_bytes: 7656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  vector<vector<ll>>vec(3,vector<ll>(3));
  vector<vector<ll>>ans(3,vector<ll>(3,0));
  for(ll i=0;i<3;i++){
    for(ll j=0;j<3;j++){
      cin>>vec.at(i).at(j);
    }
  }
  ll N;
  cin>>N;
  vector<ll>bin(N);
  for(ll i=0;i<N;i++){
    cin>>bin.at(i);
  }
  for(ll k=0;k<N;k++){
    for(ll i=0;i<3;i++){
      for(ll j=0;j<3;j++){
        if(bin.at(k)==vec.at(i).at(j)){
          ans.at(i).at(j)=1;
          break;
        }
      }
    }
  }
  if(ans.at(0).at(0)==1&&ans.at(1).at(1)==1&&ans.at(2).at(2)==1){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(ans.at(0).at(2)==1&&ans.at(1).at(1)==1&&ans.at(2).at(0)==1){
    cout<<"Yes"<<endl;
    return 0;
  }
  for(ll i=0;i<3;i++){
    if(ans.at(i).at(0)==1&&ans.at(i).at(1)==1&&ans.at(i).at(2)==1){
      cout<<"Yes"<<endl;
      return 0;
    }
    if(ans.at(0).at(i)==1&&ans.at(1).at(i)==1&&ans.at(2).at(i)==1){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}
    


Measured memory_bytes: 3648
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(M);
    vector<vector<ll>> ADJ(N+1);
    vector<ll> visited(N+1,-1);
    FORI(i,0,M)
    {
        READV(u);
        READV(v);
        ADJ[u].pb(v);
        ADJ[v].pb(u);
    }
    deque<ll> bfs;
    visited[1]=0;
    bfs.pb(1);
    while (bfs.size()>0)
    {
        ll u=bfs.front();
        bfs.pop_front();
        for(auto v:ADJ[u])
        {
            if(visited[v]==-1)
            {
                visited[v]=u;
                bfs.pb(v);
            }
        }
    }
    bool ok=true;
    FORI(i,2,N+1)
    {
        if(visited[i]==-1)
        {
            ok=false;
        }
    }
    if(ok)
    {
        cout<<"Yes"<<endl;
        FORI(i,2,N+1)
        {
            cout<<visited[i]<<endl;
        }
    }
    else
    {
        cout<<"No"<<endl;
    }

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 12912
import java.util.Scanner;

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

    void solve(Scanner sc) {
        char[] s = sc.next().toCharArray();
        int p = 0;
        for (char c : s) {
            if (c == 'p') {
                p++;
            }
        }
        System.out.println(s.length / 2 - p);
    }
}


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

int main(){
  int H,W;
  cin >> H >> W;
  char S[H][W];
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      cin >> S[i][j];
    }
  }
  
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(S[i][j] == '.'){
        int count = 0;
        int ip = -1;
        int jp = -1;
        int h,w;
        while(ip < 2){
          h = i + ip;
          w = j + jp;
          if(h >= 0 && h < H && w >= 0 && w < W && S[h][w] == '#'){
            count++;
          }
          jp++;
          if(jp > 1){
            jp = -1;
            ip++;
          }
        }
        S[i][j] = count + '0';
      }
      cout << S[i][j] << flush;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
while True:
    L=map(int,raw_input().split())
    if L==[0]:break
    q1,b,c1,c2,q2=L
    for i in range(q2,0,-1):
        cj=i*c1
        normal=int((b-cj)/c2)
        if i+normal<q1:
            continue
        elif normal>=0:
            print i,normal
            break
    else:
        print "NA"

Measured memory_bytes: 36012
import itertools
##print(ord("A"))
n = int(input())
#n,k = map(int,input().split())
h = list(map(int,input().split()))	
ans = [0]*n
for i in range(n):
    ans[h[i]-1]= i+1
#print(ans)
for i in range(n):
    print(ans[i],end=" ")
"""
for i in range(1,n+1):
    #print(i)
    for j in range(n):
        
        if h[j] == i:
            ans.append(j+1)
#print(ans)
for i in range(len(ans)):
    print(ans[i],end=" ")
"""


Measured memory_bytes: 14256
#include "bits/stdc++.h" 
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rerep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
int gcd(int a,int b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int main(){
    ll n,m;
    cin>>n>>m;
    ll a[m];
    ll task=0;
    rep(i,0,m){
        cin>>a[i];
        task+=a[i];
    }
    if(n>=task)cout<<n-task<<endl;
    else cout<<-1<<endl;
    return 0;

}

Measured memory_bytes: 3664
import sys
import math as mas

while True:
	n=int(input())
	if n==0:break
	a=[int(input()) for i in range(n)]
	ma=-100010
	for i in range(n):
		sum=0
		for j in range(i,n):
			sum+=a[j]
			ma=max(ma,sum)
	print(ma)

#for i in sys.stdin:
#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

Measured memory_bytes: 7944
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i;
    char str[20];
    
    scanf("%s", &str);
    for (i=strlen(str); i > 0; i--){
        printf("%c",str[i-1]);
    }
    printf("\n");
    return 0;
}

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

int main(){
	int qnt_dn, mass, i, p, massul=0, menor=100000, l;
	cin >> qnt_dn >> mass;
	int tipos[qnt_dn];
	int qntd =0;
	for( i=0;i<qnt_dn; i++){
		cin >> tipos[i];
		massul = massul + tipos[i];
		qntd +=1;
		if (menor > tipos[i]) menor = tipos[i];
	}

	for (l=0; massul <= mass; l++){
		massul = massul+ menor;
		qntd +=1;
	}
	cout << qntd-1;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <list>
#include <algorithm>
#include <functional>
#include <unordered_map>

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::list<unsigned> l;

  unsigned i;
  std::unordered_map<std::string,std::function<void(void)>> funcs{
    {
      "insert",
      [&l,&i](){
        std::cin >> i;
        l.push_front(i);
      }
    },
    {
      "delete",
      [&l,&i](){
        std::cin >> i;
        auto it = std::find(l.begin(),l.end(),i);
        if(it != l.end()) l.erase(it);
      }
    },
    {
      "deleteFirst",
      [&l](){
        l.erase(l.begin());
      }
    },
    {
      "deleteLast",
      [&l](){
        l.erase(--(l.end()));
      }
    }
  };

  unsigned n;
  std::string buf;
  std::cin >> n;
  for(;n;n--){
    std::cin >> buf;
    funcs[buf]();
  }

  std::cout << *(l.begin());
  for(auto it = ++l.begin(); it != l.end(); ++it){
    std::cout << ' ' << *it;
  }
  std::cout << '\n';

}

Measured memory_bytes: 32484
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
#define csanf scanf

int c[10][10];
int a[500][500];
int b[500][500];
int d[10];
int main(){
	int h,w;scanf("%d%d",&h,&w);
	rep(i,10)rep(j,10)scanf("%d",&c[i][j]);
	rep(i,h)rep(j,w)scanf("%d",&a[i][j]);
	
	priority_queue<P,vector<P>,greater<P>>que;
	memset(d,0x3f,sizeof(d));
	d[1]=0;que.push(P(0,1));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(d[p.second]!=p.first)continue;
		rep(i,10){
			if(p.first+c[i][p.second]<d[i]){
				d[i]=p.first+c[i][p.second];
				que.push(P(d[i],i));
			}
		}
	}
	int sum=0;
	rep(i,h)rep(j,w){
		if(a[i][j]==-1)continue;
		sum+=d[a[i][j]];
	}
	cout<<sum<<endl;
	/*
	vector<int>v;
	rep(i,10){
		v.push_back(i);
	}
	do{
		rep(i,h)rep(j,w)b[i][j]=a[i][j];
		int cnt=0;
		for(auto t:v){
			cnt+=
		}
	}while(next_permutation(v.begin(),v.end());*/
	
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s,temp;
    cin >> s;

    temp = s;

    int n = s.size();

    string ss = s.substr(0,(n-1)/2);

    string temp2 = ss;
    reverse(ss.begin(),ss.end());

    reverse(s.begin(),s.end());

    string sss = s.substr((n+3)/2-1);

    string temp3 = sss;
    reverse(sss.begin(),sss.end());

    // cout << s << " " << ss << " " << sss << endl;

    if((temp == s) && (temp2 == ss) &&(temp3 == sss)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



}

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

using namespace std;
typedef long long ll;

const int P=1e9+7;
int n,m,K,U;
ll f[1<<19],ans;
bool vis[20][20],pos[20][20];

#define lowbit(x) ((x)&-(x))

int main(){
	scanf("%d%d%d",&n,&m,&K);
	for(int i=1,a,b,c;i<=K;i++)scanf("%d%d%d",&a,&b,&c),a--,b--,vis[a][b]=true,pos[a][b]=c;
	n--;
	U=1<<n;
	f[0]=1;
	for(int p=0;p<m;p++){
		for(int i=0;i<n;i++){
			if(!vis[p][i]||pos[p][i])
				for(int j=0,l=1<<i;j<U;j+=l<<1)for(int k=0;k<l;k++)
					if(f[j+k])f[j+k+l-lowbit(j)]+=f[j+k];
			if(vis[p][i])
				for(int j=0,l=1<<i,k=pos[p][i]?0:l;j<U;j+=l<<1)memset(f+j+k,0,l<<3);
		}
		for(int i=0;i<U;i++)if(f[i]>=P)f[i]%=P;
	}
	for(int i=0;i<U;i++)ans+=f[i];
	printf("%lld\n",ans%P);
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
    int c,a[20];
}p[20];
int ans[15],v[20];
ll ANS=1e10,sum;
int n,m,u,x;
void dfs(int cnt,int pre){
    if(cnt==u){
//        for(int j=0;j<cnt;j++)
//        cout<<ans[j]<<" ";
//        puts("");
        sum=0;
        fill(v,v+20,0);
        for(int j=0;j<cnt;j++){
            for(int k=0;k<m;k++)
                v[k]+=p[ans[j]].a[k];
            sum+=p[ans[j]].c;
        }
        int flag=1;
        for(int j=0;j<m;j++) if(v[j]<x) {flag=0;break;}
        if(flag) ANS=min(ANS,sum);
        return;
    }
    for(int j=0;j<=n;j++){
            if(j>pre) pre=j,ans[cnt]=pre,
            dfs(cnt+1,pre);
    }
}
int main()
{
    cin>>n>>m>>x;
    for(int i=1;i<=n;i++){
        cin>>p[i].c;
        for(int j=0;j<m;j++)
            cin>>p[i].a[j];
    }
    for(u=1;u<=n;u++){
        dfs(0,0);
    }
    if(ANS==1e10) puts("-1");
    else cout<<ANS;
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
int main(void){
  int r,g,b;
  int D;
  scanf("%d %d %d",&r,&g,&b);
  D = 10*g+b;
  
  if(D%4==0) printf("YES\n");
  else printf("NO\n");
  
  return 0;
}
  


Measured memory_bytes: 1660
import math
import itertools

n = int(input())
t = [list(map(int, input().split())) for _ in range(n)]


def dis(t1, t2):
    return math.sqrt((t1[0] - t2[0]) ** 2 + (t1[1] - t2[1]) ** 2)


l = [i for i in range(n)]
res = 0
for sl in itertools.permutations(l):
    for i in range(1, n):
        res += dis(t[sl[i - 1]], t[sl[i]])
for i in range(n):
    res /= i + 1

print(res)


Measured memory_bytes: 42092
#include"iostream"
using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)cout << "Left" << endl;
	else if (a + b < c + d)cout << "Right" << endl;
	else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stdlib.h>
using namespace std;

int top;
int A[1000];
void push(int x) {
	//x = A[top];
	//top++;
	A[++top] = x;
}

int pop() {
	top--;
	return A[top + 1];
}

int main() {
	int a, b;
	int c;
	char s[100];
	top = 0;

	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			c = atoi(s);
			push(c);
		}
	}

	//cout << A[0] << endl;
	//cout << pop() << endl;
	printf("%d\n", pop());

	return 0;
}


Measured memory_bytes: 3208
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int D = sc.nextInt() * 2 + 1;
		int ans =0;
		ans = N/D;
		if (N%D > 0) {ans++;}

		System.out.println(ans);

	}
}


Measured memory_bytes: 35764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int l[200000] = {0};

int main() {
    int N;
    map<int, int> d;

    scanf("%d", &N);
    for(int i=0;i<N;i++) {
        scanf("%d", &l[i]);
    }

    for(int i=0;i<N;i++) {
        auto itr = d.find(l[i]);
        if(itr != d.end()) {
            d[l[i]]++;
        }
        else {
            d[l[i]] = 1;
        }
    }

    int ans = 0;
    for(auto i=d.rbegin();i!=d.rend();i++) {
        while(i->second > 0) {
            int isFinished = 0;
            for(int j=0;j<32;j++) {
                int v = pow(2, j) - i->first;
                if (i->first < v) {
                    continue;
                }
                if (d.find(v)!=d.end()) {
                    if ((v!=i->first && d[v]>=1) || (v==i->first && d[v]>=2)) {
                        i->second--;
                        d[v]--;
                        ans++;
                        isFinished = 1;
                        break;
                    }
                }
            }
            if(isFinished==0) {
                break;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10368
from collections import defaultdict
s = int(input())

dict = defaultdict(int)
an = s
dict[an] += 1

for i in range(2, 1000000):
    if an % 2 == 0:
        an /= 2
    else:
        an = 3*an + 1

    dict[an] += 1
    if dict[an] == 2:
        print(i)
        exit()


Measured memory_bytes: 3316
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        s: [String; n]
    }
    let mut map = HashMap::new();
    for s in s {
        *map.entry(s).or_insert(0i64) += 1;
    }
    let ss = ["AC", "WA", "TLE", "RE"];
    for &ss in &ss {
        let count = map.get(ss).unwrap_or(&0);
        println!("{} x {}", ss, count);
    }
}


Measured memory_bytes: 7868
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
const int N = 2e5+5, mod = 1e9+7;
int main() 
{
	int n;
	cin >> n;
	int a[n], p[n], q[n];
	for(int i=0; i<n; i++) cin >> a[i];
	p[0] = a[0];
	q[n-1] = a[n-1];
	for(int i=1; i<n; i++) p[i] = max(p[i-1], a[i]);
	for(int i=n-2; i>=0; i--) q[i] = max(q[i+1], a[i]);
	for(int i=0; i<n; i++)
	{
		if(!i) cout << q[1] << endl;
		else if(i == n-1) cout << p[n-2] << endl;
		else cout << max(p[i-1], q[i+1]) << endl;
	}
}

Measured memory_bytes: 3968
#include <stdio.h>
#define MAX_N 300000
int sieve(int n);

int prime[MAX_N];
bool is_prime[MAX_N+1];

int main(){
	int i;
	int n=0;
	int p;

	while(n!=1){
		scanf("%d",	&n);
		if(n==1) return 0;
		printf("%d:",n);
		p=sieve(MAX_N);
		for(i=0; i<p; i++){
			if(n%prime[i]==0){
				printf(" %d", prime[i]);
			}
		}
		printf("\n");
	}


	return 0;
}

int sieve(int n){
	int p=0;
	for(int i=0; i<=n; i++){
		if(i%7==1 || i%7==6){
			is_prime[i]=true;
		}else{
			is_prime[i]=false;
		}
	}
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<=n; i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=2*i; j<=n; j+=i) is_prime[j]=false;
		}
	}
	return p;
}

Measured memory_bytes: 1460
import sys
from collections import defaultdict

H, W, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

ctr_h = defaultdict(int)
ctr_w = defaultdict(int)
appeared = set()

for h, w in X:
    ctr_h[h] += 1
    ctr_w[w] += 1
    appeared.add(h * W + w)

val_h = sorted(ctr_h.items(), key=lambda x: -x[1])
val_w = sorted(ctr_w.items(), key=lambda x: -x[1])

max_h = val_h[0][1]
max_w = val_w[0][1]

val_h = [i for i, v in val_h if v == max_h]
val_w = [i for i, v in val_w if v == max_w]

if len(val_h) * len(val_w) > M:
    print(max_h + max_w)
    sys.exit(0)

for h in val_h:
    for w in val_w:
        if h * W + w not in appeared:
            print(max_h + max_w)
            sys.exit(0)
else:
    print(max_h + max_w - 1)


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

int main() {
	string s;
	cin>>s;
	int a = (s[0] - '0')*10 + (s[1] - '0');
	int b = (s[2] - '0')*10 + (s[3] - '0');
	if(a<=12 && b<=12 && a>0 && b>0) {
		cout<<"AMBIGUOUS";
		return 0;
	}
	if(a>12 || a==0) {
		if(b>0 && b<13) {
			cout<<"YYMM";
		}
		else cout<<"NA";
		return 0;
	}
	if(b>12 || b == 0) {
		if(a>0 && a<13) {
			cout<<"MMYY";
		}
		else cout<<"NA";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
s =[]
hash = {}
ans = 0
N.times do |i|
  # 入力を受け取って昇順ソート
  s[i] = gets.chomp.split("").sort.join
  # 登場回数をハッシュに記録
  if hash.has_key?(s[i])
    hash[s[i]] += 1
    ans += hash[s[i]]
  else
    hash[s[i]] = 0
  end 
end

puts ans


Measured memory_bytes: 40444
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 * @verified <ul>
 * <li> https://atcoder.jp/contests/arc050/tasks/arc050_c
 * <li> https://atcoder.jp/contests/abc129/tasks/abc129_f
 * </ul>
 */
class DSU {
	private int n;
	private int[] parentOrSize;

	public DSU(int n) {
		this.n = n;
		this.parentOrSize = new int[n];
		Arrays.fill(parentOrSize, -1);
	}

	int merge(int a, int b) {
		if (!(0 <= a && a < n) || !(0 <= b && b < n)) {
			// この式が成立しない物は動作しません。
			return -1;
		}
		int x = leader(a);
		int y = leader(b);
		if (x == y) return x;
		if (-parentOrSize[x] < -parentOrSize[y]) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		parentOrSize[x] += parentOrSize[y];
		parentOrSize[y] = x;
		return x;
	}

	boolean same(int a, int b) {
		if (!(0 <= a && a < n) || !(0 <= b && b < n)) {
			// この式が成立しない物は動作しません。
			return false;
		}
		return leader(a) == leader(b);
	}

	int leader(int a) {
		if (parentOrSize[a] < 0) {
			return a;
		} else {
			parentOrSize[a] = leader(parentOrSize[a]);
			return parentOrSize[a];
		}
	}

	int size(int a) {
		if (!(0 <= a && a < n)) {
			// この式が成立しない物は動作しません。
			return -1;
		}
		return -parentOrSize[leader(a)];
	}

	ArrayList<ArrayList<Integer>> groups() {
		int[] leaderBuf = new int[n];
		int[] groupSize = new int[n];
		for (int i = 0; i < n; i++) {
			leaderBuf[i] = leader(i);
			groupSize[leaderBuf[i]]++;
		}
		ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
		for (int i = 0; i < n; i++) {
			result.add(new ArrayList<>());
		}
		for (int i = 0; i < n; i++) {
			result.get(leaderBuf[i]).add(i);
		}
		return result;
	}
}

public class Main {
	public static void main(String[] $) {
		var s = new Scanner(System.in);

		var n = Integer.parseInt(s.next());
		var q = Integer.parseInt(s.next());

		var uf = new DSU(n);

		for (int i = 0; i < q; ++i) {
			var t = Integer.parseInt(s.next());
			var u = Integer.parseInt(s.next());
			var v = Integer.parseInt(s.next());

			if (t == 0)
				uf.merge(u, v);
			else
				System.out.println(uf.same(u, v) ? 1 : 0);
		}
	}
}


Measured memory_bytes: 61944
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main(){
    ll n; cin >> n;
    vl L(n);
    rep(i,n) cin >> L[i];
    sort(all(L));
    ll ans = 0;
    rep(i,n){
        REP(j,i+1,n){
            auto itr = lower_bound(all(L),L[i]+L[j]);
            ans += itr - L.begin() - j - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
function main()
  
  S = split(chomp(readline()),"")
  
  count = 0
  check = ""
  ans = 0
  
  for i in 1:length(S)

    if (S[i] == "A" || S[i] == "C" || S[i] == "G" || S[i] == "T") && (check == "A" || check == "C" || check == "G" || check == "T")
      count += 1
      check = S[i]
    elseif S[i] == "A" || S[i] == "C" || S[i] == "G" || S[i] == "T"
      ans = max(ans,count)
      count = 1
      check = S[i]
    else
      check = ""
    end
    
    ans = max(ans,count)
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 112032
#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
#define f(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
 
using namespace std;

bool check(string s,string p)
{
    for(int i=0;i<s.size()-p.size();i++)
    {
        if(s.substr(i,p.size())==p)return true;   
    }
    return false;
}


int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  	int a;
  	cin>>a;
  	cout<<a+(a*a)+(a*a*a)<<endl;
	return 0;
}


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

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

	int wt[n],val[n];

	for(int i=0;i<n;++i)
	{
		cin>>wt[i]>>val[i];
	}
	long long dp[109][100009];
	for(int i=0;i<n+1;++i)
	{
		for(int j=0;j<W+1;++j)
		{
			if(i==0 || j==0)
			{
				dp[i][j]=0;
				continue;
			}

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


Measured memory_bytes: 81152
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	int n;
	cin >> n; 
	vector<int> s(100001, 0);
	for (int i = 0; i < n; i++) {
		int cur;
		cin >> cur;
		s[cur]++;
	}
	int odd = 0;
	int even = 0;
	for (int i = 1; i <= 100000; i++) {
		if (s[i] == 0) continue;
		if (s[i] % 2 == 0) { 
			even++;
		} else {
			odd++;
		}
	}

	if (even % 2 == 0) {
		cout << even + odd << endl;
	} else {
		cout << even + odd - 1 << endl;

	}

	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  s.push_back(' ');
  char pre = s[0];
  int count = 0;
  int maximum = 0;
  rep(i,s.length()){
    if(pre==s[i])++count;
    else count = 1;
    maximum = max(maximum,count);
    pre = s[i];
  }
  YesNo(maximum>=3);
  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string s, t; cin >> s >> t;
    int n = (int)s.size();
    int ans = 0;
    rep(i, n) {
        if(s[i] != t[i]) {
            ++ ans;
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int a,b,c,d,E,F;

  cin>>a>>b>>c>>d>>E>>F;
  a*=100; b*=100;
  bool water[3001]={};
  bool sugar[3001]={};

  rep(i,31){
    rep(j,31){

      int wat=i*a+j*b;

      if(wat<=3000){
        water[wat]=true;
      }
    }
  }

  rep(i,3001){
    rep(j,3001){

      int sug=i*c+j*d;

      if(sug<=3000){
        sugar[sug]=true;
      }
    }
  }

  double maxden=0;
  int ansi=0;
  int ansj=0;

  rep(i,F+1){
    rep(j,F+1){
      if(i+j==0) continue;
      if(!water[i]) continue;
      if(!sugar[j]) continue;
      if(i+j>F) continue;

      if((double)100*j/(i+j)<=(double)100*E/(100+E) and (double)100*j/(i+j)>=maxden){
        maxden=(double)100*j/(i+j);
        ansi=i;
        ansj=j;
      }
    }
  }

  cout<< ansi+ansj<<" "<<ansj<<"\n";


}

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


Measured memory_bytes: 256
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

all = A.inject(:+)
wk = A[0]
ans = (all - 2 * wk).abs
(1..(A.size-2)).each{|i|
  wk += A[i]
  tmp = (all - 2 * wk).abs
  if ans > tmp then
    ans = tmp
  end
}

puts ans


Measured memory_bytes: 16516
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
ll A,B,T;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>A>>B>>T;
    cout<<T/A*B<<endl;
}


Measured memory_bytes: 256
import java.text.NumberFormat;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		NumberFormat format = NumberFormat.getInstance();
		format.setMaximumFractionDigits(3);
		format.setMinimumFractionDigits(3);
		while (s.hasNextInt()) {
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int d = s.nextInt();
			int e = s.nextInt();
			int f = s.nextInt();
			int nx = b * f - e * c;
			int dx = b * d - e * a;
			int ny = a * f - d * c;
			int dy = a * e - d * b;
			double x = nx == 0 ? nx : (double) nx / dx;
			double y = ny == 0 ? ny : (double) ny / dy;
			System.out.println(format.format(x) + " " + format.format(y));
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int n,m,q;
	cin >> n >> m >> q;
	int l,r,train[501][501],ans[501][501];
	for(int i=0; i<=n; i++){
		for(int j=0; j<=n; j++){
		train[i][j]=0;
		ans[i][j]=0;
		}
	}
	for(int i=0; i<m; i++){
		cin >> l >> r;
		train[l][r]++;
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			ans[i][j]=ans[i][j-1];
			for(int k=i; k<=j; k++){
				ans[i][j]+=train[k][j];
			}
		}
	}
	for(int i=0; i<q; i++){
		cin >> l >> r;
		cout << ans[l][r] << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
class abc_166:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        ans= "ARC" if S=="ABC" else "ABC"
        print(ans)
    
    def B(self):
        NK=list(map(int,input().split()))
        d=[]
        A=[]
        
        for i in range(NK[1]):
            d=int(input())
            a = list(map(int,input().split()))
            A.extend(a)
        
        print(NK[0]-len(list(set(A))))  
            
    def C(self):
        pass
    
    def D(self):
        pass
    
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_166()
    obj.B()

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

int main(){
  int t_num, mate;
  int i;
  int min;
  int count=0;

  cin >> t_num >> mate;

  int cost[t_num];

//最初のcostを最小として仮定
  cin  >> cost[0];
  min = cost[0];
  mate -= cost[0];

  for(i=1; i<t_num; i++){
    cin >> cost[i];
    mate -= cost[i];
    if(min>cost[i]){
      min = cost[i];
    }
  }

  while(mate>=min){
    mate -= min;
    count++;
  }

  cout << t_num+count << "\n";

  return 0;
}


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

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

  int n;
  cin >> n;
  vector<ll> dp(100);

  dp[0] = 2;
  dp[1] = 1;
  for (int i = 2; i <= 86; ++i) dp[i] = dp[i - 1] + dp[i - 2];
  cout << dp[n] << endl;
  
  return 0;
}


Measured memory_bytes: 256