akhauriyash/Code-Regression huggingface dataset:
import copy

# Generate Graph as Dict
N, M = list(map(int, input().split()))
G = dict()
paths = []
for i in range(0,M):
    a, b = list(map(int, input().split()))
    paths.append([a,b])
    if a in G:
        G[a] += [b]
    else:
        G[a] = [b]
    if b in G:
        G[b] += [a]
    else:
        G[b] = [a]

# Depth First Search
def dfs(s):
    visited[s-1] = True
    for p in _G[s]:
        if visited[p-1]:
            continue
        else:
            dfs(p)

# Check if the graph is connected for M cases
ans = 0

for i in range(M):
    _G = copy.deepcopy(G)
    _G[paths[i][0]].remove(paths[i][1])
    _G[paths[i][1]].remove(paths[i][0])
    
    visited = [False for i in range(N)]
    dfs(1)
    if not all(visited):
        # Count up if not connected
        ans += 1
    
print(ans)

Measured memory_bytes: 3572
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;

int n;
int q;
vector<int> S;

bool binary_search(int key){
    int h = 0;
    int t = n;

    while ( h < t ) {
	int mid = (h+t) >> 1;
	if ( S[mid] == key ) {
	    return true;
	}
	else if ( key < S[mid] ) {
	    t = mid;
	}
	else {
	    h = mid + 1;
	}
    }

    return false;
}

int main()
{
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
	int s;
	scanf("%d", &s);
	S.push_back(s);
    }

    scanf("%d", &q);
    int ans = 0;
    for ( int i = 0; i < q; i++ ) {
	int t;
    	scanf("%d", &t);
	if ( binary_search(t) ) ans++;
    }

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

    return 0;
}

Measured memory_bytes: 1528
import java.util.*;

public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    
    String line = sc.nextLine();
    String[] lines = line.split(" ");
    
    double T = Double.parseDouble(lines[0]);
    double X = Double.parseDouble(lines[1]);
    
    System.out.println(T / X);
  }
}


Measured memory_bytes: 21844
n, k = gets.split.map(&:to_i)
a = gets.split("")

now = 0
rl = 0
lr = 0

(n-1).times do |i|
  if a[i] == a[i+1]
    now += 1
    next
  end

  if a[i] == "L"
    lr += 1
    next
  end

  if a[i] == "R"
    rl += 1
  end
end

ans = now + [rl, k].min + [lr, k].min
puts ans

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(void){

    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;

    int64_t ans = a * c;
    if(ans < a*d) ans = a*d;
    if(ans < b*c) ans = b*c;
    if(ans < b*d) ans = b*d;

    cout << ans << endl;

    return 0;
}

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

const int INF = 0x3f3f3f3f;
typedef long long ll;

int d[6010][2010];
bool done[6010][2010];
int N, M, C;

typedef struct _Edge{
    int to, dist;
    _Edge(int to, int dist): to(to), dist(dist){};
}Edge;

typedef struct _Node{
    int v, gas, d;
    _Node(int v, int gas, int d): v(v), gas(gas), d(d){};
    bool operator<(const _Node& n)const{return d>n.d;}
}Node;

int dijkstra(vector<vector<Edge>> &G, set<int> &gass, int src, int dst){
    int N = G.size();
    memset(d, 0x3f, sizeof(d));
    memset(done, 0, sizeof(done));
    
    priority_queue<Node> que;
    
    d[src][C*10] = 0;
    que.push(Node(src, C*10, 0));
    
    while(!que.empty()){
        auto node = que.top(); que.pop();
        if(node.v == dst)
            return node.d;
        
        auto p = make_pair(node.v, node.gas);
        
        if(done[p.first][p.second])
            continue;
        done[p.first][p.second] = true;
             
        for(auto e: G[node.v]){
            if(node.gas < e.dist)
                continue;
            
            pair<int, int> np;
            np.first = e.to;
            if(gass.find(e.to) != gass.end())
                np.second = C*10;
            else
                np.second = node.gas - e.dist;
            
            if(d[p.first][p.second] + e.dist < d[np.first][np.second]){
                d[np.first][np.second] = d[p.first][p.second] + e.dist;
                que.push(Node(np.first, np.second, d[np.first][np.second]));
            }
        }
    }
    return -1;
}

