akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)

struct UnionFind {
    vector<int> data;
    UnionFind(int N) : data(N, -1) {}
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y){
            data[x] += data[y];
            data[y] = x;
        }
    }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]);}
    bool same(int a, int b) { return root(a) == root(b);}
};

int can_unite[2][100000];
int slime[40000][2];
int main() {
    int N, W, H;
    scanf("%d%d%d", &N, &W, &H);
    int x_, y_;
    bool edge = false;
    rep(i, N){
        scanf("%d%d", &x_, &y_); --x_; --y_;
        slime[i][0] = x_; slime[i][1] = y_;
        if(x_ == 0 || x_ == W - 1 || y_ == 0 || y_ == H - 1)
          edge = true;
    }
    
    memset(can_unite, -1, sizeof(can_unite));
    UnionFind uf(N);
    int ans = 0;
    rep(i, N) rep(j, 2) {
        int& a = can_unite[j][slime[i][j]];
        if(a == -1) a = i;
        else if(!uf.same(a, i)) {
            uf.unite(a, i);
            ans++;
        }
    }
    
    bitset<40000> roots(0);
    rep(i, N) roots[uf.root(i)] = 1;
    int temp = roots.count();
    if(temp == 1) cout << ans << endl;
    else {
        ans += temp * 2 - 1;
        if(edge) --ans;
        cout << ans << endl;
    }
    return 0;
}

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

int main(void){

  char s[100];
  int alpha[26]={0};
  cin>>s;
  for(int i=0;i<strlen(s);i++){
    alpha[(int)s[i]-(int)'a']++;
  }
  int u=0;
  for(int i=0;i<26;i++){
    if(alpha[i]%2==1)
      u=1;
  }
  if(u==1)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

vector<ll> frac(ll n){
	vector<ll> res; res.clear();
	for (ll i = 1LL; i * i <= n; ++i){
		if (n % i == 0LL){
			res.push_back(i);
			if (i * i < n){
				res.push_back(n/i);
			} // end if
		} // end if
	} // end for
	
	sort(ALL(res));
	
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll N, M; cin >> N >> M;

	vector<ll> f = frac(M);

	int ind1 = lower_bound(ALL(f), M/N) - f.begin();
	int ind2 = upper_bound(ALL(f), M/N) - f.begin();

	ll res = 0LL;
	if (ind1 == ind2){ // M / N より大きい
		res = f[ind1-1];
	}else{ // M / N に等しい
		res = f[ind1];
	} // end if

	cout << res << endl;

	return 0;
}

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

using namespace std;

int abs(int a){
    if (a < 0) {
        a = - a;
    }
    return a;
}


int N, A, B, C;
vector<int> l(8);
int dfs(int num, int a, int b, int c){
    if(num == N){
        if(a == 0 || b == 0 || c== 0){
            return 100000000;
        }else{
            int ans = abs(a - A) + abs(b - B) + abs(c - C) - 30;
            return ans;
        }
    }else{
        int dfs0 = dfs(num + 1, a, b, c);
        int dfs1 = dfs(num + 1, a + l[num], b, c) + 10;
        int dfs2 = dfs(num + 1, a, b + l[num], c) + 10;
        int dfs3 = dfs(num + 1, a, b, c + l[num]) + 10;
        int ans = min(dfs0, min(dfs1, min(dfs2, dfs3)));
        return ans;
    } 
}


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

    for(int i = 0; i < N; i++){
        cin >> l[i];
    }


    cout << dfs(0, 0, 0, 0) << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n,a,b;
           cin>>n>>a>>b;
           cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
}

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

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

    int n = s.size();
    rep (i, n)
        cout << "x";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static double[][] aa;
    static double maxx(int h,int t,int n,double p[]){
        if(h+t==n &&  h>t  ){
            return (double)1;
        }
        if(h+t==n && t>h){
            return (double)0;
        }
        if(aa[h][t]!=-1){
            return aa[h][t];
        }
        return aa[h][t]= (double)((double)p[h+t]*(double)maxx(h+1,t,n,p)+(double)((double)1-(double)p[h+t])*(double)maxx(h,t+1,n,p)) ;
    }

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        double[] p=new double[n];
        for(int j=0;j<n;j++){
            p[j]= scanner.nextDouble();
        }
        aa=new double[n][n];
        for(int j=0;j<n;j++){
            for(int i=0;i<n;i++){
                aa[j][i]=-1;
            }
        }
        System.out.println(maxx(0,0,n,p));
    }


}


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


