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

using namespace std;

int main(){
    int N, M;
    vector<int> G[100000];
    bool used[100000];
    int ans[100000];
    int ans_idx = 0;
    cin >> N >> M;
    for(int i = 0; i < N; i++) used[i] = false;
    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    stack<int> st;
    st.push(0);
    used[0] = true;
    while(true){
        int top = st.top();
        for(int i = 0; i < G[top].size(); i++){
            if(!used[G[top][i]]){
                st.push(G[top][i]);
                used[G[top][i]] = true;
                break;
            }
        }
        if(top == st.top()) break;
    }
    while(!st.empty()){
        ans[ans_idx] = st.top();
        ans_idx++;
        st.pop();
    }
    int tmp = 0;
    
    while(true){
        bool flag = true;
        for(int i = 0; i < G[tmp].size(); i++){
            if(!used[G[tmp][i]]){
                tmp = G[tmp][i];
                ans[ans_idx] = tmp;
                ans_idx++;
                used[tmp] = true;
                flag = false;
                break;
            }
        }
        if(flag) break;
    }
    cout << ans_idx << endl;
    for(int i = 0; i < ans_idx; i++){
        cout << ans[i]+1;
        if(i == ans_idx-1) cout << endl;
        else cout << ' ';
    }
}

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

int main()
{
   long long int i,j,n,t,k,m;
  cin>>n;
 long long ans=0;
 for(i=1;i<n;i++)
 {
     if(n%i==0)
     {
         ans=ans+(n/i-1);
     }
     else{
        ans=ans+n/i;
     }
 }
 cout<<ans<<endl;



    return 0;

}


Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))
newA = sorted(A)

P = 1
flag = 0

for i in range(N):
    P = P * newA[i]
    if P == 0:
        print(P)
        flag = 1
        break
    elif P > 1e18:
        print(-1)
        flag = 1
        break
        
if flag == 0:
    print(P)

Measured memory_bytes: 21716
#include <stdio.h>

int main (void)
{
	int a,b,c,d,e;
	int	pasta,juice;

	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);

	if(a>b){
	if(b>c) pasta=c;
	else pasta=b;
	}

	else{
	if(c<a) pasta=c;
	else pasta=a;
	}

	if(d>e){
		juice=e;}
	else{juice=d;}

	printf("%d\n",pasta+juice-50);

	return 0;
}

Measured memory_bytes: 592
n = int(input())
s = input()

w = 0
e = s[1:].count('E')

ans = w + e
for i in range(1, n):
    if s[i - 1] == 'W': 
        w += 1
    if s[i] == 'E':
        e -= 1
    ans = min(ans, w + e)

print(ans)