void solve(){
    string src, dst;
    cin >> src >> dst;
    
    map<string, int> stoi;
    vector<string> cs(N), cd(N);
    vector<int> ds(N);
    for(int i=0; i<N; i++){
        cin >> cs[i] >> cd[i] >> ds[i];
        
        if(stoi.find(cs[i]) == stoi.end()){
            int x = stoi.size();
            stoi[cs[i]] = x;
        }
        if(stoi.find(cd[i]) == stoi.end()){
            int x = stoi.size();
            stoi[cd[i]] = x;
        }
    }
    
    set<int> gass;
    for(int i=0; i<M; i++){
        string s; cin >> s;
        gass.insert(stoi[s]);
    }
    
    vector<vector<Edge>> G(stoi.size());
    for(int i=0; i<N; i++){
        int si = stoi[cs[i]];
        int di = stoi[cd[i]];
        
        G[si].emplace_back(di, ds[i]);
        G[di].emplace_back(si, ds[i]);
    }
    
    cout << dijkstra(G, gass, stoi[src], stoi[dst]) << endl;
}

int main(){
    while(cin >> N >> M >> C, N|M|C)
        solve();
    
    return 0;
}

Measured memory_bytes: 87232
# -*- coding: utf-8 -*-
"""
C - Linear Approximation
https://beta.atcoder.jp/contests/abc102/tasks/arc100_a
TLE
"""
import sys
from sys import stdin
input = stdin.readline

from functools import lru_cache
def _solve(arr):
    @lru_cache(maxsize=None)
    def calc_score(n):
        return sum([abs(a-(n+i)) for i, a in enumerate(arr, start=1)])

    ub = max(arr)
    lb = -max(arr)

    while True:
        mid1 = (lb*2 + ub) // 3
        mid2 = (lb + ub*2) // 3
        mid1_score = calc_score(mid1)
        mid2_score = calc_score(mid2)

        if mid2_score > mid1_score:
            ub = mid2
        else:
            lb = mid1
        if abs(ub - lb) <= 4:
            break

    ans = float('inf')
    for b in range(lb, ub+1):
        t = calc_score(b)
        ans = min(ans, t)
    return ans


from statistics import median

def solve(arr):
    def calc_score(n):
        return sum([abs(a-(n+i)) for i, a in enumerate(arr, start=1)])

    array_b = [a-i for i, a in enumerate(arr, start=1)]
    m = median(array_b)
    ans = float('inf')
    for i in range(int(m)-1, int(m)+2):
        ans = min(ans, calc_score(i))
    return ans



def main(args):
    N = int(input())
    arr = [int(a) for a in input().split()]
    ans = solve(arr)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<vector<int>> edges;

bool dfs(int i,int p,int c) {
    bool ret = false;
    for (int j : edges[i]) if (j != p) {
        if (j == c) return true;
        if (edges[j].size() == 4) return false;
        ret |= dfs(j,i,c);
    }
    return ret;
}