void solve(long long A, long long B){
    if (A < 10 && B < 10) {
        cout << A*B << endl;
    } else {
        cout << -1 << endl;
    }
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

aa=(10-a%10)%10
bb=(10-b%10)%10
cc=(10-c%10)%10
dd=(10-d%10)%10
ee=(10-e%10)%10
m=max(aa,bb,cc,dd,ee)

import math
T=10*math.ceil(a/10)+10*math.ceil(b/10)+10*math.ceil(c/10)+10*math.ceil(d/10)+10*math.ceil(e/10)-m
print(T)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>

using namespace std;

const int MAX_N = 1e5 + 5;

pair<int, int> edge (int u, int v) {
  return make_pair(min(u, v), max(u, v));
}

int root [MAX_N];
vector<int> adj_blue [MAX_N];
vector<int> adj_red [MAX_N];
set<pair<int, int>> edges_blue;
set<pair<int, int>> edges_red;

vector<pair<int, int>> todo;

int find (int u) {
  if (root[u] != u) {
    root[u] = find(root[u]);
  }
  return root[u];
}

int cc;
void merge (int u, int v) {
  u = find(u);
  v = find(v);

  if (u == v) return;
  int szu = adj_blue[u].size() + adj_red[u].size();
  int szv = adj_blue[v].size() + adj_red[v].size();
  if (szu < szv) swap(u, v);

  edges_blue.erase(edge(u, v));
  edges_red.erase(edge(u, v));
  root[v] = u;
  cc--;
  for (int w : adj_blue[v]) {
    if (find(w) != u) {
      edges_blue.erase(edge(v, find(w)));
      adj_blue[u].push_back(find(w));
      edges_blue.insert(edge(u, find(w)));
      if (edges_red.count(edge(u, find(w)))) {
        todo.push_back(make_pair(u, find(w)));
      }
    }
  }

  for (int w : adj_red[v]) {
    if (find(w) != u) {
      edges_red.erase(edge(v, find(w)));
      adj_red[u].push_back(find(w));
      edges_red.insert(edge(u, find(w)));
      if (edges_blue.count(edge(u, find(w)))) {
        todo.push_back(make_pair(u, find(w)));
      }
    }
  }
}

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

  int n;
  cin >> n;

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj_blue[u].push_back(v);
    adj_blue[v].push_back(u);
    edges_blue.insert(edge(u, v));
  }

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj_red[u].push_back(v);
    adj_red[v].push_back(u);
    edges_red.insert(edge(u, v));
    if (edges_blue.count(edge(u, v))) {
      todo.push_back(make_pair(u, v));
    }
  }

  cc = n;
  for (int i = 1; i <= n; i++) {
    root[i] = i;
  }

  while (!todo.empty()) {
    auto pr = todo.back();
    todo.pop_back();
    merge(pr.first, pr.second);    
  }

  if (cc == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 25300
#include <stdio.h>
int main(){
    int x, y, i, j;
    while(1){
        scanf("%d%d", &x, &y);
        if(x==0 && y==0)
            break;
        for(i=0; i<x; i++){
            for(j=0; j<y; j++){
                putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 1756
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

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

    int n, m;
    cin >> n >> m;
    vector vec(n, vector<bool>());
    rep(i, m)
    {
        int p;
        cin >> p;
        --p;
        string s;
        cin >> s;
        vec[p].push_back(s == "AC");
    }
    int seito = 0, pena = 0;
    for (auto &u : vec)
    {
        int q = 0;
        for (auto b : u)
        {
            if (b)
            {
                ++seito;
                pena += q;
                break;
            }
            else
            {
                ++q;
            }
        }
    }
    cout << seito << ' ' << pena << '\n';

    return 0;
}


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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PII pair <int, int>

const int N = 1e5 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 7LL;

int main(){
	int n;
	cin >> n;
	
	int sum = 0;
	for(int i = 0; i < n; ++i){
		int a;
		cin >> a;
		sum += a - 1;
	}
	
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue<int, vector<int>, greater<int> > q;
#include <map>
#include <set> //multiset set<int,greater<int>>大到小
#include <vector>// vector<int>().swap(v);清空释放内存
#include <stack>
#include <cmath> // auto &Name : STLName  Name.
#include <utility>
#include <sstream>
#include <string>//__builtin_popcount(ans);//获取某个数二进制位1的个数
#define mod 1000000007
#define mod9 998244353
#define ld long double
#define ull unsigned long long
#define db double
#define ll long long
const db eps=1e-7;
//const db pi=acos(-1);
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
#define rep(i,be,en) for (ll i=be;i<=en;i++)
#define per(i,be,en) for (int i=en;i>=be;i--)
using namespace std;
const int N=1e5+7;

ll t,n,m,k,fl=0,ans=0;
ll a[150];
int main() {
    rep(i,0,140) a[i]=i*i*i*i*i;
    scanf("%lld",&n);
    rep(i,0,140){
        rep(j,0,140){
            if(a[i]-a[j]==n){
                printf("%lld %lld\n",i,j);
                return 0;
            }else if(a[i]+a[j]==n){
                printf("%lld %lld\n",i,-j);
                return 0;
            }else if(a[j]-a[i]==n){
                printf("%lld %lld\n",-i,-j);
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3248
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
count = 0
for i in range(0, n):
    if count == 0:
        count = count + 1
        ans = ans + b[a[i]-1]
    elif a[i] == a[i-1] + 1:
        ans = ans + b[a[i]-1] + c[a[i]-2]
    else:
        ans = ans + b[a[i]-1]
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int n,m; cin>>n>>m;
    multiset <int, greater <int> > Q;
    int a;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        Q.insert(a);
    }
    int num;
    while(m--)
    {
        auto it = Q.begin();
        num = *it;
        num /= 2;
        Q.erase(it);
        Q.insert(num);
    }
    int ans = 0;
    for(auto it : Q)
    {
        ans += it;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long 
#define mod 1000000007

int main()
{
	ll n;
	cin>>n;
	ll a[n+10];
	ll sum=0;
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	ll i=1;
	ll mi=INT_MAX;
	ll s1=0,s2=0;
	while(i<n)
	{
		 s1+=a[i];
		 s2=sum-s1;
		mi=min(mi,abs(s1-s2));
		//cout<<s1<<" "<<s2<<endl;
		i++;
	}
	cout<<mi<<endl;
	
}

Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <algorithm>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int d[] = { 0, 1, 0, -1, 0 };
bool visited[20][20];
int w, h;
char c[20][20];

bool isin(int y, int x) {
  return 0 <= y && y < h && 0 <= x && x < w;
}

void wfs(int sy, int sx, int* dist) {
  queue<int> qy, qx, qd;

  REP(i, 0, h) REP(j, 0, w) visited[i][j] = false;
  visited[sy][sx] = true;
  qy.push(sy), qx.push(sx), qd.push(0);

  while(!qd.empty()) {
    int cy = qy.front(), cx = qx.front(), cd = qd.front();
    qy.pop(), qx.pop(), qd.pop();
    if(c[cy][cx] == 'o') dist[0] = cd;
    if(1 <= c[cy][cx] && c[cy][cx] <= 10) dist[c[cy][cx]] = cd;

    REP(i, 0, 4) {
      int ny = cy + d[i], nx = cx + d[i + 1], nd = cd + 1;
      if(isin(ny, nx) && !visited[ny][nx] && c[cy][cx] != 'x') {
        visited[ny][nx] = true;
        qy.push(ny), qx.push(nx), qd.push(nd);
      }
    }
  }
}

int main(void) {
  while(cin >> w >> h, w != 0 && h != 0) {
    int di = 1, sy, sx, dy[11], dx[11];
    REP(i, 0, h) {
      cin >> c[i];
      REP(j, 0, w) {
        if(c[i][j] == '*') {
          c[i][j] = di;
          dy[di] = i;
          dx[di] = j;
          di++;
        }
        if(c[i][j] == 'o') sy = i, sx = j;
      }
    }

    int dist[11][11];
    REP(i, 0, 11) REP(j, 0, 11) dist[i][j] = -1;

    wfs(sy, sx, dist[0]);
    bool possible = true;
    REP(i, 1, di) if(dist[0][i] == -1) possible = false;

    if(possible) {
      REP(i, 1, di) wfs(dy[i], dx[i], dist[i]);

      int ans = 100000;
      int order[11] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
      do {
        int move = dist[0][order[1]];
        REP(i, 1, di - 1) move += dist[order[i]][order[i + 1]];
        if(move > 0) ans = min(ans, move);
      } while (next_permutation(order + 1, order + di));
      cout << ans << endl;
    } else {
      cout << -1 << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

int main()
{
  int N, Wt;
  cin >> N >> Wt;
  int v[110], w[110];

  rep(i, N)
  {
    cin >> v[i] >> w[i];
  }

  // dp[i][w]: i番目までの品物の中で大きさがwを超えないように選んだ時の価値の最大値
  int dp[110][10001] = {};

  rep(i, N)
  {
    rep(j, Wt + 1)
    {
      if (j >= w[i])
      {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      }
      else
      {
        dp[i + 1][j] = dp[i][j];
      }
    }
  }

  cout << dp[N][Wt] << endl;
  return 0;
}


Measured memory_bytes: 7388
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a*b*c==175){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
  

  
}


Measured memory_bytes: 21204
#include<iostream>
using namespace std;
int main(){
	int n,a,a2,b,b2,c,c2;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a >> b >> c;
		a2=a*a; b2=b*b; c2=c*c;
		if(a2+b2==c2||a2+c2==b2||b2+c2==a2)cout << "YES" <<endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
def f_coincidence(MOD=10 ** 9 + 7):
    # 参考: https://atcoder.jp/contests/abc138/submissions/7013926
    from itertools import product
    L, R = [int(i) for i in input().split()]

    dp = [[[[0 for s in range(2)] for k in range(2)]
           for j in range(2)] for i in range(61)]
    dp[60][0][0][0] = 1

    for i in range(59, -1, -1):
        lb = (L >> i) & 1  # 'b' はビット値であることを示す(以下も同じ)
        rb = (R >> i) & 1

        r2 = range(2)
        for j, k, s in product(r2, r2, r2):
            pre = dp[i + 1][j][k][s]
            # ビットごとに値を試す
            for xb, yb in product(r2, r2):
                # editorial の通り、このビットの組は元の条件を満たさない
                if xb == 1 and yb == 0:
                    continue
                # editorial の通り、これ以降は x <= y が満たされる

                nj, nk, ns = j, k, s
                # 今注目している桁でMSBが立つか？
                if s == 0 and xb != yb:
                    continue  # どちらかが立っていない
                if s == 0 and xb == 1 and yb == 1:
                    ns = 1  # ここで初めてMSBが立った

                # L <= x を満たすか？
                if j == 0 and xb == 0 and lb == 1:
                    # jが0のまま xb<lb となれば、L<=xになりようがない
                    # jが1なら、xbとlbがどうなっていようがL<=xである
                    continue
                if j == 0 and xb == 1 and lb == 0:
                    nj = 1  # この桁で L<=x が確定する

                # y <= R を満たすか？
                if k == 0 and yb == 1 and rb == 0:
                    continue  # L<=x の場合分けと同じこと
                if k == 0 and yb == 0 and rb == 1:
                    nk = 1

                # 反映
                dp[i][nj][nk][ns] += pre
                dp[i][nj][nk][ns] %= MOD

    ans = sum([dp[0][j][k][s] for j in range(2) for k in range(2)
               for s in range(2)]) % MOD
    return ans

print(f_coincidence())

Measured memory_bytes: 3188
#include <map>
#include <set>
#include <list>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
const long long MOD=1000000007;
int main ( ) {
	int n,i;
	long long ans=6;
	string a,b;
	scanf("%d",&n);
	cin>>a>>b;
	if (n==1) {puts("3");return 0;}
	if (n==2) {puts("6");return 0;}
	for (i=3;i<=n;i++) {
		if (a[i-1]==b[i-1]) {
			if (a[i-2]==b[i-2]) ans*=2,ans%=MOD;
		}
		else {
			if (a[i-2]!=a[i-1]) {
				if (a[i-2]==b[i-2]) ans*=2,ans%=MOD;
				else ans*=3,ans%=MOD;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}
/*
Sample Input 1
3
aab
ccb
Sample Output 1
6

Sample Input 2
1
Z
Z
Sample Output 2
3

Sample Input 3
52
RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn
RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn
Sample Output 3
958681902
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
#define int long long
signed main()
{
  int N;
  int data[105];
  int point;
  cin >> N;--N;
  Rep(i,N)cin >> data[i];
  cin >> point;
  int dp[105][25] = {0};
  dp[0][data[0]] = 1;
  for(int i = 1; i < N; i++) {
    Rep(j,21) {
      if(j + data[i] <= 20) {
	dp[i][j] += dp[i - 1][j + data[i]];
      }
      if(j - data[i] >= 0) {
	dp[i][j] += dp[i - 1][j - data[i]];
      }
    }
  }
  cout << dp[N - 1][point] << endl;
  return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll N,M;
ll K[11];
ll Q[11];
ll S[11][11];
ll n;
ll ans;
bool found;
 
 
int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        cin >> K[i];
        for (int j=0;j<K[i];j++){
            cin >> S[i][j];
        }
    }
    for(int i=0;i<M;i++){
        cin >> Q[i];
    }
    for (int bit = 0; bit < (1<<N); bit++) {
        found = true;
        for(int j = 0;j<M;j++){
            n = 0;
            for(int k = 0;k<K[j];k++){
                if(bit & 1<<(S[j][k]-1)){
                    n++;
                }
            }
            if(n%2!=Q[j]){
                found = false;
            }
        }
        if(found) {
            ans++;
        }
        
    }
    cout << ans << endl;
    
}
 
 


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

int main() {
    long long N;
    cin >> N;
    string A = "FizzBuzz";
    string B = "Fizz";
    string C = "Buzz";
    long long sum = 0;
    for (long long i = 1; i <= N; ++i) {
        string tmp = "Nothing";
        if ((i % 5) == 0 && (i % 3) == 0) {
            tmp = A;
        }
        else if ((i % 3) == 0) {
            tmp = B;
        } 
        else if ((i % 5) == 0) {
            tmp = C;
        } 
        else {
            sum += i; 
        }//~ cout << tmp << endl;
    } 
    cout << sum << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    for(int s = 1;s<=n;s++)
    {
        int count = 0;
    for(int i = 1;i<=sqrt(s);i++)
    {
        for(int j = 1;j<sqrt(s);j++)
        {
            for(int k = 1;k<sqrt(s);k++)
            {
                if((i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i)==s)
                {
                    count++;
                }
                else if((i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i)>s)
                {
                    break;
                }
            }
        }
    }
    cout<<count<<endl;
    }
    return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n),b(n);
    int ma=0;
    rep(i,n){
        cin >> a[i];
        ma=max(ma,a[i]);
    }
    b=a;
    sort(all(b));
    rep(i,n){
        if(a[i]==ma) cout << b[n-2] << endl;
        else cout << ma << endl;
    }
return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999


int n;


bool solve(ll mid,vector<ll> rsum){
    rep(i,n+1){
        ll start = rsum[i];
        
        int a=lower_bound(all(rsum),start  +mid)-rsum.begin();
        if(a>=i+n+1)continue;
        
        int b=lower_bound(all(rsum),rsum[a]+mid)-rsum.begin();
        if(b>=i+n+1)continue;
        
        int c=lower_bound(all(rsum),rsum[b]+mid)-rsum.begin();
        if(c>=i+n+1)continue;
        
        return true;
    }
    return false;

}


int main(){
    ll sum=0;
    cin>>n;
    vector<ll> vec(n);
    rep(i,n){
        cin>>vec[i];
        sum += vec[i];
    }

    vector<ll> rsum(2*n+1,0);
    rep(i,2*n)rsum[i+1] = rsum[i]+vec[i%n];

    
    ll left = 0;
    ll right = sum;
    ll mid;
    while(1){
        mid = (left+right)/2LL;
        if(left+1>=right)break;

        bool res = solve(mid,rsum);
//        cout<<left<<" "<<right<<" "<<" "<<mid<<" "<<res<<endl;
        
        if(res){
            left = mid;
        }else{
            right = mid;
        }
    }
    cout<<mid<<endl;
}

Measured memory_bytes: 6836
N = int(input())
# N, K = [int(i) for i in input().split()]
countA = 0
countB = 0
countAB = 0
countBA = 0
for i in range(N):
    s = input()
    countAB += s.count('AB')
    if s[0] == 'B':
        countB += 1
    if s[-1] == 'A':
        countA += 1
    if s[0] == 'B' and s[-1] == 'A':
        countBA += 1
if countA != 0 and countA == countBA and countB == countBA:
    print(countAB + countBA - 1)
else:
    print(countAB + min(countA, countB))


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

int main()
{
	string S;

	cin >> S;

	bool odd=true;
	bool even=true;
	for(int i=0;i<(int)S.size();i++)
	{
		if(i%2==0 && S[i]=='L')odd=false;
		if(i%2==1 && S[i]=='R')even=false;
	}

	if(odd && even)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
	
	return 0;
}



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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)

const LL mod=(1e9)+7;
int main()
{
   LL n,k;
   int cnt=0;
   cin>>n>>k;
   while(n)
   {
       n=n/k;
       cnt++;
   }
   cout<<cnt;
}


Measured memory_bytes: 3600
using System;

class Atcoder45
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        if (a == 1)
            a += 13;
        if (b == 1)
            b += 13;

        if (a > b)
            Console.WriteLine("Alice");
        else if (a < b)
            Console.WriteLine("Bob");
        else
            Console.WriteLine("Draw");
    }
}

Measured memory_bytes: 11092
using System;
using System.Collections.Generic;

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            
            List<string> input = new List<string>();
            List<double> iList=new List<double>();
            int count=0;
            input.AddRange(Console.ReadLine().Split(' '));
            double answer =0;

            foreach(var s in input)
            {
                iList.Add(double.Parse(s));
            }
            iList.Sort();

            count=iList.Count;
            
            for(int i=0;i<count-1 ; i++)
            {
                answer = (iList[0]+iList[1])/2;
                iList.RemoveAt(0);
                iList.RemoveAt(0);
                iList.Insert(0,answer);
            }

            foreach(var i in iList)
            {
                Console.WriteLine(i);
            }
        }
}


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

using namespace std;

int main(){
    int n,t,c,T;
    int res = 1001;
    cin>>n>>T;

    while(n){
        cin>>c>>t;
        if(t<=T){
            if(c<res){
                res = c;
            } 
        }
        n--;
    }

    if(res == 1001){
        cout<<"TLE";
    }else{
        cout<<res;
    }

    return 0;
}

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


int main() {
    string s;
    cin>>s;
    int k;
    cin>>k;
    set<string> n;
    if(s.length()<=10){
        //set<string> n;
        for (int i = 0; i < s.length(); ++i) {
            for (int j = 1; j <= s.length()-i+1; ++j) {
                n.insert(s.substr(static_cast<unsigned long>(i), static_cast<unsigned long>(j)));
            }
        }
    }
    else {
        //set<string> n;
        for (int i = 1; i <= k; ++i) {
            for (int j = 0; j < s.length() - i + 1; ++j) {
                n.insert(s.substr(j,i));
            }
        }
    }
    auto itr = n.begin();
    for (int l = 1; l < k; ++l) {
        //cout<<*itr<<endl;
        itr++;
    }
    cout<<*itr<<endl;
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

string s;

int main() {
    cin >> s;
    ll b_count = 0;
    ll ans = 0;
    for(auto c : s) {
        if(c == 'B')
            b_count++;
        else
            ans += b_count;
    }

    cout << ans << endl;
}

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

int main()
{
	std::string s;
	cin >> s;
	int num = 0;
	auto iter1 = s.find_first_of('A');
	auto iter2 = s.find_last_of('Z');

	cout << iter2 - iter1 + 1 << endl;
	return 0;
}

Measured memory_bytes: 832
function main(input){
  var args = input.split('\n');
  var N = args[0];
  var nums = args.slice(1, args.length - 1);
  //filterによるindex番号と元の配列のindex番号が一致している場合のみを返す
  //そうすることで、重複している値を削除することができる
  var count = nums.filter(function(n,i,j){
    return j.indexOf(n) === i;
  }).length;
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
n, q = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(n - 1):
  a, b = map(int, input().split())
  g[a - 1].append(b - 1)
  g[b - 1].append(a - 1)
li = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  li[p - 1] += x
s = [0]
done = [0] * n
done[0] = 1
while s:
  d = s.pop()
  for node in g[d]:
    if done[node] == 0:
      li[node] += li[d]
      s.append(node)
      done[node] = 1
print(' '.join(map(str, li)))

Measured memory_bytes: 130728
#include <cstdio>

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if (a + b > c + d) 
		printf("Left");
	else if (a + b < c + d) 
		printf("Right");
	else
		printf("Balanced");
	putchar('\n');
	return  0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        int[] a2 = a.clone();
        Arrays.sort(a2);
        for(int v : a){
            if(a2[n-1] == v){
                System.out.println(a2[n-2]);
            }else{
                System.out.println(a2[n-1]);
            }
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 52036
#include <bits/stdc++.h>
#define Sekai_No_Owari return 0

using namespace std;
typedef long long ll;
void chmax(int & a, int b) { if (a < b) a = b; }

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

	int res = 0, tmp = 0, pre = 0, h;
	for (int i = 0; i < n; i++) {
		scanf("%d", &h);
		if (pre >= h) tmp++;
		else tmp = 0;

		res = max(res, tmp);
		pre = h;
	}
	cout << res << endl;

	Sekai_No_Owari;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll inf=mod*10;
    ll n,num;
    set<ll> s;
    queue<ll> q;
    cin>>n;
    for(ll i=1;i<10;i++){
    	s.insert(i);
    	q.push(i);
    }
    while(!q.empty()){
    	ll m=q.front();
    	if(m%10!=0LL){
    		num=m*10+m%10-1;
    		s.insert(num);
    		if(num<inf)q.push(num);
    	}
    	num=m*10+m%10;
    	s.insert(num);
    	if(num<inf)q.push(num);
    	if(m%10!=9LL){
    		num=m*10+m%10+1;
    		s.insert(num);
    		if(num<inf)q.push(num);
    	}
    	q.pop();
    }
    auto itr=s.begin();
    while(--n)itr++;
    cout<<*itr<<endl;

    return 0;
}


Measured memory_bytes: 27520
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
    int n = sc.nextInt();

    int ans = 0;
    for(int i = 0; i < 4; i++){
      if(n % 10 == 2){
        ans++;
      }
      n /= 10;
    }
 
    System.out.println(ans);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 20692
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define DEBUG if(false)

using ll = long long;
#define LINE printf("LINE : %d\n", __LINE__);
#define loop(i, n) for(i = 0; i < n; i++)
template<class T> using vec = vector<T>;
const int MOD = 998244353;



int main(){
  string S;
  cin >> S;
  cout << S[0] << S[1] << S[2] << endl;
  return 0;
}


Measured memory_bytes: 3628
n=int(input());s=[*input()];count=0
count=s.count('R')*s.count('G')*s.count('B')
for i in range(n+1):
  for j in range(i,n+1):
    k=2*j-i
    if k<n:
      if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
        count-=1
print(count)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;
int si[8] = {-1,0,1,-1,1,-1,0,1};
int sj[8] = {-1,-1,-1,0,0,1,1,1};

struct UnionFind {
  vector<int> d;
  // 子は親のIDを，根は木のサイズ*-1を持つ
  UnionFind(int n = 0): d(n,-1){}
  // rootを探索する
  int find(int x){
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  // 集合を統合する
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  // 同じ集合に属しているか判定
  bool same(int x, int y) {return find(x) == find(y);}
  // xの属している集合のサイズを返す
  int size(int x) {return -d[find(x)];}
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf_friend(n);
  vector<vector<int>> blk(n);
  vector<int> friends(n,0);

  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf_friend.unite(a,b);
    friends[a]++;
    friends[b]++;
  }

  rep(i,k){
    int c, d;
    cin >> c >> d;
    c--; d--;
    blk[c].push_back(d);
    blk[d].push_back(c);
  }

  rep(i,n){
    int ans = uf_friend.size(i) - friends[i] - 1;
    rep(j, blk[i].size()){
      if (uf_friend.same(i,blk[i][j])) ans--;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 8876
#include <stdio.h>

int max(int a, int b){
  int M = a;
  if(b > M)
    M = b;
  return M;
}

int main(void){
  int N;
  int T = 0;
  int i, j;
  scanf("%d", &N);
  
  int W[N];
  for(i=0; i<N; i++)
    scanf("%d", &W[i]);

  int minimum = 100, sub;
  for(i=0; i<N; i++){
    T = i;
    int S1 = 0, S2 = 0;
    for(j=0; j<T; j++)
      S1 += W[j];
    for(j=T; j<N; j++)
      S2 += W[j];
    sub = max(S1-S2, S2-S1);
    if(sub < minimum)
      minimum = sub;
  }
  
  printf("%d\n", minimum);

  return 0;
}


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

dp =[0]*N

dp[1] = abs(H[1] - H[0])

for i in range(2, N):
    dp[i] = min(dp[i-2]+abs(H[i-2] - H[i]), dp[i-1]+abs(H[i-1] - H[i]))

print(dp[-1])

Measured memory_bytes: 13980
import numpy as np
h,w=map(int,input().split())
"""
入力はスペースなしだった
文字列としてリストの行にぶち込む必要あり
icon=list()
for i in range(h):
    icon.append(list(input().split()))

"""
icon=[''] * h
for i in range(h):
    icon[i]=input()


row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if icon[i][j]=='#':
            row[i]=True
            col[j]=True

for  i in range(h):
    if row[i]==True:
        for j in range(w):
            if col[j]==True:
                print(icon[i][j],end='')
        print()  

Measured memory_bytes: 13788
h,w = map(int,input().split())
li = []
for i in range(h):
    a = list(input())
    li.append(a)
li2 = li.copy()
c = 0
for i in range(h):
    for j in range(w):
        c = 0
        if li[i][j] == ".":
            continue
        elif li[i][j] == "#":
            c = 1
            break
    if c == 0:
        li[i] = ["a"] * w
d = 0
n = []
for i in range(w):
    for j in range(h):
        d = 0
        if li[j][i] == "." or li[j][i] == "a":
            continue
        else:
            d = 1
            break
    if d == 0:
        n.append(i)
for i in n:
    for j in range(h):
        li[j][i] = "a"

for i in range(h):
    grid = ""
    for x in li[i]:
        if x != "a":
            grid += x
    if grid != "":
        print(grid)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

int a[100001];

int mpow(int b, int e)
{
    int ret=1;
    for(int i=0; i<e; i++)
    {
        ret=ret*b%mod;
    }
    return ret;
}

ll x[100001];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, ans=0, in;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> in;
        if(x[in])
        {
            ans++;
        }
        else x[in]=1;
    }
    if(ans&1) cout << n-ans-1;
    else cout << n-ans;
}

Measured memory_bytes: 1024
var input = require("fs").readFileSync("/dev/stdin", "utf8");

var lines=input.split("\n");
var n=lines[0]|0;
var a=lines[1].split(" ");
var map=Object.create(null);
map[0]=0;
var sum=0;
var res=0;
for(var i=0;i<n;++i){
    sum+=a[i]|0;
    if(sum in map){
        res+=++map[sum];
    }else{
        map[sum]=0;
    }
}
console.log(res);


Measured memory_bytes: 84684
#include <cstdio>
using namespace std;

typedef struct {
	int N;
	char C[6];
} INPUT;

INPUT input[10] = {
	{0, ""},
	{5, ".,!? "},
	{3, "abc"},
	{3, "def"},
	{3, "ghi"},
	{3, "jkl"},
	{3, "mno"},
	{4, "pqrs"},
	{3, "tuv"},
	{4, "wxyz"}
};

int main()
{
	int N;
	
	scanf("%d", &N);
	for (int i = 0; i < N; i++){
		char str[2048];
		scanf("%s", str);
		
		int j = 0;
		char now = 0;
		int num = 0;
		while (str[j] != '\0'){
			if (str[j] == '0'){
				if (now != 0){
					printf("%c", input[now - '0'].C[num % input[now - '0'].N ] );
				}
				now = 0;
				num = 0;
			}
			else {
				if (now == 0){
					now = str[j];
				}
				else {
					num++;
				}
			}
			j++;
		}
		
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <queue <ll>> v(n, queue <ll> ());
  rep(i, m) {
    ll a, b, c;
    cin >> a >> b;
    if (a == 0) {
      cin >> c;
      v.at(b).push(c);
    } else if (a == 1) {
      if (!v.at(b).empty()) {
        cout << v.at(b).front() << endl;
      } 
    } else {
      if (!v.at(b).empty()) {
        v.at(b).pop();
      }
    }
  }
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  double ans=0;
  vector<double> X(N);
  vector<string> U(N);
  for(int i=0;i<N;i++){
    cin >> X[i] >> U[i];
  if(U[i] == "JPY"){
    ans += X[i];
  }
    else{
      ans+=380000.0*X[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, m, r, q;
	while (cin >> n >> m,n|m) {
		cin >> r;
		vector<int> stu(m, 0);
		vector<vector<pii>> stutime(m);
		REP(i, r) {
			int a, b, c, d;
			cin >> a >> b >> c >> d;
			c--;
			if (d) {
				if (stu[c] == 0)
					stutime[c].push_back(pii(a,0));
				stu[c]++;
			}
			else {
				stu[c]--;
				if (stu[c] == 0)
					stutime[c][stutime[c].size() - 1].second = a;
			}
		}
		cin >> q;
		REP(i, q) {
			int a, b, c;
			cin >> a >> b >> c;
			c--;
			int ans = 0;
			REP(j, stutime[c].size()) {
				if (stutime[c][j].first <= b && a <= stutime[c][j].second) {
					ans += min(b, stutime[c][j].second) - max(a, stutime[c][j].first);
				}
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 3356
import java.util.*;

class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if((a*b)%2==0)
			System.out.println("Even");
		else
			System.out.println("Odd");

		


	}
}

Measured memory_bytes: 21844