Measured memory_bytes: 3676
A,B=map(int,input().split())
ans = 0
for x in range(A,B+1):
    s = str(x)
    l = len(s)
    pal = True
    for i in range(l//2 + 1):
        if s[i] != s[l-1-i]:
            pal = False
    if pal:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

// definition of class edge
class edge{
public:
  long long int to, cost;
  
  edge(long long int t, long long int c){
    to = t;
    cost = c;
  }
  
  bool operator < (const class edge &another) const{
    return cost < another.cost;
  }
  
  bool operator > (const class edge &another) const{
    return cost > another.cost;
    }
};

class path{
public:
  long long int to, dist;
  
  path(long long int t, long long int d){
    to = t;
    dist = d;
  }
  
  path(){
    to = 0;
    dist = 0;
  }
  
  bool operator < (const class path &another) const{
    return dist < another.dist;
  }
  
  bool operator > (const class path &another) const{
    return dist > another.dist;
  }
};


int Dijkstra(std::vector<std::vector<edge> > &G, /*long long int E, */long long int V, std::vector<long long int> &distance, long long int start);


int main(){
  // read problem
  long long int N, M, tmp_a, tmp_b, tmp, tmp_c;
  scanf("%lld%lld", &N, &M);
  
  std::vector<long long int> a, c;
  for(long long int i = 0; i < M; i++){
    scanf("%lld%lld", &tmp_a, &tmp_b);
    a.push_back(tmp_a);
    tmp_c = 0;
    for(long long int j = 0; j < tmp_b; j++){
      scanf("%lld", &tmp);
      tmp_c += (1<<(tmp-1));
    }
    c.push_back(tmp_c);
  }
  
  // make graph
  long long int V = (1<<N);
  std::vector<std::vector<edge> > G(V);
  for(long long int s = 0; s < V; s++){
    for(long long int i = 0; i < M; i++){
      // if key[i] can open some box that is not included in s
      if((s|c[i]) != s){
        G[s].push_back(edge(s|c[i], a[i]));
      }
    }
  }
  
  std::vector<long long int> distance(V);
  Dijkstra(G, V, distance, 0);
  
  std::cout << distance[(1<<N)-1];
  
  
  return 0;
  
}

int Dijkstra(std::vector<std::vector<edge> > &G, /*long long int E, */long long int V, std::vector<long long int> &distance, long long int start){
  
  // preparation of path queue
  std::priority_queue<path, std::vector<path>, std::greater<path> > path_que;
  // initialize distance
  for(long long int i = 0; i < V; i++){
    distance[i] = -1;
  }
  
  // Dijkstra method
  path path_tmp;
  // starting point
  distance[start] = 0;
  for(long long int i = 0; i < G[start].size(); i++){
    path_que.push(path(G[start][i].to, G[start][i].cost));
  }
  
  // following points
  while(!path_que.empty()){
    // pop shortest path to look into
    path_tmp = path_que.top();
    path_que.pop();
    // update distance list and push newly obtained paths
    if(distance[path_tmp.to] < 0){
      distance[path_tmp.to] = path_tmp.dist;
      for(long long int i = 0; i < G[path_tmp.to].size(); i++){
        path_que.push(path(G[path_tmp.to][i].to, path_tmp.dist + G[path_tmp.to][i].cost));
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 99172
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	map<int, int>m;
	for (int i = 0; i < N; i++) {
		cin >> K;
		m[K]++;
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> K;
		m[K]--;
		if (m[K] < 0) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  priority_queue<pair<int, int>> v;
  priority_queue<int> pq;

  for (int i = 0; i < n; i++) {
    int first, second;
    cin >> first >> second;

    v.push(pair<int, int>(-first, second));
  }

  int result = 0;

  for (int i = 1; i <= m; i++) {
    while (!v.empty() && abs(v.top().first) <= i) {
      pq.push(v.top().second);
      v.pop();
    }

    if (!pq.empty()) {
      result += pq.top();
      pq.pop();
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 1908
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    import heapq

    H = 0
    MAX = 2000000
    A = []

    while True:
        com = input()
        if com[:2] == 'en':
            break
        if com[0] == 'i':
            _, key = com.split()
            key = -int(key)  # min-ヒープになるので、-1をかけることで解決する。
            heapq.heappush(A, key)
        else:
            print(-heapq.heappop(A))



Measured memory_bytes: 45564
#include "bits/stdc++.h"
#include <random>
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define SQR(X)  ( (X)*(X) )
#define CUBE(X) ( (X)*(X)*(X) )
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;
 
 
void reader(int &a){scanf("%d",&a);}
void reader(double &a){scanf("%lf",&a);}
void reader(char a[]){scanf("%s",a);}
void reader(ll &a){scanf("%lld",&a);}
void reader(ull &a){scanf("%llu",&a);}
// void reader(string& a){cin >> a;};
template<class T,class U> void reader(T& t,U& u){reader(t); reader(u);}
template<class T,class U,class V> void reader(T& t,U& u,V& v){reader(t); reader(u); reader(v);}
 
void writer(int a,char c) {printf("%d",a); putchar(c);}
void writer(ll a,char c) {printf("%lld",a); putchar(c);}
void writer(double a,char c) {printf("%.20lf",a); putchar(c);}
void writer(char a[]) {printf("%s",a);};
void writer(char a[],char c) {printf("%s",a);putchar(c);};
void writer(char a,char c) {putchar(a); putchar(c);};
template<class T>void writerLn(T t){writer(t,'\n');}
template<class T,class U>void writerLn(T t,U u){writer(t,' ');writer(u,'\n');}
template<class T,class U,class V> void writerLn(T t,U u,V v){writer(t,' ');writer(u,' ');writer(v,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
template<class T> void writerVec(vector<T> x){int n=x.size();int i;if(!n){putchar('\n');return;}rep(i,n-1) writer(x[i],' ');writer(x[n-1],'\n');}
 
vector<std::string> split(const std::string &str, char sep){std::vector<std::string> v;std::stringstream ss(str);std::string buffer;while(std::getline(ss,buffer,sep)){v.push_back(buffer);}return v;}
 
// #define int ll
bool test = 1;
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };

//..................
ull mod = (int)1e9 + 7;
signed main(){
  int i,j,k,l;
  string s;
  while(1) {
	int N,K;
	vector<int> connect[100];
	int l[100];
	cin >> N;
	if(N == 0) return 0;
	rep(i,N) {
	  int M;
	  cin >> M;
	  rep(j,M) {
		int p;
		cin >> p;
		connect[i].push_back(p);
	  }
	}
	cin >> K;
	rep(i,K) cin >> l[i];
	int ans = -1;
	rep(i,N) {
	  bool correct = true;
	  rep(j,K) {
		rep(k,connect[i].size()) {
		  if(connect[i][k] == l[j]) break;
		}
		if(k == connect[i].size()) correct = false;
	  }
	  if(ans != -1 && correct) {
		ans = -1;
		break;
	  }
	  else if(ans == -1 && correct) ans = i;
	}
	if(ans == -1) cout << -1 << endl;
	else cout << ans+1 << endl;
  }
  return 0;
}

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

using namespace std;
ifstream fin("f.in");
ofstream fout("f.out");

#define hello cout << "hello" << endl
#define dbg(var) cout << #var << " --> " << var << endl
#define mset(a, b)  memset(a, b, sizeof(a))
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define boost ios_base::sync_with_stdio(false)

const int MOD = 1e9 + 7;
const double EPS = 1e-6;

int main(){
	boost;
	int a, b;
	cin >> a >> b;
	int ans = (a + b) % 24;
	// if(ans == 0) ans = 24;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))


a_ol = Counter(a)
def_count = 0
for item in a_ol.items():
    a_co = item[1]
    def_count += a_co * (a_co - 1)

def_count //= 2

for k in a:
    print(def_count - a_ol[k] + 1)



Measured memory_bytes: 26780
from collections import deque

R = lambda: map(int, input().split())

n, q = R()
g = [[1]] + [[] for _ in range(n)]
c = [0] * (n + 1)
for _ in range(1, n):
    a, b = R()
    g[a].append(b)
    g[b].append(a)
for _ in range(q):
    p, x = R()
    c[p] += x

vis = [False] * (n + 1)
r = [0] * n
qe = deque([0])
while qe:
    u = qe.popleft()
    for v in g[u]:
        if not vis[v]:
            vis[v] = True
            r[v - 1] = r[u - 1] + c[v]
            qe.append(v)
print(*r)


Measured memory_bytes: 63504
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define rep(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))



int main(){ FastIO;

string s;cin>>s;
if(s[1]=='R') s[1]='B';
else s[1]='R';
cout<<s;


return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

struct Edge {
    int to, dist, cost, index;
};

struct State {
    int index;
    ll cost;
    State(int i, ll c):index(i), cost(c) {}
    bool operator > (const State &r) const { return cost > r.cost; }
};

// O(ElogV)
vector<ll> dijkstra(const vector<vector<Edge>> &G, int start, int M) {
    priority_queue<State, vector<State>, greater<State>> que;
    vector<ll> dist(G.size(), INFL);
    que.emplace(start, 0);
    dist[start] = 0;
    while(not que.empty()) {
        State now = que.top(); que.pop();
        if(G[now.index].size() > 0) {
            Edge min_edge = G[now.index][0];
            for(Edge e : G[now.index]) {
                if(dist[e.to] > now.cost + e.dist) {
                    State nxt = State(e.to, now.cost + e.dist);
                    dist[e.to] = nxt.cost;
                    que.push(nxt);
                }
            }
        }
    }
    return dist;
}

class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        if(N == 0) return 0;
        vector<vector<Edge>> E(N);
        vector<int> edge_cost(M);
        rep(i, M) {
            int u, v, d, c; cin >> u >> v >> d >> c;
            u--; v--;
            E[u].push_back(Edge{v, d, c, i});
            E[v].push_back(Edge{u, d, c, i});
            edge_cost[i] = c;
        }
        auto dist = dijkstra(E, 0, M);
        vector<char> used(M);
        ll ans = 0;
        repeat(i, 1, N) {
            ll min_c = INFL;
            Edge min_e;
            min_e.index = -1;
            for(Edge e : E[i]) {
                if(dist[e.to] + e.dist == dist[i]) {
                    if(set_min<ll>(min_c, e.cost)) min_e = e;
                }
            }
            if(not used[min_e.index]) ans += min_e.cost;
            used[min_e.index] = 1;
        }
        cout << ans << endl;
        return 1;
    }
};

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

Measured memory_bytes: 4516
// 下の桁から順に払う金額を決めていく (お釣りが引き算で求まる)

#include <bits/stdc++.h>

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

using namespace std;

const int INF=1<<29;

string s;
int dp[1000001][2];

int dfs(int i,bool ge){
	if(i==s.length()) return ge?0:1;

	if(dp[i][ge]!=-1) return dp[i][ge];

	int res=INF,a=s[i]-'0';
	if(ge){
		rep(d,10){
			res=min(res,dfs(i+1,d>=a)+d+(10+d-a)%10);
		}
	}
	else{
		for(int d=1;d<10;d++){
			res=min(res,dfs(i+1,d>a)+d+(10+(d-1)-a)%10);
		}
		res=min(res,dfs(i+1,false)+(9-a));
	}
	return dp[i][ge]=res;
}

int main(){
	memset(dp,-1,sizeof dp);

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

	printf("%d\n",dfs(0,true));

	return 0;
}


Measured memory_bytes: 87300
def main():
    S = input()
    ans = 0
    ans01 = 0
    ans10 = 0
    #01010101のサンプル文字列を作製する
    S_01 = '0'
    for i in range(1,len(S)):
        if i % 2 == 1:
            S_01 += '1'
        else:
            S_01 += '0'
    #10101010のサンプル文字列を作製する
    S_10 = '1'
    for j in range(1,len(S)):
        if j % 2 == 1:
            S_10 += '0'
        else:
            S_10 += '1'
    #S_01とSの差の数を確認する
    for h in range(len(S)):
        if S_01[h] == S[h]:
            continue
        else:
            ans01 += 1
    #S_10とSの差の数を確認する
    for k in range(len(S)):
        if S_10[k] == S[k]:
            continue
        else:
            ans10 += 1

    if ans01 >= ans10:
        ans = ans10
    else:
        ans = ans01

    return ans

print(main())


Measured memory_bytes: 3316
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#define maxn 200100
using namespace std;
int n,m,tot,vis[1010],sz[1010],fr[maxn],to[maxn],th[1010][1010];
vector<int> v[1010];
int read(){
	int x=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x;
}
void dfs(int x,int s,int cur)
{
	if(vis[x]&&(th[s][x]==-1||th[s][x]==cur)) return ;
	vis[x]=1; 
	if(!th[s][x]) th[s][x]=cur;
	else if(cur!=th[s][x]) th[s][x]=-1;
	for(int i=0;i<sz[x];i++)
		dfs(v[x][i],s,cur);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;i++)
	{
		scanf("%d%d",&fr[i],&to[i]);
		v[fr[i]].push_back(to[i]); sz[fr[i]]++;
	}
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) vis[j]=0;
		vis[i]=1; th[i][i]=-1;
		for(int j=0;j<sz[i];j++) dfs(v[i][j],i,v[i][j]);
	}
	for(int i=1;i<=m;i++)
	{
		int x=fr[i],y=to[i];
		if((th[y][x]&&th[x][y]!=-1)||(!th[y][x]&&th[x][y]==-1))
			puts("diff");
		else puts("same");
	}
}

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

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

  int x_cnt = 0;
  for (auto c : s) {
    if (c == 'x')
      ++x_cnt;
  }

  if (15 - x_cnt >= 8)
    puts("YES");
  else
    puts("NO");
}

Measured memory_bytes: 256
import collections, itertools

n = int(input())
counter = collections.defaultdict(int)
for _ in range(n):
    s = input()
    counter[s[0]] += 1

ans = 0
for a, b, c in itertools.combinations('MARCH', 3):
    ans += counter[a] * counter[b] * counter[c]

print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;
 
public class Main {
    public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
      long n = scanner.nextLong();
      long m = scanner.nextLong();
      
      long g = GCD(n, m);

      int answer = 1;
      for (long i = 2; i <= g / i; i++) {
      	if ((g % i) == 0) {
        	answer++;
        	while ((g % i) == 0) {
            	g /= i;
            }
          
        }
      }
      if (g > 1) answer++;
      System.out.println(answer);
    }
  
   private static long GCD(long a, long b) {
        if(b==0) return a; 
	return a % b == 0 ? b : GCD(b, a % b);
   }
}

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

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

    int n, k;
    cin >> n >> k;
    
    int h[n], c[n];
    rep(i, n) cin >> h[i];

    c[0] = 0;
    c[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; ++i){
        int m = min(i, k);
        c[i] = (1 << 30);
        for(int j = 1; j <= m; ++j){
            c[i] = min(c[i], c[i-j] + abs(h[i] - h[i-j]));
        }
    }

    cout << c[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#define pie 3.141592653589793238
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  vector<int> t(n);
  
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  
  int a, b;
  for(int i=0; i<m; i++){
    cin >> a >> b;
    a--;
    b--;
    if(h[a]==h[b]){
      t[a]=-1;
      t[b]=-1;
    }
    else if(h[a]>h[b]){
      if(t[a]==0) t[a]=1;
      t[b]=-1;
    }
    else if(h[a]<h[b]){
      t[a]=-1;
      if(t[b]==0) t[b]=1;
    }
  }
  
  int count=0;
  for(int i=0; i<n; i++){
    if(t[i]!=-1) count++;
  }

  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3920
#include <iostream>
#include <cstring>

using namespace std ;

int main()
{
	int money ;
	cin >> money ;
	int A ;
	int B ;
	cin >> A >> B ;
	money = money - A ;
	while(money>=B)
	{
        money = money - B ;
	}
	cout << money << "\n" ;
}

Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int o=sc.nextInt();
	if((n+m+o)>=22){
    System.out.println("bust");
    }else{
     System.out.println("win");
    }
  
    
   
    }
}


Measured memory_bytes: 21844
N, M, K = map(int, input().split())




if K%N == 0 or K%M == 0:
    print("Yes")
    
else:
    flag = False
    for n in range(1, N+1):
        if flag == True:
            break
            
        for m in range(1, M+1):
            if n*(M-m) + (N-n)*m == K:
                print("Yes")
                flag = True
                break
                
    
    if flag == False:
        print("No")

Measured memory_bytes: 3060
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;



int main(){

  string s; cin >> s;
  int l=s.size();
  int flag=1;

  for (int i=0; i<l; i++){
    if ((i%2==0 && s[i]=='L') || (i%2==1 && s[i]=='R')){flag=0;break;} 
  }

  if (flag) {cout << "Yes";}
  else {cout << "No";}


  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	a := make([]int, N)
	b := make([]int, N)
	for i := 0; i < N; i++ {
		x, y := getInt(), getInt()
		a[i] = x
		b[i] = y
	}
	sort.Ints(a)
	sort.Ints(b)

	if N%2 == 1 {
		m := N / 2
		out(b[m] - a[m] + 1)
	} else {
		m0 := (N - 1) / 2
		m1 := m0 + 1
		out(b[m0] + b[m1] - a[m0] - a[m1] + 1)
	}
}


Measured memory_bytes: 8348
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n,k;cin>>n>>k;
    vl p(n);rep(i,n)cin>>p[i];

    set<ll> st;
    rep(i,k)st.insert(p[i]);
    ll idx=-1;
    rep(i,k-1){
        if(p[i]>p[i+1])idx=i;
    }

    ll ans=idx!=-1;
    ll sorted=idx==-1;
    rep(i,k,n){
        if(p[i]<p[i-1])idx=i-1;
        bool flg1=*st.begin()!=p[i-k];
        st.erase(p[i-k]);
        st.insert(p[i]);
        auto it=st.end();
        --it;
        bool flg2=*it!=p[i];
        if(idx<=i-k)sorted=1;
        else if(flg1||flg2)++ans;
    }
    ans+=sorted;
    cout<<ans<<endl;
}

Measured memory_bytes: 11264
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <memory.h>
#include <algorithm>
#include <cassert>
#include <numeric>
#include <functional>
#include <queue>

using namespace std;

#define prev prev_______________________
#define next next_______________________
#define hash hash_______________________
#define y1 y1___________________________

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(c) (c).begin(), (c).end()
#define sz(c) int((c).size())
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define fst first
#define snd second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using pii = pair<int, int>;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr);
#else
#define eprintf(args...) ;
#define cerr if (0) cerr
#endif

int n;
vi a;

bool read() {
    if  (!(cin >> n)) {
        return 0;
    }
    a.resize(1 << n);
    forn(i, sz(a)) {
        cin >> a[i];
    }
    return 1;
}

bool bit(int mask, int i) {
    return (mask >> i) & 1;
}

const int MAXN = 18;

int dp[1 << MAXN][2];

void update(int mask, int i) {
    int* d = dp[mask];
    if  (d[0] == i || d[1] == i) {
        return;
    }
    if (d[0] == -1) {
        d[0] = i;
    } else if (a[i] > a[d[0]]) {
        d[1] = d[0];
        d[0] = i;
    } else if (d[1] == -1 || a[i] > a[d[1]]) {
        d[1] = i;
    }
}

void solve() {
    assert(n <= MAXN);
    memset (dp, -1, sizeof dp);

    for (int mask = 0; mask < (1 << n); ++mask) {
        forn(i, n) {
            if (bit(mask, i)) {
                forn(c, 2) {
                    update(mask, dp[mask ^ (1 << i)][c]);
                }
            }
        }
        update(mask, mask);
    }

    static int best_sub[1 << MAXN];
    for (int mask = 1; mask < (1 << n); ++mask) {
        int ans = 0;
        forn(c, 2) {
            int i = dp[mask][c];
            assert(i != -1);
            ans += a[i];
        }
        best_sub[mask] = ans;
    }

    for (int mask = 1; mask < (1 << n); ++mask) {
        int ans = best_sub[mask];

        forn(i, n) {
            if (!bit(mask, i)) {
                continue;
            }
            int nmask = mask ^ (1 << i);
            nmask |= (1 << i) - 1;
            if (nmask == 0) {
                continue;
            }
            assert(nmask < mask);
            ans = max(ans, best_sub[nmask]);
        }

        cout << ans << "\n";
    }
    cout << endl;
}

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

#ifdef LOCAL
    #define FNAME "a"
    freopen(FNAME ".in", "r", stdin);
    freopen(FNAME ".out", "w", stdout);
#endif

    while (read()) {
        solve();
    }

    return 0;
}



Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N;
    cin >> N;
    vector<int> V(N + 1, 0), G(N);
    rep(i, N) {
        cin >> G[i];
        V[G[i]]++;
    }
    int sum = 0;
    rep(i, N + 1) sum += V[i] * (V[i] - 1) / 2;
    rep(i, N) {
        int k = V[G[i]];
        cout << sum - k * (k - 1) / 2 + (k - 1) * (k - 2) / 2 << endl;
    }
}


