akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) {
        par.resize(n, -1);
    }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

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

    int size(int x) {
        return -par[root(x)];
    }
};

vint blk[100005];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    vint ff(n, 0);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        uf.unite(a, b);
        ff[a]++;
        ff[b]++;
    }

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

    vint ans(n);
    rep(i, n) {
        int num = uf.size(i) - ff[i] - 1;
        for (int x : blk[i]) {
            if (uf.same(i, x)) num--;
        }
        ans[i] = num;
    }
    
    rep(i, n) printf("%d%s", ans[i], i != n-1 ? " " : "\n");
    return 0;
}

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

int main(){
    
    int n;
    
    cin>>n;
    
    for(int i=1;i<=n;i++){
        if(i%10==3 || i%3==0 || (i/10)%10==3|| (i/100)%10==3 || (i/1000)%10==3){
    cout<<" "<<i;
        }
    }
    cout<<endl;

    return 0;
}



Measured memory_bytes: 3092
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

vector<int> prime(int n){
    vector<int> t;
    vector<bool> x(n+1, true);

    int i;
    bool mon = false;
    for(i = 6; i * i <= n;){
        int next;
        if(mon){
            next = i + 5;
            mon = false;
        }else{
            next = i + 2;
            mon = true;
        }

        if(!x[i]){
            i = next;
            continue;
        }

        t.push_back(i);
        for(int j = i; j <= n; j += i){
            x[j] = false;
        }
        i = next;
    }

    for(; i <= n;i++){
        if(x[i] && (i % 7 == 1 || i % 7 == 6)){
            t.push_back(i);
        }
    }
    return t;
}

