akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;

// UnionFind with Size;
struct UnionFind {
    vector<int> size;
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N), size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
            size[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        par[x] = root(par[x]);
        return par[x];
    }

    int getSize(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        return size[root(x)];
    }

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y); 
        if (rx == ry) return false;
        if (size[rx] < size[ry]) swap(x, y);
        size[rx] += size[ry];
        par[ry] = rx; 
        return true;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// using namespace atcoder;
void Main()
{
    ll n, K, L;
    cin >> n >> K >> L;

    vector<ll> p(K), q(K);
    rep(i, K) cin >> p[i] >> q[i];
    vector<ll> r(L), s(L);
    rep(i, L) cin >> r[i] >> s[i];
    
    UnionFind uf1(n), uf2(n);
    rep(i, K) {
        uf1.unite(p[i]-1, q[i]-1);
    }
    rep(i, L) {
        uf2.unite(r[i]-1, s[i]-1);
    }

    typedef pair<int, int> P;
    vector<P> keys(n);
    unordered_map<int, unordered_map<int, int>> cnt;

    rep(i, n) {
        ll k1 = uf1.root(i);
        ll k2 = uf2.root(i);
        if (cnt.find(k1) == cnt.end()) {
            cnt[k1] = unordered_map<int, int>();
        }
        if (cnt[k1].find(k2) == cnt[k1].end()) {
            cnt[k1][k2] = 0;
        }
        cnt[k1][k2]++;
    }

    vector<int> res(n);
    rep(i, n) {
        ll k1 = uf1.root(i);
        ll k2 = uf2.root(i);
        res[i] = cnt[k1][k2];
    }
    

    rep(i, res.size()) std::cout << res[i] << (i == res.size() - 1 ? "" : " ");
    std::cout << endl;
}
signed main(){ Main();return 0;}

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

int main(){
  int n,k ;
  cin >> n >> k;
  vector<int> list(n);
  int ans = 0;
  for (int i=0; i<n; i++){
    cin >> list.at(i);
  }
  sort(list.begin(),list.end(),greater<int>());
  for (int j=0; j<k; j++){
    ans += list.at(j);
  }
  cout << ans << endl;
}

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

using namespace std;
const int INF = (1 << 30);
const int N = 100000 + 5;
const double eps = 1e-8;
const int M = 100 + 5;
const int MOD = 1e9;

int a[N];
int main(){
    int n, ans = 0, x, maxn = 0;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &x); ++ a[x];
        if(x > maxn) maxn = x;
    }
    for(int i = 0; i <= maxn; i++)
        ans = max(ans, a[i] + a[i + 1] + a[i + 2]);
    printf("%d\n", ans);
}


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



int main() {
  int n,m,a,count;
  a=count=0;
  cin >> n >> m ;
  vector <int> l(m);
  vector <int> r(m);
  for (int i=0;i<m;i++)
    cin >> l.at(i) >> r.at(i);
  
  int lm = *std::max_element(l.begin(), l.end());
  int rm = *std::min_element(r.begin(), r.end());


  for (int i=1;i<=n;i++){
    if(lm<=i && i<=rm)
      count++;
  }
   
 cout << count << endl;
}


Measured memory_bytes: 1024
#include <iostream>

int main(){
    char a, b;
    std::cin >> a >> b;

    if('H' == a){
        if('H' == b){
            std::cout << 'H' << std::endl;
        }else{
            std::cout << 'D' << std::endl;
        }
    }else{
        if('H' == b){
            std::cout << 'D' << std::endl;
        }else{
            std::cout << 'H' << std::endl;
        }
    }

    return 0;
    
}


Measured memory_bytes: 504
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

#define MAX_NUM 205

int main(){
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r;
    REP(i, R){
        int x;
        cin >> x;
        r.pb(x);
    }

    int dp[MAX_NUM][MAX_NUM];
    REP(i, MAX_NUM){
        REP(j, MAX_NUM){
            if(i == j) dp[i][j] = 0;
            else dp[i][j] = INF;
        }
    }

    REP(i, M){
        int A, B, C;
        cin >> A >> B >> C;
        dp[A][B] = C; dp[B][A] = C;
    }

    REP(k, N+1){
        REP(i, N+1){
            REP(j, N+1){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }


    int ans = INF;

    vector<int> vec;
    vec.resize(R);
    REP(i, R){
        vec[i] = i;
    }

    do {
        int sum = 0;
        REP(i, R - 1){
            sum += dp[r[vec[i]]][r[vec[i+1]]];
        }
        if(ans > sum) ans = sum;
    }while(next_permutation(vec.begin(), vec.end()));

    cout << ans << endl;

}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;
int main(void){
long long a,b;
cin>>a>>b;

  long long r, x;
 
  x =a*b;
  
  if(a<b){std::swap(a,b);}
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

cout<<x/b;
}



Measured memory_bytes: 256
#include <stdio.h>



int main(){

    int m, f, r;

    while(1){

        scanf("%d %d %d ", &m, &f, &r);

        if(m==-1&&f==-1&&r==-1)break;

        if(m==-1||f==-1){

            printf("F\n");

        }else if(m+f>=80){

            printf("A\n");

        }else if(m+f>=65){

            printf("B\n");

        }else if(m+f>=50){

            printf("C\n");

        }else if(m+f>=30){

            if(r>=50){

                printf("C\n");

            }else{

                printf("D\n");

            }

        }else{

            printf("F\n");

        }

    }

    return 0;

}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main() {
    // For fast I/O
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;
    vi a;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a.push_back(t);
    }
    
    for (int i = k; i < n; i++) {
        if (a[i] > a[i - k]) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
    }

    return 0;
}

Measured memory_bytes: 4280
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll a(n), b(n);
  REP(i, n) {
    ll inp; cin >> inp;
    a.at(i) = inp;
    b.at(i) = inp;
  }
  sort(b.begin(), b.end());
  ll ans=0;
  REP(i, n) {
    if (abs(upper_bound(b.begin(), b.end(), a.at(i)) - b.begin() - 1 - i) % 2 == 1) ans++;
  }
  cout << ans / 2 << endl;
  return 0;
}


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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e3 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