Measured memory_bytes: 5760
H,W = map(int,input().split())
C = [list(map(int,input().split())) for _ in [0]*10]
A = [list(map(int,input().split())) for _ in [0]*H]

for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j],C[i][k] + C[k][j])

ans = sum(C[b][1] for a in A for b in a if b!= -1)

print(ans)

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

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

int main()
{
    int R;
    cin >> R;
    cout << (R < 1200 ? "ABC" : (R < 2800 ? "ARC" : "AGC")) << endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF 1e9
ll N, M, X[101010], Y[101010];


vector<ll> opv;
char d[5];
ll D[101010];
ll tabv[4][3];

ll i, j, k;
ll ans;
ll mxn[4];

ll ctoid(char c){
    switch(c){
        case 'U':
            return 0;
        case 'R':
            return 1;
        case 'D':
            return 2;
    }
    return 3;
}

ll calc(ll n){
    ll i = 0;
    mxn[0]=-INF,mxn[1]=INF,mxn[2] = -INF, mxn[3] = INF;
    fornum(i,0,N){
        ll x = X[i];
        ll y = Y[i];
        switch(D[i]){
            case 0:
                y += n;
                break;
            case 1:
                x += n;
                break;
            case 2:
                y -= n;
                break;
            case 3:
                x-=n;
                break;
        }
        if(mxn[0]<x){
            mxn[0] = x;
        }
        if(x<mxn[1]){
            mxn[1] = x;
        }
        if(mxn[2]<y){
            mxn[2] = y;
        }
        if(y<mxn[3]){
            mxn[3] = y;
        }
    }
    //printf("%lf,%lf,%lf,%lfd\n", xmx, xmn, ymx, ymn);
    return (mxn[0]-mxn[1])*(mxn[2] - mxn[3]);
}

int main(){
    scanf("%lld", &N);
    fornum(i,0,4){
        fornum(j,0,3){
            tabv[i][j] = -INF;
        }
    }
    fornum(i, 0, N){
        scanf("%lld%lld%s", &X[i], &Y[i], d);
        X[i] *= 2;
        Y[i] *= 2;
        D[i] = ctoid(d[0]);
        j = D[i] % 2 == 0 ? D[i] / 2 == 0 : 2;
        if(tabv[0][j]<Y[i]){
            tabv[0][j] = Y[i];
        }
        j = D[i] % 2 == 1 ? D[i] / 2 == 0 : 2;
        if(tabv[1][j]<X[i]){
            tabv[1][j] = X[i];
        }
        j = D[i] % 2 == 0 ? D[i] / 2 == 1 : 2;
        if(tabv[2][j]<-Y[i]){
            tabv[2][j] = -Y[i];
        }
        j = D[i] % 2 == 1 ? D[i] / 2 == 1 : 2;
        if(tabv[3][j]<-X[i]){
            tabv[3][j] = -X[i];
        }
    }
    opv.push_back(0);
    fornum(i,0,4){
        opv.push_back((tabv[i][0]-tabv[i][1])/2);
        opv.push_back(tabv[i][0] - tabv[i][2]);
        opv.push_back(tabv[i][2] - tabv[i][1]);
    }

    ans = INF*INF;
    fornum(i,0,opv.size()){
        //printf("%lld ", opv[i]);
        if(opv[i]<0)
            continue;
        ll a = calc(opv[i]);
        if(a<ans)
            ans = a;
    }
    printf("%.12lf", ans/4.0);

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h> 
#define ll long long int  
int sumof(int x)
{
    int sum =0 ;
    while(x!=0)
    {
        sum+=x%10; 
        x/=10; 
    } 
    return sum ;
}
using namespace std;
int main() {
    ll n,a,b ;
    cin >> n >> a >> b ; 
    ll sum =0;
    for(int i=1;i<=n;i++)
    {
        if(sumof(i)>=a && sumof(i)<=b) sum+=i;
    } 
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>

int main(void){
	int y, m, d;
	scanf("%d/%d/%d", &y, &m, &d);
	if(y <= 2019 && m <= 4 && d <= 30)
		printf("Heisei\n");
	else
		printf("TBD\n");
	return 0;
}


Measured memory_bytes: 128
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, r;
    cin >> n >> r;

    if (n < 10) {
        cout << r + 100 * (10 - n) << '\n';
    } else {
        cout << r << '\n';
    }

    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int Q = reader.nextInt();
		String S = reader.next();
		int[] arr = new int[N];
		int[] beginIndex =  new int[Q];
		int[] endIndex =  new int[Q];
		for (int i = 0; i < Q; i++) {
			beginIndex[i] = reader.nextInt() - 1;
			endIndex[i] = reader.nextInt() - 1;
		}

		for (int i = 0; i < N - 1; i++) {
			arr[i+1] = arr[i];
			String tmp = S.substring(i, i+2);
			if (tmp.equals("AC")) {
				arr[i+1]++;
				if (i < N -2) {
					arr[i+2]  = arr[i+1];
					i++;
				}
			}
		}
		for (int i = 0; i < Q; i++) {
			int a = arr[endIndex[i]] - arr[beginIndex[i]];
			int ans = Math.max(a, 0);
			System.out.println(ans);
		}
		reader.close();
	}
}





Measured memory_bytes: 86420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,x,t,c;
    cin>>n>>x>>t;
    if(x>n){
        if(x%n==0){
            c=(x/n)*t;
            cout<<c<<endl;
        }
        else{
            c=t;
            cout<<c<<endl;
        }
    }
    else{
        if(n%x==0){
            c=(n/x)*t;
            cout<<c<<endl;
        }
        else{
            c=((n/x)+1)*t;
            cout<<c<<endl;
        }
    }
}


