akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

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

    int n;
    cin >> n;
    VI a(n + 1);
    eFOR(i, 1, n)cin >> a[i];

    VI in(n + 1, 0), num(n + 1, 0);
    for (int i = n; i >= 1; i--) {
        if (num[i] == a[i])in[i] = 0;
        else {
            in[i] = 1;
            for (int j = 1; j * j <= i; j++) {
                if (!(i % j)) {
                    num[j] = 1 - num[j];
                    if (j * j != i) {
                        num[i / j] = 1 - num[i / j];
                    }
                }
            }
        }
    }

    deque<int> ans;
    eFOR(i, 1, n)if (in[i])ans.push_back(i);
    cout << ans.size() << "\n";
    if (!ans.empty()) {
        cout << ans[0];
        FOR(i, 1, ans.size())cout << " " << ans[i];
        cout << "\n";
    }
}

Measured memory_bytes: 3712
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main(){
	int x,y;
	std::cin>>x>>y;
	if(y%2)puts("No");
	else if(2*x<=y&&y<=4*x)puts("Yes");
	else puts("No");
	return 0;
}


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

int main(void)
{
    int W, H, N;
    cin >> W >> H >> N;
    vector<int> x(N), y(N), a(N);

    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> a[i];
    }

    pair<int, int> rangeX = {0, W};
    pair<int, int> rangeY = {0, H};

    for(int i = 0; i < N; i++){
        switch (a[i])
        {
        case 1:
            if(rangeX.first < x[i]){
                rangeX.first = x[i];
            }
            break;
        case 2:
            if(rangeX.second > x[i]){
                rangeX.second = x[i];
            }
            break;
        case 3:
            if(rangeY.first < y[i]){
                rangeY.first = y[i];
            }
            break;
        case 4:
            if(rangeY.second > y[i]){
                rangeY.second = y[i];
            }
            break;
        }

    }

    int w = max(rangeX.second - rangeX.first, 0);
    int h = max(rangeY.second - rangeY.first, 0);

    cout << w * h << endl;

    return 0;
}


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

int main(){

	int t = 1;
	//cin >> t;
	while(t--){
		int n;
		cin >> n;
		int x;
		int count = 0;
		for(int i = 1; i <= n; ++i){
			cin >> x;
			if(i%2 && x%2) count++;
		}
		cout << count;
	}
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
    int a[5],s=0;
    for(int i=0;i<5;i++)
    cin>>a[i];
    for(int i=0;i<5;i++)
    {
        if(a[i]==0)
        {s=i+1;
        break;
    }
    
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define M 1000000007
#define enter ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define pb push_back
#define mp make_pair 
typedef long long int ll;
int main()
{
    ll n;	cin>>n;
  	ll ans = n + n*n + n*n*n;
  cout<<ans;
    return 0;
}

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

int main() {

    char alpha;
    cin >> alpha;

    if (islower(alpha)) cout << "a" << endl;
    else cout << "A" << endl;
    
    return 0;
}

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

using namespace std;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if ((r * 100 + g * 10 + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include <vector>
using namespace std;
int test[26][26];
int main() {
	long long n, m, a, sum = 0 ,ans = 10000000; cin >> n >> m;
	for (int h = 0; h < n; h++) {
		for(int i = 0; i < m; i++) {
			cin >> a; test[h][i] = a;
		}
	}
	for (int h = 0; h < n; h++) {
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < m; k++) {
					if (h != j && i != k) {
						sum += min(abs(h - j), abs(i - k))*test[j][k];
					}
				}
			}
			ans = min(sum, ans);
			sum = 0;
		}
	}
	cout << ans << endl;
	cin >> n;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;



int main(void) {
    string s;
    cin >> s;
    ll K;
    cin >> K;
    ll i;
    
    for(i=0; i<s.size(); i++) {
        ll t=('z'-s[i]+1)%26;
        
        if(i==s.size()-1) {
            s[s.size()-1]=(s[s.size()-1]-'a'+K)%26+'a';
            break;
        }else if(K<t) {
            continue;
        }else {
            s[i]='a';
            K-=t;
        }
    }
    
    pt(s);
    
}








Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  ll d, a;
  cin >> n >> d >> a;
  vector<vector<ll>> x(n, vector<ll>(2));
  for(int i = 0; i < n; i++){
    cin >> x[i][0] >> x[i][1];
  }
  sort(x.begin(), x.end());
  
  ll cnt = 0;
  queue<pair<ll, ll>> que;
  ll sum = 0;
  for(int i = 0; i < n; i++) {
    while(true){
      pair<ll, ll> tmp = que.front();
      if(tmp.first < x[i][0] && !que.empty()){
        sum -= tmp.second;
        que.pop();
      }else{
        break;
      }
    }
    if(x[i][1] <= sum * a) {
      continue;
    }

    ll r = min(x[i][0] + 2 * d, x[n - 1][0]);
    ll bomb = (x[i][1] - sum * a + a - 1) / a;
    que.push(make_pair(r, bomb));
    sum += bomb;
    cnt += bomb;
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        String a = scanner.next();
        String  b = scanner.next();
        scanner.close();
        int c = Integer.parseInt(a+b);
        
        int i = 2;
        boolean heiho = false;
        while (i*i<=c){
         
            if(c == i*i){
                heiho = true;
                System.out.println("Yes");
            }   
            i++;
        
        }
            if(heiho == false){    
                 System.out.println("No");
            }
    }
}

Measured memory_bytes: 21588
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n==0)break;
   var arr=[];
   for(var i=0;i<n;i++){
      var x=Arr.shift()-0;
      arr.push(x);
   }
   var L=1;
   var cnt=0;
   while(true){
      if(arr.length==L)break;
      for(var i=0;i<arr.length-L;i++){
         var memo=arr[i];
         if(arr[i]>arr[i+1]){
            cnt++;
            arr[i]=arr[i+1];
            arr[i+1]=memo;
         }
      }
   L++;
   }
   console.log(cnt);
}