void yes() {
    cout << "Yes\n";
}

void no() {
    cout << "No\n";
    exit(0);
}

ll a[N][N], d[N][N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int n, m, h, w;
    cin >> n >> m >> h >> w;
    forn(C, 1, 501) {
        bool shit = 0;
        forn(i, 1, n) {
            forn(j, 1, m) {
                a[i][j] = ((i - 1) % h == 0 && (j - 1) % w == 0 ? C * (h * w - 1) - 1 : -C);
                d[i][j] = d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] + a[i][j];
                if (i >= h && j >= w) {
                    if (d[i][j] - d[i - h][j] - d[i][j - w] + d[i - h][j - w] >= 0) {
                        shit = 1;
                        break;
                    }//no();
                }
            }
            if (shit) break;
        }
        if (d[n][m] <= 0) shit = 1;
        if (shit) continue;
        yes();
        forn(i, 1, n) {
            forn(j, 1, m)
                cout << a[i][j] << " ";
            cout << "\n";
        }
        return 0;
    }
    no();

    return 0;
}


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

int main() {
  int x;
  cin >> x;
  
  if (x < 600)
    cout << 8 << endl;
  else if (x < 800)
    cout << 7 << endl;
  else if (x < 1000)
    cout << 6 << endl;
  else if (x < 1200)
    cout << 5 << endl;
  else if (x < 1400)
    cout << 4 << endl;
  else if (x < 1600)
    cout << 3 << endl;
  else if (x < 1800)
    cout << 2 << endl;
  else
    cout << 1 << endl; 
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define sii set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#define INF 1000000000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
 
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}

vi adj[200001];
ll vis[200001];
ll ans;

ll dfs(ll node)
{
  vis[node]=1;
  ans++;
  for(auto child:adj[node])
  {
    if(!vis[child])
    {
      dfs(child);
    }
  }
  return ans;
}

void solve()
{
  ll n,m,a,b;
  cin>>n>>m;
  rep(i,0,m)
  {
    cin>>a>>b;
    adj[a].pb(b);
    adj[b].pb(a);
  }
  ll out=0;
  rep(i,0,n+1)
  {
    ans=0;
    if(!vis[i])
    {
      ll mx=dfs(i);
      out=max(out,mx);
    }
  }
  cout<<out;
}


int main()
{
  fastio
  int tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 22380
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		sc.close();

		//処理
		double ans = -1;
		double sum = 0;
		for(int i = 0; i < n; i++){
			sum += (double)1/a[i];
		}
		ans = (double)1 / sum;

		//出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;
 
int main() {
  int A,B,res=0;

  cin >> A >> B;
  for(int i=0; i<2; i++){
  if(A>=B){
    res += A;
    A--; 
  }
  else{
    res += B;
    B--;
  }
  }
  cout << res << endl; 
}

Measured memory_bytes: 256
let rec for_iter a b f = if a > b then [] else let x = f a in x :: for_iter (a+1) b f
let () =
  Scanf.scanf "%d %d" (fun n k ->
    if k = 0 then n*n
    else
      for_iter (k+1) n (fun b -> (n+1) / b * (b-k) + max 0 ((n+1) mod b - k))
      |> List.fold_left (+) 0)
  |> Printf.printf "%d\n"

Measured memory_bytes: 10240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.function.Function;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());

      Function<String,double[]> lineSpliteThenArray =
        s -> Stream.of(s.split(" "))
          .mapToDouble(Double::parseDouble)
          .toArray();

      double[][] vecter =
        br.lines()
          .limit(2)
          .map( lineSpliteThenArray )
          .toArray(double[][]::new);

      double p1 =
        IntStream.range(0, n)
          .parallel()
          .mapToDouble(i -> Math.abs(vecter[0][i] - vecter[1][i]) )
          .sum();

      double p2 = Math.sqrt(
        IntStream.range(0, n)
          .parallel()
          .mapToDouble(i -> Math.pow( vecter[0][i] - vecter[1][i], 2))
          .sum() );

      double p3 = Math.pow(
        IntStream.range(0, n)
        .parallel()
        .mapToDouble(i -> Math.pow( Math.abs(vecter[0][i] - vecter[1][i]), 3d))
        .sum() , 1d/3d );

      double p00 =
        IntStream.range(0, n)
          .parallel()
          .mapToDouble(i -> Math.abs(vecter[0][i] - vecter[1][i]))
          .max()
          .getAsDouble();

      System.out.printf("%.8f\n%.8f\n%.8f\n%.8f\n", p1,p2,p3,p00);
    }
  }

}