Measured memory_bytes: 3592
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
static const ll max_n = 200010;
// static const ll max_dist = 10000000;
// vector<vector<ll>> distance_table(max_n, vector<ll>(max_n, max_dist));
// vector<ll> distance_list(max_n);
vector<ll> combination_table(max_n, 0);
vector<ll> value_num(max_n, 0);
vector<ll> combination_minus1_table(max_n, 0);
vector<ll> balls(max_n);

ll N, X, Y;

int main(){
    // int u, v;
    // bool updated = alse;
    scanf("%lld", &N);
    for(ll i=0;i<N;i++){
        scanf("%lld", &X);
        balls[i] = X;
        value_num[X] ++;
    }
    // printf("ok!\n");

    ll sum_comb = 0;
    for(ll i=1;i<=N;i++){
        if(value_num[i]>1){
            ll comb = value_num[i] * (value_num[i] - 1) / 2;
            sum_comb += comb;
            combination_table[i] = comb;
            comb = (value_num[i] - 2) * (value_num[i] - 1) / 2;
            combination_minus1_table[i] = comb;
        }
    }

    for(ll i=0;i<N;i++){
        ll value = balls[i];
        ll ans = (sum_comb - combination_table[value] + combination_minus1_table[value]);
        printf("%lld\n", ans);
    }
    return 0;

}