Measured memory_bytes: 8680
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	void solve() {
		int[] a = sc.nextIntArray(10);
		int[] b = sc.nextIntArray(10);
		sort(a);
		sort(b);

		out.println((a[7] + a[8] + a[9]) + " " + (b[7] + b[8] + b[9]));
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
int main(){
ll x;
cin>>x;
int count;
ll arr[100000]={0};
for(ll i=1;;i++){
arr[i]+=arr[i-1]+i;
//cout<<count<<endl;
if(arr[i]>INF+1000000000){
  count=i;
break;
}
  
}

rep(i,count){
  if(arr[i]>=x){
    cout<<i<<endl;
    return 0;
  }
}


  return 0;
}


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

int main() {
    int N, M, P, sumPena;
    string res;
    cin>>N>>M;
    sumPena = 0;
    vector<int> Pena(N, 0);
    vector<bool> Correct(N, false);
    REP(i, 0, M){
        cin >> P >> res;
        if(res == "AC"){
            if(!Correct[P-1]){
                sumPena += Pena[P-1];
            }
            Correct[P-1] = true;
        }
        if(res == "WA" && !Correct[P-1]){
            Pena[P-1]++;
        }
    }
    int AC = count(Correct.begin(), Correct.end(), true);
    cout << AC <<" " << sumPena << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;

const int mod = 1e9+7;

int inv(int a, int m){
	assert(0<a);
	assert(a<m);
	return a==1 ? 1 : m-m*1LL*inv(m%a, a)/a;
}

struct mint{
	int x;
	mint(): x(0) {}
	mint(const auto &val): x(val%mod) { if(x<0) x+=mod; }
};

void operator+=(mint &a, const mint &b){ a.x+=b.x; if(a.x>=mod) a.x-=mod; }
mint operator+(mint a, const mint &b){ a+=b; return a; }
void operator-=(mint &a, const mint &b){ a.x-=b.x; if(a.x<0) a.x+=mod; }
mint operator-(mint a, const mint &b){ a-=b; return a; }
void operator*=(mint &a, mint b){ a.x = 1LL*a.x*b.x %mod; }
mint operator*(mint a, const mint &b){ a*=b; return a; }
mint operator/(const mint &a, const mint &b){ return mint(1LL*a.x*inv(b.x,mod)); }
mint operator""m(unsigned long long x){return mint(x);}
ostream& operator<<(ostream &o, const mint &m){ return o<<m.x; }



int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	vector<ll> a(n);
	for(auto &_ : a) cin>>_;
	
	
	auto s = accumulate(ALL(a), 0m);
	
	auto ss = 0m;
	for(ll x : a) ss+=x*x;
	
	cout<<(s*s - ss)/2<<endl;
	
	
	return 0;
}


Measured memory_bytes: 4752
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    cin>>n;
    vector<vector<int>> g(n,vector<int>());
    FOR(i,0,n-1){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        g[a].PB(b);
        g[b].PB(a);
    }
    int cnt1=1;
    int cnt0=0;
    vi c(n,-1);
    queue<int> q;
    vi ans(n,0);
    c[0]=1;
    q.push(0);
    while (q.size())
    {
        auto nw=q.front(),color=c[nw]^1;
        q.pop();
        for(auto x:g[nw]){
            if(c[x]==-1){
                q.push(x);
                c[x]=color;
                cnt1+=color;
                cnt0+=1^color;
            }
        }
    }
    if(cnt0>cnt1){
        swap(cnt0,cnt1);
        FOR(i,0,n){
            c[i]=c[i]^1;
        }
    }
    //cerr<<"odd&even:"<<cnt0<<" "<<cnt1<<" c[0]:"<<c[0]<<endl;
    FOR(i,0,n){
    //    cerr<<c[i]<<" ";
    }
    cerr<<endl;
    int n3=n/3;
    deque<int> dq;
    if(n3>=cnt0){
        int nx3=3,nx=1;
        FOR(i,0,n){
            if(c[i]==0){
                ans[i]=nx3;
                nx3+=3;
            }
        }
        FOR(i,0,n){
            if(c[i]==1){
                if(nx3>n)break;
                ans[i]=nx3;
                nx3+=3;
                if(nx3>n)break;
            }
        }
        FOR(i,0,n){
            if(ans[i]==0){
                ans[i]=nx;
                nx++;
                if(nx%3==0){
                    nx++;
                }
            }
        }

    }else{
        int nx=1,nx2=2,nx3=3;
        FOR(i,0,n){
            if(c[i]==0){
                ans[i]=nx;
                nx+=3;
                if(nx>n)break;
            }
        }
        FOR(i,0,n){
            if(c[i]==1){
                ans[i]=nx2;
                nx2+=3;
                if(nx2>n)break;
            }
        }
        FOR(i,0,n){
            if(ans[i]==0){
                ans[i]=nx3;
                nx3+=3;
            }
        }
    }


    

    FOR(i,0,n){
        cout<<ans[i]<<" ";
    }
}


