akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long


class AProduct {
public:
	void solve(std::istream& in, std::ostream& out) {
    int a,b;
    in >> a >> b;
    int t = a * b;
    if(t % 2 == 0){
      out << "Even" << endl;
    }
    else{
      out << "Odd" << endl;
    }
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	AProduct solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3552
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

long N,M;
long A[100000],B[100000];

long ans[100000];

//引用元
//http://drken1215.hatenablog.com/entry/2019/03/03/224600
struct UnionFind {
    vector<long> parent;
    
    UnionFind(long n) : parent(n, -1) { }
    void init(long n) { parent.assign(n, -1); }
    
    //xの属している木の根っこを返す
    long root(long x) {
        if (parent[x] < 0) return x;
        else return parent[x] = root(parent[x]);//経路圧縮
    }
    
    long size(long x) {return -parent[root(x)];}
    bool is_same_tree(long x,long y) {return root(x)==root(y);}
    
    bool merge(long x,long y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (parent[x] > parent[y]) swap(x, y);//xの親の方がyの親より小さくなるようにする
        parent[x] += parent[y];
        parent[y] = x;//yの親をxとする
        return true;
    }
};

void solve(){
	UnionFind uf(N+1);
	ans[M-1] = N*(N-1)/2;
	for(int i=M-1;i>=1;i--){
		if(uf.is_same_tree(A[i],B[i])){
			ans[i-1] = ans[i];
			continue;
		}
		ans[i-1] = ans[i] - uf.size(A[i])*uf.size(B[i]);
		uf.merge(A[i],B[i]);
	}
}
 
int main(){
	cin >> N >> M;
	for(int i=0;i<M;i++)cin >> A[i] >> B[i];
 
	solve();

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


Measured memory_bytes: 3696
#include<stdio.h>


 void bsort(float a[], int N){//小さい順に並び替える
        int i,j;
        for(i=0;i<N-1;i++){
            for(j= N-1;j>i;j--){
                if(a[j -1] > a[j]){
                    float tmp = a[j];
                    a[j] = a[j-1];
                    a[j-1] = tmp;
                }
            }
        }
    }



int main()
{
    int N;
  scanf("%d", &N);
   float A[N];

  int i= 0;
  for(i=0;i<N;i++){
    scanf("%f", &A[i]);
  }
  float ans = 0;
  
  bsort(A,N);
  
  for(i=0;i<N-1;i++){
  ans = (A[i] + A[i+1])/2;
  A[i+1] = ans;
  }


  printf("%f",ans);
    return 0;
}


Measured memory_bytes: 128
i = input().split()
K = int(i[0])
A = int(i[1])
B = int(i[2])

if B - A <= 1:
  print(1+K)
else:
  remainK = K - (A - 1)
  current = A

  if remainK % 2 == 1:
    remainK -= 1
    current += 1

  t = int(remainK / 2) * int(B-A)
  print(int(current + t))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<unordered_map>
#include<cmath>
#include<algorithm>
using namespace std;
typedef  long long ll;

int main(int argc, char const *argv[])
{
    int n,k;
    cin >> n >> k;
    vector<int>h(n);
    
    ll h_sum=0;

    for (size_t i = 0; i < n; i++)
    {
        cin >> h[i];
        h_sum += h[i];
    }
    
    sort(h.begin(),h.end(),greater<int>());

    for(int i = 0;i < k && i <h.size();i++)
    {
        h_sum -=h[i];
    }
    cout << h_sum <<endl;

    return 0;
}


Measured memory_bytes: 1024
n[10],k,t,i=9,h;main(j){for(;t=~scanf("%x",n+i);k=i--?0:printf("%x\n",k,i=8))for(h=1;h;k|=t&h,h*=2)for(j=9,t=*n^k;--j;)t-=n[j]^k;}

Measured memory_bytes: 604
#include <cstdio>

int main() {
  int N;
  scanf("%d", &N);

  int odd=0, even=0, quad=0;
  for (int i=0; i<N; ++i) {
    int a;
    scanf("%d", &a);

    if (a % 4 == 0) {
      ++quad;
    } else if (a % 2 == 0) {
      ++even;
    } else {
      ++odd;
    }
  }

  if (odd == 0)
    return !printf("Yes\n");

  if (quad == 0)
    return !printf("No\n");

  if (odd == quad+1)
    return !printf("%s\n", even? "No":"Yes");

  printf("%s\n", (odd<=quad)? "Yes":"No");
}
    


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

int main(){
    ll n;
    cin >>n;
    cout <<(n+1)/2;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;

typedef struct{
  long long int x,y;
}ho;
ho house[100000];
vector<long long int> hx;
vector<long long int> hy;
long long int x[2]={0};
long long int y[2]={0};
long long int ans=1LL<<62,ax=0,ay=0;

int w,h,n;

int main(void){
  scanf("%d %d %d",&w,&h,&n);
  for(int i=0;i<n;i++){
    scanf("%d %d",&house[i].x,&house[i].y);
    hx.push_back(house[i].x);
    hy.push_back(house[i].y);
  }
  sort(hx.begin(),hx.end());
  sort(hy.begin(),hy.end());

  int xs,xp=(hx.size()+1)%2+1; //奇数１偶数２
  int ys,yp=(hy.size()+1)%2+1;
  xs=hx.size();
  ys=hy.size();
  for(int i=0;i<xp;i++) x[i]=hx[xs/2+i-xp/2];
  for(int i=0;i<yp;i++) y[i]=hy[ys/2+i-yp/2];

  long long int nx,ny;
  long long int lx,ly;
  long long int nmax=0;
  long long int temp=0;
  for(int i=0;i<xp;i++){
    nx=x[i];
    for(int j=0;j<yp;j++){
      ny=y[j];
      nmax=0;
      temp=0;
      for(long long int l=0;l<n;l++){
	lx=nx-house[l].x;
	ly=ny-house[l].y;
	lx*=(lx>=0)?1:-1;
	ly*=(ly>=0)?1:-1;
	long long int tamp=lx+ly;
	if(nmax<tamp) nmax=tamp;
	tamp*=2;
	temp+=tamp;
      }
      temp-=nmax;
      //      printf("(%lld,%lld):%lld\n",nx,ny,temp);
      if(temp<ans){
	ans=temp;
	ax=nx;
	ay=ny;
      }
    }
  }
  /*
  printf("xp:%d\nyp:%d\n",xp,yp);
  for(int i=0;i<2;i++)printf("%d.x:%lld\n  y:%lld\n",i,x[i],y[i]);
  */
  printf("%lld\n%lld %lld\n",ans,ax,ay);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll x,y;
    cin>>x>>y;
    vector<vector<ll>>v={{1,3,5,7,8,10,12},{4,6,9,11},{2}};
    ll a,b;
    for(ll j=0;j<v.size();j++)
    {
        for(ll i=0;i<v[j].size();i++)
        {
            if(v[j][i]==x) a=j;
            if(v[j][i]==y) b=j;
        }
    }
    if(a==b)
        cout<<"Yes";
  else
    cout<<"No";
}


Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main(){

	int n; cin >> n;
	int count = 0;
	bool flag = false;
	while(n--){
		int d1,d2;cin >> d1 >> d2;
		if(d1==d2)count++;
		else count = 0;

		if(count==3)flag = true;
	}

	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    long long h[n][3];
    for(int i=0 ; i<n ; i++)
        cin >> h[i][0] >> h[i][1] >> h[i][2];
    long long cost[n][3] = {0};
    cost[0][0] = h[0][0];
    cost[0][1] = h[0][1];
    cost[0][2] = h[0][2];
    for(int i=1 ; i<n ; i++)
    {
        cost[i][0] = h[i][0] + max(cost[i-1][1] , cost[i-1][2]);
        cost[i][1] = h[i][1] + max(cost[i-1][0] , cost[i-1][2]);
        cost[i][2] = h[i][2] + max(cost[i-1][1] , cost[i-1][0]);
    }
    cost[n-1][0] = max(cost[n-1][0] , cost[n-1][1]);
    cout << max(cost[n-1][0] , cost[n-1][2]);
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  
  ll n,q,ans=0;cin>>n;
  vll a(n),cnt(100001,0);
  rep(i,0,n){
    cin>>a[i];
    cnt[a[i]]++;
    ans+=a[i];
  }
  cin>>q;
  vll b(q),c(q);
  rep(i,0,q){
    cin>>b[i]>>c[i];
    cnt[c[i]]+=cnt[b[i]];
    ans+=(c[i]-b[i])*cnt[b[i]];
    cnt[b[i]]=0;
    cout<<ans<<endl;
  }
  
  
}



Measured memory_bytes: 6360
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  int a,b; cin >> a >> b;
  cout << a*b << endl;
  return 0;
}


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

using namespace std;
using ll = long long int;

ll GCD(ll a, ll b) {
  if (b == 0) {
    return a;
  }
  return GCD(b, a % b);
}

ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }

int main() {
  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;

  const ll lcm = LCM(n, m);
  const ll gcd = GCD(n, m);

  // string a, b;
  // a.resize(lcm, '_');
  // b.resize(lcm, '_');

  // const ll n_cd = lcm / n;
  // for (size_t i = 0; i < s.size(); i++) {
  //   a[i * n_cd] = s[i];
  // }

  // const ll m_cd = lcm / m;
  // for (size_t i = 0; i < t.size(); i++) {
  //   b[i * m_cd] = t[i];
  // }
  // for (size_t i = 0; i < lcm; i++) {
  //   if (a[i] != '_' && b[i] != '_') {
  //     if (a[i] != b[i]) {
  //       ok = false;
  //     }
  //   }
  // }

  const ll n_cd = lcm / m;
  const ll m_cd = lcm / n;

  string a;
  string b;

  for (size_t i = 0; i < s.size(); i += n_cd) {
    a.push_back(s[i]);
  }
  for (size_t i = 0; i < t.size(); i += m_cd) {
    b.push_back(t[i]);
  }
  
  if (a == b) {
    cout << lcm << endl;
  } else {
    cout << (-1) << endl;
  }
}

Measured memory_bytes: 512
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(h1) inp(m1) inp(h2) inp(m2) inp(k)
	int time=(h2-h1)*60+m2-m1;
	int mins=24*60;
	time%=mins;
	if(time<0)
		time+=mins;
	cout<<max(0ll,time-k)<<'\n';
	printclock;
}

Measured memory_bytes: 3804
import javax.net.ssl.SSLContext;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;

public class Main {