Measured memory_bytes: 8832
# ABC156a


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    n, r = map(int, input().split())
    if n >= 10:
        print(r)
    else:
        print(100*(10-n)+r)


if __name__ == '__main__':
    main()


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


int main(){
    string s;
    cin >> s;
    int g, p;
    g=p=0;
    
    int point=0;
    for(int i=0; i<s.length(); i++){
        if(i==0){
            g++;
            p++;
            if(s[i]=='p') point--;
        }
        else {
            if(s[i]=='g'){
                if(p>0){
                    p--;
                    point++;
                }
                else {
                    g++;
                    p++;
                }
            }
            else {
                if(p>0){
                    p--;
                }
                else {
                    g++;
                    p++;
                    point--;
                }
            }
        }
    }
    cout << point << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

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

    vector<long> L(N);

    FOR(i, N) {
        cin >> L[i];
    }

    int ans = 0;

    FOR(i, N) {
        FOR(j, i) {
            FOR(k, j) {
                if (L[i] == L[j]) {
                    continue;
                }

                if (L[j] == L[k]) {
                    continue;
                }

                if (L[k] == L[i]) {
                    continue;
                }

                if (L[i] >= L[j] + L[k]) {
                    continue;
                }

                if (L[j] >= L[k] + L[i]) {
                    continue;
                }

                if (L[k] >= L[i] + L[j]) {
                    continue;
                }

                ans += 1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<cmath>
using namespace std;
int N,D,ans,noww;
struct node {
	int coord[11];
} sav[11];
int main() {
	ios::sync_with_stdio(false);
	cin>>N>>D;
	for(int i=1; i<=N; i++) {
		for(int j=1; j<=D; j++) {
			cin>>sav[i].coord[j];
		}
	}
	for(int i=1; i<N; i++) {
		for(int j=i+1; j<=N; j++) {
			if(i!=j) {
				noww=0;
				for(int k=1; k<=D; k++) {
					noww+=pow(sav[i].coord[k]-sav[j].coord[k],2);
				}
				double jud=sqrt(noww);
				if((int)jud==jud)ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  int m;
  char s;
  cin>>n;
  while(cin>>s,s!='='){
    cin>>m;
    if(s=='+') n += m;
    if(s=='-') n -= m;
    if(s=='/') n /= m;
    if(s=='*') n *= m;
  }
  cout<<n<<endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a;
  cin >> a;
 
  cout << ((a/10)%111==0 || (a%1000)%111==0 ?"Yes":"No") << endl;
       
}


Measured memory_bytes: 256
from fractions import gcd
from collections import defaultdict

N, X, D = map(int, input().split())

if D == 0:
    if X == 0:
        ans = 1
    else:
        ans = N + 1
else:
    if D < 0:
        X = -X
        D = -D
    g = gcd(X, D)
    X //= g
    D //= g

    AN = X + D * (N - 1)

    intervals_dict = defaultdict(list)
    for k in range(N + 1):
        start = k * (2 * X + (k - 1) * D) // 2
        end = k * (2 * AN - (k - 1) * D) // 2

        intervals_dict[start % D].append((start // D, end // D + 1))

    ans = 0
    for k, v in intervals_dict.items():
        v.sort()

        current_stop = -float("inf")
        for start, stop in v:
            ans += max(stop, current_stop) - max(start, current_stop)
            current_stop = max(current_stop, stop)

print(ans)


Measured memory_bytes: 72968
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>


using namespace std;

int main() {
  int n,k;
  cin>>n>>k;
  vector<int> c(n,0);
  for(int i=0;i<n;i++){
    cin>>c[i];
  }
  sort(c.begin(),c.end());

  int ans=0;
  for(int i=0;i<k;i++){
    ans+=c[i];
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  int N, K;
  cin >> N;
  cin >> K;
  int number = 1;
  for (int i = 0; i < N; i++) {
	if (number * 2 < number + K) {
		number = number * 2;
    }
	else{
		number = number + K;
    }
  }
  cout <<  number << endl;

}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = (a*(a -1))/2;
        sum += (b * (b-1)) /2;
        System.out.println(sum);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

vector<vi> g(1e5);
vi dp(1e5);

int f(int i) {
  if (dp[i] != 0) {
    return dp[i];
  } else {
    if (g[i].size() == 0) {
      return dp[i] = 0;
    } else {
      for (auto&& j : g[i]) {
        cmax(dp[i], f(j)+1);
      }
      return dp[i];
    }
  }
}

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

  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    g[x-1].push_back(y-1);
  }

  ll ans = 0;
  rep(i, n) {
    cmax(ans, f(i));
  }
  cout << ans << endl;
}


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

array<int, 100001> arr{};
int main() {
    int n, ans; ans = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &arr[i]);
        if (arr[arr[i]] == i) {
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4148
#include<stdio.h>
#include<string.h>

int main(void){
	char str[128];
	int l,i,flg=0;
	scanf("%s",str);
	l=strlen(str);
	i=0;
	while(i<=l/2-1){
		//printf("%d:%c %d:%c\n",i,str[i],l-1-i,str[l-1-i]);
		if(str[i]!=str[l-1-i]){
			flg=1;
			break;
		}
		i++;
	}
	//printf("flg:%d\n",flg);
	if(flg==0){
		i=0;
		while(i<=(l/2)/2-1){
			//printf("%d:%c %d:%c\n",i,str[i],l/2-1-i,str[l/2-1-i]);
			//printf("%d:%c %d:%c\n",i+(l+3)/2-1,str[i+(l+3)/2-1],l-1-i,str[l-i-1]);
			if(str[i]!=str[l/2-1-i] && str[i+(l+3)/2-1]!=str[l-1-i]){
				flg=1;
				break;
			}
			i++;
		}
	}
	puts((flg)?"No":"Yes");
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

bool is_month(int num) {
    bool ans = false;
    if(1 <= num && num <= 12) {
        ans = true;
    }
    return ans;
}

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

    int inputnum = stoi(s);
    int first = inputnum / 100;
    int second = inputnum % 100;
    string ans;

    if(is_month(first) && is_month(second)) {
        ans = "AMBIGUOUS";
    } else if(is_month(first)) {
        ans = "MMYY";
    } else if(is_month(second)) {
        ans = "YYMM";
    } else {
        ans = "NA";
    }

    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=1e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;


int main()
{
  

    	string a;
    	int n;
    	cin>>n>>a;

    	if(n>=3200)cout<<a<<endl;
    	else cout<<"red\n";
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int K,A,B;
  bool flag=false;
  cin >> K >> A >>B;
  for(int i=A;i<=B;i++){
    if(i%K==0)
      flag = true;
  }
  if(flag)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
}
      
  

Measured memory_bytes: 3636
N = int(input())
H = list(map(int, input().split()))

inv = 0
max_inv = 0
for n in range(1, N):
    if H[n] <= H[n-1]:
        inv += 1
    else:
        inv = 0
    
    max_inv = max(max_inv, inv)

print(max_inv)



Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 3e5+10;
const int inf = 0x3f3f3f3f;
const ll MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
#define X first
#define Y second

int a[maxN];
int b[maxN];
int c[maxN];
int main() {
	int n;
	scanf("%d",&n);
	string A,B;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		A.push_back('0'+a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		B.push_back('0'+b[i]);
	}
//	cout<<A<<endl;
//	cout<<B<<endl;
	unordered_map<string,int> mp;
	string p;
	int cnt = 1;
	for(int i=1;i<=n;i++)
	{
		c[i] = i;
		p.push_back('0'+c[i]);
		mp[p] = cnt;
	}
	cnt++;
//	cout<<p<<endl;
//	printf("%d\n",cnt);
	while (next_permutation(c+1,c+n+1) )
	{
		p.clear();
		for(int i=1;i<=n;i++)
		{
			p.push_back(c[i]+'0');
		}
		mp[p] = cnt;
		cnt++;
//		cout<<p<<endl;
//		printf("%d\n",cnt);
	}
	int ans = abs(mp[A] - mp[B]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4492
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int ignore=1;
    //cin>>ignore;
    while(ignore--)
    {
      ll n;
      cin>>n;
      
      string s;
      cin>>s;
      string temp = s;      
      sort(temp.begin(),temp.end());
      ll ans = 0;
      for(int i=0;i<n;i++)
      {
          if(s[i]=='W' && temp[i] != s[i])
          {
              ans++;
          }
          
      }
      cout<<ans<<endl;
    }
    
}

Measured memory_bytes: 3880
#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int num, sum, ttl;

    cin >> num;
    ttl = num;
    sum = 0;

    while(ttl >= 10){
        sum += ttl % 10;
        ttl /= 10;
    }
    sum += ttl;

    if(num % sum == 0){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 760
n = int(input())
a = [input() for i in range(n)]

fields = [0 for x in "MARCH"]
index = {v:i for i, v in enumerate("MARCH")}

for i in a:
    try:
        fields[index[i[0]]] += 1
    except:
        pass

import itertools
result = 0
for i in itertools.combinations(fields, 3):
    result += list(itertools.accumulate(i, lambda l, r: l * r))[-1]
print(result)


Measured memory_bytes: 9752
#include <iostream>

using namespace std;

long long warikiri(long long A, long long B, long long C){
    if(A%C){
        A = A - A%C;
    }else{
        A -= C;
    }
    B = B - B%C;
    return (B-A)/C;
}

int main(){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long ans = 0;
    ans += warikiri(A, B, C);
    ans += warikiri(A, B, D);

    if(C<D){
    long long tmp = C;
    C = D;
    D = tmp;
  }
  long long x = C * D;
  long long r = C % D;
  while(r!=0){
    C = D;
    D = r;
    r = C % D;
  }

    ans -= warikiri(A, B, x/D);
    cout << B - A + 1 - ans << endl;
    return 0;
}

Measured memory_bytes: 256