Measured memory_bytes: 15220
H, W = map(int, input().split())
ans = []

if H % 3 == 0:
    print(0)
    exit()
else:
    ans.append(W)

s1 = [H * (W // 3), H // 2 * (W - W // 3), (H // 2 + H % 2) * (W - W // 3)]
s2 = [H * (W // 3 + 1), H // 2 * (W - W // 3 - 1), (H // 2 + H % 2) * (W - W // 3 - 1)]

ans.append(min(max(s1) - min(s1), max(s2) - min(s2)))

H, W = W, H

if H % 3 == 0:
    print(0)
    exit()
else:
    ans.append(W)

s1 = [H * (W // 3), H // 2 * (W - W // 3), (H // 2 + H % 2) * (W - W // 3)]
s2 = [H * (W // 3 + 1), H // 2 * (W - W // 3 - 1), (H // 2 + H % 2) * (W - W // 3 - 1)]

ans.append(min(max(s1) - min(s1), max(s2) - min(s2)))

print(min(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k;scanf("%d%d%d",&a,&b,&k);
    for(int i=100;i>=1;i--){
        if(a%i==0 and b%i==0)k--;
        if(!k){
            printf("%d\n",i);
            return 0;
        }
    }
}

Measured memory_bytes: 256
s=input()
n=len(s)
s1=''
s2=''
for i in range(n):
    if i%2==0:
        s1+='0'
        s2+='1'
    else:
        s1+='1'
        s2+='0'
dif1=sum(s1[i]!=s[i] for i in range(n))
dif2=sum(s2[i]!=s[i] for i in range(n))
print(min(dif1,dif2))

Measured memory_bytes: 3316
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
x = na()

ans = inf
for i in range(n):
    if i + k - 1 < n:
        l, r = x[i], x[i + k - 1]
        ans = min(ans, min(abs(l) + abs(r - l), abs(r) + abs(r - l)))

print(ans)

Measured memory_bytes: 58736
from sys import stdin


def main():
    lines = stdin.readlines()
    N, M = map(int, lines[0].split())
    print(sum([1
               for i in range(1 << N)
               if sum([1
                       for s, p in zip(
                           [sum(1 << int(j) - 1
                                for j in i.split()[1:])
                            for i in lines[1:-1]], lines[-1].split())
                       if bin(i & s).count("1") % 2 == int(p)]) == M]))
    return


main()


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

using usize = ::std::size_t;
using u64 = ::std::int_least64_t;
//using u64 = int;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;

u64 n, E;
u64 H, W;
u64 d[10][10], w[10][10];
bool negative_cycle = false;

void floydWarshall(){
    for (int i = 0; i <= 9; i++){
        for (int j = 0; j <= 9; j++){
            d[i][j] = w[i][j];
        }
    }
    for (int k = 0; k <= 9; k++){
        for (int i = 0; i <= 9; i++){
            for (int j = 0; j <= 9; j++){
                if(d[i][k] == Inf || d[k][j] == Inf) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    return;
}

int main(int argc, char *argv[])
{
    // input from txt （提出時にこの箇所は削除すること）
    //ifstream in("in.txt");
    //cin.rdbuf(in.rdbuf());
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    //cin >> n >> E;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            cin >> w[i][j];
        }
    }
    
    
    floydWarshall();
    u64 total = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int a;
            cin >> a;
            if(a == -1) continue;
            else total += d[a][1];
        }
    }
    
    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 3580
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int N, A, B, C;
vector<int> l;

int dfs(int i, int a, int b, int c)
{
	if (i == N) {
		if (a == 0 || b == 0 || c == 0) return (int)INF;
		return abs(A - a) + abs(B - b) + abs(C - c);
	}

	// 入れない
	int res;
	res = dfs(i + 1, a, b, c);
	
	// 一個づつ入れていく
	int cmp;
	int lOne = l[i];
	cmp = dfs(i + 1, a + lOne, b, c);
	cmp += (0 < a) ? 10 : 0;
	res = min(res, cmp);
	cmp = dfs(i + 1, a, b + lOne, c);
	cmp += (0 < b) ? 10 : 0;
	res = min(res, cmp);
	cmp = dfs(i + 1, a, b, c + lOne);
	cmp += (0 < c) ? 10 : 0;
	res = min(res, cmp);
	return res;
}



int main()
{
	cin >> N >> A >> B >> C;
	REP(i, N) {
		int a;
		cin >> a;
		l.emplace_back(a);
	}
	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

bool is_good(vector<string> &v) {
  int n = v.size();
  bool f(true);
  rep(i, 0, n) rep(j, i, n) f &= (v[i][j] == v[j][i]);
  return f;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<string> v(N);
  rep(i, 0, N) { cin >> v[i]; }
  int ans = 0;
  rep(i, 0, N) {
    vector<string> w(v);
    rep(x, 0, N) rep(y, 0, N) w[x][y] = v[(x + i) % N][y];
    ans += is_good(w) * N;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  String n=sc.next();
  int m=sc.nextInt();
  Graph g=new Graph();
  for(int i=0;i<m;i++){
  g.add(sc.next(),sc.next());
  }
  System.out.println(g.isConnect("1",n)?"POSSIBLE":"IMPOSSIBLE");
}

}
class Graph {
	Map<String, ArrayList<String>> edge ;
	Map<String, Integer> vertex ;
	public Graph() {
		edge = new HashMap<String, ArrayList<String>>();
		vertex=new HashMap<String,Integer>();
	}
	public void add(String a, String b) {
		if (edge.containsKey(a)) {
			edge.get(a).add(b);
			vertex.put(a,vertex.get(a)+1);
		} else {
			ArrayList<String>cont=new ArrayList<>();
			cont.add(b);
			edge.put(a, cont);
			vertex.put(a,1);
		}
		if (edge.containsKey(b)) {
			edge.get(b).add(a);
			vertex.put(b,vertex.get(b)+1);
		} else {
			ArrayList<String>cont=new ArrayList<>();
			cont.add(a);
			edge.put(b, cont);
			vertex.put(b,1);
		}
	}
	public boolean isConnect(String a,String b) {
		if(!vertex.containsKey(a)||!vertex.containsKey(b))return false;
		Map<String,Boolean>check=new HashMap<String,Boolean>();
		ArrayList<String>queue=new ArrayList<>();
		check.put(a,false);
        
      ArrayList<String>cont=new ArrayList<>(edge.get(a));
      for(int i=0;i<cont.size();i++)if(!check.containsKey(cont.get(i))) {
					queue.add(cont.get(i));
					check.put(cont.get(i),false);
				}
      
      for(int i=0;i<queue.size();i++){
      	ArrayList<String>cont2=new ArrayList<>(edge.get(queue.get(i)));
        for(int j=0;j<cont2.size();j++)
        	check.put(cont2.get(j),false);
      }
		return check.containsKey(b);
	}
}


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

struct UnionFind{
  int num;//連結成分の数
  vector<int> r,p;//そのグループのサイズ,自分の親っぽいやつ
  UnionFind(){}
  UnionFind(int n):num(n),r(n,1),p(n,0){iota(p.begin(),p.end(),0);}

  int find(int x){//どのグループに所属するか
    return (x==p[x]?x:p[x]=find(p[x]));//xがグループの名前と一致するまでxを親にする
  }

  bool same(int x,int y){//同じグループかどうか
    return find(x)==find(y);
  }

  void unite(int x,int y){//xとyを同じグループにする
    x=find(x);y=find(y);//xとyのグループの名前をどっちかが変える
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);//サイズが大きい方をxとする
    r[x]+=r[y];//yの親をxにする（今までyだったグループ名がxになる）
    p[y]=x;
    num--;
  }

  int size(int x){//グループの大きさ
    return r[find(x)];
  }

  int count() const{//グループの数
    return num;
  }
};
template<typename T,bool directed>//directedは有向のこと
struct Fordfulkerson{
  struct edge{
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  vector<vector<edge> > G;
  vector<int> used;

  Fordfulkerson(){}
  Fordfulkerson(int n):G(n),used(n){}//n個の頂点

  void add_edge(int from,int to,T cap){
    G[from].emplace_back(to,cap,G[to].size());//edgeのrevには逆辺の番号が入る
    G[to].emplace_back(from,directed?0:cap,G[from].size()-1);//有向グラフならcapは0
  }

  T dfs(int v,int t,T f){//v->tにfの流量を道が見つかり次第通していく感じ　通った量が返り値
    if(v==t) return f;//ゴール
    used[v]=true;//通った確認
    for(int i=0;i<(int)G[v].size();i++){
      edge &e = G[v][i];
      if(!used[e.to]&&e.cap>0){//まだ通ってなくてcap的にいける場所があるなら
        T d=dfs(e.to,t,min(f,e.cap));//そこからtまで通せるだけ通そうとして見る
        if(d>0){//dだけ通った
          e.cap-=d;//流量を減らす
          G[e.to][e.rev].cap+=d;//逆辺の流量を増やす
          return d;//d通せた
        }
      }
    }
    return 0;
  }

  int flow(int s,int t,T lim){
    T fl=0;
    while(1){
      fill(used.begin(),used.end(),0);//usedの初期化
      T f=dfs(s,t,lim);//sからtまで逆辺を考慮しつつ通す
      if(f==0) break;//全く通らないなら終了
      fl+=f;//通ってるなら流量を増やす
      lim-=f;//初期流量を減らす
    }
    return fl;
  }

  int flow(int s,int t){//全力で流す
    return flow(s,t,numeric_limits<T>::max()/2);
  }

};

signed main(){
  int N,M;cin>>N>>M;
  std::vector<int> x(M),y(M);
  for(int i=0;i<M;i++)cin>>x[i]>>y[i];
  int ans1,ans2;
  UnionFind uf(M);
  for(int i=0;i<M;i++)
    for(int j=i+1;j<M;j++)
      if(x[i]==x[j]||y[i]==y[j])uf.unite(i,j);
  ans2=M-uf.count();
  Fordfulkerson<int,1> fl(10000);
  set<int> usedx,usedy;
  for(int i=0;i<M;i++){
    fl.add_edge(x[i],y[i]+1000,1);
    if(!usedx.count(x[i])){
      fl.add_edge(0,x[i],1);
      usedx.insert(x[i]);
    }
    if(!usedy.count(y[i])){
      fl.add_edge(y[i]+1000,3000,1);
      usedy.insert(y[i]);
    }
  }
  ans1=M-fl.flow(0,3000);
  cout<<ans1<<" "<<ans2<<endl;
}



Measured memory_bytes: 3348
<?php
//$N = (int)trim(fgets(STDIN));
$S = trim(fgets(STDIN));
//list($N,$X,$T) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$P = array_map('intval',explode(" ",trim(fgets(STDIN))));

$len = strlen($S);
$sum = 0;
for($i=0;$i<$len;$i++) {
  $sum += $S[$i];
}
if ((($sum % 9) == 0) || ($sum==0)) {
  printf("Yes\n");
}
else {
  printf("No\n");
}


Measured memory_bytes: 16428
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, L;
    cin >> N >> L;
    vector<string> v(N);
    for (auto& i : v) cin >> i;
    sort(v.begin(), v.end());
    for (auto i : v) cout << i; cout << endl;
 
    return 0;
}

Measured memory_bytes: 256
n, k, q = [int(v) for v in input().split()]
a = [int(input()) - 1 for i in range(q)]

point = [k - q for i in range(n)]

for v in a:
    point[v] += 1

for p in point:
    if p > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 11780
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)

using namespace std;

signed main()
{
    int A, B;
    cin >> A;
    cin >> B;
    int answer = 0;
    int now = 1;
    while (now < B) {
        now -= 1;
        now += A;
        answer++;
    }
    cout << answer << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;

  int cnt = 0;
  for (int i = a; i <= b; i++) {
    if ((to_string(i).substr(0, 1) == to_string(i).substr(4, 1)) &&
        (to_string(i).substr(1, 1) == to_string(i).substr(3, 1)))
      cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n;
int a[101];

void input(){
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll ans = INF;
    int mx = -INF;
    int mn = INF;
    for(int i=0;i<n;i++) mx = max(mx, a[i]);
    for(int i=0;i<n;i++) mn = min(mn, a[i]);
    for(int i=mn;i<=mx;i++){
        ll total = 0;
        for(int j=0;j<n;j++) total += (a[j]-i)*(a[j]-i);
        ans = min(ans, total);
    }
    cout << ans << endl;
    return 0;
}

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

int solve(int p, int q) {
    if(p<0) return 0;
    return (p+q-1)/q;
}

int main() {
    int n,h;
    cin>>n>>h;
    vector<int> a(n),b(n);
    for(int i=0; i<n; i++) cin>>a[i]>>b[i];

    int max = 0;
    for(int i=0; i<n; i++) {
        if(max < a[i]) {
            max = a[i];
        }
    }

    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());

    int l = 0, ret = h+1;
    for(int i=0; i<n; i++) {
        ret = min(ret, i+solve(h-l, max));
        l += b[i];
    }
    ret = min(ret, n+solve(h-l,max));
    cout << ret << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	map<char,int> mp;
	int i,num=0;
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		if(!mp[s[i]])
		{
			mp[s[i]]=1;
			num++;
		}
		else
		{
			mp[s[i]]++;
		}
		if(num>2||mp[s[i]]>2)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	//入力
	string s;cin>>s;
	ll ans;cin>>ans;
	
	//まずはかけ算
	ll ans1(0);
	int tmp(1);
	
	if(s.length()==1)
	{
		ans1=s[0]-'0';
	}
	else
	{
		for(int i=0;i<(s.length())/2;i++)
		{
			if(i==0)
			{
				if(s[i*2+1]=='+')
				{
					ans1+=s[i*2]-'0';
					if(i==(-3+s.length())/2)
				{
					ans1+=s[i*2+2]-'0';
				}
			}
			else
			{
				tmp*=s[i*2]-'0';
				if(i==(-3+s.length())/2)
				{
					tmp*=s[i*2+2]-'0';
					ans1+=tmp;
				}
			}
		}
		else
		{
			if(s[i*2+1]=='+')
			{
				if(s[i*2-1]=='*')
				{
					tmp*=s[i*2]-'0';
					ans1+=tmp;tmp=1;
					if(i==(-3+s.length())/2)
					{
						ans1+=s[i*2+2]-'0';
					}
				}
				else
				{
					ans1+=s[i*2]-'0';
					if(i==(-3+s.length())/2)
					{
						ans1+=s[i*2+2]-'0';
					}
				}
			}
			else
			{
				tmp*=s[i*2]-'0';
				if(i==(-3+s.length())/2)
				{
					tmp*=s[i*2+2]-'0';
					ans1+=tmp;
				}
			}
		}}
	}
		//足し算
	ll ans2(0);
	if(s.length()==1)
	{
		ans2+=s[0]-'0';
	}
	else
	{
		for(int i=0;i<(s.length())/2;i++)
		{
			if(i==0)
			{
				if(s[i*2+1]=='+')
				{
					ans2+=s[i*2]-'0'+s[i*2+2]-'0';//cout<<"-1-"<<" "<<ans2<<endl;
				}
				else
				{
					ans2+=(s[i*2]-'0')*(s[i*2+2]-'0');//cout<<"-2-"<<" "<<ans2<<endl;
				}
			}
			else
			{
				if(s[i*2+1]=='+')
				{
					ans2+=s[i*2+2]-'0';//cout<<"-3-"<<" "<<ans2<<endl;
				}
				else
				{
					ans2*=s[i*2+2]-'0';//cout<<"-4-"<<" "<<ans2<<endl;
				}
			}
		}
	}
	
	bool m =(ans==ans1);
	bool l =(ans==ans2);
		
	if(m&&!l){cout<<'M'<<endl;}
	if(!m&&l){cout<<'L'<<endl;}
	if(m&&l){cout<<'U'<<endl;}
	if(!m&&!l){cout<<'I'<<endl;}
	
	return 0;
}

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

 #define int long long
 using namespace std;

int a[100020];
void solve(){
	int n;
	cin>>n;
//	cout<<" "<<n<<endl;
	int sum=0;
	if(n==0) exit(0);
	for(int i=0;i<n;i++){
	cin>>a[i];
		sum+=a[i];
	}
	
	int ans=0;
	for(int i=0;i<n;i++){
		if(a[i]*n<=sum)ans++;
	}
	cout<<ans<<endl;
	return;
}

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

 
    	
    	for(int i=0;;i++){
    		solve();
    	
    	}
    	return 0;
    	
            }


Measured memory_bytes: 3220
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $iter:expr, $($r:tt)*) => {
        // let mut iter = $s.split_whitespace();
        input_inner!{$iter, $($r)*}
    };
    // ($($r:tt)*) => {
    //     let s = {
    //         use std::io::Read;
    //         let mut s = String::new();
    //         std::io::stdin().read_to_string(&mut s).unwrap();
    //         s
    //     };
    //     let mut iter = s.split_whitespace();
    //     input_inner!{iter, $($r)*}
    // };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let s = {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    };
    let mut iter = s.split_whitespace();

    input! {
        source = iter,
        n: usize,
        m: usize,
    }

    let mut table = vec![vec![false; n]; m];

    for i in 0..n {
        input! {
            source = iter,
            k: usize,
            a: [usize1; k],
        }

        for a in a {
            table[a][i] = true;
        }
    }

    let ans = table.iter().map(|row| row.iter().fold(true, |a, b| a && *b)).
        filter(|&b| b).count();

    println!("{}", ans);
}


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

int main() {
	int N; cin >> N;
	int a[100010];
	for(int i=0; i<N; ++i) cin >> a[i];
	sort(a, a+N);
	bool flag=true;
	if(N%2){
	    if(a[0]) flag=false;
	    else{
	        for(int i=2; i<N; i*=2){
	            if(a[i-1]!=i || a[i]!=i){
	                flag=false;
	                break;
	            }
	        }
	    }
	}
	else{
	    for(int i=2; i<=N; i*=2){
	        if(a[i-2]!=i-1 || a[i-1]!=i-1){
	            flag=false;
	            break;
	        }
	    }
	}
	long ans=flag;
	if(flag) for(int i=1; i*2<=N; ++i) ans=(ans*2)%1000000007;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int i,j,n,k;
		int s[],b[][],sum[];
		boolean flag;
		
		while(true){
			flag=true;
			n=sc.nextInt();
			k=sc.nextInt();
			if(n+k==0) break;
			s=new int[k];
			sum=new int[k];
			b=new int[n][k];
			for(i=0;i<k;i++){
				s[i]=sc.nextInt();
				sum[i]=0;
			}
			for(i=0;i<n;i++){
				for(j=0;j<k;j++){
					b[i][j]=sc.nextInt();
				}
			}
			for(i=0;i<k;i++){
				for(j=0;j<n;j++){
					sum[i]+=b[j][i];
				}
			}
			for(i=0;i<k;i++){
				//System.out.println(s[i]+" "+sum[i]);
				if(s[i]<sum[i]){
					flag=false;
				}
			}
			if(flag) System.out.println("Yes");
			else System.out.println("No");
		}
	}

}

Measured memory_bytes: 13000
#include <cstdio>

int main() {
    int n,k;
    scanf("%d%d",&n,&k);
    int h;
    int c=0;
    for(int i=0;i<n;i++) {
        scanf("%d",&h);
        if(h>=k)c++;
    }
    printf("%d",c);
    return 0;
}

Measured memory_bytes: 128
n, w = map(int, input().strip().split())
data = [list(map(int, input().strip().split())) for _ in range(n)]

# i番目に重さがj以下となるように選んだときの価値の総和の最大値
dp = [[0] * (w + 1) for _ in range(n)]

for i in range(0, n):
    for j in range(w + 1):
        # i 番目の品物の重さと価値
        wi, vi = data[i]
        if i == 0:
            take = vi if j - wi >= 0 else 0
            miss = 0
            dp[i][j] = max(take, miss)
        else:
            # i番目の品物を入れる場合
            take = dp[i - 1][j - wi] + vi if j - wi >= 0 else 0
            # 入れない場合
            miss = dp[i - 1][j]
            dp[i][j] = max(take, miss)

print(max(dp[n - 1]))


Measured memory_bytes: 152228
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s = input()

print("Yes" if "7" in s else "No")


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

int main() {
  string s;
  cin >> s;
  s='>'+s+'<';
  
  long ans=0;
  int n=s.size()-1;
  vector<int>b(n,-1);
  vector<int>c(n,-1);
  rep(i,n){
    if(s.at(i)=='>'&&s.at(i+1)=='<'){
      b.at(i)=0;
      c.at(i)=0;
    }
  }
  rep(i,n-1){
    if(b.at(i)>-1&&s.at(i+1)=='<'){
      b.at(i+1)=b.at(i)+1;
    }
  }
  for(int i=n-1;i>0;i--){
    if(c.at(i)>-1&&s.at(i)=='>'){
      c.at(i-1)=max(c.at(i)+1,c.at(i-1));
    }
  }
    
  rep(i,n){
    ans+=max(b.at(i),c.at(i));
  }
  cout<<ans<<endl; 
}

Measured memory_bytes: 7700
#include <stdio.h>

int main(void)
{
	int n, m, i, sum = 0;

	scanf("%d %d", &n, &m);
	for (i = 1; i <= m; i++)
	{
		int a;
		scanf("%d", &a);
		sum += a;
	}

	if (sum > n)
		puts("-1");
	else
		printf("%d", n - sum);
	return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int Q;
    cin >> Q;
    vector<int> l(Q), r(Q), x(100001);
    vector<bool> is_prime(100001);
    for(int i=0; i<Q; i++){
        cin >> l[i] >> r[i];
    }

    fill(is_prime.begin(), is_prime.end(), 1);
    is_prime[0]=0;
    is_prime[1]=0;
    for(int i=2; i<=100000; i++){
        if(is_prime[i]){
            for(int j=i*2; j<=100000; j+=i){
                is_prime[j]=0;
            }
        }
    }
    fill(x.begin(), x.end(), 0);
    int cnt=0;
    for(int i=1; i<=100000; i++){
        if(i%2==1 && is_prime[i]==1 && is_prime[(i+1)/2]==1){
            cnt++;
        }
        x[i]=cnt;
    }
    
    for(int q=0; q<Q; q++){
        cout << x[r[q]] - x[l[q]-1] << endl;
    }


    return 0;
}


Measured memory_bytes: 1792
class UnionFind:
    def __init__(self,n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rank = [0]*(n+1)

    def find(self,x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self,x,y):
        return self.find(x) == self.find(y)

    def size(self,x):
        return -self.root[self.find(x)]

    def member(self,x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_member(self):
        return {r:self.member(r) for r in self.roots()}

    def __str__(self):
        return "\n".join("{}: {}".format(r,self.member(r)) for r in self.roots())

def main():
    N,M,K = map(int,input().split())
    adj = [[] for _ in range(N)]
    ans = [None]*N
    uf = UnionFind(N)
    for i in range(M+K):
        a,b = map(lambda x : int(x)-1,input().split())
        if i < M:
            uf.unite(a,b)
            adj[a].append(b)
            adj[b].append(a)
        elif uf.same(a,b):
            adj[a].append(b)
            adj[b].append(a)
    for i in range(N):
        ans[i] = uf.size(i) - len(adj[i]) - 1
    print(*ans,sep=" ")


if __name__ == '__main__':
    main()

Measured memory_bytes: 108576
import math
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = A[-1]
target = math.ceil(A[-1] / 2)
dis = float('inf')
for a in A:
    tmp_dis = abs(target - a)
    if tmp_dis < dis:
        dis = tmp_dis
        tmp_ans = a
print(ans, tmp_ans)


Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define out(a) cout << a << endl
ll factorial(int n) {if (n == 1) return 1; return n * factorial(n - 1);}
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always



int main() {
    int n; cin >> n;
    cout << factorial(n) << endl;
}



Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
typedef long long int ll;
#define FOR(i,a,n) for(int i=a;i<n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int V;//??????
int E;//???
struct edge { int from, to, cost; };
typedef std::pair<int, int> PP;
std::vector<edge> e;
int Par[100000];
int Rank[100000];
void init(int n) {
	for (int i = 0; i < n; i++) {
		Par[i] = i;
		Rank[i] = 0;
	}
}
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 (Rank[x] < Rank[y]) {
		Par[x] = y;
	}
	else {
		Par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
// ??????????????????????????????????????¢??° 
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
int kruskal() {
	init(V);
	sort(e.begin(), e.end(), comp);
	int ans = 0;
	for (int i = 0; i<E; i++) {
		if (!same(e[i].from, e[i].to)) {
			unite(e[i].from, e[i].to);
			ans += e[i].cost;
		}
	}
	return ans;
}
int main() {
	while (std::cin >> V&&V) {
		std::cin >> E;
		int a, b, c;
		char aa, bb;
		for (int i = 0; i < E; i++) {
			std::cin >> a >> aa >> b >> bb >> c;
			e.push_back(edge{ a,b,c });
		}
		std::cout << kruskal() / 100 - V + 1 << std::endl;
		e = {};
	}
	return 0;
}

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

int main() {
  int i,A,B;
  cin >> A >> B;
  
  for(i=1;i<21;i++){
  	if(A * i == B ){
      cout << A+B << endl;
      break;
    }
  }
  if(i==21) cout << B-A << endl;
}


Measured memory_bytes: 256