    public static void main(String[] args) throws IOException {

        BigDecimal M = new BigDecimal(1_000_000_000 + 7);

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int i = Integer.parseInt(reader.readLine());

        BigDecimal result = BigDecimal.ONE;

        for (int index = 1; index <= i; index++) {
            result = result.multiply(new BigDecimal(index));
            if (result.compareTo(M) >= 0) {
                result = result.divideAndRemainder(M)[1];
            }
        }

        System.out.println(result.longValue());


//        PrintWriter writer = new PrintWriter(System.out);
//
//        writer.close();


    }
}


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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  
  set<int> R, G, B;
  for(int i=0; i<N; i++){
    if(S[i]=='R') R.insert(i);
    else if(S[i]=='G') G.insert(i);
    else B.insert(i);
  }
  
  int bs=B.size();
  long long result=0;
  for(auto r:R){
    for(auto g:G){
      int t=bs;
      int i=max(r,g);
      int j=min(r,g);
      if((i+j)%2==0&&B.count((i+j)/2)>0) t--;
      if(2*i-j>=0&&B.count(2*i-j)>0) t--;
      if(2*j-i<N&&B.count(2*j-i)>0) t--;
      result+=t;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 3792
//113
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include <vector>
using namespace std;

int main(){
    int N;
    float T,A;
    cin >> N >> T >> A;

    vector<float> vec(N);
    for(int i = 0; i < N; i++)
    {
        /* code */
        cin >> vec[i];
        vec[i] = T - (vec[i] * 0.006);

        //cout << "hk:" << vec[i] << endl;

        vec[i] = abs(A - vec[i]);
        //cout << "sa" << vec[i] << endl;

    }

    float num = 100000;
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        /* code */
       if(num > vec[i]){
           num = vec[i];
           ans = i+1;
       }
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int ans;
	
	
	while (scanf(" %d", &n) != EOF){
		
		ans = n % 39;
		if (ans == 0){
			ans = 39;
		}
		printf("3C");
		
		if (ans <= 9 && ans >= 1){
			printf("0");
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 600
N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q)]
B = [K]*N
p = 0
for i in range(Q):
    B[A[i]-1] += 1
for i in range(N):
    if(B[i] > Q):
        print("Yes")
    else:
        print("No")

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

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORTASC(c) sort((c).begin(), (c).end())
#define SORTDESC(c, t) sort((c).begin(), (c).end(), std::greater<t>());
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

const double PI = acos(-1.0);

using ll = long long;
using namespace std;

int main()
{
    ll k;
    ll antennas[5];

    cin >> antennas[0] >> antennas[1] >> antennas[2] >> antennas[3] >> antennas[4] >> k;

    REP(i, 4){
        REP(j, 4-i){
            if (abs(antennas[i] - antennas[i+j+1]) > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;

    return 0;
}

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

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator &itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() {return i;}
  Iterator &end() {return n;}
};

template<class T> T at(vector<T> v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

typedef int Weight;
struct Edge {
  int from, to;
  Weight weight;
  Edge(int from, int to, Weight weight) :
    from(from), to(to), weight(weight) {}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

Matrix adjacency(const Graph &graph) {
  int n = graph.size();
  Matrix distance(n, Array(n, 1e9));
  for (const Edges &edges : graph) for (const Edge &edge : edges) {
    distance[edge.from][edge.to] = edge.weight;
  }
  return distance;
}

void debug(const Graph &g) {
  for (const Edges &es : g) for (const Edge &e : es) {
    cerr << e.from << " " << e.to << " " << e.weight << endl;
  }
}

Graph graph;
vector<int> c;

int solve(int v, int from) {
  if (c[v]) {
    for (const auto &edge : graph[v]) if (edge.to == from) return edge.weight;
    exit(-1);
  } else {
    int res1 = 0, res2 = 1e9;
    for (const auto &edge : graph[v]) {
      if (edge.to != from) res1 += solve(edge.to, v);
      else res2 = edge.weight;
    }
    return min(res1, res2);
  }
}

int main() {
  int n;
  cin >> n;
  c.resize(n, 0);
  for (int i : range(1, n)) cin >> c[i];
  graph.resize(n);
  for (int i : range(n - 1)) {
    int u, v, p;
    cin >> u >> v >> p;
    graph[u].emplace_back(u, v, p);
    graph[v].emplace_back(v, u, p);
  }
  cout << solve(0, -1) << endl;
}

Measured memory_bytes: 1264
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> P;

struct Graph
{
    int n;
    vector<vector<int>> g;
    
    Graph(int n) : n(n){
        g.resize(n);
    }
    
    void init(int n_){
        n = n_;
        g.resize(n_);
    }
    
    void add_edge(int from, int to){
        g[from].push_back(to);
    }
};

vector<int> BipartiteGraph(Graph &g){
    int n = g.n;
    vector<int> b(n);
    queue<int> que;
    for(int i = 0; i < n; i++){
        if(b[i]) continue;
        b[i] = 1;
        que.push(i);
        while(que.size()){
            int u = que.front();
            que.pop();
            for(int v : g.g[u]){
                if(b[u] == b[v]){
                    for(int i = 0; i < n; i++) b[i] = -1;
                    return b;
                }
                if(b[v] == 0){
                    b[v] = 3 - b[u];
                    que.push(v);
                }
            }
        }
    }
    return b;
}

int main()
{
    int n;
    cin >> n;
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add_edge(a, b);
        g.add_edge(b, a);
    }
    vector<int> b = BipartiteGraph(g);
    int a[3]{0};
    for(int i = 0; i < n; i++){
        a[b[i]]++;
    }
    int x = 1, y = 2, z = 3;
    int ans[200005];
    if(a[1] <= n / 3 || a[2] <= n / 3){
        int j;
        if(a[1] <= n / 3) j = 1;
        else j = 2;
        for(int i = 0; i < n; i++){
            if(b[i] == j){
                ans[i] = z;
                z += 3;
            }
            else{
                if(x <= n){
                    ans[i] = x;
                    x += 3;
                }
                else if(y <= n){
                    ans[i] = y;
                    y += 3;
                }
                else{
                    ans[i] = z;
                    z += 3;
                }
            }
        }
    }
    else{
        for(int i = 0; i < n; i++){
            if(b[i] == 1){
                if(x <= n){
                    ans[i] = x;
                    x += 3;
                }
                else{
                    ans[i] = z;
                    z += 3;
                }
            }
            else{
                if(y <= n){
                    ans[i] = y;
                    y += 3;
                }
                else{
                    ans[i] = z;
                    z += 3;
                }
            }
        }
    }
    for(int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
}

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

int main() 
{
    int n;
    cin >> n;
    vector<int> p(n+1);
    vector<int> q(n+1);
    vector<int> v(n+1);
    for (int i=1; i<=n; i++)
        cin >> p[i];
    for (int i=1; i<=n; i++)
        cin >> q[i];
    for (int i=1; i<=n; i++)
        v[i] = i;
    int a,b,i=1;
    do
    {
        if (v==p)
            a = i;
        if (v==q)
            b = i;
        i++;
    } while (next_permutation(v.begin()+1,v.end()));
    cout << abs(a-b);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
LIST = [0]*(100001)
Q = int(input())


b =[0]*Q
c =[0]*Q
for i in range(Q):
    b[i], c[i] = map(int, input().split())

for i in A:
    LIST[i]+=1

s = sum(A)

for i in range(Q):
    s += LIST[b[i]]*(c[i]-b[i])
    LIST[c[i]]+=LIST[b[i]]
    LIST[b[i]] = 0
    print(s)


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

int main()
{
    int ans = 0;
    string s;
    cin >> s;
    REP(i, 4)
    {
        if (s.at(i) == '+')
        {
            ans++;
        }
        else
        {
            ans--;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll ans , ans2 , ans3 , x;
ll a[7];
int dpT[11][11][11];
int dp(int x , int y , int z)
{
    if(dpT[x][y][z] != -1)
        return dpT[x][y][z];
    int ans = 0;
    if(x >= 2)
    {
        ans = max(ans ,  2 + dp(x - 2 , y , z));
    }
    if(y >= 2)
    {
        ans = max(ans ,  2 + dp(x , y - 2 , z));
    }
    if(z >= 2)
    {
        ans = max(ans ,  2 + dp(x , y , z - 2));
    }
    if(x > 0 && y > 0 && z > 0)
        ans = max(ans , 3 + dp(x - 1 , y - 1, z - 1));
    return dpT[x][y][z] = ans;

}
void process2(int a0 , int a3 , int a4)
{
    ans3 = 0;
    if(a0 && a3 && a4)
    {
        ans3 = 3;
        a0--;
        a3--;
        a4--;
    }
    ans3 += 2 * (a0 / 2);
    ans3 += 2 * (a3 / 2);
    ans3 += 2 * (a4 / 2);
}
void process(int a0 , int a3 , int a4)
{
    a0 -= x; a3 -= x; a4 -= x;
    ans2 += 2 * (a0 / 2);
    ans2 += 2 * (a3 / 2);
    ans2 += 2 * (a4 / 2);
}
ll go()
{
    x = min(a[0] , min(a[3] , a[4]));
    ans2 = x * 3;
    process(a[0] , a[3] , a[4]);
    process2(a[0] , a[3] , a[4]);
    ll ans = a[1] * 2;
    ans += 4 * (a[0] / 2);
    ans += 4 * (a[3] / 2);
    ans += 4 * (a[4] / 2);
    if(a[0] % 2 && a[3] % 2 && a[4] % 2)
        ans += 6;
    return max(ans3 + a[1] , max(ans / 2 , ans2 + a[1]));
}
int main()
{
    for(int i = 0; i < 7; i++)
        cin >> a[i];
    cout << go();

}


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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int  n;
  cin >> n;
  vi d(n);
  REP(i, 0, n)  cin >> d[i];
  ll ans = 0;

  REP(i, 0, n){
      REP(j, i+1, n){
          ans += d[i] * d[j];
      }
  }


  cout << ans << endl;

  return 0;
}


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

#define INF (1<<20)
typedef pair< int , int > P;
typedef pair< int , P > Pi;
struct Edge { int to,cost,des; };
vector< vector< Edge > > Graph;
int V,E,L;

int Dijkstra(int s,int g) {
  int min_cost[111][111];
  fill_n(*min_cost,111*111,INF);
  priority_queue < Pi ,vector< Pi >,greater< Pi > > que;
  que.push(Pi(0,P(L,s)));
  min_cost[s][L] = 0;
  while(!que.empty()){
    int cost = que.top().first;
    int des = que.top().second.first;
    int now = que.top().second.second;
    que.pop();
    if(now == g) return cost;
    if(cost > min_cost[now][des]) continue;
    for(int i=0;i<Graph[now].size();i++){
      Edge e = Graph[now][i];
      if(des >= e.des && min_cost[e.to][des-e.des] > cost){
	min_cost[e.to][des-e.des] = cost;
	que.push(Pi(cost,P(des-e.des,e.to)));
      }
      if(min_cost[e.to][des] > cost + e.cost){
	min_cost[e.to][des] = cost + e.cost;
	que.push(Pi(min_cost[e.to][des],P(des,e.to)));
      }
    }
  }
  return (-1);
}

int main(){
  while(cin >> V >> E >> L , (V||E||L)){
    Graph.resize(V+1);
    for(int i=0;i<E;i++){
      int a,b,c,d;
      cin >> a >> b >> c >> d;
      a--; b--;
      Edge e; e.to = b; e.cost = d; e.des = c;
      Graph[a].push_back(e);
      e.to = a;
      Graph[b].push_back(e);
    }
    cout << Dijkstra(0,V-1) << endl;
    Graph.clear();
  }
}

Measured memory_bytes: 1504
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a=0;
    scanf("%d",&a);
    int num4 = a % 10;
    int num3 = a/10%10;
    int num2 = a/100%10;
    int num1 = a/1000;
    if(num1 + num2 + num3 + num4 == 7)
        printf("%d+%d+%d+%d=7",num1,num2,num3,num4);
    else if(num1 + num2 + num3 - num4 == 7)
        printf("%d+%d+%d-%d=7",num1,num2,num3,num4);
    else if(num1 + num2 - num3 - num4 == 7)
        printf("%d+%d-%d-%d=7",num1,num2,num3,num4);
    else if(num1 + num2 - num3 + num4 == 7)
        printf("%d+%d-%d+%d=7",num1,num2,num3,num4);
    else if(num1 - num2 - num3 - num4 == 7)
        printf("%d-%d-%d-%d=7",num1,num2,num3,num4);
    else if(num1 - num2 + num3 - num4 == 7)
        printf("%d-%d+%d-%d=7",num1,num2,num3,num4);
    else if(num1 - num2 + num3 + num4 == 7)
        printf("%d-%d+%d+%d=7",num1,num2,num3,num4);
    else if(num1 - num2 - num3 + num4 == 7)
        printf("%d-%d-%d+%d=7",num1,num2,num3,num4);
    return 0;
}

Measured memory_bytes: 128
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int x=scan.nextInt();
            out.println(x==0?1:0);
        }
        out.flush();
        out.close();
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


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

int main() {
  ll n, m, k; cin >> n >> m >> k;
  n++; m++;
  vector<int> A(n), B(m);
  rep(i,n) { if (i==0) continue; cin >> A[i]; }
  rep(i,m) { if (i==0) continue; cin >> B[i]; }
  ll sum = 0;
  int ai = 0;
  while (ai < n-1 && sum + A[ai+1] <= k) {
    ai++;
    sum += A[ai];
  }

  int bi = 0;
  int ans = ai+bi;
  while (ai >= 0) {
    while (bi < m-1) {
      if (k >= sum + B[bi+1]) {
        bi++;
        sum += B[bi];
      }
      else break;
    }
    ans = max(ai+bi, ans);
    sum -= A[ai]; ai--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4844
N,A = map(int,input().split())
ls1 = [0] + list(map(int,input().split()))

dp = [[[0 for k in range(2600)] for j in range(51) ] for i in range(51)]
for i in range(51):
    dp[i][0][0] = 1
for j in range(1,N+1):
    for k in range(1,j+1):
        for s in range(2600):
            if s < ls1[j]:
                dp[j][k][s] = dp[j-1][k][s]
            elif s >= ls1[j]:
                dp[j][k][s] = dp[j-1][k-1][s-ls1[j]] + dp[j-1][k][s]
ans = 0
for k in range(1,N+1):
    ans += dp[N][k][k*A]
print(ans)

Measured memory_bytes: 71388
#include <bits/stdc++.h>
using namespace std;
char S[100100];
int R[100100];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	scanf("%s", S);
	priority_queue<pair<int, int>> pq;
	pq.emplace(0, n);
	fill(R, R + 1 + n, (int) 1e9);
	R[n] = 0;
	int ok = 1;
	for (int i = n - 1; i >= 0; --i) {
		if (S[i] == '1') continue;
		while (pq.size() && pq.top().second > i + m) pq.pop();
		if (pq.empty()) {
			ok = 0;
			break;
		}
		R[i] = -pq.top().first + 1;
		pq.emplace(-R[i], i);
	}
	if (!ok) return !puts("-1");
	vector<int> res;
	for (int i = 0; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			if (R[j] + 1 == R[i]) {
				res.push_back(j - i);
				i = j - 1;
				break;
			}
		}
	}
	for (int x : res) printf("%d ", x);
	printf("\n");
}


Measured memory_bytes: 1404
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main() {
  string cards[3];
  queue<char> qs[3];
  cin >> cards[0] >> cards[1] >> cards[2];
  int idx = 0;
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < cards[i].length(); j++) {
      qs[i].push(cards[i][j]);
    }
  }
  while(!qs[idx].empty()) {
    char c = qs[idx].front();
    qs[idx].pop();
    idx = c - 'a';
  }
  cout << (char)(idx + 'A') << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 
 */

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		Scanner as = new Scanner(System.in);
		
		int n = 0;
		int i = 0;
		int j = 0;
		int count = 0;
		int gre[];
		int pnum[];
		
		n = Integer.parseInt(as.next());
		
		pnum = new int[n];
		gre = new int[n];
		
		for(i=0;i<n;i++){
			
			pnum[i] = Integer.parseInt(as.next());
			gre[i] = (int) Math.sqrt(pnum[i]);
			//System.out.println("moto:"+pnum[i]);
			//System.out.println("root:"+gre[i]);
			
		}
		
		for(i=0;i<n;i++){
			for(j=2;j<=gre[i]+1;j++){
				
				if(j == gre[i]+1 && pnum[i] != 1){
					
					//System.out.println(pnum[i]);
					count++;
					
				}
				if(pnum[i] % j == 0){
					
					break;
					
				}
				
			}
		
		}
		
		sb.append(count);
		System.out.println(sb.toString());

	}

}

Measured memory_bytes: 41268
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve(parseProblem())
}

func parseProblem() (int, []int) {
	n := scanInt(sc)
	as := make([]int, n+2)
	for i := 1; i <= n; i++ {
		as[i] = scanInt(sc)
	}
	return n, as
}

// package: gocom
// packed src of [/Users/masumi/dev/src/github.com/masu-mi/gamemo/lib/gocom/next.go] with goone.

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}
func resolve(n int, as []int) {
	sum := 0
	for i := 1; i < len(as); i++ {
		sum += abs(as[i] - as[i-1])
	}
	for i := 1; i <= n; i++ {
		v := sum - (abs(as[i]-as[i-1]) + abs(as[i+1]-as[i])) + abs(as[i+1]-as[i-1])
		fmt.Println(v)
	}
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k,x;
    cin>>k>>x;
    if(k*500>=x)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }


int main(void){
    char c;
    cin >> c;
    cout << char(c+1) << endl;
    return 0;
}


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

int main() {
    int N,M;
    cin >> N >> M;
    int X[M];
    for (int i = 0; i < M; ++i) cin >> X[i];
    if(N>=M) cout << 0 <<endl;
    else{
        sort(X, X + M);  // 小さい順にソート
        //for (int i = 0; i < M; ++i) cout << X[i];
        int Xd[M-1];
        for (int i = 0; i < M-1; ++i) Xd[i]=X[i+1]-X[i];

        int L=X[M-1]-X[0];
        //cout << L;
        if(N==1)cout << L <<endl;
        else{
            sort(Xd, Xd + M-1, greater<int>());  // 大きい順にソート
            for(int i=0;i<N-1;i++){
                L=L-Xd[i];
            }
            cout << L <<endl;
        }
    }
}

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

int main() {
    string str, patt, subs;
    cin >> str >> patt;
    bool flag = false;
    
    for (long unsigned int i = 0; i < str.length(); i++) {
        if (str.length() - i < patt.length()) {
            subs = str.substr(i) + str.substr(0, patt.length() - str.length() + i);
        } else {
            subs = str.substr(i, patt.length());
        }
        if (patt == subs) {
            flag = true;
            break;
        }
    }

    if (flag == true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mod 1000000007
int main(){
	ll n;
	cin>>n;
	ll a[n+1],b[n+1],c[n+1];
	for(ll i=1;i<=n;i++)
		cin>>a[i]>>b[i]>>c[i];
	ll dp[n+1][4];
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<4;j++)
			dp[i][j]=0;
	}
	dp[1][1]=a[1],dp[1][2]=b[1],dp[1][3]=c[1];
	for(ll i=2;i<=n;i++)
	{
		dp[i][1]=a[i]+max(dp[i-1][2],dp[i-1][3]);
		dp[i][2]=b[i]+max(dp[i-1][1],dp[i-1][3]);
		dp[i][3]=c[i]+max(dp[i-1][2],dp[i-1][1]);
	}
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));


}

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

long long n,m;
long long ans;

int main()
{
    scanf("%lld%lld",&n,&m);
    ans=1e17;
    if(n>=3)
    {
        if(n%3!=0)
            ans=m;
        else
            ans=0;
    }
    if(m>=3)
    {
        if(m%3!=0)
            ans=min(ans,n);
        else
            ans=0;
    }

    for(int i=1;i<=m;i++)
    {
        long long s1,s2,s3;
        s1=(n+1)/2*(m-i);
        s2=i*n;
        s3=(n/2)*(m-i);
        ans=min(max(max(s1,s2),s3)-min(s1,min(s2,s3)),ans);
    }
    swap(n,m);
    for(int i=1;i<=m;i++)
    {
        long long s1,s2,s3;
        s1=(n+1)/2*(m-i);
        s2=i*n;
        s3=(n/2)*(m-i);
        ans=min(max(max(s1,s2),s3)-min(s1,min(s2,s3)),ans);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
int N;
int K;
cin>>N;
cin>>K;
if(N%K==0)
cout<<0;
else
cout<<1;
system("pause");
return 0;
}


Measured memory_bytes: 504
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(args){
    const input = args.split("\n");
  	const tmp = input[0];
    var result = '';

    for(var i=0; i<tmp.length; i++){
        result += (i%2 == 0 ? tmp[i] : '');
    }

    console.log(result);
}

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

void trace(int A[], int N) {
    for(int i = 0; i < N; i++) {
        if(i > 0) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

void insertionsort(int A[], int N) {
    for(int i = 1; i < N; i++) {
        int v = A[i];
        int j = i - 1;
        while(j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}
int main() {
    int A[100], N;

    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    trace(A, N);
    insertionsort(A, N);
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
int mod;
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
void solve() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	map<int,int > ma;
	map<int, int> pos;
	for (int i = 0; i < n; i++) {
		pos[a[i]] = i;
		if (ma[a[i]] == -1)continue;
		ma[a[i]]++;
		if (ma[a[i]] > 1)ma[a[i]] = -1;
	}
	for (int i = 0; i < n; i++) {
		int ok = 1;
		for (int j = 1; j <= sqrt(a[i]); j++) {
			if (a[i] % j == 0) {
				int x = a[i] / j, y = j;
				if (ma[x] == -1 || ma[y] == -1) {
					ok = 0;
					break;
				}
				if (ma[x] == 1 && pos[x] != i) {
					ok = 0;
					break;
				}
				if (ma[y] == 1 && pos[y] != i) {
					ok = 0;
					break;
				}
			}
		}
		if (ok)ans++;

	}
	cout << ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 42180
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#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 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 ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
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;

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(){
    set<int> S;
    int q; cin >> q;
    REP(i, q){
        int op, x; cin >> op >> x;
        switch(op){
            case 0:
                S.insert(x);
                cout << S.size() << endl;
                break;
            case 1:
                cout << noboolalpha << (S.find(x) != S.end()) << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 12496
#include "stdio.h"
#include "math.h"

int main()
{
	int d, x;

	while(scanf("%d", &d) != EOF){
		x = 0;

		for(int i = 0; i < 600; i += d)	x += (d * pow(i, 2.0));

		printf("%d\n", x);
	}

	return 0;
}

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

int f(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;

  int sumOfDigits = f(N);
  
  if (N % sumOfDigits == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	ll res = 0;

	vector<ll> a(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	map<ll, ll> x;
	for (ll i = 0; i < n; i++)
	{
		x[i + a[i]]++;
	}

	for (ll i = 0; i < n; i++)
	{
		if (x[i - a[i]] > 0)
		{
			res += x[i - a[i]];
		}
	}

	println(res);
}

Measured memory_bytes: 27372
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
        
        st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());

        if(n<10) {
            pw.println(k + 100*(10-n));
        }
        else {
            pw.println(k);
        }
        
        
        
        
        
        pw.flush();
        pw.close();
    }
}


Measured memory_bytes: 21204
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}

};

class Dijkstra{
	using Point = pair<ll,ll>;
	vector<ll> dist;
public:
	void CalcShortestPath(int start,ConnectNodeInfo& connect){
		dist.resize(connect.size(),1LL<<60);
		dist[start] = 0;

		priority_queue<Point,vector<Point>,greater<Point>> Q;
		Q.emplace(0,start);
		while(!Q.empty()){
			auto p = Q.top();
			Q.pop();
			int v = p.second;
			if(dist[v]<p.first){
				continue;
			}
			for(auto e:connect[v]){
				if(dist[e.first]>dist[v]+e.second){
					dist[e.first] = dist[v]+e.second;
					Q.emplace(dist[e.first],e.first);
				}
			}
		}
	}
	ll GetDistance(int i){
		return dist[i];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),M=in();
	ConnectNodeInfo connect(3*N);
	REP(i,M){
		int u=in()-1,v=in()-1;
		connect.AddDirectionalConnection(3*u,3*v+1,1);
		connect.AddDirectionalConnection(3*u+1,3*v+2,1);
		connect.AddDirectionalConnection(3*u+2,3*v,1);
	}

	int s=in()-1,t=in()-1;
	ll minK = 1ll<<60;
	REP(i,3){
		Dijkstra Dij;
		Dij.CalcShortestPath(3*s+i,connect);
		REP(j,3){
			if(Dij.GetDistance(3*t+j)<1ll<<60 && !(Dij.GetDistance(3*t+j)%3ll)){
				chmin(minK,Dij.GetDistance(3*t+j)/3ll);
			}
		}
	}
	out(minK>=1ll<<60 ? -1 : minK);
	return 0;
}


Measured memory_bytes: 19072
S = str(input())

odd = 'RUD'
even= 'LUD'
frag = True

for i in range(len(S)):
    if i%2 == 0 and S[i] not in odd:
        frag =False
        break
    elif i%2 !=0 and S[i] not in even:
        frag = False
        
if frag :
    print('Yes')
else:
    print('No')
    

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

const int MAXNN = 1e2+5;
const int MAXN  = 1e5+5;
int val[MAXNN],weight[MAXNN];
#define ll long long

ll dp[MAXN][MAXNN];

int main()
{
    int n,cap;cin >> n >> cap;
    for(int i=1;i<=n;++i){
        cin >> val[i] >> weight[i];
    }
    for(int i=1;i<=n;++i){
        for(int j=0;j<=cap;++j){
            if(j>=val[i]){
                dp[j][i] = dp[j-val[i]][i-1] + weight[i];
            }
            dp[j][i] = max(dp[j][i],dp[j][i-1]);
        }
    }
    cout << dp[cap][n];
}


Measured memory_bytes: 82304
use proconio::input;
fn main() {
    input!(n: usize, a: [[u64; n]; n]);
    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            for k in 0..n {
                if a[i][k] + a[k][j] < a[i][j] {
                    println!("-1");
                    std::process::exit(0);
                }
            }
            if (0..n)
                .filter(|&k| k != i && k != j)
                .all(|k| a[i][k] + a[k][j] > a[i][j])
            {
                ans += a[i][j];
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  
  if(N.at(0) == '7' || N.at(1) == '7' ||  N.at(2) == '7'){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
n,w=map(int,input().split())
val=[0]*n
wt=[0]*n
dp=[[0 for x in range(w+1)] for x in range(n+1)] 
for i in range(n):
  a,b=map(int,input().split())
  wt[i]=a
  val[i]=b
for i in range(1,n+1):
    for j in range(1,w+1):
        if(wt[i-1] <= j):
            dp[i][j]=max(val[i-1] + dp[i-1][j-wt[i-1]] , dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[n][w])

  
  


Measured memory_bytes: 171528