signed main(){
    vector<int> p = prime(300000);


    while(true){
        int n;
        cin >> n;

        if(n == 1){
            break;
        }

        cout << n << ":";
        rep(i, (int)p.size()){
            if(n % p[i] == 0){
                cout << " " << p[i];
            }
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3284
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

#define MAXN 1005

long long a[MAXN],a1[MAXN],n,sum[2],used[MAXN],flag,r[MAXN],l[MAXN];
bool dele[MAXN];
vector<int> ans;

void del(int x)
{
    ans.push_back(x+1);
    a[x]=0;
    memset(dele,0,sizeof dele);
    memset(used,0,sizeof used);
    if(x!=0)
    {
        dele[x-1]=1;
        a[x]+=a[x-1];
    }
    if(x!=n-1)
    {
        dele[x+1]=1;
        a[x]+=a[x+1];
    }
    for(int i=0;i<n;i++)
        a1[i]=a[i];
    int cnt=0;
    for(int i=0;i<n;i++)
        if(dele[i]==0)
            a[cnt++]=a1[i];
    for(int i=0;i<n;i++)
        if(a[i]>0&&flag==i%2)
            used[i]=1;
    n=cnt;
}

void work()
{
    int maxid=0;
    for(int i=0;i<n;i++)
        if(a[i]>a[maxid])
            maxid=i;
    printf("%lld\n%d\n",a[maxid],n-1);
    int sum=n;
    for(int i=0;i<maxid;i++)
    {
        printf("%d\n",1);
        sum--;
    }
    for(int i=n-1;i>maxid;i--)
    {
        printf("%d\n",sum);
        sum--;
    }
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(int i=0;i<n;i++)
        if(a[i]>0)
            sum[i%2]+=a[i];
    if(sum[0]==0&&sum[1]==0)
    {
        work();
        return 0;
    }
    if(sum[0]>sum[1])
        flag=0;
    else
        flag=1;
    for(int i=0;i<n;i++)
    {
        l[i]=i-1;
        r[i]=i+1;
    }
    for(int i=0;i<n;i++)
        if(a[i]>0&&flag==i%2)
            used[i]=1;
    while(n>1)
    {
        for(int i=0;i<n;i++)
        {
            if(i==0||i==n-1)
            {
                if(used[i]==0)
                {
                    if(i==0)
                        flag^=1;
                    del(i);
                    break;
                }
            }
            else if(used[i-1]==used[i+1])
            {
                del(i);
                break;
            }
        }
    }
    printf("%lld\n%d\n",a[0],ans.size());
    for(int i=0;i<ans.size();i++)
        printf("%d\n",ans[i]);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		int k = sc.nextInt();
		
		char c = s.charAt(k-1);
		
		String sample = String.valueOf(c);
		
		String[] strs = s.split("");
		
		StringBuffer sb = new StringBuffer();
		
		for(int i=0; i<strs.length; i++) {
			if(strs[i].equals(sample)) {
				sb.append(sample);
			}else {
				sb.append("*");
			}
		}
		
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 22612
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e16;

/*
<url:https://onlinejudge.u-aizu.ac.jp/#/problems/0321>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};


int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,M,K; cin >> N >> M >> K;
    vector<int> ps(N+1,-1);
    UnionFind uf(N+M+1);
    
    int ans = 0;
    bool f = false;
    for(int i = 0; i < K;i++){
        int op,x,y; cin >> op >> x >> y;
        if(f) continue;
        if(op == 1){
            if(ps[uf.root(x)] == -1 && ps[uf.root(y)] == -1){
                uf.unionSet(x, y);
            }else if(ps[uf.root(x)] == -1 && ps[uf.root(y)] != -1){
                int tmp = ps[uf.root(y)];
                uf.unionSet(x, y);
                ps[uf.root(x)] = tmp;
            }else if(ps[uf.root(x)] != -1 && ps[uf.root(y)] == -1){
                int tmp = ps[uf.root(x)];
                uf.unionSet(x, y);
                ps[uf.root(x)] = tmp;
            }else{
                if(ps[uf.root(x)] != ps[uf.root(y)]){
                    ans = i + 1;
                    f = true;
                    continue;
                }
                uf.unionSet(x, y);
            }
        }else{
            if(ps[uf.root(x)] == -1){
                uf.unionSet(x, y + N);
                ps[uf.root(x)] = y + N;
            }else{
                if(ps[uf.root(x)] == y + N){
                    uf.unionSet(x, y+N);
                }else{
                    ans = i + 1;
                    f = true;
                    continue;
                }
            }
        }
    }
    
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4132
N, M = map(int,input().split())
roads = []
for i in range(M):
  a,b = map(int,input().split())
  roads.append([a,b])

ans = []
for i in range(1,N+1):
  counter = 0
  for j in range(M):
    if i in roads[j]:
      counter += 1
  ans.append(counter)

for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define spc printf(" ")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007
#define FI freopen("input.txt","r",stdin)
#define FO freopen("output.txt","w",stdout)
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///#define triangle_area(a,b,m,n,x,y) (a*(n-y)+m*(y-b)+x*(b-n))/2.0
///int ax[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ay[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction

///using namespace __gnu_pbds;
using namespace std;

///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //FI;
    //FO;
    #endif
    //ios_base::sync_with_stdio(0); cin.tie(0);
    int N;
    while(si(N)==1)
    {
        bool f=true;
        for(int i=1;i<=9;i++)
        {
            if(N%i==0)
            {
                int x=N/i;
                if(x>=1 && x<=9)
                {
                    puts("Yes");
                    f=false;
                    break;
                }
            }
        }
        if(f)puts("No");
    }
    return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, k, t;std::cin >> n >> k;
  vll a, b;
  ll z=0;

  re(i, n){
    std::cin >> t;
    if(t<0) a.push_back(abs(t));
    else if(t>0) b.push_back(t);
    else z++;
  }
  sort(all(a));
  sort(all(b));
  ll INF = 1000000000000000005;


  ll l = -INF, r = INF;
  while(r-l>1){
    ll mid = (l+r)/2, c = 0;
    //bool flag = (mid==-8);
    re(i, a.size()){
      if(mid>=0){
        c += z + b.size();
        ll tmp = upper_bound(all(a), mid/a[i]) - a.begin();
        if(a[i]*a[i]<=mid) tmp--;
        c += tmp;
      }else{
        ll tmp = lower_bound(all(b), abs(mid)/a[i] + (mid%a[i]!=0?1:0)) - b.begin();
        c += b.size() - tmp;
      }
      //if(flag) std::cout << c << '\n';
    }
    re(i, b.size()){
      if(mid>=0){
        c += z + a.size();
        ll tmp = upper_bound(all(b), mid/b[i]) - b.begin();
        if(b[i]*b[i]<=mid) tmp--;
        c += tmp;
      }else{
        ll tmp = lower_bound(all(a), abs(mid)/b[i] + (mid%b[i]!=0?1:0)) - a.begin();
        c += a.size() - tmp;
      }
      //if(flag) std::cout << c << '\n';
    }

    if(mid>=0) c += (z*(z-1)) + z*(a.size()+b.size());
    c/=2;
    //std::cout << mid << " " << c << '\n';
    if(c>=k) r = mid;
    else l = mid;
  }
  std::cout << r << '\n';

  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

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


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    int count1 = 0, count2 = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '#') count1++;
        else count2++;
    }
    ans = min(count1, count2);
    int w = 0, b = 0;
    for (int i = 0; i < n-1; ++i) {
        if (s[i] == '#') b++;
        else w++;

        ans = min(ans, b + count2 - w);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
#include <bitset>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define*********************************/
ll chl['z' - 'a' + 1];
/*****************************functions********************************/

/****************************main function*****************************/
int main(void) {
	string S; cin >> S;
	for (int i = 0; i < S.size(); i++) {
		chl[S[i] - 'a']++;
	}
	ll ans = 1;
	for (int i = 'a' - 'a'; i <= 'z' - 'a'; i++) {
		for (int j = i + 1; j <= 'z' - 'a'; j++) {
			ans += chl[i] * chl[j];
		}
	}
	cout << ans << endl;
	return 0;
}

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

x1 = 0
for i in range(N):
    x1 += A[i]*((-1)**i)

print(x1, end=" ")
for i in range(N-1):
    x2 = A[i]*2-x1
    if i == N-2:
        print(x2)
    else:
        print(x2, end=" ")
    x1 = x2

Measured memory_bytes: 14032
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    int ans = n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    for (int i = 0; i < n - 1; i++) {
        if (d.at(i) == d.at(i + 1)) ans--;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    map<int, int> mp;
    bool flag=true;
    for(int m=0; m<M; m++) {
        int s, c;
        cin >> s >> c;
        if(!flag) continue;
        if(mp.find(s)!=mp.end()) {
            if(mp[s]!=c) {
                flag = false;
            }
        } else {
            mp[s] = c;
            if(N>=2 && s==1) {
                if(c==0) {
                    flag=false;
                }
            }
        }
    }
    
    int ans=0;
    if(flag) {
        int pow=1;
        for(int n=1; n<N; n++) {
            pow *= 10;
        }
        
        for(int i=1; i<=N; i++) {
            if(N!=1 && i==1 && mp[i]==0) mp[i]++;
            ans += pow*mp[i];
            pow /= 10;
        }
    } else {
        ans = -1;
    }
    
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>
  
static int gdbi = 0;
  
void
east(int dice[6])
{
    int t = dice[2];
    dice[2] = dice[0]; /* 3 ??? 1 */
    dice[0] = dice[3]; /* 1 ??? 4 */
    dice[3] = dice[5]; /* 4 ??? 6 */
    dice[5] = t;       /* 6 ??? 3 */
}
  
void
south(int dice[6])
{
    int t = dice[1];
    dice[1] = dice[0]; /* 2 ??? 1 */
    dice[0] = dice[4]; /* 1 ??? 5 */
    dice[4] = dice[5]; /* 5 ??? 6 */
    dice[5] = t;       /* 6 ??? 2 */
}
  
void
rotate(int dice[6])
{
    int t = dice[3];
    dice[3] = dice[1]; /* 4 ??? 2 */
    dice[1] = dice[2]; /* 2 ??? 3 */
    dice[2] = dice[4]; /* 3 ??? 5 */
    dice[4] = t;       /* 5 ??? 4 */
}
  
bool
compare(int dice1[6], int dice2[6])
{
    int u, v;
    int i;
  
    u = dice1[0];
    v = dice1[1];
    for (i = 0; i < 4; ++i)
    {
        if (dice2[1] == v)
            break;
  
        south(dice2);
    }
  
    if (dice2[1] != v) /* dice2[2]????????¢???????????????????????? */
    {
        for (i = 0; i < 4; ++i)
        {
            if (dice2[1] == v) /* dice2[2]????????¢??? */
                break;
  
            rotate(dice2);
        }
    }
  
    if (dice2[1] != v)
        return false;
  
    for (i = 0; i < 4; ++i)
    {
        if (dice2[0] == u) /* dice2[1]????????¢??? */
            break;
  
        east(dice2);
    }
  
    for (i = 0; i < 6; ++i)
    {
        if (dice1[i] != dice2[i])
            break;
    }
  
    if (i == 6)
        return true;
    else
        return false;
}
  
bool
solve(int dice[100][6], int n)
{
    int i, j;
  
    for (i = 0; i < n - 1; ++i)
    {
        for (j = i + 1; j < n; ++j)
        {
            if (i == 0 && j == 30)
                gdbi++;
  
            if (compare(dice[i], dice[j]))
                return false;
        }
    }
  
    return true;
}
  
int
main(int argc, char** argv)
{
    int dice[100][6];
    int n;
    int i, j;
  
    scanf("%d\n", &n);
    for (i = 0; i < n; ++i)
    {
        for (j = 0; j < 6; ++j)
            scanf("%d", &dice[i][j]);
    }
  
    printf("%s\n", solve(dice, n) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 2104
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n+1);
	int mi=inf,ma=-1;
	rep(i,n){
		int a;cin>>a;
		mi=min(mi,a);
		ma=max(ma,a);
		in[a]++;
	}
	bool h=true;
	loop(i,mi,ma+1)if(in[i]==0)h=false;
	if(in[mi]>2)h=false;
	loop(i,mi+1,ma+1)if(in[i]==1)h=false;
	if(in[mi]==1&&ma-mi!=mi)h=false;
	if(in[mi]==2&&ma-mi+1!=mi)h=false;
	if(h)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}










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

int main()
{

    char s[100009];

    scanf("%s",s);

    int i,j;

    int len = strlen(s);

    long long p[13];

    p[0] = 1;


    int c = 0;

    long long int a[13];

    int si;

    for(si=0;si<len;si++)
    {

        for(i=0;i<13;i++)
            a[i] = 0;

        if(s[si] =='?')
        {
            for(j=0;j<10;j++)
                for(i=0;i<13;i++)
                    a[(i*10+j)%13] += p[i];
        }
        else
        {
            c = s[si] - '0';
            for(i=0;i<13;i++)
                a[(i*10+c)%13] += p[i];
        }

        
        for(i=0;i<13;i++)
            p[i] = a[i]%1000000007;
        
    }

    printf("%lld",p[5]);

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

d.sort()
t.sort()

d = array_count(d)
t = array_count(t)

for i in range(len(t)):
    t[i][1] = -1 * t[i][1]
    d.append(t[i])

d.sort()

for i in range(1,len(d)):
    if d[i-1][0] == d[i][0]:
        d[i-1][1] = d[i-1][1] + d[i][1]
        d[i][1] = 0

flag = True

for i in range(len(d)):
    if d[i][1] < 0:
        flag = False
        break

if flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 64744
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using edge = pair<int, long long>;
using Graph = vector<vector<edge>>;

int main() {
    int n, m; cin >> n >> m;
    int l; cin >> l;
    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c; a--, b--;
        if (c > l) continue;
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
    using pll = pair<long long, long long>;
    vector<vector<pll>> dist(n, vector<pll>(n, {INF, INF}));
    for (int s = 0; s < n; s++) {
        using Pi = pair<pll, int>;
        priority_queue<Pi, vector<Pi>, greater<Pi>> que;
        dist[s][s] = {0, 0}; que.emplace(dist[s][s], s);
        while (!que.empty()) {
            pll p; int u; tie(p, u) = que.top(); que.pop();
            long long cnt, used; tie(cnt, used) = p;
            if (p > dist[s][u]) continue;
            for (auto &e: g[u]) {
                int v; long long c; tie(v, c) = e;
                long long nused = used + c;
                pll np = {cnt, nused};
                if (nused > l) np = {cnt + 1, c};
                if (chmin(dist[s][v], np)) que.emplace(dist[s][v], v);
            }
        }
    }
    int q; cin >> q;
    while (q--) {
        int a, b; cin >> a >> b; a--, b--;
        long long res = dist[a][b].first;
        if (res == INF) cout << -1 << endl;
        else cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 5644
#include <iostream>
#include <utility>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n;  cin >> n;
    vector<int>v(n);
    rep(i, n)   cin >> v[i];
    vector<int>e(1001001);
    vector<int>o(1001001);
    rep(i, n){
        if(i%2){
            e[v[i]]++;
        }else{
            o[v[i]]++;
        }
    }
    //<最頻値、出現回数> ->  <最頻値, 書き換え回数>
    vector<pair<int, int> >dice(2, pair<int, int>(-1, 0));      
    vector<pair<int, int> >dico(2, pair<int, int>(-1, 0));
    for(int i = 1; i <= 1000000; i++){
        if(e[i] > dice[0].second){
            if(dice[0].second > dice[1].second){
                dice[1].first = dice[0].first;
                dice[1].second = dice[0].second;
            }
            dice[0].first = i;
            dice[0].second = e[i];
        }else if(e[i] > dice[1].second){
            dice[1].first = i;
            dice[1].second = e[i];
        }
        if(o[i] > dico[0].second){
            if(dico[0].second > dico[1].second){
                dico[1].first = dico[0].first;
                dico[1].second = dico[0].second;
            }
            dico[0].first = i;
            dico[0].second = o[i];
        }else if(o[i] > dico[1].second){
            dico[1].first = i;
            dico[1].second = o[i];
        }
    }
    //書き換え回数に変換
    rep(i, 2){
        dice[i].second = n/2 - dice[i].second;
        dico[i].second = (n+1)/2 - dico[i].second;
    }
    if(dice[0].first == dico[0].first){
        cout << min(dice[0].second+dico[1].second, dice[1].second+dico[0].second) << endl;
    }else{
        cout << dice[0].second + dico[0].second << endl;
    }
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
	string s;
	cin>>s;
	for(int i= 0; i<s.length();i++)
	{
		if(s[i] == '7')
	{
		cout<<"Yes"<<endl;
		return 0;
	}
}
	
		cout<<"No"<<endl;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


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

Measured memory_bytes: 3572
import sys
import math
input = sys.stdin.readline

n, k = map(int, input().split())
tmp = float(k)
need = [] # 必要なコイントス回数
while tmp > 1:
    need.append(math.ceil(tmp))
    tmp /= 2
need.append(1)
# print(need)
# # # range(need[i+1], need[i]) の範囲で、コイントスが i 回必要

bunsi = max(0, n-k+1)
bunbo = 1
for i in range(len(need) - 1):
    bunsi *= 2
    bunbo *= 2
    if need[i+1] > n:
        continue
    elif need[i] > n:
        l = len(range(need[i+1], n+1))
    else:
        l = len(range(need[i+1], need[i]))
    bunsi += l

print("{0:.12f}".format(bunsi/bunbo/n))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

int main(){
	string S;
  	cin >> S;
  	int M = S.size();
  	string A;
  	for(int i = 0; i < M; i++){
    	A = A + "x";
    }
  	cout << A << endl;
}


Measured memory_bytes: 256
from sys import stdin

a, v = [int(x) for x in stdin.readline().rstrip().split()]
b, w = [int(x) for x in stdin.readline().rstrip().split()]
t = int(input())


if a == b:
    print('YES')
elif a > b:
    dis = a-b
    if v*t - w*t >= dis:
        print('YES')
    else:
        print('NO')
else:
    if a + v*t >= b + w*t:
        print('YES')
    else:
        print('NO')




Measured memory_bytes: 9188
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    int N, K;
    cin>>N>>K;
    vector<int> h(N);
    for(int i=0;i<N;++i){
        cin>>h[i];
    }
    int ans = 0;
    for(int i=0;i<N;++i){
        if(h[i]>=K) ans++;
    }
    cout<<ans<<endl;
}



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

//using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"

void Main() {
    int p,q,r;
    std::cin >> p >> q >> r;
    std::vector<int> v = {p, q, r};
    std::sort(v.begin(), v.end());
    
    std::cout << v[0] + v[1] << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
def getlist():
	return list(map(int, input().split()))

N, D = getlist()

XL = []

for i in range(N):
	X = getlist()
	XL.append(X)

ans = 0
for i in range(N):
	for j in range(i + 1, N):
		c = 0
		for k in range(D):
			c += (XL[i][k] - XL[j][k]) ** 2
		for k in range(150):
			if k ** 2 == c:
				ans += 1
				break

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int i;
/*
int linearSearch(int n, int A[], int key){
	i = 0;
	A[n] = key;
	while (A[i] != key)
		i++;
	if (i == n)
		return -1;
	return i;
}
*/

int main(void) {
	int n,q,j,count=0;
	
	scanf("%d",&n);
	int S[n];
	
	for(i=0; i<n; i++){
		scanf("%d",&S[i]);
	}
	
	scanf("%d",&q);
	int T[q];
	
	for(i=0; i<q; i++){
		scanf("%d",&T[i]);
		for (j=0; j<n; j++){
			if (T[i]==S[j]){
				count++;
				break;
			}
		}
	}
	printf("%d\n",count);
	
	return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<string>


#define INPUT_MAX 101	// 入力文字数の最大値
#define KAKKO_MAX 49	// 左括弧の数の最大値

using namespace std;

int main(void)
{
	int countMaru = 0;			// '('の数 - ')'の数
	int countKaku = 0;			// '['の数 - ']'の数
	int idx = 0;				// stackに入っている値の数
	string stack(KAKKO_MAX, '\0');		// '('、'['を入力順に格納する変数
	string dataset(INPUT_MAX, '\0');	// 各データセットを格納する変数
	
	while(getline( cin, dataset))
	{
		if(dataset[0] == '.')
		{
			break;
		}
		for(int i = 0; i < INPUT_MAX; i++)
		{
			if(dataset[i] == '.')
			{
				if((countMaru == 0) && (countKaku == 0))
				{
					cout << "yes\n";
					break;
				}
				else
				{
					cout << "no\n";
					break;
				}
			}
			else if(dataset[i] == '(')
			{
				if(idx == KAKKO_MAX)
				{
					cout << "no\n";
					break;
				}
				countMaru++;
				stack[idx] = '(';
				idx++;
			}
			else if(dataset[i] == '[')
			{
				if(idx == KAKKO_MAX)
				{
					cout << "no\n";
					break;
				}
				countKaku++;
				stack[idx] = '[';
				idx++;
			}
			else if(dataset[i] == ')')
			{
				if(idx == 0)
				{
					cout << "no\n";
					break;
				}
				else if(stack[idx-1] == '[')
				{
					cout << "no\n";
					break;
				}
				else
				{
					idx--;
					stack[idx] = '\0';
					countMaru--;
				}
			}
			else if(dataset[i] == ']')
			{
				if(idx == 0)
				{
					cout << "no\n";
					break;
				}
				else if(stack[idx-1] == '(')
				{
					cout << "no\n";
					break;
				}
				else
				{
					idx--;
					stack[idx] = '\0';
					countKaku--;
				}
			}
			else
			{
				// 処理なし
			}
		}
		
		idx = 0;
		countMaru = 0;
		countKaku = 0;
	}
	
	return 0;
}




Measured memory_bytes: 3132
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            int a, b, c, count;
            a = cin.GetInt();
            b = cin.GetInt();
            c = cin.GetInt();

            count = 0;

            for (int i = a; i <= b; i++)
                if (c % i == 0)
                    count++;

            Console.WriteLine("{0}", count);
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public string GetLine()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            string line;
            this._i = 0;
            do
            {
                line = Console.ReadLine();
            } while (line == "");

            this._s = line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);

            return this._s[this._i++];
        }

        public int GetInt()
        {
            return int.Parse(this.GetLine());
        }

        public long GetLong()
        {
            return long.Parse(this.GetLine());
        }

        public double GetDouble()
        {
            return double.Parse(this.GetLine());
        }
    }
}

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


int main(){
    int n,k,ans;
    cin >> n >>k;
    if (n%2==0) {
        ans=n/2;
    }
    else ans=n/2+1;
    if (ans>=k)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
/**
 * 2016/8/14
 * AOJ 0033 ball
 */
#include <iostream>
#include <fstream>
using namespace std;
int n;
int Map[10];
bool solve(int begin,int left,int right){
	if (begin==10)return true;
	if(Map[begin]<left && Map[begin]<right)
		return false;
	if(Map[begin]>left && Map[begin]>right)
		return solve(begin+1,left,Map[begin]) || solve(begin+1,Map[begin],right);
	if(Map[begin]<left)
		return solve(begin+1,left,Map[begin]);
	if(Map[begin]<right)
		return solve(begin+1,Map[begin],right);
}
int main(){
	cin>>n;
	while(n--){
		//reader
		for(int i=0;i<10;++i)cin>>Map[i];
		//solver
		if(solve(0,0,0))cout<<"YES\n";
		else cout<<"NO\n";
	}
}

Measured memory_bytes: 1120
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
from collections import Counter
C=Counter(A)
Q=int(input())

ANS=0
for i in C:
    ANS+=i*C[i]
    
for qq in range(Q):
    B,X=map(int,input().split())
    ANS+=X*C[B]
    C[X]+=C[B]

    ANS-=B*C[B]
    del(C[B])
    print(ANS)

Measured memory_bytes: 24008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll mm= min(a,min(b,min(c,min(d,e))));
    ll cnt=(n + (mm - 1)) / mm;
    cout << 5+(cnt-1) << endl;
}

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

int main() {
  int N ,a=0, ans=100000000;
  cin >>N;
  vector<int> X(N);
  
  for (int i = 0; i < N; i++)
  {
    cin >> X.at(i);
  }
  sort(X.begin(), X.end());
  for (int i = X.at(0); i <= X.at(N-1); i++)
  {
    for (int j = 0; j < N; j++)
    {
      a += (X.at(j) - i )*(X.at(j) - i );
    }
    if (ans > a)
    {
      ans = a;
    }
    a = 0;
  }
  cout << ans <<endl;
  return 0;
  
}

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

int main() {
	int m, n;
	std::cin >> n >> m;
	std::vector<std::vector<int>> a_mat;
	std::vector<int> b_mat;
	a_mat.resize(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int a;
			std::cin >> a;
			a_mat[i].push_back(a);
		}
	}
	for (int i = 0; i < m; i++) {
		int a;
		std::cin >> a;
		b_mat.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		int c = 0;
		for (int j = 0; j < m; j++) {
			c += a_mat[i][j]*b_mat[j];
		}
		std::cout << c << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3188
#include<stdio.h>
int main(void){
  long int n,k,ans;
  scanf("%ld %ld",&n,&k);
  long int nk=n%k;
  long int k_nk=k-(n%k);
  if(nk<=k_nk){
    ans=nk;
  }else{
    ans=k_nk;
  }
  printf("%ld",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    string s;
    ll k;
    cin >> s;
    cin >> k;
    ll pos = 0;

    rep(i,s.length()){
        if(s[i] == '1'){
            pos++;
            if(k == pos){
                cout << "1" << endl;
                break;
            }
        }else{
            cout << s[i] << endl;
            break;
        }
    }
    return 0;
}

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

template <typename T>
class SegmentTree {
	using func_t = function<T(T, T)>;
	const int n;
	const T id;
	func_t merge;
	vector<T> data;
	int size(int n) {
		int res;
		for (res = 1; res < n; res <<= 1);
		return res;
	}
	T sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return data[node];
		return merge(sub(l, r, node * 2, lb, (lb + ub) / 2), sub(l, r, node * 2 + 1, (lb + ub) / 2, ub));
	}
public:
	SegmentTree(int n_, T id_, func_t merge_) :
		n(size(n_)), id(id_), merge(merge_), data(n * 2, id) {}
	void init(const vector<T>& data_) {
		for (int i = 0; i < (int)data_.size(); i++)
			data[i + n] = data_[i];
		for (int i = n - 1; i >= 0; i--)
			data[i] = merge(data[i * 2], data[i * 2 + 1]);
	}
	void add(int p, T val) {
		p += n;
		data[p] += val;
		while (p >>= 1) data[p] = merge(data[p * 2], data[p * 2 + 1]);
	}
	T find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y;
	cin >> n >> q;
	SegmentTree<int> st(n, 0, [](int l, int r) { return l + r; });
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x - 1, y - 1));
		}
		else {
			st.add(x - 1, y);
		}
	}
	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int x;
  cin >> x;
  
  while (x > 100) {
    int k = x % 10;
    if (k > 5)
      k -= 5;
    if ((x / 10) % 10 != 0)
      k = 5;
    //cout << x << " - " << 100 + k << " = " << x - (100 + k) << endl;
    x -= 100 + k;
    if (x % 100 == 0)
      break;
  }
  
  if (x % 100 == 0)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		Integer N = sc.nextInt();
		Integer[] diameter = new Integer[N];
		for (int i = 0; i < diameter.length; i++) {
			diameter[i] = sc.nextInt();
		}
		Arrays.sort(diameter, Comparator.reverseOrder());
		int ans = 0;
		for (int i = 0; i < diameter.length; i++) {
			if (i != 0 && diameter[i - 1] == diameter[i])
				continue;
			ans++;
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 22736
def main():
    n = int(input())
    a = list(map(int, input().split()))
    dp=[]
    for i in range(n):
    	dp.append([0] * n)
    for i in range(n):
        dp[i][i] = a[i]

    for i in range(n - 2, -1, -1):
        for j in range(i + 1, n):
            dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])
    print(dp[0][n - 1])
main()

Measured memory_bytes: 112860
x,y = map(int,input().split())
c = 0
if x==1:
    c+=300000
elif x == 2:
    c+=200000
elif x == 3:
    c+=100000
    
if y==1:
    c+=300000
elif y == 2:
    c+=200000
elif y == 3:
    c+=100000

if x == 1 and y == 1:
    c+=400000
    
print(c)

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

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

	if (e - a <= k){
		cout << "Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}

	
	
	
	return 0;
}



Measured memory_bytes: 256
from collections import *

H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
xd = defaultdict(int)
yd = defaultdict(int)

for i in range(H):
    for j in range(W):
        xd[A[i][j]] = i
        yd[A[i][j]] = j

arr = [[] for _ in range(D)]

for i in range(D+1, H*W+1):
    arr[i%D].append(abs(xd[i]-xd[i-D])+abs(yd[i]-yd[i-D]))

acc = [[0] for _ in range(D)]

for i in range(D):
    for j in range(len(arr[i])):
        acc[i].append(acc[i][-1]+arr[i][j])
    
Q = int(input())

for _ in range(Q):
    L, R = map(int, input().split())
    
    if L%D==0:
        print(acc[0][R//D-1]-acc[0][L//D-1])
    else:
        print(acc[L%D][R//D]-acc[L%D][L//D])

Measured memory_bytes: 83816
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

const int N_MAX = 405;

int N;
long long A[N_MAX], prefix_sum[N_MAX];
long long dp[N_MAX][N_MAX];

int main() {
    scanf("%d", &N);
    prefix_sum[0] = 0;
    memset(dp, 63, sizeof(dp));

    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
        prefix_sum[i + 1] = prefix_sum[i] + A[i];
        dp[i][i] = 0;
        dp[i][i + 1] = A[i];
    }

    for (int i = N - 1; i >= 0; i--)
        for (int j = i + 2; j <= N; j++)
            for (int k = i + 1; k < j; k++)
                dp[i][j] = min(dp[i][j], prefix_sum[j] - prefix_sum[i] + dp[i][k] + dp[k][j]);

    printf("%lld\n", dp[0][N] - prefix_sum[N]);
}


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

using namespace std;

int main(){
        int N;
        cin>>N;
        vector <int> a(N);
        for(int i=0;i<N;i++){
                cin>>a[i];
        }
        int A=0, B=0;
        sort(a.rbegin(), a.rend());
        for(int i=0;i<N;i++){
                if(i%2==0){
                        A+=a[i];
                }
                else{
                        B+=a[i];
                }
        }
        cout<<A-B<<endl;
        return 0;
}


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

int h, w, s;
P memo[35][35][35][35];
int u[35][35];
int sum, diff;

struct CumulativeSum2D{
    vector<vector<int> > data;
    CumulativeSum2D(int H, int W) : data(H + 1, vector<int>(W + 1, 0)) {}
    //要素(x,y)に値zを加える
    void add(int x, int y, int z){
        ++x, ++y;
        if(x >= data.size() || y >= data[0].size()) return;
        data[x][y] += z;
    }
    void build(){
        for(int i = 1; i < data.size(); i++) {
        for(int j = 1; j < data[i].size(); j++) {
            data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
            }
        }
    }
    //左上[sy, sx], 右下(gy, gx)の矩形内の和を求める(半開区間) (0-index)
    int query(int sx, int sy, int gx, int gy){
        return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
    }
};

CumulativeSum2D cs(35, 35);

P solve(int y1, int x1, int y2, int x2){
    if(memo[y1][x1][y2][x2].first != -1) return memo[y1][x1][y2][x2];
    int inside = cs.query(y1, x1, y2, x2);    
    if(inside < diff) return memo[y1][x1][y2][x2] = {-1, -1};
    P res = {1, inside - diff};
    rep(i, y1 + 1, y2){
        P part1 = solve(y1, x1, i, x2);
        P part2 = solve(i, x1, y2, x2);
        if(part1.first == -1 || part2.first == -1) continue;
        int parts = part1.first + part2.first;
        int demand = min(part1.second, part2.second);
        if(res.first < parts){
            res = {parts, demand};
        }else if(res.first == parts && res.second < demand){
            res = {parts, demand};
        }
    }
    rep(i, x1 + 1, x2){
        P part1 = solve(y1, x1, y2, i);
        P part2 = solve(y1, i, y2, x2);
        if(part1.first == -1 || part2.first == -1) continue;
        int parts = part1.first + part2.first;
        int demand = min(part1.second, part2.second);
        if(res.first < parts){
            res = {parts, demand};
        }else if(res.first == parts && res.second < demand){
            res = {parts, demand};
        }
    }
    return memo[y1][x1][y2][x2] = res;
}


int main(){
    while(cin >> h >> w >> s, h){
        sum = 0;
        rep(i, 0, 35) rep(j, 0, 35) rep(k, 0, 35) rep(l, 0, 35) memo[i][j][k][l] = {-1, -1};
        rep(i, 0, 35) rep(j, 0, 35) cs.data[i][j] = 0;
        rep(i, 0, h){
            rep(j, 0, w){
                cin >> u[i][j];
                sum += u[i][j];
                cs.add(i, j, u[i][j]);
            }
        }
        cs.build();
        diff = sum - s;
        P ans = solve(0, 0, h, w);
        cout << ans.first << ' ' << ans.second << endl;
    }   
}


Measured memory_bytes: 14900
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	ll X, Y, Z;
	cin >> X >> Y >> Z;
	
	cout << ((X - Z) / (Y + Z)) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int arr[10005];
    for(int i=0;i<10005;i++)
    {
        arr[i]=0;
    }
    int n;
    cin>>n;
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                int ans=i*i+j*j+k*k+i*j+j*k+i*k;
                if(ans<=10005)
                    arr[ans]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<arr[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3184
# -*- coding: utf-8 -*-
import sys

def main():
	a, b, x = map(int,input().split(" "))
	
	tmp = b // x
	tmp2 = a // x
	ans = tmp -tmp2
	
	if a % x == 0: ans = ans + 1
	
	print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 2940
<?php
$n=trim(fgets(STDIN));
for($i=0;$i<$n;++$i){
    $name[$i] = trim(fgets(STDIN));
}

//１文字目がMARCHのどれかが何人いるか
$count=array(0,0,0,0,0);
foreach ($name as $word) {
    if ($word[0]==="M") {
        $count[0]++;
    }elseif ($word[0]==="A") {
        $count[1]++;
    }elseif ($word[0]==="R") {
        $count[2]++;
    }elseif ($word[0]==="C") {
        $count[3]++;
    }elseif ($word[0]==="H") {
        $count[4]++;
    }
}

/*
//条件の文字で0人の文字数
$countNull=0;
for ($i = 0; $i < 5; $i++) {
    if ($count[$i]===0) {
        $count[$i]=null;
        $countNull++;
    }
}
//print_r($count);
//echo($countNull);
if ($countNull>=3) {
    exit("0");
}
*/

//5C3の10通り
$combi[0]=$count[0]*$count[1]*$count[2];
$combi[1]=$count[0]*$count[1]*$count[3];
$combi[2]=$count[0]*$count[1]*$count[4];
$combi[3]=$count[0]*$count[2]*$count[3];
$combi[4]=$count[0]*$count[2]*$count[4];
$combi[5]=$count[0]*$count[3]*$count[4];
$combi[6]=$count[1]*$count[2]*$count[3];
$combi[7]=$count[1]*$count[2]*$count[4];
$combi[8]=$count[1]*$count[3]*$count[4];
$combi[9]=$count[2]*$count[3]*$count[4];

//print_r($combi);
echo(array_sum($combi));

?>

Measured memory_bytes: 21620
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int S, W;
  cin >> S >> W;

  if(S <= W) cout << "unsafe" << endl;
  else cout << "safe" << endl;

  return 0;
}


Measured memory_bytes: 3600