akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n,k,c;  cin >> n >> k >> c;
    string s;   cin >> s;
    vector<int>L(k+1);
    int ptr = 1;
    for(int i = 0; i < s.size();){
        if(s[i] == 'o'){
            if(ptr > k) break;
            L[ptr++] = i;
            i += c + 1;
        }else{
            i++;
        }
    }
    vector<int>R(k+1);
    reverse(s.begin(), s.end());
    ptr = k;
    for(int i = 0; i < s.size();){
        if(s[i] == 'o'){
            if(ptr < 0) break;
            R[ptr--] = n-i-1;
            i += c + 1;
        }else{
            i++;
        }
    }
    for(int i = 1; i <= k; i++){
        if(L[i] == R[i])    cout << L[i]+1 << endl;
    }
}


Measured memory_bytes: 3332
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>




int ASCttenannoryaku(const void *a,const void *b) {
	return *(int *)a - *(int *)b;
}
int main(void)
{
	char s[4];
	scanf("%s",s);
	int a = 0, b = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'A')
			a++;
		else b++;
	}
	if (a > 0 && b > 0)
		printf("Yes");
	else
		printf("No");
	return 0;
}

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

int main() {
    unsigned int N, M;
    cin >> N >> M;

    if (M % 2 != 0){
        if (N % 2 == 0){
            N ++;
        }
        for (unsigned int i = N; i <= M; i = i + 2){
            if (M % i == 0){
                cout << M / i << endl;
                return 0;
            }
        }
    }else{
        for (unsigned int i = N; i <= M; i++){
            if (M % i == 0){
                cout << M / i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int j=n-1; j>=0; j--){
    cout << a[j] ;
    if(j==0)break;    
    cout << " " ;
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3100
dic = {"C":0, "C#":1, "D":2, "D#":3,
       "E":4, "F":5, "F#":6, "G":7,
       "G#":8, "A":9, "A#":10, "B":11}
t = int(input())
for _ in range(t):
  n, m = map(int, input().split())
  t_lst = [-100] + list(map(lambda x:dic[x],input().split()))
  s_lst = list(map(lambda x:dic[x],input().split()))
  s_lst.reverse()
  
  def search(stack):
    t_index, s_index = stack.pop()
    if s_index == m: return t_index == 0
    if t_index <= 0 or t_index > n: return False
    base = t_lst[t_index]
    proc = s_lst[s_index]
    diff = (proc - base) % 12
    if diff == 1  :stack.append((t_index - 2, s_index + 1))
    if diff == 0  :stack.append((t_index - 1, s_index + 1))
    if diff == 11 :stack.append((t_index + 1, s_index + 1))
    return False
  stack = [(n, 0), (n - 1, 0)]
  while stack:
    if search(stack):
      print("Yes")
      break
  else:
    print("No")


Measured memory_bytes: 9672
n = int(input())
ar = list(map(int, input().split()))
res = 0
mod = 10 ** 9 + 7
for i in range(60):
    zero = 0
    one = 0
    for j in range(len(ar)):
        if ar[j] % 2 == 0:
            zero += 1
        else:
            one += 1
        ar[j] = ar[j] // 2
    curr = (zero * one * (1 << i)) % mod
    res = (res + curr) % mod
print(res)


Measured memory_bytes: 122808
#include<iostream>
#include<algorithm>
#include<queue>
using lint=int64_t;
using namespace std;

const int dh[]={0,-1,0,1};
const int dw[]={1,0,-1,0};

using Info=pair<int,pair<int,int>>;
Info makeInfo(int d,int h,int w)
{
	return make_pair(d,make_pair(h,w));
}

int main()
{
	int H,W;
	string A[1010];

	cin >> H >> W;
	for(int i=0;i<H;i++)
		cin >> A[i];
	
	int dist[1010][1010]={};
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			dist[i][j]=-1;

	queue<Info> que;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			if(A[i][j]=='#')
			{
				dist[i][j]=0;
				que.push(makeInfo(0,i,j));
			}
	
	while(!que.empty())
	{
		int cd=que.front().first;
		int ch=que.front().second.first;
		int cw=que.front().second.second;
		que.pop();

		for(int i=0;i<4;i++)
		{
			int nh=ch+dh[i];
			int nw=cw+dw[i];

			if(nh<0 || nw<0 || nh>=H || nw>=W)continue;
			if(dist[nh][nw]!=-1)continue;

			dist[nh][nw]=cd+1;
			que.push(makeInfo(cd+1,nh,nw));
		}
	}

	int ans=0;
	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
			ans=max(ans,dist[i][j]);
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 17424
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#define ll long long
#define N 5003
#define M 202
#define pi pair < int , int >
#define mkp(a,b) make_pair(a, b)

using namespace std;

ll g[N][N], dis[N];
int a[N], b[N][M], l[N][M], r[N][M];
int n, m;

stack < pi > st;

int read();

int main(){
	n = read();m = read();
	for(int i = 1; i < n; ++i) a[i] = read(), dis[i] = dis[i - 1] + a[i];
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			b[i][j] = read();
	for(int i = 1; i <= m; ++i){
		for(int j = 1; j <= n; ++j){
			int x = b[j][i];
			while(!st.empty() && st.top().first <= x){
				int p = st.top().second;st.pop();
				r[p][i] = j - 1;
			}
			st.push(mkp(x, j));
		}
		while(!st.empty()){
			int p = st.top().second;
			r[p][i] = n;st.pop();
		}
		for(int j = n; j; --j){
			int x = b[j][i];
			while(!st.empty() && st.top().first < x){
				int p = st.top().second;st.pop();
				l[p][i] = j + 1;
			}
			st.push(mkp(x, j));
		}
		while(!st.empty()){
			int p = st.top().second;
			l[p][i] = 1;st.pop();
		}
	}
	for(int i = 1; i <= m; ++i)
		for(int j = 1; j <= n; ++j){
			int xl = l[j][i], xr = r[j][i], x = b[j][i];
			g[xl][j] += x;g[xl][xr + 1] -= x;
			g[j + 1][j] -= x;g[j + 1][xr + 1] += x;
		}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			g[i][j] += g[i][j - 1];
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			g[j][i] += g[j - 1][i];
	ll ans = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = i; j <= n; ++j)
			ans = max(ans, g[i][j] - dis[j - 1] + dis[i - 1]);
	cout << ans << endl;
	return 0;
}

int read(){
	int x = 0;char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return x;
}

Measured memory_bytes: 207616
#include<iostream>

using namespace std;

int main(void)
{
	int n,m;
	cin >> n >> m;
	int count[55]={};
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin >> a >> b;
		count[a-1]++;
		count[b-1]++;
	}
	for(int i=1;i<=n;i++)
		cout << count[i-1] << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
c = 0
for x in range(n):
    for i in range(n-1, x, -1):
        if a[i] < a[i-1]:
            a[i], a[i-1] = a[i-1], a[i]
            c += 1
print(*a)
print(c)

Measured memory_bytes: 7784
#include <bits/stdc++.h>
using namespace std;
int dp[200005];
long long MOD;
long long modpow(long long x, long long e){
	if(MOD<=0) return 0;
	if(x==1||e==0) return 1;
	long long c=modpow(x,e/2);
	long long c1=(c*c)%MOD;
	if(e%2==0) return c1;
	else return (c1*x)%MOD;
}
int countSetBits(int n) 
{ 
    int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	reverse(s.begin(), s.end());
	long long cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]=='1') cnt++;
	}
	dp[0]=0;
	for(int i=1;i<=200000;i++){
		dp[i]=dp[i%countSetBits(i)]+1;
	}
	long long cur1=0, cur2=0;
	for(int i=0;i<n;i++){
		if(s[i]=='1'){
			MOD=cnt-1;
			if(MOD>0) cur2=(cur2+modpow(2, i))%MOD;
			MOD=cnt+1;
			cur1=(cur1+modpow(2, i))%MOD;
		}
	}
	vector<int>v;
	for(int i=0;i<n;i++){
		long long ans;
		if(s[i]=='1'){
			MOD=cnt-1;
			if(MOD==0){
				v.push_back(0);
				goto hell;
			}
			ans=(cur2-modpow(2, i)+MOD)%MOD;
		}
		else{
			MOD=cnt+1;
			ans=(cur1+modpow(2, i))%MOD;
		}
		v.push_back(dp[ans]+1);
		hell:;
	}
	reverse(v.begin(), v.end());
	for(int i:v) cout<<i<<"\n";
}

Measured memory_bytes: 5236
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int a[100'000], b[100'000], c[100'000];

int x[100'000];
int64_t xsum[100'000 + 1];

int main()
{
    int n;
    cin >> n;
    rep(i, n)
    {
        cin >> a[i];
    }
    rep(i, n)
    {
        cin >> b[i];
    }
    rep(i, n)
    {
        cin >> c[i];
    }

    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);

    rep(i, n)
    {
        x[i] = &c[n] - upper_bound(c, c + n, b[i]);
    }

    irep(i, n)
    {
        if (i == 0) {
            xsum[i] = 0;
        } else {
            xsum[i] = xsum[i - 1] + x[i - 1];
        }
    }

    int64_t result = 0;
    rep(i, n)
    {
        int j = upper_bound(b, b + n, a[i]) - &b[0];
        result += xsum[n] - xsum[j];
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 2560
N,C,K = map(int, input().split())
L = []
for a in range(N):
  L.append(int(input()))
L.sort()
L.append(10**10)
x = 0
y = 0
z = L[0]
for i in range (N+1):
  if y < C and z+K >= L[i]:
    y += 1
  else:
    x += 1
    y = 1
    z = L[i]    
print(x)

Measured memory_bytes: 13368
//
// Created by yamunaku on 2019/07/30.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    vl a(n+1), b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans=0;
    per(i,n){
        ans+=min(b[i],a[i+1]);
        b[i]-=min(b[i],a[i+1]);
        ans+=min(b[i],a[i]);
        a[i]-=min(b[i],a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

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

int main(){
    int N; cin >> N;
    vector<int> X(N);
    rep(i,N) cin >> X[i];
    int ans = INF;
    rep(i,101){
        int now = 0;
        rep(j,N){
            now += (X[j]-i)*(X[j]-i);
        }
        ans = min(ans,now);
    }
    cout << ans << endl;
}



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

int main(){
    string s;
    cin >> s;
    vector<int> backet(26, 0);
    for(int i = 0; i < s.length(); i++){
        backet[s[i]-'a']++;
    }
    string ans = "yes";
    for(int i = 0; i < 26; i++){
        if(backet[i] >= 2) ans = "no";
    }
    cout << ans << endl;
    return 0;
}

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

struct Point{
   long x, y;
};

int main(){
   set<Point> points;
   long N,D;
   cin>>N>>D;
   long count = 0;
   for(int i=0; i<N; i++){
      long x, y; cin>>x>>y;
      double d = sqrt(x*x+y*y);
      if(d <= D) count++;
   }

   cout << count << endl;
}

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

int main() {
	// your code goes here
	long long int x;
	cin>>x;
	long long int a=0;
	long long int cnt=100;
	while(cnt<x){
		cnt=cnt*1.01;
		a++;
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 3640
import sys
readline = sys.stdin.readline
write = sys.stdout.write
n, q = map(int, readline().split())
 
N0 = 2**(n-1).bit_length()
data = [None]*(2*N0)
INF = (-1, 2**31-1)

def update(l, r, v):
    L = l + N0; R = r + N0
    while L < R:
        if R & 1:
            R -= 1
            data[R-1] = v
 
        if L & 1:
            data[L-1] = v
            L += 1
        L >>= 1; R >>= 1
        
def _query(k):
    k += N0-1
    s = INF
    while k >= 0:
        if data[k]:
            s = max(s, data[k])
        k = (k - 1) // 2
    return s
def query(k):
    return _query(k)[1]
 
 
ans = []
for i in range(q):
    t, *cmd = map(int, readline().split())
    if t:
        ans.append(str(query(cmd[0])))
    else:
        s, t, x = cmd
        update(s, t+1, (i, x))
        
write("\n".join(ans))
write("\n")


Measured memory_bytes: 15604
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC103B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var list = Array.ConvertAll(Console.ReadLine().Split(), int.Parse).ToList();
            var max = list.Max();
            var min = list.Min();
            Console.WriteLine(max - min);
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node{
  int key;
  Node *next,*prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  int isf = 0;
  while(1){
    if(cur == nil)break;
    if(isf++ > 0)printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFitst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com ,&key);
    if(com[0] == 'i'){insert(key); np++; size++;}
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
        if(com[6] == 'F')deleteFitst();
        else if(com[6] == 'L')deleteLast();
      }else{
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();

  return 0;
}



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

int main() {
    int N, Y;
    cin >> N >> Y;
    int x = -1, y = -1, z = -1;

    for (int i = 0; i <= 2000; i++) {
        for (int j = 0; j <= 2000; j++) {
            if (9*i + 4*j == Y/1000 - N) {
                int k = N - (i + j);
                if (k >= 0) x = i, y = j, z = k;
            }
        }
    }

    printf("%d %d %d", x, y, z);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

	int a = stdIn.nextInt();
	int b = stdIn.nextInt();
	int c = stdIn.nextInt();
	int d = stdIn.nextInt();


	int deatht = (a % d == 0) ? a/d : a/d+1;
	int deatha = (c % b == 0) ? c/b : c/b+1;

	System.out.println((deatht < deatha) ? "No" : "Yes");
    }
}

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

using namespace std;

struct Node {
  int p;
  string s;
  Node(int x, string y) {
    p = x;
    s = y;
  }
};

auto operator<(const Node &e, const Node &f) {
  if (e.s.compare(f.s) > 0)
    return true;
  else
    return false;
}

int main() {
  int n, a, s, g;
  while (cin >> n >> a >> s >> g, n) {
    vector<vector<Node>> G(n);
    vector<vector<int>> GG(n);
    for (int i = 0; i < a; ++i) {
      int x, y;
      string str;
      cin >> x >> y >> str;
      G[x].emplace_back(y, str);
      GG[y].push_back(x);
    }
    stack<int> st;
    vector<bool> memo(n);
    bool flag = false;
    st.push(g);
    memo[g] = 1;
    while (!st.empty()) {
      int now = st.top();
      st.pop();
      for (auto next : GG[now]) {
        if (!memo[next]) {
          st.push(next);
          memo[next] = 1;
        }
      }
    }
    vector<vector<string>> magic(n, vector<string>(310, ""));
    priority_queue<Node> pq;
    pq.emplace(s, "");
    while (!pq.empty()) {
      auto now = pq.top();
      if (now.p == g) {
        cout << now.s << endl;
        goto BREAK;
      }
      if (now.s.length() > 300) {
        // cout << now.s << endl;
        break;
      }
      pq.pop();
      for (auto n : G[now.p]) {
        string ss = now.s + n.s;
        string &mg = magic[n.p][ss.length()];
        if (mg.compare(ss) > 0 || mg == "") {
          if (!memo[n.p])
            continue;
          mg = ss;
          pq.emplace(n.p, ss);
        }
      }
    }
    cout << "NO" << endl;
  BREAK:;
  }
}


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

int main(){
	int l,r,d;
	cin>>l>>r>>d;
	if(d==1){
		cout<<r-l+1;
		return 0;
	}
	if(l>r) swap(l,r);
	if(d>r){
		cout<<0<<endl;
		return 0;
	}
    int op=0;
  	for(int i=l;i<=r;i++){
        	if(i%d==0) op++;
        }
        cout<<op<<endl;
	return 0;
}

Measured memory_bytes: 3628
N,M,X = map(int,input().split())
ca = []

for i in range(N):
    ca.append(list(map(int,input().split())))

ans = 1e10


for i in range(2**N):
    flag = True
    sanko = [0]*M
    cost = 0
    for j in range(N):
        tmp = 0
        if (i>>j)&1:
            cost += ca[j][0]
            for h in range(1,M+1):
                sanko[h-1] += ca[j][h]
    for s in sanko:
        if s < X:
            flag = False
            break
    if flag:
        ans = min(ans,cost)

if ans == 1e10:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9208
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (int)N; i++)

const int UNVISITED = -1;
vector<bool> articulation;
vector<int> low;
vector<int> dist;
vector<vector<int>> adjacentList;

int dfs(int i, int d, int parent) {
  low[i] = d;
  dist[i] = d;
  bool articulate = false;
  int numberOfChildren = 0;
  for(auto n: adjacentList[i]) {
    if(dist[n] == UNVISITED) {
      numberOfChildren++;
      low[i] = min(low[i], dfs(n, d+1, i));
      articulate = articulate || (d <= low[n]);
    } else if(parent != n) {
      low[i] = min(low[i], dist[n]);
    }
  }
  articulation[i] = (i == 0 ? (numberOfChildren > 1) : articulate);
  return low[i];
}

int main () {
  int V, E;
  cin >> V >> E;
  articulation = vector<bool>(V, false);
  low = vector<int>(V, 0);
  dist = vector<int>(V, UNVISITED);
  adjacentList = vector<vector<int>>(V);

  for(int i = 0; i < E; i++) {
    int s, t;
    cin >> s >> t;
    adjacentList[s].push_back(t);
    adjacentList[t].push_back(s);
  }

  dfs(0, 0, -1);

  for(int i = 0; i < V; i++) {
    if(articulation[i]) cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 3112
l = []
for i in range(1,151):
    for j in range(1,151):
        if i==j or i>j: continue
        l += [[i**2+j**2,i,j]]
l = sorted(l)
while True:
    h,w = map(int,input().split())
    if w==h==0: break
    i = l.index([w**2+h**2,h,w])+1
    print(*l[i][1:],sep=' ')

Measured memory_bytes: 8956
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(0, A + B - N) << endl;
    return 0;
}


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

 int main()
 {
      int n;
      cin>>n;
      string s,s2,s3;
      cin>>s>>s2;

      for(int i=0;i<s.size();i++)
      {
          //for(int j=i;j<i+1;j++)
          //{
              s3+=s[i];
              s3+=s2[i];
          //}
      }

      cout<<s3<<endl;

      return 0;
 }


Measured memory_bytes: 256
from collections import defaultdict
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n = inp()
nums = [0] + inlt()
num_dict = defaultdict(int)
cnt = 0
for i in range(1,n + 1):
    num_dict[i - nums[i]] += 1

for i in range(1,n + 1):
    ii = i + nums[i]
    jj = i - nums[i]
    if num_dict[jj] > 0:
        num_dict[jj] -= 1
    cnt += num_dict[ii]
    

print(cnt)



Measured memory_bytes: 128836
import sys
from math import gcd

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    k = int(rl())
    ans = 0
    for a in range(1, k + 1):
        for b in range(1, k + 1):
            for c in range(1, k + 1):
                d = gcd(a, b)
                ans += gcd(c, d)
    print(ans)


if __name__ == '__main__':
    solve()


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

eightper = []
n = int(a/0.08)
if int(n*0.08) == a:
    pass
elif int(n*0.08) == a - 1:
    n += 1
else:
    n -= 1

while int(n*0.08) == a:
    eightper.append(n)
    n += 1
    
for e in eightper:
    if int(e*0.1) == b:
        print(e)
        break
else:
    print(-1)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

public class Main {
	static FastReader in = new FastReader();

	public static void main(String[] args) {
		solve();
	}

	static void solve() {
		int n = in.nextInt();
		int[] arr = in.readarr(n);
		
		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		
		for(int i = 0; i < n; i++)
		{
			if(i + 1 < n)dp[i + 1] = Math.min(dp[i] + (Math.abs(arr[i] - arr[i + 1])), dp[i + 1]);
			if(i + 2 < n)dp[i + 2] = Math.min(dp[i] + Math.abs(arr[i] - arr[i + 2]), dp[i + 2]);
		}
		
		System.out.println(dp[n - 1]);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readarr(int abc) {
			int[] temp = new int[abc];
			for (int i = 0; i < abc; i++)
				temp[i] = nextInt();
			return temp;
		}
	}
}


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

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> vec(N);
  for(int i=0; i<N; i++){
  cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  string S;
  for(int j=0; j<N; j++){
    S += vec.at(j);
  }
  cout << S << endl;
}


Measured memory_bytes: 3612
#include<stdio.h>
int main(void)
{
	double r;
	double pi = 3.141592653589;

	scanf("%lf", &r);

	if (0 < r < 10000) {

		printf("%f %f\n", pi*r*r, 2 * pi*r);
	}

	return(0);
}


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

int main(){
	string str;
	cin >> str;
	string res = "";
	for(int i = 0;i < str.size();i++){
		if(res == "")res += str[i];
		else if(str[i] != res[res.size() - 1])res += str[i];
	}
	if(res[0] == res[res.size() - 1]){
		cout << res[0] << endl;
	}
	else cout << 'o' << endl;
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll tree[800005],ht[200005],cst[200005];


void up(ll node,ll l,ll r,ll i,ll x)
{
    if(l>i||r<i)
        return;
    if(l==r)
    {
        tree[node]=max(tree[node],x);
        return;
    }
    ll ln=node*2,mid=(l+r)/2;
    up(ln,l,mid,i,x);
    up(ln+1,mid+1,r,i,x);
    tree[node]=max(tree[ln],tree[ln+1]);
    return ;
}


ll qry(ll node,ll l,ll r,ll i)
{
    if(l>i)
        return 0;
    if(r<=i)
        return tree[node];
    ll ln=node*2,mid=(l+r)/2;
    return max(qry(ln,l,mid,i),qry(ln+1,mid+1,r,i));
}

int main()
{
    ll n,m,i,j,k,a,b,c,x,y,z;
    cin>>n;
    for(i=1;i<=n;i++){
        scanf("%lld",&ht[i]);
    }
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&cst[i]);
    }
    ll ans=0;
    for(i=1;i<=n;i++){
        //cout<<i<<endl;
        a=ht[i];
        b=qry(1,1,n,a);
        //cout<<b<<endl;
        ans=max(ans,b+cst[i]);

        up(1,1,n,a,b+cst[i]);
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;

}



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

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    int N, M;
    cin >> N >> M;
    if (N % M == 0){
        cout << N/M;
    
    } else {
        cout << N/M + 1;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

  int A[20][5];
  int n, N;
  char S;

  for (int i = 0; i < 20; i++)
    for (int j = 0; j < 5; j++)
      A[i][j] = 0;

  cin >> n;

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

    if (S == 'S')
      A[N-1][0] = 1;

    else if (S == 'H')
      A[N-1][1] = 1;

    else if (S == 'C')
      A[N-1][2] = 1;

    else
      A[N-1][3] = 1;

  }

  for ( int j = 0; j < 4; j++)
    for (int i = 0; i < 13; i++){

      if (A[i][j] == 0) {
        if (j == 0)
          cout << "S " << i+1 << endl;
        if (j == 1)
          cout << "H " << i+1 << endl;
        if (j == 2)
          cout << "C " << i+1 << endl;
        if (j == 3)
          cout << "D " << i+1 << endl;
      }
    }

  return 0;
}



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

int main(void)
{
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());

    if (s < t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
	int N, i, ano = 0;
	long A[200005] = {};
	cin >> N;
	for (i = 0;i < N;i++) {
		cin >> A[i];
	}
 
	sort(A, A + N);
 
	for (i = 0; i < N - 1;i++) {
		if (A[i] == A[i + 1]) {
			ano = 1;
		}
	}
 
	if (ano == 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 1792
<?php
list($a,$b,$c) = explode(" ",trim(fgets(STDIN)));
$max = max($a,$b,$c);

if($max % 2 == 0){
    echo 0;
}else{
    $min = min($a,$b,$c);
    $nokori = $a + $b + $c - $max - $min;
    echo $min * $nokori;
}

Measured memory_bytes: 3704
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    for i in n..1000 {
        let t = i % 10;
        if t == i / 10 % 10 && t == i / 100 {
            println!("{}", i);
            return;
        }
    }
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 5e8 // cf. INT_MAX ≒ 2x10^9
#define ALL(a) a.begin(), a.end()
#define MAXEL max_element
#define MINEL min_element
#define POW (long long)pow
#define BIT(i) (long long)pow(2, i)
typedef long long Lint;
#define LINF 2e18 // cf. LLONG_MAX ≒ 9x10^18

int main() {
  Lint n, k;
  cin >> n >> k;
  if (k % 2) {
    cout << (n / k) * (n / k) * (n / k) << endl;
  }

  else {
    cout << (n / k) * (n / k) * (n / k) +
                ((n + k / 2) / k) * ((n + k / 2) / k) * ((n + k / 2) / k)
         << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<vector>

using namespace std;

#define long long long
#define ft(i, a, b) for (long i = (long)a ; i <= (long)b ; i++)
#define fd(i, a, b) for (long i = (long)a ; i >= (long)b ; i--)

const int mxN = 1e5 + 5;
const long oo = 1e15;
const long MOD = 1e9 + 7;
const int base = 311;

long n , k , x , ans;
bool mark[mxN];

void Solve() {
    long y;
    cin >> x;
    ft(i , 1 , x) cin >> y , mark[y] = true;
}

void FastInput() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
}

void Input() {
    cin >> n >> k;
    ft(i , 1 , k) {
        Solve();
    }
    ft(i , 1 , n) if (mark[i] == false) ans++;
    cout << ans;
}

int main() {
    FastInput();
    Input();
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int H,W; cin >> H >> W;
  vector<string> A(H);
  rep(i, H) cin >> A[i];

  int h = 0, w = 0;
  while(h >= 0 && h < H && w >= 0 && w < W) {
    A[h][w] = '.';

    int cnt = 0;
    int nnh = h;
    int nnw = w;
    rep(i, 4) {
      int nh = h + dy[i];
      int nw = w + dx[i];

      if(nh >= 0 && nh < H && nw >= 0 && nw < W && A[nh][nw] == '#') {
        if(i == 0 || i == 1) {
          if(cnt) {
            cout << "Impossible" << endl;
            return 0;
          } else {
            nnh = nh;
            nnw = nw;
          }
          ++cnt;
        } else {
          cout << "Impossible" << endl;
          return 0;
        }
      }
    }
    h = nnh;
    w = nnw;
    if(cnt == 0) break;
  }

  cout << "Possible" << endl;
  return 0;
}


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

int main()
{
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0;i <= n;i++) for (int j = 0;j <= m;j++)
	{
		int in = i*j+(n-i)*(m-j);
		if (in == k)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int A, B;
   cin >> A >> B;
   if (B == 1) cout << 0 << endl;
   else if (B <= A) cout << 1 << endl;
   else {
      int ans = (B - 1) / (A - 1);
      if ((B - 1) % (A - 1) != 0) ans++;
      cout << ans << endl;
   }
   return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int c = 0;
		int[] d = new int[a];
		for(int i = 0; i < a; i++){
			d[i] = sc.nextInt();
		} 
		for(int i = 0; i < a; i+=2){
			if(d[i] % 2 == 1){
				c ++;
			}
		}
		System.out.println(c);
		
		
	}
}

Measured memory_bytes: 35700
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long int ll;

int main()
{
	int n;
	cin>>n;
	int b=0,c=0,d=0;
	rep(i,n){
		int num;
		cin>>num;
		if( num % 4 == 0){
			b++;	
		}else if( num % 2 != 0){
			d++;
		}else{
			c++;
		}
	}
	if( c == 0){
		if( d <= b + 1){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		if(b >= d){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, c;
  cin >> N;
  c = 0;
 
  for( int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    c += r-l+1;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
$n, $a, $b = gets.split.map(&:to_i)
$hs = $n.times.map { gets.to_i }
max_t = ($hs.max.to_f / $b).ceil

def enough(t)
  return false if t == 0

  $hs.map {|h| h - t * $b}.select {|h| h > 0}.reduce(0) { |times, rh|
    times + (rh.to_f / ($a - $b)).ceil
  } <= t
end

def is_min_enough(t)
  enough(t) && !enough(t-1)
end


def find_min_enough_t(min, max)
  mid = (min + max) / 2
  if is_min_enough(mid)
    mid
  elsif enough(mid)
    find_min_enough_t(min, mid-1)
  else
    find_min_enough_t(mid+1, max)
  end
end

puts find_min_enough_t(1, max_t)

Measured memory_bytes: 74884
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n[]=new int[3],i,j,t;
		for(i=0;i<3;i++) n[i]=stdIn.nextInt();
		for(i=0;i<2;i++) {
			for(j=2;j>i;j--) {
				if(n[j-1]>n[j]) {
					t=n[j-1];
					n[j-1]=n[j];
					n[j]=t;
				}
			}
		}
		if(n[0]!=n[1]) System.out.print(n[0]);
		else System.out.print(n[2]);
	}
}

Measured memory_bytes: 21844
N, A, B, C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cnt,a,b,c):
    if cnt == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
        #最初は0から始めていて不要な処理が一回あるため-30する。
    res0 = dfs(cnt + 1,a,b,c)
    res1 = dfs(cnt + 1,a + l[cnt],b,c) + 10
    res2 = dfs(cnt + 1,a,b + l[cnt],c) + 10
    res3 = dfs(cnt + 1,a,b,c + l[cnt]) + 10
    return min(res0,res1,res2,res3)

print(dfs(0,0,0,0))

Measured memory_bytes: 9220
import math

n = int(input())
li = list(map(int, input().split(" ")))

for i in range(n - 1, 0, -1):
    if li[i - 1] <= li[i]:
        continue
    li[i - 1] -= 1
    if li[i - 1] > li[i]:
        print("No")
        exit()

print("Yes")

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

using namespace std;

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w,b;
    cin>>h>>w>>b;
    unordered_map<int,int> xtrack;
    unordered_map<int,int> ytrack;
    map<pair<int,int>,int>coor;
    for(int i=1;i<=b;i++){
        int x,y;
        cin>>x>>y;
        coor[make_pair(x,y)]=1;
        xtrack[x]++;
        ytrack[y]++;
    }
    int xmax=INT_MIN;
    int ymax=INT_MIN;
    for(auto i:xtrack){
        xmax=max(xmax,i.second);
    }
    for(auto j:ytrack){
        ymax=max(ymax,j.second);
    }
    vector<int> xcan;
    vector<int> ycan;
    for(auto i:xtrack){
        if(i.second==xmax){
            xcan.push_back(i.first);
        }
    }
    for(auto j:ytrack){
        if(j.second==ymax){
            ycan.push_back(j.first);
        }
    }
    int ans=xmax+ymax-1;
    for(int i=0;i<(int)xcan.size();i++){
        for(int j=0;j<(int)ycan.size();j++){
            if(coor[make_pair(xcan[i],ycan[j])]==0){
                    ans=xmax+ymax;
                    break;
            }
        }
    }
    cout<<ans;
    return 0;
}

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

 
int main() {
    int n;
    cin >> n;
    vector<int> ans(n+1);
    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                int s = x*x + y*y + z*z;
                s += x*y + y*z + z*x;
                if(s > n) continue;
                ans[s]++;
            }

        }

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


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define li unsigned long long
#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
const ll M = 1e9 + 7;
using namespace std; 
int main() 
{
	FAST
	ll n,W;
	cin>>n>>W;
	vector<pair<ll,ll>> v;
  	v.push_back({0,0});
	for(ll i=1;i<=n;i++)
	{
      	ll w,v1;
		cin>>w>>v1;
      	v.push_back({w,v1});
	}
  	sort(v.begin(),v.end());
	ll dp[n+5][W+5]={0};
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=W;j++)
		{
          	if(i==0 || j==0) dp[i][j]=0;
			else if(v[i].first>j) dp[i][j]=dp[i-1][j];
			else       dp[i][j]=max(dp[i-1][j],v[i].second+dp[i-1][j-v[i].first]);
		}
	}
	cout<<dp[n][W];
	return 0;
}

Measured memory_bytes: 82304
h,w=gets.split.map(&:to_i)
a=[]
10.times{a<<gets.split.map(&:to_i)}
m=[]
h.times{m<<gets.split.map(&:to_i)}
def wd(a)
  0.upto(9){|k|
    0.upto(9){|i|
      0.upto(9){|j|
        a[i][j]=[a[i][j],a[i][k]+a[k][j]].min
        }
      }
    }
end
wd(a)
c=Array.new(10,0)
m.flatten.reject{|i| i==-1 or i==1}.each{|i| c[i]+=1}
sum=0
2.upto(9){|i| sum+=c[i]*a[i][1]}
sum+=c[0]*a[0][1]
puts sum

Measured memory_bytes: 3324
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);

	public static void main(String[] $){
		PrimeIterator p=new PrimeIterator(100000);
		while(true){
			int n=s.nextInt();
			if(n==0)
				return;
			int a=s.nextInt();
			int b=s.nextInt();
			
			int ri=0,rj=0,v=0;
			for(int i=2;i*i<=n;i=p.bitset.nextSetBit(i+1)){
				for(int j=i;i*j<=n&&a*j<=i*b;j=p.bitset.nextSetBit(j+1)){
					if(v<i*j) {
						v=i*j;
						ri=i;
						rj=j;
					}
				}
			}
			System.out.println(ri+" "+rj);
		}
	}
}
class PrimeIterator implements Iterable<Integer>,PrimitiveIterator.OfInt{
	BitSet bitset;
	private int currentvalue,limit;

	public PrimeIterator(int limit){
		currentvalue=0;
		bitset=new BitSet(limit+1);
		this.limit=limit;
		construct();
	}
	/** Atkin's sieve */
	private final void construct(){
		int sqLim=(int)Math.sqrt(limit+0.5);
		{
			int n;
			for(int z=1;z<=5;z+=4){
				for(int y=z;y<=sqLim;y+=6){
					int ysq=y*y;
					for(int x=1;x<=sqLim&&(n=4*x*x+ysq)<=limit;++x)
						bitset.flip(n);
					for(int x=y+1;x<=sqLim&&(n=3*x*x-ysq)<=limit;x+=2)
						bitset.flip(n);
				}
			}
			for(int z=2;z<=4;z+=2){
				for(int y=z;y<=sqLim;y+=6){
					int ysq=y*y;
					for(int x=1;x<=sqLim&&(n=3*x*x+ysq)<=limit;x+=2)
						bitset.flip(n);
					for(int x=y+1;x<=sqLim&&(n=3*x*x-ysq)<=limit;x+=2)
						bitset.flip(n);
				}
			}
			for(int y=3;y<=sqLim;y+=6){
				int ysq=y*y;
				for(int z=1;z<=2;++z)
					for(int x=z;x<=sqLim&&(n=4*x*x+ysq)<=limit;x+=3)
						bitset.flip(n);
			}
		}
		{
			//remove square
			for(int n=5;n<=sqLim&&n!=-1;n=bitset.nextSetBit(n+1)){
				int nsq=n*n;
				for(int k=nsq;k<=limit;k+=nsq)
					bitset.clear(k);
			}
		}
		bitset.set(2);
		bitset.set(3);
	}

	@Override
	public boolean hasNext(){
		int r=getNextValue();
		return 0<=r&&r<=limit;
	}
	private int getNextValue(){
		return bitset.nextSetBit(currentvalue+1);
	}
	@Override
	public int nextInt(){
		int r=getNextValue();
		if(r<0||limit<r) throw new NoSuchElementException();
		return currentvalue=r;
	}
	@Override
	public OfInt iterator(){
		return this;
	}
	public BitSet getClonedBitSet(){
		return (BitSet)bitset.clone();
	}
}



Measured memory_bytes: 36820
N, P = map(int, input().split())
A = list(map(int, input().split()))

import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def calc(n):
    ans = 0
    for r in range(n-n%2, -1, -2):
        ans += combinations_count(n, r)
    return ans
    
gusu = 0
for a in A:
    if a%2 == 0:
        gusu +=1
kisu = N - gusu

p0 = 2**gusu*calc(kisu)
if P == 0:
    print(p0)
else:
    print(2**N-p0)


Measured memory_bytes: 61968
while True:
  a, b, c = input().split()
  a = int(a)
  c = int(c)
  if b == "+":
    print(a+c)
  elif b == "-":
    print(a-c)
  elif b == "/":
    print(int(a/c) )
  elif b == "*":
    print(a*c)
  else:
    break
  


Measured memory_bytes: 5592
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back
#define ALL(C)     (C).begin(),(C).end()

const int CONST = 12;

bool have_same(vector<int> &a){
  rep(i,a.size())REP(j,i+1,a.size())if (a[i] == a[j])return true;
  return false;
}

void generate(vector<string> & a,vector<vector<int> > &b){
  vector<int> base[5];
  string    opdata[5]={"","7","M7","m","m7"};
  base[0].pb(0);base[0].pb(4);base[0].pb(7);
  base[1].pb(0);base[1].pb(4);base[1].pb(7);base[1].pb(10);
  base[2].pb(0);base[2].pb(4);base[2].pb(7);base[2].pb(11);
  base[3].pb(0);base[3].pb(3);base[3].pb(7);
  base[4].pb(0);base[4].pb(3);base[4].pb(7);base[4].pb(10);

  vector<int> pat;

  string option="";
  string ori[]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
  string add[]={"-9","9","+9","-11","11","+11","-13","13","+13"};
  int   addp[]={1,2,3,4,5,6,8,9,10};
  string   h[]={"-5","+5"};
  int     hp[]={11,1};
  

  rep(k,5){
    pat=base[k];
    option=opdata[k];
    rep(i,12){      
      vector<int> cpy=pat;
      rep(j,pat.size())cpy[j]=(cpy[j]+i)%CONST;
      a.pb(ori[i]+option);
      b.pb(cpy);
      vector<int> cpy2=cpy;
      cpy2.pb(-1);
      rep(j,9){
	cpy2[cpy2.size()-1]=(i+addp[j])%CONST;
	if (have_same(cpy2))continue;
	a.pb(ori[i]+option+"("+add[j]+")");
	b.pb(cpy2);
      }
      
      int base=cpy[2];
      rep(j,2){
	//cpy[cpy.size()-1]=(base+hp[j])%CONST;
	cpy[2]=(base+hp[j])%CONST;
	a.pb(ori[i]+option+"("+h[j]+")");
	b.pb(cpy);
      }
    }
  }
   
  rep(i,a.size()){
    //    cout << a[i] << " ";// << b[i].size() << endl;
    //    rep(j,b[i].size())cout << b[i][j]<<" ";cout <<endl;
    sort(ALL(b[i]));
  }
}


bool  is_same_vector(vector<int> &a,vector<int> &b){
  if (a.size() != b.size())return false;
  rep(i,a.size())if (a[i] != b[i])return false;
  /*  
  cout << endl;
  cout <<"tete"<<endl;
  rep(i,a.size())cout << a[i];cout << endl;
  rep(i,b.size())cout << b[i];cout << endl;
  */  
  return true;
}

main(){
  vector<string> a;
  vector<vector<int> > b;
  generate(a,b);
  string ori[]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
  map<string,int> M;
  rep(i,12)M[ori[i]]=i;
  
  int te;
  cin>>te;
  while(te--){
    int cnt = 0;
    int n;
    cin>>n;
    vector<int> in;
    rep(i,n){
      string tmp;cin>>tmp;in.pb(M[tmp]);
    }
    sort(ALL(in));
    
    //    rep(k,in.size()){
      rep(i,a.size()){
	if (is_same_vector(b[i],in)){
	  if (cnt)cout << " ";
	  cout << a[i];
	  cnt++;
	}
      }
      /*      
      int tmp = in[0];
      rep(i,in.size()-1)in[i]=in[i+1];
      in[in.size()-1]=tmp;
    }
      */
    if (cnt == 0)cout << "UNKNOWN";
    cout << endl;
  }
  return false;
}

Measured memory_bytes: 0
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {
	
	public static void main(String[] args) {
		while (read()) {
			solve();
		}
	}
	
	static int N;
	static int[] ss;
	static Scanner sc = new Scanner(System.in);
	static boolean read() {
		N = sc.nextInt();
		if (N == 0) return false;
		
		ss = new int[N];
		fill(ss, 0);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 5; j++) {
				ss[i] += sc.nextInt();
			}
		}
		return true;
	}
	
	static void solve() {
		sort(ss);
		System.out.println(ss[N - 1] + " " + ss[0]);
	}
	

}

Measured memory_bytes: 12000
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    int ans = 1;
    rep(i,n){
        if (ans<=k){
            ans+=ans;
        }
        else{
            ans+=k;
        }
    }

    cout << ans;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  int ans = 0, cnt = 0;
  for(int i=0; i<n-1; ++i){
    if(an[i] >= an[i+1]) ++cnt;
    else cnt = 0;
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3784
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall 

n = int(input())
s = list()
for i in range(n):
    s.append([int(x) for x in list(input())])
s=np.array(s)
d=floyd_warshall(csr_matrix(s))
c=d[:, np.argmax(d)%n]
for i in range(n):
    for j in range(i+1, n):
        if (s[i, j] == 1) and abs(c[i] - c[j]) != 1:
            print(-1)
            exit()
r=int(np.amax(d)+1)
print(r)



Measured memory_bytes: 24824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >>a>>b;
  int c=a+b;
  if(c%2==0){
    int d=c/2;
    cout <<d<<endl;
  }
  else{
    cout << "IMPOSSIBLE"<<endl;
  }
}

Measured memory_bytes: 256