akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;
const int N = 1e5 +10 ;
const int inf = 0x3f3f3f3f ;
struct st{int p,b,c;};
bool operator < (st a,st b){return a.c>b.c;}
inline int read(){
    char c;int f=1 ;
    while ((c=getchar())<'0' || c>'9') if (c=='-') f=-1 ;
    int res=c-'0' ;
    while ((c=getchar())>='0' && c<='9') res=res*10+c-'0' ;
    return res*f ; 
}
map<int ,vector<int> > E[N] ; 
map<int,int > d[N] ; 
vector <int> G[N];
priority_queue <st> q ;
int n,m;
int main(){
    n=read();m=read() ;
    for (int i=1;i<=m;i++){
        int a,b,c ;
        a=read();b=read();c=read();a--;b-- ;
        E[a][c].push_back(b) ;E[b][c].push_back(a) ;
        G[a].push_back(c) ;G[b].push_back(c) ; 
    }
    d[0][0]=0;q.push({0,0,0}) ;
    while(!q.empty()){ //一波Dijkstra 
        st p=q.top();q.pop() ;
        if (d[p.p][p.b]!=p.c){
            continue ;
        }
        if (d[p.p].find(0)==d[p.p].end() || d[p.p][0]>p.c){
            d[p.p][0]=p.c ;
            q.push({p.p,0,p.c}) ;
        }
        if (p.b==0){
            for (int i=0;i<G[p.p].size();i++){
                int v=G[p.p][i] ;
                if (d[p.p].find(v)==d[p.p].end() || d[p.p][v]>p.c+1){
                    d[p.p][v]=p.c+1 ;
                    q.push({p.p,v,p.c+1}) ;
                 }
             }
            continue ; 
        }
        for (int i=0;i<E[p.p][p.b].size();i++){
            int v=E[p.p][p.b][i] ;
            if (d[v].find(p.b)==d[v].end() || d[v][p.b]>p.c){
                d[v][p.b]=p.c ;
                q.push({v,p.b,p.c}) ;
            }
        }
    }
    int ans=inf ;
    for (map<int,int>::iterator p=d[n-1].begin();p!=d[n-1].end();p++) ans=min(ans,p->second) ;
    if (ans==inf) printf("-1\n") ;
    else printf("%d\n",ans) ;
}

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

using namespace std;
#define ll long long
const int N = 1e5 + 5, mod = 1e9 + 7;

int dp[N];