Measured memory_bytes: 33340
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = input()

d = {'R': R, 'S': S, 'P': P}

win = T.replace('r', 'P').replace('s', 'R').replace('p', 'S')

SUM = 0
flag = [True] * N
for i in range(N):
  if i < K:
    SUM += d[win[i]]
  else:
    if i >= K and win[i] == win[i-K]:
      if flag[i-K]:
        flag[i] = False
      else:
        SUM += d[win[i]]
    else:
      SUM += d[win[i]]

print(SUM)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N = 200000 + 5;
int n, a[N], b[N];
long long k;

inline long long check (long long aa) {
	long long ans = 0;
	rep (i, 1, n) {
		long long x = a[i], y = b[n - i + 1];
		long long lst = aa / y;
		ans += (x - lst) >= 0 ? (x - lst) : 0;
	}
//	printf ("%lld %d %lld\n", aa, ans <= k, ans);
	return ans <= k;
}

int main () {
	scanf ("%d%lld", &n, &k);
	rep (i, 1, n) scanf ("%d", &a[i]);
	rep (i, 1, n) scanf ("%d", &b[i]);
	sort (a + 1, a + n + 1);
	sort (b + 1, b + n + 1);
	long long l = 0, r = 1e12, mid;
	while (l < r) {
		mid = (l + r) >> 1;
		if (check (mid)) r = mid;
		else l = mid + 1;
	}
	printf ("%lld\n", l);
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <deque>
#include <cmath>

using namespace std;

long long N,K;
long long x[100000];
deque<long long> p,m;

int main(){
    cin >> N >> K;
    for(long long i=0;i<N;i++) cin >> x[i];
    for(long long i=0;i<N;i++){
        if(x[i] == 0){
            K--;
            continue;
        }
        if(x[i] > 0){
            p.push_back(x[i]);
        }else{
            m.push_front(-x[i]);
        }
    }
    if(K<=0){
        cout << 0 << endl;
        return 0;
    }
    long long min_l = 5e18;
    for(long long i=0;i<=K;i++){
        if(p.size() < i || m.size() < K-i) continue;
        long long l;
        if(i == 0){
            l = m[K-1];
        }else if(i == K){
            l = p[K-1];
        }else{
            l = p[i-1] + m[K-1-i] + min(p[i-1],m[K-1-i]);
        }
        min_l = min(l,min_l);
    }
    cout << min_l << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)    scanf("%d",&x)
#define sl(x)    scanf("%lld",&x)
#define ss(s)    scanf("%s",s)
#define pi(x)    printf("%d\n",x)
#define pl(x)    printf("%lld\n",x)
#define ps(s)    printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>    pii;
typedef pair<ll, ll>    pl;
typedef vector<int>        vi;
typedef vector<ll>        vl;
typedef vector<pii>        vpii;
typedef vector<pl>        vpl;
typedef vector<vi>        vvi;
typedef vector<vl>        vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];