int main() {
    int n,m;
    cin >> n >> m;
    edges.resize(n);
    for (int i = 0;i < m;++i) {
        int u,v;
        cin >> u >> v;
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    if (n+2 > m || n < 5) {
        cout << "No" << endl;
        exit(0);
    }
    int cnt = 0;
    for (int i = 0;i < n;++i) {
        if (edges[i].size()%2) {
            cout << "No" << endl;
            exit(0);
        }
        if (edges[i].size() >= 6) cnt += 3;
        else if (edges[i].size() == 4) cnt += 1;
    }
    if (cnt > 2) {
        cout << "Yes" << endl;
        exit(0);
    }
    bool ans;
    for (int i = 0;i < n;++i) if (edges[i].size() == 4) {
        ans = dfs(i,-1,i);
        break;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

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

int main() {
  int n, m; cin >> n >> m;
  if (n==m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 101
#define MAX 2001

void prims(void);

int n;
int G[N][N],pi[N],w[N][N];

int main()
{
  int sum = 0;
  int i, j;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &G[i][j]);
      w[i][j] = G[i][j];
    }
  }
  
  prims();
  
  for(i = 0; i < n; i++){
    if(w[i][ pi[i] ] != -1){
      sum += w[i][ pi[i] ];
    }
  }
  
  printf("%d\n", sum);
  
  return 0;
}

void prims(void){
  int mincost, u, v, i;
  int color[n], d[n];
  
  for(u=0; u<n; u++){
    d[u] = MAX;
    pi[u] = -1;
    color[u] = 0;
  }
  
  d[0] = 0;
  
  while(1){
    mincost = MAX;
    for(i=0; i<n; i++){
      if(mincost > d[i] && color[i] != 1){
	u = i;
	mincost = d[i];
      }
    }
    
    if(mincost == MAX){
      break;
    }
    
    color[u] = 1;
    
    for(v=0; v<n; v++){
      if(color[v] != 1 && w[u][v] < d[v] && w[u][v] != -1){
	pi[v] = u;
	d[v] = w[u][v];
      }
    }
    
  }
  
}

Measured memory_bytes: 680
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int n;
	cin >> n;
	vi x(n);
	rep(i, n) {
		cin >> x[i];
	}

	ll mn = INF;
	Rep(i, 100) {
		ll tmp = 0;
		rep(j, n) {
			tmp += (x[j] - i) * (x[j] - i);
		}
		mn = min(mn, tmp);
	}
	cout << mn << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			int n = in.nextInt();
			int[] search = new int[n-1];
			int count = 0;
			for(int i=0; i<n-1; i++) {
				search[i] = i+2;
			}
			for(int i=0; i<search.length; i++) {
				if (search[i] != -1) {
					count++;
					int tmp = search[i];
					for(int j=i; j<search.length; j+=(i+2)) {
//						System.out.println(search[j] + " " +  j);
							search[j] = -1;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 54332
local ior = io.read
local am, bm, cm, x = ior("*n", "*n", "*n", "*n")

local cnt = 0
for a = 0, am do for b = 0, bm do for c = 0, cm do
  if(a * 500 + b * 100 + c * 50 == x) then cnt = cnt + 1 end
end end end
print(cnt)


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

int main() {
  long long a,b,c,ans=0,x=0;
  cin>>a>>b>>c;
  while(a%2==0&&b%2==0&&c%2==0){
    x=1;
    int A=a,B=b,C=c;
    if(a==b&&b==c){
      cout<<-1;
      break;
    }
    else{
      a=(B+C)/2;
      b=(C+A)/2;
      c=(A+B)/2;
      ans++;
      //continue;
    }
   // cout<<a<<" "<<b<<" "<<c;
  }
  if(ans!=0){
    cout<<ans;
  }
  else if(x==0){
    cout<<0;
  }
  

}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += B[A[i] - 1]
    if i>=1 and A[i] - A[i-1] == 1:
        ans += C[A[i-1] - 1]

print(ans)

Measured memory_bytes: 9160
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

sim l l' r m | l' > r = m
             | m == (-1) = sim l (l'+1) r m'
             | m' < m = sim l (l'+1) r m'
             | otherwise = sim l (l' + 1) r m
             where
              m' = (l * l') `mod` 2019

simulate l r m | l == r = m
               | otherwise = simulate (l+1) r m'
               where
                m' = sim l (l+1) r m

main = do
  [l, r] <- getIntList
  if r >= l + 2019
    then print 0
    else do
      let l' = l `mod` 2019
      let r' = r `mod` 2019
      let s | r' == l' + 1 = (r' * l') `mod` 2019
            | l' > r' = 0
            | otherwise = simulate l' r' (-1)
      print s


Measured memory_bytes: 4876
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  int n;
  string s;

  cin >> n >> s;

  //累積和　配列の用意
  vector<int> black_cumulativeSum;
  vector<int> white_cumulativeSum;
  int b_sum = 0;
  int w_sum = 0;
  black_cumulativeSum.push_back(b_sum);
  white_cumulativeSum.push_back(w_sum);
  for(int i=0; i<s.size(); i++){
    if(s.at(i) == '#'){
      b_sum++;
    }else{
      w_sum++;
    }
    black_cumulativeSum.push_back( b_sum );
    white_cumulativeSum.push_back( w_sum );
  }

  long ans = 9999999999;
  for(int i=0; i<s.size()+1; i++){
    int temp=0;
    temp = black_cumulativeSum.at(i);
    temp += white_cumulativeSum.at(n) - white_cumulativeSum.at(i);
    if( ans > temp){
      ans = temp;
    }
  }

  cout << ans;
}


Measured memory_bytes: 2168
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	int N, K;
	scanf("%d%d", &N, &K);
	if(K > N / 2){
		puts("-1");
	}else{
		for(int i = 0; i < K; ++i){
			int p = i;
			for(int j = 0; j < N - 1; ++j){
				int diff = min(j, N - j - 2) + 1;
				if(diff % 2 == 0){ diff = -diff; }
				if(N % 2 == 0 && j * 2 >= N){ diff = -diff; }
				int next = (p + diff + N) % N;
				printf("%d %d\n", p + 1, next + 1);
				p = next;
			}
			puts("");
		}
	}
	return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N, M;
int P[111111], Y[111111];
int cnt[111111];

// １スタート
map<int, int> G[111111];

signed main() {
   cin >> N >> M;
   rep (i, M) {
      cin >> P[i] >> Y[i];
      G[P[i]][Y[i]] = 0;
      // G[P[i]].insert(Y[i]);
   }

   for (int i = 1; i <= N; i++) {
      int cnt = 0;
      for (auto x : G[i]) {
         G[i][x.first] = cnt;
         cnt++;
      }
   }

   rep (i, M) {
      int p = P[i], y = Y[i];
      // auto itr = G[p].find(y);
      // int pos = itr - G[p].begin();
      // int d = std::distance(G[p].begin(), G[p].find(y));
      // d++;
      int d = G[p][y]+1;
      printf("%06lld%06lld\n", p, d);
   }

   return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int k, n;
    cin >> k >> n;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    int dif[n] = {};
    dif[0] = a[0] + k - a[n - 1];
    rep(i, 1, n) {
        dif[i] = a[i] - a[i - 1];
    }
    int mx = 0;
    rep(i, 0, n) mx = max(mx, dif[i]);
    cout << k - mx << endl;
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int n;
double dp[305][305][305];

double solve(int i, int j, int k) {
	if (i < 0 || j < 0 || k < 0) return 0;
	if (!(i || j || k)) return 0;
	if (dp[i][j][k]) return dp[i][j][k];
	dp[i][j][k] = (double)n/(i+j+k) * (1 + (double)i/n*solve(i-1, j, k) + (double)j/n*solve(i+1, j-1, k) + (double)k/n*solve(i, j+1, k-1));
	return dp[i][j][k];

}

signed main(){
    IOS;
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> n;
    int i, j, k;
    i = j = k = 0;
    for (int ii = 0; ii < n; ii++) {
    	int a;
    	cin >> a;
    	i += (a == 1);
    	j += (a == 2);
    	k += (a == 3);
    }
    dbg3(i, j, k)
    cout << fixed << setprecision(10) << solve(i, j, k);
    return 0;
}

Measured memory_bytes: 219392
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k,t; cin >> k >> t;
  vector<int> a(t);
  REP(i,t) cin >> a[i];
  sort(ALL(a), greater<int>());
  cout << max(a[0]-1-(k-a[0]), 0) << '\n';
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[5];
int main(){
	int i,j,k,n,ans=0;
	for(i=1;i<=3;i++) cin>>a[i];
	cin>>n;
	for(i=0;i<=a[1];i++){
		for(j=0;j<=a[2];j++){
			for(k=0;k<=a[3];k++){
				if(500*i+100*j+50*k==n) ans++;
			}
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main()
{
    int a, b, c, k, big, sum;
    cin >> a >> b >> c >> k;
    big = max(max(a, b), c);
    if (big == a)
        sum = b + c;
    else if (big == b)
            sum = a + c;
    else
        sum = a + b;
    for (int i = 0; i < k; ++i)
        big *= 2;
    cout << big + sum;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;
int dp[5][110], num[3][110];
int n;

void dfs(int x, int y)
{
	if (y > n) return;
	if (dp[x][y] != -1) return;
	if (x == 1)
	{
		dfs(x + 1, y);
		dfs(x, y + 1);
		dp[x][y] = max(dp[x + 1][y], dp[x][y + 1]) + num[x][y];
	}
	else
	{
		dfs(x, y + 1);
		dp[x][y] = dp[x][y + 1] + num[x][y];
	}
}

int main()
{
	int i, j;
	scanf("%d", &n);
	for (i = 1; i <= 2; i++)
	{
		for (j = 1; j <= n; j++)
		{
			scanf("%d", &num[i][j]);
		}
	}
	memset(dp, -1, sizeof(dp));
	dp[2][n] = num[2][n];
	dfs(1, 1);

	printf("%d\n", dp[1][1]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main(){
	int n,m;
  cin>>n>>m;
  vector<vector<int> > mat_a(n, vector<int>(m));
  vector<int> mat_b(m);
  vector<int> mat_c(n);
  rep(i,n){
    rep(j,m){
      cin>>mat_a.at(i).at(j);
    }
  }
  rep(i,m){
    cin>>mat_b.at(i);
  }
  rep(i,n){
    rep(j,m){
      mat_c.at(i) += (mat_a.at(i).at(j) * mat_b.at(j));
    }
    cout << mat_c.at(i) << endl;
  }
}


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

public class Main {
	static int[] dp1=new int[1000001];
	static int[] dp2=new int[1000001];
	static int[] p=new int[100000];
	static int max=0;
	
	static void n() {
		for(int num=1; num*(num+1)*(num+2)/6<1000000; num++) {
			dp1[num*(num+1)*(num+2)/6]=1;
			if((num*(num+1)*(num+2)/6)%2!=0){
				dp2[num*(num+1)*(num+2)/6]=1;
			}
			p[num]=num*(num+1)*(num+2)/6;
			max=num;
		}
	}

	static void dp() {
		for(int num=1; num<=1000000; num++) {
			for(int i=1; i<=max; i++) {
				if(num>p[i]) {
					dp1[num]=Math.min(dp1[num], dp1[num-p[i]]+1);
					//System.out.println("i="+i+"dp1["+num+"]="+dp1[num]);
					if(p[i]%2!=0)
					dp2[num]=Math.min(dp2[num], dp2[num-p[i]]+1);
					//System.out.println("i="+i+"dp2["+num+"]="+dp2[num]);
				}
			}
		}
	}

	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			Arrays.fill(dp1, 100000000);
			Arrays.fill(dp2, 100000000);
			n();
			dp();
			while(sc.hasNext()) {
				int N=sc.nextInt();
				if(N==0) break;
				
				System.out.println(dp1[N]+" "+dp2[N]);
				
			}
		}
	}
} 


Measured memory_bytes: 34852
import sys

import numpy as np

input = sys.stdin.readline
N = int(input())
T, A = list(map(int, input().split()))
H = list(map(int, input().split()))
ans = [0] * N
for i, h in enumerate(H):
    ans[i] = abs(A - T + h * 0.006)
print(np.argmin(ans) + 1)


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

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

	if(a*b%2 == 0)
		cout << "Even" << endl;
	else
		cout << "Odd" << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  string s; cin>>s;
  vector<ll> hash(26);
  for(i=0;i<s.size();i++){
    if(hash[s[i]-'a']==0){
      hash[s[i]-'a']=1;
    }
    else{
      judge=false;break;
    }
  }
  if(judge)cout<<"yes"<<endl;
  else cout<<"no"<<endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

ans = [0]*n

for i in reversed(range(n)):
  j = i+1
  b = 0
  while j <= n:
    b += ans[j-1]
    j += i+1
  if b%2 != l[i]:
    ans[i] = 1

print(sum(ans))
print(' '.join(map(str, [i+1 for i, x in enumerate(ans) if x!= 0])))

Measured memory_bytes: 19004
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int N, K; cin >> N >> K;
    int cnt = 0;
    while(N){
        N /= K;
        ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 768
using System;
public class Hello{
    public static void Main(){
        // StringBuilderは分からないのでなし
        string n = Console.ReadLine();
        string ans = "";
        for (int i = 0; i<n.Length;i++){//Length()にかっこ不要
            if (n[i]=='1'){//""だとstring
                ans += "9";
            }
            else if (n[i]=='9'){
                ans += "1";
            }
            else{
                ans += n[i];
            }
        }
        System.Console.WriteLine(ans);
    }
}


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

typedef struct {
	double x, y, z, r;
} Coord;
typedef struct {
	int from, to;
	double weight;
} Edge;

Coord coord[ 100 ];
int parent[ 100 ];
Edge edge[ 4950 ];

int compare( const void *a, const void *b ) {
	double at = (*(Edge *)a).weight, bt = (*(Edge *)b).weight;

	if ( at < bt )
		return -1;
	else
		return 1;
}

int find( int x ) {
	if ( parent[ x ] == x )
		return x;
	else
		return parent[ x ] = find( parent[ x ] );
}

void unite( int x, int y ) {
	parent[ find( y ) ] = find( x );
}

double kruskal( int v, int e ) {
	int i;
	double sum;

	qsort( edge, e, sizeof(Edge), &compare );

	for ( i = 0; i < v; i++ )
		parent[ i ] = i;

	sum = 0.0;
	for ( i = 0; i < e; i++ )
		if ( find( edge[ i ].from ) != find( edge[ i ].to ) ) {
			unite( edge[ i ].from, edge[ i ].to );
			sum += edge[ i ].weight;
		}

	return sum;
}

int main( void ) {
	int i, j;
	int n;

	while ( scanf( "%d", &n ), n ) {
		int cnt;
		double sum;

		for ( i = 0; i < n; i++ )
			scanf( "%lf %lf %lf %lf", &coord[ i ].x, &coord[ i ].y, &coord[ i ].z, &coord[ i ].r );

		cnt = 0;
		for ( i = 0; i < n; i++ )
			for ( j = i + 1; j < n; j++ ) {
				edge[ cnt ].from = i;
				edge[ cnt ].to = j;
				edge[ cnt ].weight = fmax( hypot( hypot( coord[ i ].x - coord[ j ].x, coord[ i ].y - coord[ j ].y ), coord[ i ].z - coord[ j ].z ) - coord[ i ].r - coord[ j ].r, 0.0 );
				cnt++;
			}

		printf( "%.3f\n", kruskal( n, cnt ) );
	}

	return 0;
}

Measured memory_bytes: 880
require 'pp'

# Nと空白区切の入力値を数値の配列で返却する
def gets_i_list()
  return gets.chomp.to_i, gets.chomp.split(" ").map(&:to_i)
end

N, a_list = gets_i_list

simple_a_list = a_list.map do |a|
  if a.odd?
    1
  elsif a % 4 == 0
    4
  else
    2
  end
end

c1 = simple_a_list.count(1)
c2 = simple_a_list.count(2)
c4 = simple_a_list.count(4)

if c1.zero?
  puts "Yes"
elsif c1.zero? && c4.zero?
  puts "Yes"
elsif c1 + (c2%2) -1 <= c4
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 10504
/*
[abc137] B - One Clue
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int K, X;

void solve() {
    for (int i = X - K + 1; i < X + K; i++) {
        cout << i << " ";
    }
    cout << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int n = 0, a[100], i;

	scanf("%d", &n);

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

	for(i = 0; i < n - 1; i++){
		printf("%d ", a[n - i -1]);
	}

	printf("%d\n", a[0]);

	return 0;



}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

    int n, m, a[112345], b[112345];
    bool used[112345] = {false};
    vector<int> g[112345], num, res;

    cin >> n >> m;

    REP(i, m)
    num.push_back(0);

    REP(i, m)
    {
        cin >> a[i] >> b[i];
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);

        num[a[i]]++;
        num[b[i]]++;
    }

    int s = a[0], e = b[0];
    used[s] = true;
    used[e] = true;

    res.push_back(s);
    res.push_back(e);

    while (true)
    {
        int s_ = 0, e_ = 0;
        while (s_ < g[s].size() && used[g[s][s_]])
            s_++;

        while (e_ < g[e].size() && used[g[e][e_]])
            e_++;

        if (s_ == g[s].size() && e_ == g[e].size())
            break;

        if (s_ == g[s].size())
        {
            e = g[e][e_];
            used[e] = true;

            res.push_back(e);
        }
        else
        {
            s = g[s][s_];
            used[s] = true;

            res.insert(res.begin(), s);
        }
    }

    cout << res.size() << endl;

    REP(i, res.size())
    {
        cout << res[i];
        if (i < res.size() - 1)
            cout << " ";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 8440
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

struct Point {
	ll x, y;
};




void bfs(Point start, vector<vector<ll>>& distance, const vector<vector<bool>> maze , const ll h, const ll w){
	queue <Point> Q;
	Q.push(start);
	distance[start.x][start.y] = 0;
	
	while (!Q.empty()) {
		Point now = Q.front();
		ll nowDistance = distance[now.x][now.y];
		Q.pop();
		Point pt1, pt2, pt3, pt4;
		pt1 = pt2 = pt3 = pt4 = now;
		pt1.x++;
		pt2.y++;
		pt3.x--;
		pt4.y--;
		vector <Point> nextPointList;
		nextPointList.push_back(pt1);
		nextPointList.push_back(pt2);
		nextPointList.push_back(pt3);
		nextPointList.push_back(pt4);
		for (Point next : nextPointList) {
			if (0 <= next.x && next.x < h && 0 <= next.y && next.y < w && maze[next.x][next.y] == true && distance[next.x][next.y] == -1) {
				distance[next.x][next.y] = nowDistance + 1;
				Q.push(next);
			}
		}
	}
}


int main() {
	ll h, w;
	cin >> h >> w;
	vector <vector<bool>> maze;
	vector <vector<ll>> distance;
	maze.resize(h);
	distance.resize(h);
	Point st;
	for (ll i = 0; i < h; i++) {
		maze[i].resize(w);
		distance[i].resize(w);
		string s;
		cin >> s;
		for (ll j = 0; j < w; j++) {
			distance[i][j] = -1;
			if (s[j] == '.') {
				maze[i][j] = true;
				st.x = i;
				st.y = j;
			}
		}
	}
	//cout << st.x << st.y << endl;
	bfs(st, distance, maze, h, w);
	ll maxDistance = -1;
	Point mdp;
	for (ll i = 0; i < h; i++) {
		for (ll j = 0; j < w; j++) {
			//cout << distance[i][j];
			Point mdp;
			mdp.x = i;
			mdp.y = j;
			if (maze[i][j] == true) {
				bfs(mdp, distance, maze, h, w);
				for (ll ii = 0; ii < h; ii++) {
					for (ll jj = 0; jj < w; jj++) {
						if (distance[ii][jj] > maxDistance) {
							maxDistance = distance[ii][jj];
						}

					}
				}
				for (ll ii = 0; ii < h; ii++) {
					for (ll jj = 0; jj < w; jj++) {
						distance[ii][jj] = -1;
					}
				}
			}
		}
		//cout << endl;
	}
	
	cout << maxDistance << endl;



	
} 

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{		
		int N = GetInt();
		Console.WriteLine(N * (N + 1) / 2);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
import sys, operator
def solve():
    readline = sys.stdin.buffer.readline
    write = sys.stdout.write
    N, M, H, K = map(int, readline().split())
    if N == M == H == K == 0:
        return False
    K2 = (1 << K)
    G = [[] for i in range(N)]
    for i in range(M):
        a, b, c, h, r = map(int, readline().split()); a -= 1; b -= 1
        u = 1 << (r-1)
        G[a].append((b, c, h*N, u))
        G[b].append((a, c, h*N, u))
    s, t = map(int, readline().split()); s -= 1; t -= 1
    INF = 10**18
    r_dist = [0]*K2
    HN = H*N
    for state in range(K2):
        dist = [INF]*(N*H+N)
        dist[s] = 0
        for h0 in range(0, HN, N):
            h1 = HN - h0
            for v in range(N):
                cost = dist[h0 + v]
                if cost == INF:
                    continue
                for w, d, h, u in G[v]:
                    if h1 < h:
                        continue
                    k = h0 + h + w
                    if state & u:
                        if cost < dist[k]:
                            dist[k] = cost
                    else:
                        if cost + d < dist[k]:
                            dist[k] = cost + d
        r_dist[state] = min(dist[k] for k in range(t, HN+N, N))
    P = int(readline())
    vs = [INF]*K2
    for i in range(P):
        l, d, *ks = map(int, readline().split())
        state = 0
        for k in ks:
            state |= 1 << (k-1)
        vs[state] = d
    vs[0] = 0
    for s1 in range(K2):
        for s2 in range(s1+1, K2):
            vs[s1 | s2] = min(vs[s1 | s2], vs[s1] + vs[s2])
    ans = min(map(operator.add, r_dist, vs))
    if ans < INF:
        write("%d\n" % ans)
    else:
        write("-1\n")
    return True
while solve():
    ...


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

//これだと時間が足りなかった？
int main() {
    long long X; cin >> X;
    long long A=100;
    int n=0;
    while(A<X){
        A+=A/100;
        n++;
    }
    cout << n << endl;
}

Measured memory_bytes: 3556
from collections import deque


def main():
    N = int(input())
    A = list(map(int, input().split()))
    q = deque()
    for i in range(N):
        if (N-i) % 2 == 1:
            q.appendleft(A[i])
        else:
            q.append(A[i])
    print(" ".join(map(str, q)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 123732
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define ll long long int
#define sf(a) scanf("%d", &a)
#define forn(n) for(int i = 0; i < n; ++i)
#define form(m) for(int j = 0; j < m; ++j)
const int mx = 1e6+5;
const int inf = 0x3f3f3f3f;
 
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	char a,b;
	cin >> a >> b;
	string v [] = {"",""};
	forn(b-'0') v[0] += a;
	forn(a-'0') v[1] += b;
	sort(v,v+2);
	cout << v[0] << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

vector<int> tonari[200010];

int main() {
    int a,b,c;
    cin>>a>>b>>c;

    if(a==b&&c==4*a) {
        cout<<"No"<<endl;
        return 0;
    }

    int val=c-a-b;
    if(val<=0){
        cout<<"No"<<endl;
        return 0;
    }else{
        ll left=1ll*val*val,right=4ll*a*b;
        if(left>right){
            cout<<"Yes"<<endl;
        }else cout<<"No"<<endl;
        return 0;
    }

    if(sqrt(1.0*a)+sqrt(1.0*b)<sqrt(1.0*c)){
        cout<<"Yes"<<endl;
    } else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 4992
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  ll count=0;
  rep(i,n){
    if(a[a[i]]==i)count++;
  }
  cout<<count/2<<endl;
}
  

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

int a[101]={0};

int main()
{
	int n, x;
	cin >> n;
	
	for (int i=1; i<=n; i++)
	{
		cin >> x;
		a[x]=1;
	}
	
	int s=0;
	for (int i=1; i<=100; i++) s+=a[i];
	
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

N=int(input())

A=list(map(int, input().split()))
B=list(map(int, input().split()))

total = 0
for i in range(N):
    tmp = 0
    for j in range(i + 1):
        tmp += A[j]
    for j in range(i, N):
        tmp += B[j]
    total = max(total, tmp)

print(total)

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

int main()
{
    string s;
    cin>>s;
    long long int L=s.length();
    long long int i;
    long long int maxi=100002;
    long long int T=1;
    for(i=0;i<L; i++)
    {
        if(s[i]!=s[i+1]){
            maxi=min(maxi,max(T,L-T));
        }
        T++;
    }
    cout<<maxi<<endl;
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  vector<string>S(N);
  for(int i=0;i<N;i++)cin>>S[i];
  set<string>s;
  for(auto it:S)s.insert(it);
  cout<<s.size()<<endl;
  return 0;
}


Measured memory_bytes: 25072
#include<iostream>

using namespace std;

const int vecx[4] = { -1,0,1,0 };
const int vecy[4] = { 0,1,0,-1 };
int table[100][100];
bool islook[100][100];
int h, w;

void dfs(int _i, int _j) {
	islook[_i][_j] = true;
	for (int i = 0; i < 4; i++) {
		if (_i + vecx[i] < 0 || _i + vecx[i] >= h || _j + vecy[i] < 0 || _j + vecy[i] >= w) {
			continue;
		}
		if (table[_i + vecx[i]][_j + vecy[i]] == table[_i][_j] && !islook[_i + vecx[i]][_j + vecy[i]]) {
			dfs(_i + vecx[i], _j + vecy[i]);
		}
	}
}

int main(){
	while (cin >> h >> w, h*w) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				char buffer;
				cin >> buffer;
				if (buffer == '#')table[i][j] = 0;
				if (buffer == '*')table[i][j] = 1;
				if (buffer == '@')table[i][j] = 2;
			}
		}
		int ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (!islook[i][j]) {
					ans++;
					dfs(i, j);
				}
			}
		}
		cout << ans << endl;
		ans = 0;
		for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)table[i][j] = 0, islook[i][j] = false;
	}
	return 0;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(int argc, char const *argv[])
{
	int n;
	ll ans = 0;
	scanf("%d",&n);
	int a = n/3,b = n/5,c = n/15;
	ans = 1ll*(1+n)*n/2 - 1ll*3*(1+a)*a/2 - 1ll*5*(1+b)*b/2+ 1ll*15*(1+c)*c/2;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a == b ? c : (a == c ? b : a)) << endl;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin >>n;
    vi a(n);rep(i,n) cin >> a[i];
    vi cnt(n);rep(i,n) cnt[a[i]]++;
    if (n%2==0) {
        for(int i=1; i<n; i+=2) {
            if (cnt[i]!=2) {
                ct(0);
                return 0;
            }
        }
    } else {
        if ((cnt[0]!=1)) {
            ct(0);
            return 0;
        }
        for(int i=2; i<n; i+=2) {
            if (cnt[i]!=2) {
                ct(0);
                return 0;
            }
        }
    }
    ll ans = modPow(2,n/2);
    ct(ans);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
int n, a[maxn];
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i =0 ;i < n*2;++i)
		cin >> a[i];
	sort(a, a+n*2);
	int res = 0;
	for(int i = 0;i < n*2;i += 2)
		res += a[i];
	cout << res << '\n';
}



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

int main(){
  int n,counter=0;//counter:奇数カウント
  int a[100010];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==1)counter++;
  }
  if(counter%2==0)cout << "YES" <<endl;
  else cout << "NO" <<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  char str[55];
  char key[55]={'z'};
  char t[55];
  char cmp[55];
  char temp[55];
  cin >> str >> t;
  int t_len=strlen(t);
  int s_len=strlen(str);
  strcpy(cmp,str);
  for(int i=0;i<s_len;i++){
    if(cmp[i]=='?')
      cmp[i]='a';
  }
  strcpy(temp,cmp);
  int sp[50];
  int cnt,c=0;
  for(int i=0;i<s_len;i++){
    if(str[i]==t[0]||str[i]=='?'){
      cnt=0;
      for(int j=0;j<t_len;j++){
        if(str[i+j]==t[j]||str[i+j]=='?'){
          cnt++;
          if(cnt==t_len){
            sp[c]=i;
            c++;
          }
        }
        else
          break;
      }
    }
  }
  if(c==0){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  for(int i=0;i<c;i++){
    strcpy(cmp,temp);
    for(int j=0;j<t_len;j++){
      cmp[sp[i]+j]=t[j];
    }
    if(strcmp(key,cmp)>0)
      strcpy(key,cmp);
  }
  cout << key << endl;
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
using namespace std;
#define mp make_pair
#define sc second
#define fs first
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ABS(a) (((a)>0)?(a):(-(a)))
typedef long long LL;
typedef pair < int , int > pii;
const LL MOD=1000000007;
int n,m,k,d,t,a[105],p;
LL C[105][105];
void precal(){
	int xb,x2;
	for(xb=0;xb<100;xb++) C[xb][0]=1;
	for(xb=1;xb<100;xb++){
		for(x2=1;x2<100;x2++){
			C[xb][x2]=C[xb-1][x2]+C[xb-1][x2-1];
		}
	}
}
int main(){
	scanf("%d%d",&n,&p);
	int xb,x2;
	for(xb=0;xb<n;xb++) {
		scanf("%d",&a[xb]);
		if(a[xb]&1) d++;
	}
	precal();
	LL res=0,mul=1;
	for(xb=d;xb<n;xb++) mul*=2;
	if(!p){
		for(xb=0;xb<=d;xb+=2){
			res+=C[d][xb];
		}
	}
	else{
		for(xb=1;xb<=d;xb+=2){
			res+=C[d][xb];
		}
	}
	cout<<res*mul;
	return 0;
}

Measured memory_bytes: 384
N,M=map(int,input().split())
edges=[list(map(int,input().split())) for i in range(M)]
ans=0
for x in edges:
    l=list(range(N))
    for y in edges:
        if y!=x:
          l=[l[y[0]-1]if l[i]==l[y[1]-1] else l[i] for i in range(N)]
    if len(set(l))!=1:
      ans+=1
print(ans)


Measured memory_bytes: 3188