akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class Main {
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
    	
    	int N = sc.nextInt();
    	int[] A = new int[N];
    	
    	int mnum = 0;
    	boolean iszero = false;
    	long a = 0;
    	
    	for(int i=0;i<N;i++){
    		int p = sc.nextInt();
    		A[i] = Math.abs(p);
    		if(p<0){
    			mnum += 1;
    		}
    		if(p==0){
    			iszero = true;
    		}
    	}
    	
    	if(mnum%2 == 0 || iszero == true){
    		for(int i=0;i<N;i++){
    			a += A[i];
    		}
    		
        	System.out.println(a);
    	}
    	else{
    		Arrays.sort(A);
    		for(int i=1;i<N;i++){
    			a += A[i];
    		}
			a -= A[0];
        	System.out.println(a);
    	}
    	
    }
    
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

int main(){
  int n, l;
  cin >> n >> l;
  vector<string>s(n);
  for(int i = 0; i<n; i++)
    cin >> s.at(i);
  
  sort(s.begin(), s.end());
  
  for(int i = 0; i<n; i++)
    cout << s.at(i);
  cout << endl;
}

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

int main()
{
	int sum,l;
	string s;
	cin >> s;
	sum = 0;
	for (int i = 1; i < s.length(); i++)
	{
		if (s[i - 1] == s[i])
		{
			sum++;
			if (s[i - 1] == '1')
				s[i] = '0';
			else s[i] = '1';
		}

	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class Seg_sum():
    def __init__(self,x):
        #####単位元######
        self.ide_ele_min = 0
        self.func = lambda a,b : a+b

        self.n = len(x)

        #num_max:n以上の最小の2のべき乗
        self.num_max =2**(self.n-1).bit_length()
        self.x = [self.ide_ele_min]*2*self.num_max

        for i,num in enumerate(x, self.num_max):
            self.x[i] = num
        for i in range(self.num_max-1,0,-1):
            self.x[i] = self.func(self.x[i<<1],self.x[(i<<1) + 1])

    def update(self,i,x):
        i += self.num_max
        self.x[i] = x
        while(i>0):
            i = i//2
            self.x[i] = self.func(self.x[i<<1],self.x[(i<<1) + 1])

    def query(self,i,j):
        res = self.ide_ele_min
        if i>=j:
            return res
        i += self.num_max
        j += self.num_max -1
        while(i<=j):
            if(i==j):
                res = self.func(res,self.x[i])
                break
            if(i&1):
                res = self.func(res,self.x[i])
                i += 1
            if(not j&1):
                res = self.func(res,self.x[j])
                j -= 1
            i = i>>1
            j = j>>1
        return res

n,q = map(int,readline().split())
c = tuple(map(int,readline().split()))
lr = tuple(map(int,read().split()))
it = iter(lr)
lrq = [[] for _ in range(n)]
for i,l,r in zip(range(q),it,it):
    lrq[r-1].append((l-1,i))

st = Seg_sum([1]*(n+1))
ans = [0] * q
before = [-1] * (n+1)
c_ind = 0
for r in range(n):
    for l,i in lrq[r]:
        while(c_ind <= r):
            bef = before[c[c_ind]]
            if(bef!=-1):
                st.update(bef,0)
            before[c[c_ind]] = c_ind
            c_ind += 1

        ans[i] = st.query(l,r+1)

print('\n'.join(map(str,ans)))

Measured memory_bytes: 245684
#include <cstdint>
#include <cstdio>

#include <atcoder/math>

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

  for (int i = 0; i < t; ++i) {
    int n, m, a, b;
    scanf("%d %d %d %d", &n, &m, &a, &b);
    printf("%lld\n", atcoder::floor_sum(n, m, a, b));
  }
}


Measured memory_bytes: 1704
#include<stdio.h>
#include<math.h>
#include<limits.h>
#include<assert.h>
#include<stdbool.h>
#include<stddef.h>
#include<stdint.h>
#include<string.h>
#include<unistd.h>
#include<stdlib.h>

#include<ctype.h>
#include<time.h>
typedef long long ll;
#define pi 3.14159
int main()
{ 
int x,y;
scanf("%d %d",&x,&y);
printf("%d\n",6-x-y);



return 0;
}

Measured memory_bytes: 128
<?php 
  $array = explode(" ", trim(fgets(STDIN)));
  $ways = array($array[0], $array[1]);
  sort($ways);
  list($a, $b) = $ways;
  $c = $array[2];
  $answer = $a < $c && $c < $b ? "Yes" : "No";
  echo $answer;
  echo "\n";
 ?>

Measured memory_bytes: 3828
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::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;
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

constexpr int M = 1000;
constexpr int N = 30000;
char str[N+10];
std::bitset<M> F, S, A;


int main(void){
    int n; scanf("%d%s", &n, str);
    REP(i, n){
        int c = str[i] - '0';
        A |= (S << c);
        S |= (F << (10 * c));
        F[100 * c] = true;
    }
    const int m = A.count();
    printf("%d\n", m);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    String s = sc.next();
    if (a >= 3200) {
      System.out.println(s);
    } else {
      System.out.println("red");
    }
  }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

// UnionFind
struct UnionFind {
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll N) : par(N), siz(N, 1LL) {
        for(int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x) {
        if(par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)
            return;
        if(siz[rx] < siz[ry])
            swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x) { return siz[root(x)]; }
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    vector<pii> query(M);
    UnionFind uf(N);
    map<int, set<int>> mp;
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        query[i] = MP(x, y);
        uf.unite(x, y);
    }
    rep(i, N) { mp[uf.root(i)].insert(i); }
    int res = 0;
    rep(i, N) {
        if(mp[uf.root(i)].count(P[i] - 1))
            res++;
    }
    cout << res << endl;
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL n, m;cin >> n >> m;
    vector<pair<LL, LL>> v;
    inc(i, 0, n){
        LL a, b;cin >> a >> b;
        v.pb({a, b});
    }
    sort(v.begin(), v.end());
    LL ans = 0;
    inc(i, 0, n){
        if(m >= v[i].se){
            ans += v[i].fi*v[i].se;
            m -= v[i].se;
        }else{
            ans += m*v[i].fi;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int MOD = 1000000007;
const int N = 200005;

int n;
int a[N];

int solve() {
  scanf("%d", &n);

  int prod = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);

    ans = (ans + 1LL * a[i] * prod) % MOD;
    prod = (prod + a[i]) % MOD;
  }
  printf("%d\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


Measured memory_bytes: 4528
while True:
    N = int(raw_input())

    if N == 0: break

    W, H = map(int, raw_input().split())
    table = [[0 for i in range(H)] for j in range(W)]

    for i in range(N):
        x, y = map(int, raw_input().split())
        x -= 1; y -= 1;

        table[x][y] = 1

    S, T = map(int, raw_input().split())
    ans = -1

    for x in range(W-S+1):
        for y in range(H-T+1):
            t = 0
            for i in range(S):
                for j in range(T):
                    if table[i+x][j+y] == 1:
                        t += 1

            ans = max(ans, t)

    print ans



Measured memory_bytes: 4796
#include<iostream>
#include <string>
#include<vector>
typedef long long ll;

using namespace std;
int main()
{
	int n, t, a;
	cin >> n;
	cin >> t >> a;
	vector<int> hs(n);
	for (int i = 0; i < n; i++) {
		cin >> hs[i];
	}
	double sa_min=1000;
	int kotae;
	for (int i = 0; i < n; i++) {
		double sa;
		if (1.0*a - (1.0*t - 0.006*hs[i]) > 0){
			sa= 1.0*a - (1.0*t - 0.006*hs[i]);
		}
		else {
			sa = -(1.0*a - (1.0*t - 0.006*hs[i]));
		}
		if (sa <= sa_min) {
			sa_min = sa;
			kotae = i + 1;
		}
	}
	cout << kotae;
	return 0;
}

Measured memory_bytes: 256
N, K = gets.chop.split.map(&:to_i)
h = []
N.times { h << gets.to_i }
h.sort!
min = h[K-1] - h[0]
i = 1
while i + K <= N
  if min > h[i+K-1] - h[i]
    min = h[i+K-1] - h[i]
  end
  i += 1
end
puts min


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

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> f(h);
    rep (i, h)
        cin >> f[i];

    vector<bool> hDel(h, false);
    vector<bool> wDel(w, false);
    rep (i, h)
    {
        bool ok = true;
        rep (j, w)
        {
            if (f[i][j] == '#')
            {
                ok = false;
                break;
            }
        }
        if (ok)
            hDel[i] = true;
    }
    rep (i, w)
    {
        bool ok = true;
        rep (j, h)
        {
            if (f[j][i] == '#')
            {
                ok = false;
                break;
            }
        }
        if (ok)
            wDel[i] = true;
    }

    rep (i, h)
    {
        if (hDel[i] == true)
            continue;
        rep (j, w)
        {
            if (wDel[j] == true)
                continue;
            cout << f[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <atcoder/all>

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
using namespace atcoder;

signed main(){
	fastio
	int n;
	cin >> n;
	while(n--){
		int n,m,a,b;
		cin >> n >> m >> a >> b;
		cout << floor_sum(n,m,a,b) << "\n";
	}
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 5e3 + 5;
const int mod = 1e9 + 7;
int n, m;
int f[maxn][maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> m;
    for(int i = 0 ; i <= m ; ++i)f[0][i] = 1;
    for(int i = 1 ; i <= n ; ++i){
        for(int j = 1 ; j <= m ; ++j){
            f[i][j] = (f[i][j - 1] * 2 + (ll)f[i - 1][j - 1] * (j - 1)) % mod;
        }
        for(int j = 1 ; j <= m ; ++j){
            f[i][j] = (f[i][j] + (ll)f[i - 1][j] * (j + 1)) % mod;
        }
    }
    cout << f[n][m];
}



Measured memory_bytes: 101404
#include<bits/stdc++.h>
using namespace std;
struct node {
  struct node* left;
  int idx;
  struct node* right;
};

int main(){
  int n, k, m;
  node list[10000], *root;

  while(cin >> n >> k >> m, n){
    for(int i = 0; i < n; i++){
      list[i].left = &list[(i + n - 1) % n];
      list[i].idx = i + 1;
      list[i].right = &list[(i + 1) % n];
      if(list[i].idx == m) root = &list[i];
    }
    while(root != root -> right){
      root -> left -> right = root -> right;
      root -> right -> left = root -> left;
      for(int i = 0; i < k; i++) root = root -> right;
    }
    cout << root -> idx << endl;
  } 
}

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

int main(){
  long n;
  long* a;
  long i;
  long t;
  std::cin >> n;
  a = new long[n];
  t = 0;
  for(i=0;i<n;i++){
    std::cin >> a[i];
    t = t ^ a[i];
  }
  for(i=0;i<n;i++){
    std::cout << (a[i] ^ t) << " ";
  }
    std::cout << std::endl;
    
}

Measured memory_bytes: 5188
N = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
ary = [a,b,c,d,e]
# ind_min = ary.index(min(ary))
# cnt = 
if N % min(ary) == 0:
    print(int(N/min(ary)+4))
else:
    print(int(N/min(ary)+5))


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

int main(){
  int n;
  cin >> n;
  vector<int> s(n),p(n);
  for (int i=0;i<n;++i) cin >> p[i];
  
  for (int i=0;i<n;++i){
      s[i]=p[i];
  }
  sort(s.begin(),s.end());
  int cnt=0;
  for (int i=0;i<n;++i){
    while (s[i]==p[i]){
      swap(p[i],p[i+1]);
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>

using namespace std;

int main(){
    unsigned long long int n;
    vector<char> name;
    int namelen = 0;

    scanf("%llu", &n);
    // n--;

    // if(n == 0){
    //     name.insert(name.begin(), 0);
    //     namelen++;
    // }
    while(n > 0){
        // auto nametop = name.begin();
        char c = (n-1)%26;
        name.insert(name.begin(), c);
        namelen++;
        // printf("%d %d %c %llu\n", name[namelen-1], c, c + 'a', n);
        n = (n-1)/26;
    }

    for(auto i = 0; i < namelen; ++i){
        printf("%c", name[i] + 'a');
    }

    // if(namelen > 1){
    //     printf("%c", name[0] + 'a' - 1);
    //     for(auto i = 1; i < namelen; ++i){
    //         printf("%c", name[i] + 'a');
    //     }
    // }else{
    //     printf("%c", name[0] + 'a');
    // }

    printf("\n");
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll N,T;
    cin >> N >> T;

    vector<ll> t(N);
    rep(i,N) cin >> t[i];

    ll ans = 0;
    rep(i,N-1)
    {
        if( t[i+1] - t[i] < T ) ans += t[i+1] - t[i];
        else ans += T;
    }
    cout << ans+T << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

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

    vvl G(n);  // 辺の重みがすべて1のグラフ
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    ll ans = 0;
    rep(v, n) {
        bool ok = true;
        for(auto u : G[v]) {
            if(h[v] <= h[u]) {
                ok = false;
            }
        }
        if(ok) {
            ans++;
        }
    }

    out(ans);
    re0;
}

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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;




int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);


	int n; cin >> n;

	string str;
	cin >> str;
	int S = str.length();

	int ans = 0;

	rep(i, S - 2) {
		if (str.substr(i, 3) == "ABC") ans++;

	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    int n,q;
    cin >> n >> q;
    vector<int> value(n+1);
    vector<vector<int>> G(n+1);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,q){
        int a,b;
        cin >> a >> b;
        value[a] += b;
    }

    queue<int> que;
    que.push(1);
    vector<bool> seen(n+1,false);
    while(que.size() != 0){
        int v = que.front();
        que.pop();
        seen[v] = true;

        for(auto nv : G[v]){
            if(seen[nv]) continue;
            value[nv] += value[v];
            que.push(nv);
        }
    }

    for(int i = 1;i <= n;i++) cout << value[i] << " ";
    cout << endl;

}


Measured memory_bytes: 16484
arr = 3.times.map{ gets.split.map(&:to_i) }
n = gets.to_i
n.times do
  num = gets.to_i
  arr.each_with_index do |row, y|
    row.each_with_index do |ele, x|
      arr[y][x] = 0 if ele == num
    end
  end
end
arr.each do |row|
  if row.all?{|v| v == 0 }
    puts 'Yes'
    exit
  end
end
arr.transpose.each do |column|
  if column.all?{|v| v == 0 }
    puts 'Yes'
    exit
  end
end
result = []
arr.each_with_index do |row, y|
  row.each_with_index do |ele, x|
    if x == y
      result << ele
    end
  end
end
if result.all?{|v| v == 0 }
  puts 'Yes'
  exit
end
result2 = []
arr.each_with_index do |row, y|
  row.each_with_index do |ele, x|
    if x + y == 2
      result2 << ele
    end
  end
end
if result2.all?{|v| v == 0 }
  puts 'Yes'
  exit
end
puts 'No'

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, m, n) for (int i = m; i < n; i++)
using T = tuple<int, int, int>;

int main() {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--;
  cw--;
  dh--;
  dw--;
  vector<string> s(h);
  for (string &i : s) cin >> i;
  vector<vector<int>> l(h, vector<int>(w, -1));
  deque<tuple<int,int,int>> q;
  q.push_back({ch, cw, 0});
  while (!q.empty()) {
    auto [gh, gw, gl] = q.front();
    q.pop_front();
    if (l[gh][gw] != -1) continue;
    l[gh][gw] = gl;
    if (gh + 1 < h and s[gh + 1][gw] == '.') q.push_front({gh + 1, gw, gl});
    if (gh - 1 >= 0 and s[gh - 1][gw] == '.') q.push_front({gh - 1, gw, gl});
    if (gw + 1 < w and s[gh][gw + 1] == '.') q.push_front({gh, gw + 1, gl});
    if (gw - 1 >= 0 and s[gh][gw - 1] == '.') q.push_front({gh, gw - 1, gl});
    FOR(i, -2, 3) FOR(j, -2, 3) {
      int nh = gh + i, nw = gw + j;
      if (0 <= nh and nh < h and 0 <= nw and nw < w and s[nh][nw] == '.') q.push_back({nh, nw, gl + 1});
    }
  }
  cout << l[dh][dw] << endl;
  return 0;
}

Measured memory_bytes: 10668
#include<bits/stdc++.h>
#define ri register int
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long Ull;
#define fi first
#define se second
#define pb push_back
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read(){
	int ans=0;
	char ch=gc();
	while(!isdigit(ch))ch=gc();
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	return ans;
}
namespace modular{
	const int mod=1e9+7;
	inline int add(int a,int b){return a+b<mod?a+b:a+b-mod;}
	inline int dec(int a,int b){return a<b?a-b+mod:a-b;}
	inline int mul(int a,int b){return (ll)a*b%mod;}
	inline void Add(int&a,int b){a=a+b<mod?a+b:a+b-mod;}
	inline void Dec(int&a,int b){a=a<b?a-b+mod:a-b;}
	inline void Mul(int&a,int b){a=(ll)a*b%mod;}
	inline int ksm(int a,int p){int ret=1;for(;p;p>>=1,Mul(a,a))(p&1)&&(Mul(ret,a),1);return ret;}
}
using namespace modular;
const int N=2e5+5;
ll pre[N];
int n,a[N];
inline ll getsum(int l,int r){return pre[r]-pre[l-1];}
inline ll calc(int l1,int r1,int l2,int r2){
	ll mn=max(r1-l1+1,r2-l2+1),A=getsum(l1,r1),B=getsum(l2,r2);
	if(A>B)swap(A,B);
	return B-A;
}
int main(){
	#ifdef ldxcaicai
	freopen("lx.in","r",stdin);
	#endif
	n=read();
	for(ri i=1;i<=n;++i)a[i]=read();
	for(ri i=1;i<=n;++i)pre[i]=pre[i-1]+a[i];
	ll res=1e18;
	for(ri i=1;i<n;++i)res=min(res,calc(1,i,i+1,n));
	cout<<res;
	return 0;
}

Measured memory_bytes: 2816
import java.util.*;

public class Main {

	public static void main(String[] args){
		
		List<Integer> numList = new ArrayList<>();
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		
		sc.nextInt();
		
		
		while(sc.hasNext()) {
			int num = sc.nextInt();
			numList.add(num);
		}
		
		int count = 0;
		int mul = 1;
		LOOP: {
			while(true) {
				for(int i=0; i<numList.size(); i++) {
					int num = numList.get(i);
					if(num % 2 == 0) {
						numList.set(i, num / 2);
					} else {
						break LOOP;
					}
				}
				count++;
			}
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 10000;

int num[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};  // num[i] : iを作るのに必要なマッチの本数

int main() {
    int n, m;
    cin >> n >> m;

    vector<int> a(m);
    rep(i, m) {
        cin >> a[i];
        a[i]--;  // a[i]を0-indexにする
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());  // aを降順ソート

    vector<int> dp(n+1, -INF);  // dp[i] : i本(iは1-index)のマッチを使って条件を満たすように整数を作るときの桁数の最大値

    dp[0] = 0;
    for(int i = 1; i <= n; i++) {
        rep(j, m) {
            if(i >= num[a[j]]) {
                dp[i] = max(dp[i], dp[ i - num[a[j]] ] + 1);
            }
        }
    }

    int nokori = n;  // 残っているマッチの本数
    rep(i, dp[n]) {  // dp[n]桁作る
        rep(j, m) {  // a[j]が作れるか調べる
            if(nokori >= num[a[j]] && dp[ nokori - num[a[j]] ] == dp[nokori] - 1) {  // a[j]が作れる場合
                cout << a[j] + 1;  // 1-indexにしたa[j]を出力して
                nokori -= num[a[j]];  // 残り本数をnum[a[j]]本減らして
                break; // 次の桁に行く
            }
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,i;
    scanf("%d",&n);
    int a[n];
    for( i = 0 ; i < n ; i++ ){
        scanf("%d",&a[i]);
    }
    for( i = i-1 ; i >= 0 ; i-- ){
        printf("%d",a[i]);
        if( i != 0 ){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;
const ll N=200005;
vector<ll>v[N];
ll ans[N];

void dfs(ll c,ll node){
  for(auto y:v[c]){
    if(y==node)continue;
    ans[y]+=ans[c];
    dfs(y,c);
  }
}

int main(){
  ll n,q;cin>>n>>q;
  rep(i,0,n-1){
    ll a,b;cin>>a>>b;
    --a,--b;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  while(q--){
    ll p,x;cin>>p>>x;
    ans[--p]+=x;
  }
  dfs(0,0);
  rep(i,0,n){
    cout<<ans[i]<<" ";
  }

  return 0;
}


Measured memory_bytes: 24320
#include<iostream>
#include<bits/stdc++.h>
#define Size 3001
#define ll long long
using namespace std;
ll dp[Size][Size][2];
ll util(int s,int e,int turn,vector<int>&vec,vector<ll>&sum)
{
  if(s>e)
  return 0;
  if(dp[s][e][turn]>0)
  return dp[s][e][turn];
  ll sum1=sum[e]-sum[s],sum2=0;
  if(s==0)
  sum2=sum[e-1];
  else
  sum2=sum[e-1]-sum[s-1];
  dp[s][e][turn]=max((ll)vec[s]+sum1-util(s+1,e,(turn+1)%2,vec,sum),(ll)vec[e]+sum2-util(s,e-1,(turn+1)%2,vec,sum));
  return dp[s][e][turn];
}
int main()
{
  int n;
  cin>>n;
  vector<ll> sum(n);
  vector<int> vec;
  for(int i=0;i<n;i++)
  {
    int a;
    cin>>a;
    if(i>0)
    sum[i]=(ll)a+sum[i-1];
    else
    sum[i]=a;
    vec.push_back(a);
  }
  //cout<<"input taken"<<endl;
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    dp[i][j][0]=0,dp[i][j][1]=0;
  }
  for(int i=0;i<n;i++)
  dp[i][i][0]=(ll)vec[i],dp[i][i][1]=(ll)vec[i];
  //cout<<"assigned"<<endl;
  ll T=util(0,n-1,0,vec,sum);
  //cout<<T<<endl;
  ll J=sum[n-1]-T;
  /*for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
      cout<<dp[i][j][0]<<" ";
    cout<<endl;
  }*/
  cout<<T-J<<endl;
  return 0;
}


Measured memory_bytes: 141312
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>

#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    n=abs(n);
    m=abs(m);
    if(n*m==0)return max(n,m);
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main() {
    int k;cin>>k;
    string s;cin>>s;
    if(s.size()<=k){
        cout<<s<<endl;
        return 0;
    }
    else {
        rep(i,k)cout<<s[i];
        cout<<"..."<<endl;
    }
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n % 10 == 9 || n / 10 == 9) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# D - Candy Distribution
# https://atcoder.jp/contests/abc105/tasks/abc105_d

from collections import Counter

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

accr = [0] * (n + 1)

for i in range(n):
  accr[i + 1] = accr[i] + A[i]

li = [i % m for i in accr]

C = Counter(li)

ans = 0
for v in C.values():
  if v > 1:
    ans += v * (v - 1) // 2

print(ans)


Measured memory_bytes: 18844
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
#define ll long long
int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> a(n);
  vector<ll>b(m);
  for(ll i=0;i<n;i++){
    cin >> a[i];
  }
  for(ll i=0;i<m;i++){
    cin >> b[i];
  }
  ll time = 0, num = 0;
  if(k<a[0]){
    for(int i=0;i<n;i++){
      if(time+b[i]>k){
        break;
      }else{
        num++;
        time += b[i];
      }
      
    }
    cout << num << endl;
    return 0;
  }
  ///////////////////////////
  ll a_ind = 0;
  for(ll i=0;i<n;i++){
    if(time+a[i]>k){
      break;
    }else{
      num++;
      a_ind++;
      time += a[i];
    }
  }
  ll b_ind = 0;
  for(ll i=0;i<m;i++){
    if(time+b[i]>k){
      break;
    }else{
      num++;
      b_ind++;
      time += b[i];
    }
  }
  ll max_num = num;
  while(a_ind!=0){
    time -= a[a_ind-1];
    a_ind--;
    num--;
    while(true){
      if(b_ind==b.size()||time+b[b_ind]>k){
        break;
      }else{
        time += b[b_ind];
        num++;
        b_ind++;
      }
    }
    if(max_num<num){
      max_num = num;
    }
  }
  cout << max_num << endl;
  return 0;
}

Measured memory_bytes: 6400
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_E main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int N, M;  cin >> N >> M;
    vi X(M), Y(M), Z(M);
    REP(i, M) {
        cin >> X[i] >> Y[i] >> Z[i];
        X[i]--; Y[i]--;
    }

    vvi es(N);
    REP(i,M) {
        es[X[i]].push_back(Y[i]);
        es[Y[i]].push_back(X[i]);
    }

    vb vis(N, false);
    int ans = 0;
    REP(i,N) {
        if (vis[i]) continue;

        queue<int> que;    
        que.push(i);
        while(!que.empty()) {
            int x = que.front(); que.pop();
            vis[x] = true;
            for(int nx : es[x]) {
                if (vis[nx]) continue;
                que.push(nx);
            }
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7672
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.{Comparator, StringTokenizer}

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    type Edge = ((Int, Int), Int)
    val E = Array.fill[ListBuffer[(Int, Int)]](N)(ListBuffer.empty)
    (0 until N - 1) foreach { _ =>
      val a, b = sc.nextInt() - 1
      val c = sc.nextInt()
      E(a) += ((b, c))
      E(b) += ((a, c))
    }

    val Q, K = sc.nextInt()
    val INF = 1000000000 * N
    val d = Array.fill[Long](N)(INF)
    d(K - 1) = 0

    def toEdges(v: Int): Seq[Edge] =
      E(v) collect { case (u, c) if d(u) == INF => ((v, u), c)}

    var q = E(K -1) map { case (b, c) => ((K - 1, b), c)}
    while(q.nonEmpty) {
      q = q flatMap { case ((a, b), c) =>
        d(b) = d(a) + c
        toEdges(b)
      }
    }

    (0 until Q) foreach { _ =>
      val x, y = sc.nextInt() - 1
      println(d(x) + d(y))
    }
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 105772
from collections import deque
Q =[]
n,q = map(int,input().split())

for i in range(n):
    Q.append(deque())
for i in range(q):
    a = input().split()
    if a[0] == "0":
        Q[int(a[1])].append(a[2])
    elif a[0] == "1":
        if Q[int(a[1])]:
            print(Q[int(a[1])][-1])
    else:
        if Q[int(a[1])]:
            Q[int(a[1])].pop()
     


Measured memory_bytes: 20828
#include<bits/stdc++.h>
using namespace  std;
const int maxn = 1e5+5;
const int maxm = 1e5+5;
const int mod  = 1e9+7;
const int inf  = 0x3f3f3f3f;
//typedef __int128  II;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int n,q,k,a[1000010]; char s[1000010];
int main()
{
    scanf( "%d%s%d" , &n , s+1 , &q );
    a[0] = 0; for( int i=1 ; i<=n ; i++ ) a[i] = a[i-1]+(s[i]=='M');
    for  ( int i=1 ; i<=q ; i++ )
    {
        scanf( "%d" , &k );
        LL ans = 0,sum = 0;
        queue<int>Q;
        for( int i=1 ; i<=n ; i++ )
        {
            while( !Q.empty()&&i-Q.front()>=k )
            {
                 sum -= a[i-1]-a[Q.front()]; Q.pop();
            }
            if ( s[i]=='D' ) Q.push(i);
            else if( s[i]=='M' ) sum += Q.size();
            else if( s[i]=='C' ) ans += sum;
        }
        printf( "%lld\n" , ans );
    }
    return   0;
}


Measured memory_bytes: 9240
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(100100, 0);
    for(int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    
    vector<int> dp(100100, 1000000000);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 1; j <= k; j++)
        {
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <map>

using namespace std;
#define pb push_back
#define mp make_pair


int main()
{
        int n,k;
        cin>>n>>k;
        if( n%k == 0  ) cout<<0<<endl;
        else cout<<1<<endl;

}

























Measured memory_bytes: 256
#include <stdio.h>

int isprime(int n)
{
	int i;
	
	for (i = 2; i * i <= n; i++){
		if (n % i == 0){
			return (0);
		}
	}
	return (1);
}

int main(void)
{
	int n;
	int i;
	
	while (scanf("%d", &n) != EOF){
		i = n;
		while (isprime(--i) == 0);
		printf("%d ", i);

		i = n;
		while (isprime(++i) == 0);
		printf("%d\n", i);
	}
	
	return (0);
}

Measured memory_bytes: 0
package main

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

var scanner = bufio.NewScanner(os.Stdin)

// 文字列を1行取得
func StrStdin() (stringReturned string) {
//	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringInput := scanner.Text()

	stringReturned = strings.TrimSpace(stringInput)
	return
}

// 整数値1つ取得
func IntStdin() (int, error) {
	stringInput := StrStdin()
	return strconv.Atoi(strings.TrimSpace(stringInput))
}

// 空白や空文字だけの値を除去したSplit()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}

	return
}

// デリミタで分割して文字列スライスを取得
func SplitStrStdin(delim string) (stringReturned []string) {
	// 文字列で1行取得
	stringInput := StrStdin()

	// 空白で分割
	// stringSplited := strings.Split(stringInput, delim)
	stringReturned = SplitWithoutEmpty(stringInput, delim)

	return
}

// デリミタで分割して整数値スライスを取得
func SplitIntStdin(delim string) (intSlices []int, err error) {
	// 文字列スライスを取得
	stringSplited := SplitStrStdin(" ")

	// 整数スライスに保存
	for i := range stringSplited {
		var iparam int
		iparam, err = strconv.Atoi(stringSplited[i])
		if err != nil {
			return
		}
		intSlices = append(intSlices, iparam)
	}
	return
}

func main() {
	nk, _ := SplitIntStdin(" ")
	n, k := nk[0], nk[1]
	kind := make([]int, n)
	for i := 0; i < k; i++ {
		var tmp []int
		var err error
		if tmp, err = SplitIntStdin(" "); err != nil {
			panic(err)
		}
		kind[tmp[0]-1] = tmp[1]
	}
	dp := make([][3][3]int, n)
	if kind[0] > 0 {
		dp[0][0][kind[0]-1] = 1
	} else {
		for i := 0; i < 3; i++ {
			dp[0][0][i] = 1
		}
	}
	if kind[1] > 0 {
		for i := 0; i < 3; i++ {
			dp[1][i][kind[1]-1] = dp[0][0][i]
		}
	} else {
		for i := 0; i < 3; i++ {
			for j := 0; j < 3; j++ {
				dp[1][i][j] = dp[0][0][i]
			}
		}
	}
	for i := 1; i < n-1; i++ {
		if kind[i+1] > 0 {
			for j := 0; j < 3; j++ {
				if j == kind[i+1]-1 {
					for k := 0; k < 3; k++ {
						if j != k {
							dp[i+1][j][kind[i+1]-1] += dp[i][k][j]
							dp[i+1][j][kind[i+1]-1] %= 10000
						}
					}
				} else {
					for k := 0; k < 3; k++ {
						dp[i+1][j][kind[i+1]-1] += dp[i][k][j]
						dp[i+1][j][kind[i+1]-1] %= 10000
					}
				}
			}
		} else {
			for j := 0; j < 3; j++ {
				for k := 0; k < 3; k++ {
					for l := 0; l < 3; l++ {
						if j != k || k != l {
							dp[i+1][k][j] += dp[i][l][k]
							dp[i+1][k][j] %= 10000
						}
					}
				}
			}
		}
	}
	result := 0
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			result += dp[n-1][i][j]
		}
	}
	// fmt.Println(dp)
	// fmt.Println(kind)
	fmt.Println(result % 10000)
}



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


int gcd(int A,int B){
  if(B>A)swap(A,B);
  if(B==0)return A;
  return gcd(B,A%B);
}

int main(){
  long long N,A,B,C,D,E;
  cin >>N>>A>>B>>C>>D>>E;
  cout << max({(N-1)/A,(N-1)/B,(N-1)/C,(N-1)/D,(N-1)/E})+5 << endl;
  return 0;
}
  
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(), v.end()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const ll inf = 10000000000000000;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


//UF木
struct UnionFind {
private:
	vector<int> par, ran, sz;
public:
	UnionFind(int n) {
		par.resize(n, 0);
		ran.resize(n, 0);
		sz.resize(n, 1);
		rep(i, n) {
			par[i] = i;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return;
		if (ran[x] < ran[y]) {
			par[x] = y; sz[y] += sz[x];
		}
		else {
			par[y] = x; sz[x] += sz[y];
			if (ran[x] == ran[y])ran[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int num(int x) { return sz[find(x)]; }
};

int n, m, ans;
int p[100005];

int main() {

	cin >> n >> m;
	UnionFind uf(n);
	rep(i, n)cin >> p[i];
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		uf.unite(p[x] - 1, p[y] - 1);
	}

	rep(i, n) {
		if (uf.same(p[i] - 1, p[p[i] - 1] - 1))ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
package main

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

func getsAsIntArray() (line []int) {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		str := scanner.Text()
		if str == "" {
			break
		}
		data, err := strconv.Atoi(str)
		if err != nil {
			break
		}
		line = append(line, data)
	}

	return
}

func main() {

	lines := getsAsIntArray()
	sort.Sort(sort.Reverse(sort.IntSlice(lines)))
	for i, v := range lines {
		if i < 3 {
			fmt.Println(v)
		}
	}
}



Measured memory_bytes: 1108
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n) for(int i=a; i<n; i++)
#define SPEED ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
int main() 
{
	SPEED; 
	string s;
	cin>>s;
	if(s=="ABC") cout<<"ARC";
	else cout<<"ABC";
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

template<typename T>
using vec2 = vector<vector<T>>;
template<typename T>
using vec3 = vec2<vector<T>>;
template<typename T>
using vec4 = vec3<vector<T>>;
template<typename T>
using vec5 = vec4<vector<T>>;
template<typename T>
using vec6 = vec5<vector<T>>;



int main(){
    int N;cin>>N;
    vector<ll> A;
    vector<ll> sum(N+1);
    ll MOD = 1000000007;
    for(int i = 0;i < N;i++){
        ll a;cin>>a;
        A.push_back(a);
        sum[i+1] = (sum[i] + a)%MOD;
    }
    ll res = 0;
    for(int i = 0;i < N;i++){
        res += (A[i] * (sum[N]-sum[i +1]+MOD)) % MOD;
        res %= MOD;
    }

    cout<<res<<endl;
}

Measured memory_bytes: 6928
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;

long long power(long long a, long long b) {
    //a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
    }
  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
  vector<int> pr;
void Sieve(ll int n) 
{ 
    bool prime[10000000];
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 




//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}


  
int main() {
     ll int n;
     cin>>n;
    ll int a[n];
     map<int,int>mp;
     ll int s=0;
     for(int i=0;i<n;i++)
     {
         cin>>a[i];
         s+=a[i];
         mp[a[i]]++;
     }
     ll int q;
     cin>>q;
     for(int i=0;i<q;i++)
     {
         ll int b,c;
         cin>>b>>c;
         if(mp.find(b)!=mp.end())
         {
             s+=mp[b]*c;
             s-=mp[b]*b;
             cout<<s<<endl;
             mp[c]+=mp[b];
             mp.erase(b);
         }
         else
         {
             cout<<s<<endl;
         }
     }
}


Measured memory_bytes: 7232
#include <iostream>
#include <cmath>
using namespace std;
//#define debug

class Triangle{
	float m_x[3],m_y[3],m_xp,m_yp;
	float m_vx[3],m_vy[3];//点Pからの相対座標
	float m_nv1,m_nv2, m_rot,m_rot_sum,m_cos_sita;
	int m_p1,m_p2;
	bool m_pointIsSetted;
public:
	Triangle(){m_pointIsSetted=false;m_rot_sum=0;}
	void setPoint(float x1, float y1, float x2, float y2, float x3, float y3){
		m_x[0]=x1; m_y[0]=y1;
		m_x[1]=x2; m_y[1]=y2;
		m_x[2]=x3; m_y[2]=y3;
		m_pointIsSetted=true;
	}
	bool isPointIn(float xp,float yp){
		m_xp=xp;m_yp=yp;

		//点Pからの相対座標の計算
		for(int i=0;i<3;++i){
			m_vx[i]=m_x[i]-xp;
			m_vy[i]=m_y[i]-yp;
		}

		m_rot_sum = 0;
		for(int i=0;i<3;++i){
			m_p1=i;
			if(i==2)m_p2=0; else m_p2=i+1;
			m_nv1=sqrt(pow(m_vx[m_p1],2.0)+pow(m_vy[m_p1],2.0));
			m_nv2=sqrt(pow(m_vx[m_p2],2.0)+pow(m_vy[m_p2],2.0));

			m_cos_sita = (m_vx[m_p1]*m_vx[m_p2]+m_vy[m_p1]*m_vy[m_p2]) / (m_nv1*m_nv2);
			m_rot = acos( m_cos_sita );
//			if(m_cos_sita<0){m_rot=-m_rot;}
			m_rot_sum += m_rot;
#ifdef debug
			cout<<m_p1<<"  "<<m_p2<<endl;
			cout<<"cos_sita: "<<m_cos_sita<<endl;
			cout<<"sita: "<<m_rot<<endl;
			cout<<"sum of rot: "<<m_rot_sum<<endl;
#endif
		}

		if(abs(m_rot_sum)>6.0){return true;}else{return false;}

	}
};

int main(){

	float x1,y1,x2,y2,x3,y3,xp,yp;
	Triangle oTri;

	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
		oTri.setPoint(x1,y1,x2,y2,x3,y3);
		if(oTri.isPointIn(xp,yp)){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}


	}
	return 0;
}

Measured memory_bytes: 1240
N, Y = map(int, input().split())

resx, resy, resz = (-1, -1, -1)
# xn = Y//10000
for x in range(Y//10000+1):
    for y in range((Y-10000*x)//5000+1):
        z = N - x - y
        total = 10000*x + 5000*y + 1000*z

        if total == Y:
            resx, resy, resz = (x, y, z)
            break

print(resx, resy, resz)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

inline int sqr(int x){
	return x * x;
}

int n, ans, a[110];
int cal(int x){
	int ret = 0;
	for(int i=0; i<n; i++){
		ret += sqr(a[i]-x);
	}
	return ret;
}

int main(){
	ans = 0x7fffffff;
	scanf("%d", &n);
	for(int i=0; i<n; i++)	scanf("%d", a+i);
	sort(a, a+n);
    for(int i=a[0]; i<=a[n-1]; i++){
		ans = min(ans, cal(i));
    }
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128