void solve() {
    ll n,i,j,a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 10656
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<int> X(N); rep(i,N) cin >> X.at(i);
    sort(begin(X), end(X));
    ll mi = 1LL<<62;
    for (int i = X[0]; i <= X[N-1]; i++) {
        ll sum = 0;
        rep(j,N) sum += pow(i-X[j],2);
        mi = min(mi, sum);
    }
    cout << mi << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int arr[3][3], check[9];
    for(int i=0,j=3;i<3,j<=9;i++,j=j+3)
    {
        scanf("%d %d %d", &arr[i][0], &arr[i][1], &arr[i][2]);
        check[j-3]=arr[i][0];
        check[j-2]=arr[i][1];
        check[j-1]=arr[i][2];
    }
    int N;
    scanf("%d", &N);
    int x;
    for(int n=0;n<N;n++)
    {
        scanf("%d", &x);
        for(int i=0;i<9;i++)
        {
            if(check[i]==x)
                check[i]=0;
        }
    }
    if(check[0]==0 && check[1]==0 && check[2]==0)
    {
        printf("Yes");
        return 0;
    }
    if(check[0]==0 && check[4]==0 && check[8]==0)
    {
        printf("Yes");
        return 0;
    }
    if(check[0]==0 && check[3]==0 && check[6]==0)
    {
        printf("Yes");
        return 0;
    }
    if(check[1]==0 && check[4]==0 && check[7]==0)
    {
        printf("Yes");
        return 0;
    }
    if(check[2]==0 && check[4]==0 && check[6]==0)
    {
        printf("Yes");
        return 0;
    }
    if(check[2]==0 && check[5]==0 && check[8]==0)
    {
        printf("Yes");
        return 0;
    }
    if(check[3]==0 && check[4]==0 && check[5]==0)
    {
        printf("Yes");
        return 0;
    }
    if(check[6]==0 && check[7]==0 && check[8]==0)
    {
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

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

int func(int x) {
  if(x<0) return (-1)*x;
  else return x;
}

int main() {

  int n, sum = 0, min = INF, tol = 0;
  cin >> n;
  int w[n];
  rep(i, n) {
    cin >> w[i];
    sum += w[i];
  }

  rep(i, n-1) {
    tol += w[i];
    if(min>func(sum-tol-tol)) min = func(sum-tol-tol);
  }

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;



public class Main
{	
	public static void main(String args[]) throws IOException
	{
		FastScanner fs = new FastScanner();
		
			int L = fs.nextInt()-1,R = fs.nextInt(),d = fs.nextInt();
			
			System.out.println(R/d-L/d);
	}

}
class FastScanner
{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer str = new StringTokenizer("");
	
	String next() throws IOException
	{
		while(!str.hasMoreTokens())
			str = new StringTokenizer(br.readLine());
		
		return str.nextToken();
	}
	
	int nextInt() throws IOException
	{
		return Integer.parseInt(next());
	}
	
	float nextfloat() throws IOException
	{
		return Float.parseFloat(next());
	}
	
	double nextDouble() throws IOException
	{
		return Double.parseDouble(next());
	}
	long nextLong() throws IOException
	{
		return Long.parseLong(next());
	}
	int[] arrayIn(int n) throws IOException
	{
		int arr[] = new int[n];
		for(int i=0; i<n; i++)
		{
			arr[i] = nextInt();
		}
		return arr;
	}
}



	

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

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

#define fr first
#define sc second

int main(){
	int n;
	int t=0,x=0,y=0;
	bool ret = true;
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++){
		int t_,x_,y_;
		scanf("%d%d%d",&t_,&x_,&y_);
		int d = abs(x-x_)+abs(y-y_);
		if(d > t_-t || ((d+t_-t)&1))ret = false;
		t = t_; x = x_; y = y_;
	}
	if(ret)puts("Yes");
	else puts("No");
}



Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    h, w = MII()
    s = ['#'*(w+2)]
    for i in range(h):
        s.append('#'+ IS() + '#')
    s.append('#'*(w+2))
    print(*s,sep='\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
first=int(input())
number=input().split()
numbers=[int(n) for n in number]
 
count=0
 
if all(a % 2 ==0 for a in numbers):
    count+=1
else:
    pass
 
answer=[m/2 for m in numbers]
 
while all(n % 2 ==0 for n in answer):
    count+=1
    answer=[m/2 for m in answer] 
 
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100;

int T, dp[N][N], n, d[N];

main(){
  cin >> T;
  while(T--){
    cin >> n;
    for(int i=0;i<n;i++) cin >> d[i];
    fill(dp[0], dp[N], 0);
    for(int k=1;k<n;k++){
      for(int i=0;i<n;i++){
        for(int j=0;j<k;j++){
          dp[i][(i+k)%n] = max(dp[i][(i+k)%n], dp[i][(i+j)%n] + dp[(i+j+1)%n][(i+k)%n] + abs(d[i] - d[(i+j+1)%n]));
        }
      }
    }
    int ans = 0;
    for(int i=0;i<n;i++) ans = max(ans, dp[i][(i+n-1)%n]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a,b;
    cin >> n >> a >> b;
    
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        int sum = 0;
        int org = i;
        while(true)
        {
            sum += org % 10;
            if(org < 10){
                break;
            }else{
                org /= 10;
            }
        }
        if(a <= sum && sum <= b){
            ans += i;
        }
    }
    cout << ans << endl;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>

using namespace std;
typedef long long  ll;

const ll mod = 1000000007;

int main()
{
	string str;
	cin >> str;
	if (str.size() < 26)
	{
		map<char, ll> mp;
		for (ll i = 0; i < str.size(); i++)
		{
			mp[str[i]]++;
		}
		for (char i = 'a'; i < 'z' + 1; i++)
		{
			if (mp[i] == 0)
			{
				cout << str + i << endl;
				return 0;
			}
		}
	}
	ll index = str.size() - 1;
	for (ll i = str.size() - 1; i > 0 ; i--)
	{
		if (str[i - 1] > str[i])
		{
			index = i - 1;
		}
		else break;
	}
	if (index == 0)
	{
		cout << -1 << endl;
		return 0;
	}
	string q = str.substr(index, 1);
	for (ll i = index; i < str.size(); i++)
	{
		if (str.substr(index - 1, 1) < str.substr(i, 1))
		{
			q = min(q, str.substr(i, 1));
		}
	}
	string ans;
	if (index != 1)
	{
		ans += str.substr(0, index - 1);
	}
	cout << ans + q << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define rev(r) reverse(r.begin(),r.end())
#define SORT(ar) sort(ar.begin(), ar.end())
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define in(a) scanf("%d",&a)
#define pr(x) printf("%d ",x)
#define endl '\n'
#define read(v,n) for(int h=0;h<n;h++) cin>>v[h];
#define fo(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i>=b;i--)
#define mo 1000000007
#define N 300007
ll dp[101][100001];

int main()
{
    ll n,W,i,j,k;
    cin>>n>>W;
    ll w[n+1],v[n+1];
    fo(i,1,n+1) cin>>w[i]>>v[i];
    fo(i,1,n+1)
    {
        fo(j,1,W+1)
        {
            if(j>=w[i]) dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][W]<<endl;
}


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

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int i,n,j=0;
	cin>>n;
	double a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	vector<double> dp(n+1);
	vector<double> ndp(n+1);
	double x=1.0;
	dp[0]=x;
	for(i=1;i<=n;i++)
	{
		x*=(1-a[i-1]);
		ndp[0]=x;
		for(j=1;j<=i;j++)
		{
			ndp[j]=dp[j-1]*a[i-1]+(1.0-a[i-1])*dp[j];
		}
		dp=ndp;
	}
	double ans=1.0;
	for(i=n;i>n/2;i--)
		ans+=ndp[i];
	ans--;
	cout<<std::setprecision(14)<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3892
import java.util.Scanner;
import java.util.HashMap;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.nextLine();
        String T = scanner.nextLine();
        int n = S.length();
        if(T.length() != n) {
            System.out.println(n + ", " + T.length());
            System.out.println("No");
            System.exit(0);
        }
        int[] s = new int[n];
        int[] t = new int[n];
        HashMap<Character,Integer> hm
            = new HashMap<Character,Integer>();
        for(int i = 0; i < n; ++i) {
            char c = S.charAt(i);
            if(!hm.containsKey(c)) {
                hm.put(c, hm.size());
            }
            s[i] = hm.get(c);
        }
        hm.clear();
        for(int i = 0; i < n; ++i) {
            char c = T.charAt(i);
            if(!hm.containsKey(c)) {
                hm.put(c, hm.size());
            }
            t[i] = hm.get(c);
        }
        for(int i = 0; i < n; ++i) {
            if(s[i]!=t[i]) {
                System.out.println("No");
                System.exit(0);
            }
        }
        System.out.println("Yes");
    }
}


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

int main() {
  string S;
  cin >> S;
  vector<string> wea;
  wea = {"Sunny", "Cloudy", "Rainy"};
  for (int i = 0; i<3; i++) {
    if (S == wea[i]) cout << wea[(i+1)%3] << endl;
  }
}


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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n;
ll k, a[200009];

bool f(ll x) {
    ll cnt = 0, y;
    rep(i, n) {
        if(a[i] == 0) {
            cnt += (x >= 0 ? n : 0);
        } else {
            y = x / a[i];
            if(x < 0 && y * a[i] > x) y += (a[i] < 0 ? 1 : -1);

            if(a[i] > 0) {
                cnt += upper_bound(a, a + n, y) - a;
            } else {
                cnt += a + n - lower_bound(a, a + n, y);
            }
        }
        if(a[i] * a[i] <= x) cnt--;
        //  cout << y << " " << cnt << endl;
    }
    cnt /= 2;
    return cnt >= k;
}

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

    cin >> n >> k;
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    ll l = (-1e18) - 1, r = 1e18 + 1;
    while(r - l > 1) {
        ll mid = (l + r) / 2;
        if(f(mid))
            r = mid;
        else
            l = mid;
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
/* A */
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans, cnt;

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

	char c;
	cin >> c;

	if (toupper(c) == c) {
		cout << "A" << endl;
	}
	else {
		cout << "a" << endl;
	}

	return 0;
}

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

int cnt[4001][4001];

int main(){
	string a, b;
	int na, nb;

	for(;;){
		if(cin >> a >> b){
			na = a.length();
			nb = b.length();

			for(int i=0; i<na+1; i++){
				cnt[i][0] = 0;
			}
			for(int j=0; j<nb+1; j++){
				cnt[0][j] = 0;
			}

			int mx = 0;
			for(int i=0; i<na; i++){
				for(int j=0; j<nb; j++){
					if(a[i]==b[j]){
						cnt[i+1][j+1] = cnt[i][j] + 1;
						if(mx < cnt[i+1][j+1]){
							mx = cnt[i+1][j+1];
						}
					}else{
						cnt[i+1][j+1] = 0;
					}
				}
			}
			cout << mx << endl;
		}else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 63740
/*HOME - Volume0 - 0046
   Differential
      2012/11/06(火)*/
#include<stdio.h>
int main(void)
{
	float x,max,min,answer;
	max=0.0;
	min=10000.0;
	while(scanf("%f",&x)!=EOF) {
		if(x>=max) {
			max=x;
		}
		if(x<=min) {
			min=x;;
		}
	}
	answer=max-min;
	printf("%f\n",answer);
	return 0;
}

Measured memory_bytes: 644
#include<stdio.h>
int a[2000000];
int main()
{
	int n,next;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int cnt=0;next=1;
	for(int i=1;i<=n;i++)
	{
		next=a[next];
		cnt++;
		if(next==2)
			break;       
	}
	if(next==2)
		printf("%d\n",cnt);
	else	
		printf("-1\n");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#define N 1001
using namespace std;
int main(){
  int n,m,c,d,l,r,flag,sum;
  int V[N]={0};
  cin >> n >> m;
  for(int i=0;i<m;i++) cin >> c >> d,V[c]=max(V[c],d);
  l=r=flag=sum=0;
  for(int i=0;i<=n;i++){
    if(flag&&V[i]!=0) r=max(r,V[i]);
    if(V[i]!=0&&!flag) l=i,r=V[i],flag=1;
    if(flag&&r==i) sum+=3*(r-l),flag=0;
    if(!flag) sum++;
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxn = 1e5+5;
int dp[maxn][13]; string s;

int dfs(const int i, const int j)
{
    if (i == s.size())
        return j == 5;
    int& ans = dp[i][j];
    if (-1 == ans) {
        ans = 0;
        if (s[i] != '?') {
            const int k = ((s[i]-'0') + j*10) % 13;;
            ans += dfs(i+1,k);
            ans %= mod;
        }
        else {
            FOR(d,0,10) {
                const int k = (j*10+d) % 13;
                ans += dfs(i+1,k);
                ans %= mod;
            }
        }
    }
    return ans;
}
    
int main()
{
    while (cin >> s) {
        memset(dp,-1,sizeof(dp));
        cout << dfs(0,0) << endl;
    }
    return 0;
}


Measured memory_bytes: 10240
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

class st{
public:
  int cost,end;
  bool operator<(const st & a)const{
    if (end != a.end)return end < a.end;
    return cost < a.cost;
  }
};

int solve(vector<st> &a){
  int now=0,ret=0;
  rep(i,a.size()){
    if (now+a[i].cost <= a[i].end){
      now+=a[i].cost;
      ret++;
    }
  }
  return ret;
}

const int N = 1000;
const int inf = (1<<20);
int dp[N][N+2];
int solve2(vector<st> &a){
  int n=a.size();
  rep(i,n)rep(j,n+1)dp[i][j]=inf;
  rep(i,n)dp[i][0]=0;
  rep(i,n){
    if (a[i].cost <= a[i].end)dp[i][1]=a[i].cost;
  }
  rep(i,n){
    REP(j,1,n+1){
      if (i > 0 && dp[i-1][j-1]+a[i].cost <= a[i].end){
        dp[i][j]=min(dp[i][j],dp[i-1][j-1]+a[i].cost);
      }
      if (i > 0)dp[i][j]=min(dp[i][j],dp[i-1][j]);
    }
  }
  int maxi=0;
  rep(i,n+1){
    if (dp[n-1][i] < inf){
      maxi=i;
    }
  }
  return maxi;
}

main(){
  int n;
  while(cin>>n && n){
    vector<st> a(n);
    rep(i,n){
      cin>>a[i].cost>>a[i].end;
    }
    sort(a.begin(),a.end());
    //rep(i,a.size())cout << a[i].cost <<" " << a[i].end << endl;
    cout << solve2(a) << endl;
  }
}

Measured memory_bytes: 0
#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;

bool is_ok4(int n){
	return (n % 4 == 0);
}

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

	int r, g, b; cin >> r >> g >> b;
	
	bool ok = is_ok4(10*g + b);

	cout << (ok ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 256
//矩阵连乘问题，递归方程采用课本P47的递归方程。
//与课本P47的程序相比，两者都是填m[][]的上三角，
//但本程序是横向填表，而课本程序是斜向填表。
//本程序按照 自底向上，自左向右 的顺序来计算m[][]的上三角。
//程序中有记录相应断开位置到s[][]。

#include <iostream>
using namespace std;

void MatrixChain(int, int[], int **, int **);
void print(int, int, int **);
void CalculateMin(int i, int j, int p[], int **m, int **s);

int main()
{
    int n;
    cin >> n;
    int *tempP = new int[2 * n]; //p[0]为A1的行数；p[i]为Ai的列数

    int *p = new int[n + 1];    //p[0]为A1的行数；p[i]为Ai的列数
    int **m = new int *[n + 1]; //m[i][j]为Ai连乘到Aj的最少乘次数
    int **s = new int *[n + 1]; //s[i][j]为 Ai连乘到Aj的最优解的第一层断开位置
    for (int i = 1; i <= n; i++)
    {
        m[i] = new int[n + 1];
        s[i] = new int[n + 1];
    }

    for (int i = 0; i < 2 * n; i++)
    {
        cin >> tempP[i];
    }

    for (int i = 0; i <= n; i++)
    {
        p[i] = i == 0 ? tempP[0] : tempP[i * 2 - 1];
    }

    MatrixChain(n, p, m, s);
    cout << m[1][n] << endl; //最优值存储在m[1][n]
    //print(1, n, s); //打印最优计算方式

    return 0;
}

void MatrixChain(int n, int p[], int **m, int **s)
{
    //以下双重循环对m[][]的上三角进行填表
    //填表顺序为自底向上，自左向右
    for (int i = n; i >= 1; i--) //i表示行
    {
        for (int j = i; j <= n; j++) //j表示列，因为只填上三角，所以j的初值为i
        {
            //以下按照矩阵连乘问题的递归公式来求每一个m[i][j]
            if (i == j)
            {
                m[i][j] = 0;
            }
            else
            {
                CalculateMin(i, j, p, m, s);
            }
        }
    }
}

void CalculateMin(int i, int j, int p[], int **m, int **s)
{
    m[i][j] = m[i][i] + m[i + 1][j] + p[i - 1] * p[i] * p[j]; //若i与j不相等，m[i][j]的初值为断开位置为i时的最优值

    s[i][j] = i;                    //记录当前断开位置位置为i
    for (int k = i + 1; k < j; k++) //k用于尝试不同的断开位置
    {
        int curr = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
        if (curr < m[i][j]) //当前k值作为Ai连乘到Aj的断开位置能获得更少计算量
        {
            m[i][j] = curr; //刷新最优值
            s[i][j] = k;   //刷新相应断开位置
        }
    }
}

void print(int i, int j, int **s)
{
    if (i == j)
        cout << "A" << i;
    else
    {
        cout << "(";
        print(i, s[i][j], s);
        print(s[i][j] + 1, j, s);
        cout << ")";
    }
}


































































































Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll a[3];
	set<ll> st;
	repn(i, 3) {
		cin >> a[i];
		st.insert(a[i]);
	}
	cout << st.size();

	system("PAUSE");
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define ll long long
#define WEIGHTSUM minWeight[i] + weight
#define VALUESUM value + i
using namespace std;
bitset <100009> reached;
int minWeight[100009];

int main() {
    int n, w, weight, value, result = 0;
    reached[0] = 1;

    cin >> n >> w;
    for (int i = 1; i <= n; i++) {
        cin >> weight >> value;

        reached[0] = 1;
        for (int i = 100009; i >= 0; i--)
            if (reached[i] && minWeight[i] + weight <= w) {
                if (!reached[VALUESUM])
                    minWeight[VALUESUM] = WEIGHTSUM;
                minWeight[VALUESUM] = min(minWeight[VALUESUM], WEIGHTSUM);

                result = max(result, VALUESUM);
                reached[VALUESUM] = 1;
            }
    }

    cout << result;

    return 0;
}


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

int dist(int a, int b) {
  if (a > b)
	  return a - b;
	return b - a;
}

template <class T>
T min_(T a, T b) {
  if (a < b)
	  return a;
	return b;
}

int main () {
  int n;
  cin >> n;
	int a[n];
	int h[n];

	for (int i = 0; i < n; ++i)
	  cin >> h[i];

	a[0] = 0;
	a[1] = dist(h[0], h[1]);
	for (int i = 2; i < n; ++i) {
	  int d1 = dist(h[i-1], h[i]);
	  int d2 = dist(h[i-2], h[i]);
		a[i] = min_(a[i-1] + d1, a[i-2] + d2);
	}
	cout << a[n-1] << endl;

  return 0;
}

Measured memory_bytes: 1024
/* ***********************************************
Author        :kuangbin
Created Time  :2013/11/15 16:30:39
File Name     :G.cpp
************************************************ */

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
const int INF = 0x3f3f3f3f;
struct Edge
{
	int to,next;
	int w;
}edge[20010];
int head[110];
int tot;
void addedge(int u,int v,int w)
{
	edge[tot].to = v;
	edge[tot].next = head[u];
	edge[tot].w = w;
	head[u] = tot++;
}

void init()
{
	tot = 0;
	memset(head,-1,sizeof(head));
}
int dp[110][1010];
int n,m;
bool vis[110][1010];
void SPFA(int s)
{
	queue<pair<int,int> >q;
	q.push(make_pair(s,0));
	for(int i = 1;i <= n;i++)
		for(int j = 0;j < 1010;j++)
			dp[i][j] = INF;
	memset(vis,false,sizeof(vis));
	dp[s][0] = 0;
	vis[s][0] = true;
	while(!q.empty())
	{
		pair<int,int> tmp = q.front();
		int u = tmp.first;
		int k = tmp.second;
		//printf("%d %d\n",u,k);
		q.pop();
		vis[u][k] = false;
		for(int i = head[u];i != -1;i = edge[i].next)
		{
			int v = edge[i].to;
			//cout<<v<<endl;
		//	printf("%d %d\n",dp[v][k],dp[u][k] + edge[i].w);

			if(dp[v][k] > dp[u][k] + edge[i].w)
			{
			//	cout<<"*"<<endl;
				dp[v][k] = dp[u][k] + edge[i].w;
				if(!vis[v][k])
				{
					q.push(make_pair(v,k));
					vis[v][k] = true;
				}
			}

			if(k < m &&  dp[v][k+1] > dp[u][k] )
			{
				dp[v][k+1] = dp[u][k] ;
				if(!vis[v][k+1])
				{
					q.push(make_pair(v,k+1));
					vis[v][k+1] = true;
				}
			}
		}
	}
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int c;
	while(scanf("%d%d%d",&n,&m,&c) == 3)
	{
		if(n == 0 && m == 0 && c == 0)break;
		init();
		int u,v,w;
		for(int i = 0;i < m;i++)
		{
			scanf("%d%d%d",&u,&v,&w);
			addedge(u,v,w);
		}
		SPFA(1);
	//	for(int i = 1;i <= n;i++)
	//		for(int j = 0;j <= m;j++)
	//			printf(" %d %d %d\n",i,j,dp[i][j]);
		int ans = m ;
		for(int i = 0;i <= m;i++)
			if(dp[n][i] <= c)
			{
				ans = i;
				break;
			}
		cout<<ans<<endl;
	}
    return 0;
}

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

#define MAX_N (int)1e+5
#define MAX_M (int)1e+5

int n, m;
std::vector<std::vector<int>> g(MAX_N + 1, std::vector<int>());
int dp[MAX_N + 1];

int rec(int v) {
  if(dp[v] >= 0) return dp[v];

  dp[v] = 0;
  for(auto w : g[v]) {
    dp[v] = std::max(dp[v], rec(w) + 1);
  }

  return dp[v];
}

int main() {
  std::cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    int x, y;
    std::cin >> x >> y;
    g[x].push_back(y);
  }

  for(int i = 0; i <= n; ++i) dp[i] = -1;

  int ans = -1;
  for(int i = 0; i < n; ++i) {
    ans = std::max(ans, rec(i + 1));
  }

  std::cout << ans << std::endl;
}

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

long A, B;

int Gcd(long a, long b){
  int temp;
  while ( a%b!=0 ){
    temp = b;
		b = a % b;
		a = temp;
  }
  return b;
}

int main(){
  cin >> A >> B;
  long lcm = A*B/Gcd(A, B);
  cout << lcm << endl;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    cout << max({a * 2 - 1, b * 2 - 1, a + b}) << endl;
}

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

int main () {
  int N , P ;
  cin >> N >> P ;
  bool can = false ;
  for(int i = 0 ; i <  N ; i++ ){
    int a ;
    cin >> a ;
    if(a%2==1) can = true ;
  }
  long long ans = 0 ;
  if(P==0){
    if(can){
      ans = pow(2,N-1) ;
    } else {
      ans = pow(2,N) ;
    }
  }else {
    if(can){
      ans = pow(2,N-1) ;
    } else {
      ans = 0;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<vector>
 
#define mx(ans, cnt) ans = max(ans, cnt)
#define fauto(a) for(auto i : a) cout << i << " "; cout << endl;
#define sp(n) fixed << setprecision(n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define _ << " " <<
#define swp(x, y) if (x > y) swap(x, y);
#define swpg(x, y) if (x < y) swap(x, y);
#define ff first
#define ss second
#define xx first
#define yy second
#define pb push_back
#define nn end1
 
 
using ll = long long;
using ull = unsigned long long;
using namespace std;
int main ()
{
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll m;
        cin>>m;
        if(m>=400 && m<=599)
        {
            cout<<8;
        }
        if(m>=600 && m<=799)
        {
            cout<<7;
        }
        if(m>=800 && m<=999)
        {
            cout<<6;
        }
        if(m>=1000 && m<=1199)
        {
            cout<<5;
        }
        if(m>=1200 && m<=1399)
        {
            cout<<4;
        }
        if(m>=1400 && m<=1599)
        {
            cout<<3;
        }
        if(m>=1600 && m<=1799)
        {
            cout<<2;
        }
        if(m>=1800 && m<=1999)
        {
            cout<<1;
        }
    }
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
  int N = 0;
  long sum =0;

  scanf("%d\n",&N);
  for(int i =1;i<(N+1);i++){
    if((i%3!=0) && (i%5!=0)){
      sum += i;
    }
  }
  printf("%ld\n",sum);
  return 0;
}

Measured memory_bytes: 1736