int fp(int a, int p) {
    if (!p) return 1;
    int t = fp(a, p >> 1);
    t = (t * 1LL * t) % mod;
    if (p & 1) t = (t * 1LL * a) % mod;
    return t;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = k; i >= 1; i--) {
        dp[i] = fp(k / i, n);
        for (int j = i + i; j <= k; j += i) dp[i] = (dp[i] - dp[j] + mod) % mod;
        ans = (ans + (dp[i] * 1LL * i) % mod) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=101;
int n,B[MAXN];
int main()
{
	n=read();
	for(int i=1;i<n;++i)
		B[i]=read();
	int ans=0;
	for(int i=1;i<=n;++i)
	{
		if(i==1)
			ans+=B[i];
		else if(i==n)
			ans+=B[i-1];
		else
			ans+=min(B[i-1],B[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long getDigit(long long a){
long long cnt=0;
long long x=a;
while (x>=1){
   x /=10;
   cnt++; 
}
return cnt;
}

int main(){
    long long N;
    cin >> N;
    long long tmp1=getDigit(N);
    long long tmp2;
for (long long i=1;i<=sqrt(N);i++){
    if(N%i==0){
       tmp1=getDigit(N/i);
    }
}
cout << tmp1 <<endl;
return 0;
}

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

using namespace std;

int main()
{
    string s, result;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if((i + 1) % 2 == 1)
            result.push_back(s[i]);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
using namespace std;
int main() {
    while (true) {
        int a,b;
        char op;
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?') {
            break;
        } else if (op == '+') {
            printf("%d\n", a + b);
        } else if (op == '-') {
            printf("%d\n", a - b);
        } else if (op == '*') {
            printf("%d\n", a * b);
        } else {
            printf("%d\n", a / b);
        }
    }
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int sl = s.length();
    string k = "keyence";
    if (s == k) {
        cout << "YES" << endl;
        return 0;
    }
    rep(i, sl) {
        reps(ii, i, sl) {
            string tmp = s.substr(0, i) + s.substr(ii + 1);
            if (tmp == k) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

int N, K;

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

    veci n(N, 0);

    int ans = N;
    rep(i, K) {
        int d;
        cin >> d;
        rep(k, d) {
            int a;
            cin >> a;
            a--;
            if (n[a] == 0) ans--;
            n[a]++;
        }
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;
int main(){
 int n;
 string s;
 cin >> n;
 cin >> s;
int  ans=1;
if(n%2==1){
  ans=0;
}else{
for(int i=0;i<n/2;i++){
  if(s.at(i)!=s.at(i+(n/2))){
    ans=0;
  }
}

}


if(ans){
 cout << "Yes" <<endl; 
 }else{
   cout <<"No"<<endl;
 }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
// #define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 1e5 + 5;
ll dp[MAXN];
vector<ll> graph[MAXN];

ll dfs(ll u){
    ll &ans = dp[u];
    if(ans != -1) return dp[u];

    ans = 0;
    for(ll v:graph[u]){
        ans = max(ans,1+dfs(v));
    }
    return ans;
}

void solve(){
    memset(dp,-1,sizeof(dp));
    ll n,m; cin>>n>>m;

    FOR(i,1,m){
        ll u,v; cin>>u>>v;
        graph[u].push_back(v);
    }

    memset(dp,-1,sizeof(dp));
    ll ans = 0;
    FOR(i,1,n) ans = max(ans,dfs(i));
    cout<<ans<<endl;
}

signed main(){


    FastRead;    

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

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

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int cmp1(const void *a, const void *b){ // 昇順
    // qsort
    // http://www.cc.kyoto-su.ac.jp/~yamada/ap/qsort.html

    return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b){ // 降順
    // qsort
    // http://www.cc.kyoto-su.ac.jp/~yamada/ap/qsort.html

    return *(int*)b - *(int*)a;
}


int main() {
    int n,m;
    cin >> n >> m;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }
    sort(a,a+n);
    /*
    rep(i,n){
        cout << a[i];
    }
    */
    cout << endl;
    ll b[m][2];
    rep(i,m){
        cin >> b[i][1] >> b[i][0];
    }
    qsort(b, m, sizeof(b[0]), cmp1);
    /*
    rep(i,m){
        cout << b[i][0] << b[i][1];
    }
    */

    int count = 0;

    int now = m-1;
    int c = 0;
    ll ans = 0;
    rep(i,n){
        if(a[i]<b[now][0]){
            count++;
            c++;
            ans += b[now][0];
            if(c==b[now][1]){
                now--;
                c = 0;
            }
        }
        if(now<0){
            break;
        }
    }
    srep(i,count,n){
        ans += a[i];
    }
    
    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 4220
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#include <numeric>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET{IOSET(){cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> l(q), r(q);
    rep(i, q) {
        cin >> l[i] >> r[i];
        --l[i];
    }
    
    int d = (int)sqrt(n);
    vector<int> S(q);
    rep(i, q) S[i] = i;
    sort(all(S), [&](int a, int b) {
        if (l[a] / d != l[b] / d) return l[a] < l[b];
        return r[a] < r[b];
    });
    
    vector<int> ans(q, 0);
    vector<int> cnt(n + 1, 0);
    int sum = 0;
    rep(i, l[S[0]], r[S[0]]) {
        if (cnt[a[i]]++ == 0) ++sum;
    }
    ans[S[0]] = sum;
    rep(i, q - 1) {
        if (r[S[i]] < r[S[i + 1]]) {
            rep(j, r[S[i]], r[S[i + 1]]) {
                if (cnt[a[j]]++ == 0) ++sum;
            }
        } else {
            for (int j = r[S[i]] - 1; j >= r[S[i + 1]]; --j) {
                if (--cnt[a[j]] == 0) --sum;
            }
        }
        if (l[S[i]] < l[S[i + 1]]) {
            rep(j, l[S[i]], l[S[i + 1]]) {
                if (--cnt[a[j]] == 0) --sum;
            }
        } else {
            for (int j = l[S[i]] - 1; j >= l[S[i + 1]]; --j) {
                if (cnt[a[j]]++ == 0) ++sum;
            }
        }
        ans[S[i + 1]] = sum;
    }
    
    rep(i, q) cout << ans[i] << "\n";
}


Measured memory_bytes: 15480
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

void replace(string &s) {
    int a, b;
    string p;
    cin >> a >> b >> p;
    string x = s.substr(0, a);
    if (b+1 == s.size()) {
        s = x + p;
    }else {
        string y = s.substr(b+1, s.size()-x.size()-p.size());
        s = x + p + y;
    }
}

string sreverse(string s) {
    string a = "";
    REP(i,s.size()) {
        a += s[s.size()-1-i];
    }
    return a;
}

void reverse(string &s) {
    int a, b;
    cin >> a >> b;
    string x = s.substr(0, a);
    string z = s.substr(a, b+1-a);
    if (b+1 == s.size()) {
        s = x + sreverse(z);
    }else {
        string y = s.substr(b+1, s.size()-x.size()-z.size());
        s = x + sreverse(z) + y;
    }
}

void print(string s) {
    int a, b;
    cin >> a >> b;
    For(i,a,b+1) {
        cout << s[i];
    }
    cout << endl;
}

int main() {
    string s;
    int n;
    cin >> s >> n;
    REP(i,n) {
        string o;
        cin >> o;
        if (o == "replace") replace(s);
        else if (o == "reverse") reverse(s);
        else print(s);
    }
    return 0;
}

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

typedef long long ll;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

const int MAX_V =100000;
const ll INF = 1LL<<60;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i,G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int a, b, c, Q, K, x, y;
    cin >> V;
    rep(i, V - 1) {
        cin >> a >> b >> c;
        G[a - 1].push_back({b - 1, c});
        G[b - 1].push_back({a - 1, c});
    }
    cin >> Q >> K;
    dijkstra(K - 1);
    rep(i, Q) {
        cin >> x >> y;
        cout << d[x - 1] + d[y - 1] << "\n";
    }
}

Measured memory_bytes: 11120
#coding:utf-8

import math

datas = [float(x) for x in input().split()]
p1 = (datas[0], datas[1])
p2 = (datas[2], datas[3])

print(math.sqrt(math.pow(p1[0]-p2[0], 2)+math.pow(p1[1]-p2[1],2)))

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

#define int          long long
#define ld          long double
#define pb          push_back
#define pii         pair<int,int> 
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F         first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define mem(x)      memset(x,0,sizeof(x));
#define what_is(x)  cerr << #x << " is " << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)

using namespace std;

const int N=2e5+5;
int bit[N+1];

void update(int idx,int val){
    while(idx<N){
        bit[idx]=max(bit[idx],val);
        idx+=idx&(-idx);
    }
}

int query(int idx){
    int sum=0;
    while(idx>0){
        sum=max(sum,bit[idx]);
        idx-=idx&(-idx);
    }
    return sum;

}

void solve(){
    int n;
    cin>>n;
    int h[n],a[n];

    rep(i,0,n){
        cin>>h[i];
    }

    rep(i,0,n)cin>>a[i];

    

    int ans;
    rep(i,0,n){
        int y=query(h[i]);
        ans=max(ans,y+a[i]);

        update(h[i],y+a[i]);

        
        
    }

    cout<<ans<<endl;



}



signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
   

    int t=1,i=1;
    //cin>>t;
    

    while(t--){
       // cout<<"Case #"<<i++<<": ";
        solve();
    
    }

    return 0;
}

Measured memory_bytes: 4992
using System;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
            //using (var sr = new InputReader(new StreamReader("input.txt")))
            {
                var task = new Task();
                using (var sw = Console.Out) {
                    //using (var sw = new StreamWriter("output.txt")) {
                    task.Solve(sr, sw);
                    //Console.ReadKey();
                }
            }
        }
    }

    internal class Task
    {
        public void Solve(InputReader sr, TextWriter sw)
        {
            var input = sr.ReadArrayOfInt32();
            var a = input[0];
            var b = input[1];
            if (a % 3 == 0) {
                sw.WriteLine("Possible");
                return;
            }
            if (b % 3 == 0) {
                sw.WriteLine("Possible");
                return;
            }
            if ((a + b) % 3 == 0) {
                sw.WriteLine("Possible");
                return;
            }

            sw.WriteLine("Impossible");
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(NextString());
    }

    public long NextInt64()
    {
        return Int64.Parse(NextString());
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose) {
            if (dispose)
                sr.Close();
            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;

bool check(int n){
	int r=0;
	while(n!=0){
		r++,n/=10;
	}
	return  r%2==1;
}
int cnt;
void solve(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(check(i))cnt++;
	}
	cout<<cnt;
}
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int N=1e5+5;

int n,a;
int b[N];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a),b[a]=i;
	for(int i=1;i<n;i++)
		printf("%d ",b[i]);
	printf("%d\n",b[n]);
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int n,ans,num[23000001];
int mod=1e9+7;
inline void add(int &x, int y){
    x+=y;
    if(x>=mod) x-=mod;
}
int cheng(long long a,int b){
	long long sum=1;
	for(;b;b>>=1){
		if(b%2==1){
			sum=(sum*a)%mod;
		}
		a=(a*a)%mod;
	}
	return int(sum);
}
int main(){
	cin>>n;
	for(int i=1;i<=23000000;i++)num[i]=num[i/10]+1;
	int j=1,s=0;
	for(int i=1;i<1e7;i++){
		while(s<n){
			s+=num[j];
			j++;
		}
        if(s==n)ans=(ans+1)%mod;
        s-=num[i];
	}
	for(int i=1;i<=n/8;i++){
		if(n%i==0){
			add(ans,((cheng(10,n/i)-cheng(10,n/i-1)-i+1)%mod+mod)%mod);
		}
		else ans=(ans+1)%mod;
	}
	cout<<ans%mod;
}

Measured memory_bytes: 90112
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;



int main() {
    int x, n;
    cin >> x >> n;
    vector<bool> ds(102, false);
    rep(i, n){ 
        int p; cin >> p;
        ds[p] = true;
    }
    int dismin = numeric_limits<int>::max(); 
    int ans = 0;
    rep(p, 102){ 
        if (ds[p]) continue;
        int d = abs(p-x); 
        if (d < dismin) {
            dismin = d;
            ans = p;
        }
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
N,M = map(int,input().split())
G = dict([(i,[]) for i in range(1,N+1)])
for i in range(M):
  a,b = map(int,input().split())
  G[a].append(b)
  G[b].append(a)
#深さ優先探索  
l = [0]
def dfs(p,s):
  for i in G[p]:
    if s[i] == "0":
      a = s[:i] + "1" + s[i+1:]
      dfs(i,a)
  if s == "0" + N*"1":
    l[0] += 1
#捜査
s = "01"+(N-1)*"0"
    
dfs(1,s)
print(l[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}


int main(){
  ll N,K; cin >> N >> K;
  ll num[N];
  map<ll,ll> mp_count;
  ll a,b;
  REP(i,N){
    cin >>a>>b;
    num[i] = a;
    mp_count[a] +=b;
  }
  sort(num,num+N);
  ll r = 0;
  ll point=-1;
  ll left_size = 0;
  REP(i,N){
    ll n = num[i];
    if(n==point){continue;}
    point = n;
    left_size += mp_count[point];
    if(left_size>=K){r = point; break;}
  }
  printf("%d\n",r);
}

Measured memory_bytes: 4992
from collections import defaultdict

def main():
    num, color_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num - 1)]
    graph_data = defaultdict(set)
    mod = 10 ** 9 + 7

    for i in range(num - 1):
        a, b = data[i]
        graph_data[a].add(b)
        graph_data[b].add(a)

    ans_data = [0 for i in range(num + 1)]
    ans_data[1] = color_num % mod

    now_set = set()
    next_set = set()
    now_set.add(1)

    while len(now_set) > 0:
        for now_ele in now_set:
            if now_ele == 1:
                count = color_num - 1
            else:
                count = color_num - 2

            for next_ele in graph_data[now_ele]:
                if ans_data[next_ele] != 0:
                    continue
                if count <= 0:
                    ans_data[next_ele] = -1
                else:
                    ans_data[next_ele] = count % mod
                count -= 1
                next_set.add(next_ele)
        now_set = next_set
        next_set = set()

    ans = 1
    for i in range(1, num + 1):
        if ans_data[i] <= 0:
            ans = 0
            break
        ans *= ans_data[i]
        ans %= mod

    print(ans)












if __name__ == '__main__':
    main()


Measured memory_bytes: 108888
#include <iostream>
#include <iomanip>
#include <vector>
#include <complex>
#include <cmath>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
 
int lcm(int a,int b){
    return (a/gcd(a,b))*b;
}
 
int main(){
    int num,ans;
    int tmp[15];
    cin>>num;
    for(int i=0;i<num;i++){
        cin>>tmp[i];
    }
    ans=lcm(tmp[0],tmp[1]);
    for(int j=2;j<num;j++){
        ans=lcm(ans,tmp[j]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <tuple>
#include <queue>
#include <iomanip>

#define MOD (1000000007)
using namespace std;

typedef long long ll;

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

    vector<int> A(N, 0);
    for(int i = 1; i < N;i++) {
        int tmp;
        cin >> tmp;

        A[tmp-1]++;
    }

    for(int i = 0; i < N;i++) {
        cout << A[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{ll s,t,d; Edge(ll s,ll t,ll d):s(s),t(t),d(d){}};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;

int main() {
  ll N; cin>>N;
  vi a(N); REP(i,N) cin>>a[i];
  vi cnt(9);
  REP(i,N) {
    ll x=a[i];
    ll c;
    if(x<400) c=1;
    else if(x<800) c=2;
    else if(x<1200) c=3;
    else if(x<1600) c=4;
    else if(x<2000) c=5;
    else if(x<2400) c=6;
    else if(x<2800) c=7;
    else if(x<3200) c=8;
    else c=0;
    cnt[c]+=1;
  }
  ll x=0;
  FOR(i,1,9) if(cnt[i]) x+=1;
  cout<<max(1ll,x)<<' '<<x+cnt[0]<<endl;

}


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

string s;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    cin >> s;
    int n = s.size();
    for(int i = 0; i < (n - 1) / 2; ++i) {
        if(s[i] != s[n / 2 - 1 - i]) {
            cout << "No\n";
            return 0;
        }
        if(s[i] != s[n - 1 - i]) {
            cout << "No\n";
            return 0;
        }
    }
    for(int i = (n + 1) / 2; i < n; ++i) {
        if(s[i] != s[n + n / 2 - i]) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
B = sorted([int(i) for i in input().split()], reverse=True)
C = sorted([int(i) for i in input().split()], reverse=True)

a = []
for x in range(X):
    for y in range(Y):
        for z in range(Z):
            if ((x + 1) * (y + 1) * (z + 1) <= K):
                a.append(A[x] + B[y] + C[z])
            else:
                break

for b in sorted(a, reverse=True)[:K]:
    print(b)


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

using namespace std;

string target;
int ans;

bool judge();

int main()
{
  int n;
  cin >> n;
  cin >> target;
  for(int i = 0; i < n; i++)
  {
    if(judge())
      ans++;
  }
  cout << ans << endl;
}

bool judge()
{
  string input;
  cin >> input;
  for(int i = 0; i < input.length(); i++)
  {
    if(input[i] == target[0])
    {
      for(int j = 1; j < input.length(); j++)
      {
        if(input[j + i] == target[1])
        {
          for(int k = 2; k < target.length(); k++)
          {
            if(i + k * j >= input.length() || target[k] != input[i + k * j])
              goto skip;
          }
          return true;
        skip:;
        }
      }
    }
  }

  return false;
}

Measured memory_bytes: 1208
import java.io.*;
import java.util.Arrays;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int in[] = parseInts(br.readLine().split(" "));
		int in1[][] = new int[in[0]][in[1]];
		int in2[] = new int[in[1]];
		for(int i=0; i<in[0]; i++){
			in1[i] = parseInts(br.readLine().split(" "));
		}
		for(int n=0; n<in[0]; n++){
			for(int m=0; m<in[1]; m++){
				in2[m] += in1[n][m];
				System.out.print(in1[n][m] + " ");
			}
			System.out.println(sum(in1[n]));
		}
		for(int i=0; i<in[1]; i++){
			System.out.print(in2[i] + " ");
		}
		System.out.println(sum(in2));
	}
	static int[] parseInts(String[] s){
		int[] x = new int[s.length];
		for(int i=0; i<s.length; i++){
			x[i] = Integer.parseInt(s[i]);
		}
		return x;
	}
	static int sum(int[] x){
		int t = 0;
		for(int a : x){
			t += a;
		}
		return t;
	}
}

Measured memory_bytes: 25492
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <vector>
#include <set>
#include <map>

#define PI (3.14159265358979323846)
#define INF (1e+9)
#define DV_NUM (100000007)
#define MAX (1e+18)

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main()
{
    long N,K;
    cin >> N >> K;

    long idx = N/K;

    long min1 = N - K * (long)idx;
    long min2 = K*((long)idx+1)-N;

    long ans = min(min1,min2);

    cout << ans << endl;
    
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
const double PI = 3.14159265359;
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define INF 1000000000000
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
int arr[100001];
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
ll n,q,sum=0;
cin>>n;
ll a[n];
FOR(i,n)
{
	cin>>a[i];
	sum+=a[i];
	arr[a[i]]++;
}
cin>>q;
ll b[q],c[q];
FOR(i,q)
{
	cin>>b[i]>>c[i];
if(arr[b[i]]>0)
     {
     	sum+=(c[i]-b[i])*arr[b[i]];
     	
     	arr[c[i]]+=arr[b[i]];
     	arr[b[i]]=0;
     	
	 }
	 cout<<sum<<endl;
}


return  0;
}






Measured memory_bytes: 6312
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const string MINUSINF="-";

void chmax(string &a,string b){
    if(a==MINUSINF)a=b;
    else if(a.size()<b.size())a=b;
    else if(a.size()==b.size()){
        if(a<b)a=b;
    }
}

long long match[10]={2,5,5,4,5,6,3,7,6};
string dp[11000];

int main(){
    int N,M;cin>>N>>M;
    vector<int>A(M);
    for(int i=0;i<M;i++)cin>>A[i];
    for(int i=0;i<11000;i++)dp[i]=MINUSINF;
    dp[0]="";
    for(int i=0;i<=N;i++){
        if(dp[i]==MINUSINF)continue;
        for(auto a:A) chmax(dp[i+match[a-1]],dp[i]+(char)('0'+a));

    }
    cout<<dp[N]<<endl;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	cout << (a + b) % 24 << endl;
	
	return 0;
}


Measured memory_bytes: 764
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        var t = Console.ReadLine().Split(' ');
        int X = int.Parse(t[0]);
        int A = int.Parse(t[1]);
        if (X < A)
            Console.WriteLine(0);
        else
            Console.WriteLine(10);
    }
}

Measured memory_bytes: 11220
use whiteread::parse_line;

fn main() {
    let (a, b, c): (usize, usize, usize) = parse_line().unwrap();
    let mut abc = vec![a, b, c];

    if abc.iter().any(|x| x % 2 == 0) {
        println!("0");
    } else {
        abc.sort();
        println!("{}", abc[0] * abc[1]);
    }
}


Measured memory_bytes: 2152
using System;

class MyClass
{
    static void Main(string[] args)
    {
        int n;
        while ((n = int.Parse(Console.ReadLine())) != 0)
        {
            int robotx = 10;
            int roboty = 10;
            int[] x = new int[n];
            int[] y = new int[n];
            bool[] get = new bool[n];
            for (int i = 0; i < n; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                x[i] = int.Parse(str[0]);
                y[i] = int.Parse(str[1]);
                get[i] = false;
            }
            int m = int.Parse(Console.ReadLine());
            for (int i = 0; i < m; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                int move = int.Parse(str[1]);
                if (str[0] == "N")
                {
                    for (int j = 1; j <= move; j++)
                    {
                        for (int k = 0; k < n; k++)
                        {
                            if (x[k] == robotx && y[k] == roboty+j)
                            {
                                get[k] = true;
                            }
                        }
                    }
                    roboty += move;
                }
                else if (str[0] == "S")
                {
                    for (int j = 1; j <= move; j++)
                    {
                        for (int k = 0; k < n; k++)
                        {
                            if (x[k] == robotx && y[k] == roboty-j)
                            {
                                get[k] = true;
                            }
                        }
                    }
                    roboty -= move;
                }
                else if (str[0] == "E")
                {
                    for (int j = 1; j <= move; j++)
                    {
                        for (int k = 0; k < n; k++)
                        {
                            if (x[k] == robotx + j && y[k] == roboty)
                            {
                                get[k] = true;
                            }
                        }
                    }
                    robotx += move;
                }
                else if (str[0] == "W")
                {
                    for (int j = 1; j <= move; j++)
                    {
                        for (int k = 0; k < n; k++)
                        {
                            if (x[k] == robotx - j && y[k] == roboty)
                            {
                                get[k] = true;
                            }
                        }
                    }
                    robotx -= move;
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (!get[i])
                {
                    get[0] = false;
                }
            }
            if (get[0])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010
#define lb lower_bound 

/*
約数列挙 N=2*10^5
普通にやるとO(N*N)になってしまってどうしよう
j*j<=NにすることでO(N*sqrt(N))にできる
*/

int main()
{
  int n;cin>>n;
  vector<ll> a(n);
  vector<ll> used(1000020,0);
  for (int i=0;i<n;i++)
  {
    cin>>a[i]; 
    used[a[i]]++;
  }
  
  ll count=0;
  for (int i=0;i<n;i++)
  {
    //Nの約数を列挙するよ！
    ll N = a[i]; 
    vector<ll> d(0,0);
    for (int j=1;j*j<=N;j++)
    {
      if (N%j==0)
      {
        d.push_back(j);//1,2,3...
        if (N/j == j) continue;
        d.push_back(N/j);//60,30,20...
      }
    }
    int flag=1;
    for (auto x : d)
    {
      if (x < N && used[x]>0) flag=0;
      if (x == N && used[x]>1) flag=0;
    }
    if (flag==1)
    {
      count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 12704
import std.stdio, std.algorithm, std.range, std.conv, std.string, std.math;
import core.stdc.stdio, core.bitop;
// foreach, foreach_reverse, writeln

void main() {
	int n, MOD;
	scanf("%d%d", &n, &MOD);
	
	long[][] c = new long[][](n+1,n+2);
	c[0][0] = 1;
	foreach (i; 0..n) {
		foreach (j; 0..i+1) {
			(c[i+1][j] += c[i][j]) %= MOD;
			(c[i+1][j+1] += c[i][j]) %= MOD;
		}
	}

	long[][] dp = new long[][](n+1,n+1);
	dp[0][0] = 1;
	foreach (i; 0..n) {
		foreach (j; 0..n+1) {
			(dp[i+1][j] += dp[i][j]) %= MOD;
			(dp[i+1][j] += dp[i][j]*j) %= MOD;
			if (j != n) (dp[i+1][j+1] += dp[i][j]) %= MOD;
		}
	}

	//long pow(long x, long times, long MOD) {
	//	long ret = 1;
	//	while (times) {
	//		if (times&1) (ret *= x) %= MOD;
	//		times >>= 1;
	//		(x *= x) %= MOD;
	//	}
	//	return ret;
	//}
	//long powpow(long x, long y, long MOD) {
	//	foreach (i; 0..y) {
	//		(x *= x) %= MOD;
	//	}
	//	return x;
	//}

	long[] p2 = new long[n+1];
	p2[0] = 1;
	foreach (i; 0..n) p2[i+1] = p2[i]*2%MOD;

	long[] pp2 = new long[n+1];
	pp2[0] = 2;
	foreach (i; 0..n) pp2[i+1] = pp2[i]*pp2[i]%MOD;

	long ans = 0;
	foreach (i; 0..n+1) {
		long cur = 0;
		long two = 1;
		foreach (j; 0..i+1) {
			long a = dp[i][j]*c[n][i]%MOD;
			//long x = powpow(2,n-i,MOD)*pow(pow(2,n-i,MOD),j,MOD)%MOD;
			long x = pp2[n-i]*two%MOD;
			(cur += a*x) %= MOD;
			(two *= p2[n-i]) %= MOD;
		}
		if (i%2 == 0) {
			ans += cur;
		} else {
			ans += MOD-cur;
		}
		ans %= MOD;
	}
	writeln(ans);
}

Measured memory_bytes: 146556
n=int(input())
hh=list(map(int,input().split()))
ans=0
while 1:
    l=0
    while l<n and hh[l]==0:l+=1
    if l==n:break
    r=l
    while r<n and hh[r]>0:r+=1
    mn=min(hh[l:r])
    for i in range(l,r):hh[i]-=mn
    ans+=mn
print(ans)


Measured memory_bytes: 3060
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    input! {
        mut a:usize,
        mut b:usize,
        k:usize,
    }

    for i in 0..k {
        if i % 2 == 0 {
            a /= 2;
            b += a;
        } else {
            b /= 2;
            a += b;
        }
    }

    println!("{} {}", a, b);
}


Measured memory_bytes: 2156
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b)
    {
        cout << c << endl;
    }
    else if (a == c)
    {
        cout << b << endl;
    }
    else
    {
        cout << a << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
class Integer
  def divisor
    res = []
    1.upto((self**0.5)) do |i|
      if self % i == 0
        res.push i
        res.push self / i if i != self / i
      end
    end
    res.sort
  end
end

def answer_if_valid(x, a, d)
  b = a - d
  if x == a ** 5 - b ** 5
    puts "#{a} #{b}"
    exit
  end
end

x = gets.to_s.to_i

r = x % 5

x.divisor.select{|t| r == t % 5}.each do |d|
  (-200..200).each{ |a| answer_if_valid(x, a, d) }
end


Measured memory_bytes: 14764
#include <bits/stdc++.h>
using namespace std;
int main() {
 int W,H,N;
 cin >> W >> H >> N;
 vector<int> x(N);
 vector<int> y(N);
 vector<int> a(N);
 vector<vector<bool> > S(W, vector<bool>(H,false));
 for (int i = 0; i < N; i++) {
   cin >> x[i] >> y[i] >> a[i];
 }
 for (int i = 0; i < N; i++) {
   if (a[i] == 1) {
     for (int j = x[i] - 1; j >= 0; j--) {
       for (int k = 0; k < H; k++) {
         S[j][k] = true;
       }
     }
   }
   else if (a[i] == 2) {
     for (int j = x[i]; j < W; j++) {
       for (int k = 0; k < H; k++) {
         S[j][k] = true;
       }
     }
   }
   else if (a[i] == 3) {
     for (int j = y[i] - 1; j >= 0; j--) {
       for (int k = 0; k < W; k++) {
         S[k][j] = true;
       }
     }
   }
   else if (a[i] == 4) {
     for (int j = y[i]; j < H; j++) {
       for (int k = 0; k < W; k++) {
         S[k][j] = true;
       }
     }
   }
 }
 int ans = 0;
 for (int i = 0; i < W; i++) {
   for (int j = 0; j < H; j++) {
     if (S[i][j] == false) {
       ans++;
     } 
   }
 }
 cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  long long a[n][m];
  long long b[m];
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cin >> a[i][j];
    }
  }
  for (int j = 0; j < m; j++)
  {
    cin >> b[j];
  }

  for (int i = 0; i < n; i++)
  {
    long long c = 0;
    for (int j = 0; j < m; j++)
    {
      c += (a[i][j] * b[j]);
    }
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 3104
n = gets.chomp.to_i
v = []
n.times do |i|
 (a, b, c) = gets.chomp.split(" ")
 a = a.to_i
 b = b.to_i
 c = c.to_i

 if c>b && c>a && a*a + b*b == c*c
  v[i] = 'YES'
 elsif a<b && b>c && a*a + c*c == b*b
  v[i] = 'YES'
 elsif b<a && c<a && b*b + c*c == a*a
  v[i] =  'YES'
 else
  v[i] = 'NO'
 end
end

n.times do |i|
  puts v[i]
end

Measured memory_bytes: 8768
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());
#define vunique(v) unique(v.begin(), v.end());

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	int count = 1;
	int a, b, c, d;
	a = N / 1000;
	N %= 1000;
	b = N / 100;
	N %= 100;
	c = N / 10;
	N %= 10;
	d = N;
	bool flag = true;
	if(a == b and a == c) flag = false;
	if(b == c and b == d) flag = false;
	if(flag) cout << "No" << endl;
	else cout << "Yes" << endl;
}


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

int N, M;
vector<vector<int> > adj;

int cnt, odd;
vector<int> col;
void dfs(int u, int c) {
    cnt++;
    col[u] = c;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(col[v] != -1) {
            if(col[v] == col[u]) odd = 1;
            continue;
        }
        dfs(v, c ^ 1);
    }
}

int a, b, c;
int main() {
    scanf("%d %d", &N, &M);
    adj.resize(N);
    for(int i = 0; i < M; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    col = vector<int>(N, -1);
    a = b = c = 0;
    for(int i = 0; i < N; i++) {
        if(col[i] == -1) {
            cnt = odd = 0;
            dfs(i, 0);
            if(cnt == 1) a++;
            else if(odd) b++;
            else c++;
        }
    }

    long long ans = 0;
    ans += 2LL * a * (N - a) + 1LL * a * a;
    ans += 1LL * b * b;
    ans += 2LL * c * c;
    ans += 2LL * b * c;
    printf("%lld", ans);
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

using namespace std;
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}

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

          int t=1;
          //cin>>t;
          while(t--)
          {
                    string s;
                    ll sum=0;
                    cin>>s;
                    for(int i=0;i<s.size();++i)
                         sum += s[i]-'0';
                    if(sum%9==0)
                         cout<<"Yes";
                    else
                         cout<<"No";
          }
          return 0;
}


Measured memory_bytes: 3756
#include <iostream>

int main()
{
    int w, n;
    std::cin >> w >> n;

    int state[30] = {};
    for (int i = 0; i < w; ++i) state[i] = i + 1;

    for (int i = 0; i < n; ++i) {
        int a, b;
        char comma;
        std::cin >> a >> comma >> b;
        int tmp = state[a - 1]; state[a - 1] = state[b - 1]; state[b - 1] = tmp;
    }

    for (int i = 0; i < w; ++i) std::cout << state[i] << std::endl;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int count = 0;
        int[] f = new int[5];
        for (int i = 0; i < 10; i++) {
            if(a % 10 != 0) a++;
            else {
                f[0] = i;
                break;
            }
        }
        for (int i = 0; i < 10; i++) {
            if(b % 10 != 0) b++;
            else {
                f[1] = i;
                break;
            }
        }
        for (int i = 0; i < 10; i++) {
            if(c % 10 != 0) c++;
            else {
                f[2] = i;
                break;
            }
        }
        for (int i = 0; i < 10; i++) {
            if(d % 10 != 0) d++;
            else {
                f[3] = i;
                break;
            }
        }
        for (int i = 0; i < 10; i++) {
            if(e % 10 != 0) e++;
            else {
                f[4] = i;
                break;
            }
        }
        Arrays.sort(f);
        int max = f[4];
        int ans = a + b + c + d + e - max;
        System.out.println(ans);
    }
}

Measured memory_bytes: 35552