akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 310000
ll MOD=998244353;
ll inv[N];

vector<vec> G(N);
main(){
    int n=in();
    vector<string> v;
    int a=0,b=0,ans=0;
    int flag=0;
    rep(i,n){
        string s;
        cin>>s;
        if(s[0]=='B')b++;
        rep(j,s.size()-1){
            if(s[j]=='A'&&s[j+1]=='B')ans++;
        }
        if(s[s.size()-1]=='A')a++;
        if(s[0]=='B'&&s[s.size()-1]=='A')flag++;
    }
    if(flag==a&&flag==b){
        if(flag==0)cout<<ans;
        else cout<<ans+flag-1;
        return 0;
    }
    cout<<ans+min(a,b);
}



Measured memory_bytes: 7552
#include <bits/stdc++.h>
#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;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    a.push_back(-1);
    n++;
    ll ans=0;
    if(a[0]!=0){cout<<-1<<endl; return 0;}
    for(int i=1; i<n; ++i){
        if(a[i-1]+1<a[i]){cout<<-1<<endl; return 0;}
        else if(a[i-1]+1>a[i]){
            ans+=a[i-1];
        }
    }
    cout<<ans<<endl;
}

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

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

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a%b);
}

map<pair<int, int>, int> g_range_gcd;

int range_gcd(const vector<int>& A, int l, int r) {
    if (r - l == 1)
        return A[l];
    if (g_range_gcd.count(make_pair(l, r)) != 0) {
        return g_range_gcd[make_pair(l, r)];
    }
    int m = (l + r) / 2;
    return g_range_gcd[make_pair(l, r)] = gcd(range_gcd(A, l, m), range_gcd(A, m, r));
}

int range_gcd2(const vector<int>& A, int l, int r, int x) {
    if (r - l == 1) {
        return l == x ? -1 : A[l];
    }
    if (x < l || r <= x) {
        return range_gcd(A, l, r);
    }
    int m = (l + r) / 2;
    int a = range_gcd2(A, l, m, x);
    int b = range_gcd2(A, m, r, x);
    if (a == -1) return b;
    if (b == -1) return a;
    return gcd(a, b);
}

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    int res = 1;
    for (int i = 0; i < N; i++) {
        res = max(res, range_gcd2(A, 0, N, i));
    }
    cout << res << endl;
}

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

int main() {
  vector<int>vec(3);
  for(int i=0; i<3; i++){
    cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
  cout << vec.at(2)-vec.at(0) << endl;
}


Measured memory_bytes: 3604
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String[] strAry = br.readLine().split(" ");
			int n = Integer.parseInt(strAry[0]);
			int x = Integer.parseInt(strAry[1]);
			if (n == 0 && x == 0) break;
			int count = 0;
				for (int i = 1; i <= n; i ++) {
					for (int j = 1; j <= n; j++) {
						if (j < i) continue;
							for (int k = 1; k <= n; k++) {
								if (k < i || k < j) continue;
								if ((i + j + k) == x && i != j && j != k && k != i) {
									count++;
								}
							}
					}
				}
				System.out.println(count);
		}
	}
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >>n;
  vector<int> dp(n);
  vector<int> h(n);
  for(int i = 0; i<n;i++){
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[0]-h[1]);
  for(int i = 2; i<n;i++){
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
  }
  cout << dp[n-1];
}


Measured memory_bytes: 1024
n = int(input())
d = len(str(n))
n_sum = 0
for i in range(d):
    n_sum += int(str(n)[i])
def judge(n):
    for i in range(1, len(n)):
        if n[i] != "9":
            return True
    return False
print(n // (10 ** (d - 1)) - 1 + 9 * (d - 1) if judge(str(n))  else n_sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n, a, b;
    cin >> n;
    vector<pair<int, int>> p_red;
    rep(i, n){
        cin >> a >> b;
        p_red.emplace_back(a, b);
    }
    vector<pair<int, int>> p_blue;
    rep(i, n){
        cin >> a >> b;
        p_blue.emplace_back(a, b);
    }
    sort(p_red.begin(), p_red.end());
    sort(p_blue.begin(), p_blue.end());

    int ans = 0;
    rep(i, n){
        int idx = 0;
        int m = 0;
        bool ok = false;
        rep(j, p_red.size()){
            if(p_blue[i].first > p_red[j].first && p_blue[i].second > p_red[j].second){
                ok = true;
                if(m <= p_red[j].second){
                    idx = j;
                    m = p_red[j].second;
                }
            }
            else if(p_blue[i].first <= p_red[j].first){
                break;
            }
        }
        if(ok){
            p_red.erase(p_red.begin() + idx);
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int a,b;
	cin>>a>>b;

	cout<<a*b<<endl;

	return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int n;

class Matrix{
public:
    vector<vector<ll>> m;
    int height,width;
    Matrix(int h,int w){//sizeを指定
        height = h;
        width = w;
        m.resize(h);
        REP(i,h){
            m[i].resize(w);
        }
    }
    Matrix operator*(Matrix b){
        int h=height;
        int w=b.width;
        int n=width;
        //if(n!=b.height){
        //}d
        Matrix c(h,w);
        REP(i,h){
            REP(j,w){
                ll v=0;
                REP(k,n){
                    v+=m[i][k]*b.m[k][j];
                }
                c.m[i][j]=v;
            }
        }
        return c;
    }
    Matrix operator*(ll x){
        Matrix c(height,width);
        c.m=m;
        REP(i,height)REP(j,width)c.m[i][j]*=x;
        return c;
    }
    Matrix operator+(Matrix b){//大きさが同じことが前提
        Matrix c(height,width);
        REP(i,height)REP(j,width)c.m[i][j]=m[i][j]+b.m[i][j];
        return c;
    }
    Matrix operator-(Matrix b){
        Matrix c(height,width);
        REP(i,height)REP(j,width)c.m[i][j]=m[i][j]-b.m[i][j];
        return c;
    }
    void operator*=(ll x){
        REP(i,height)REP(j,width)m[i][j]*=x;
    }
    
};


Matrix pow_mat(Matrix a,int k){
    if(k==1){
        return a;
    }
    if(k%2==0){
        return pow_mat(a,k/2)*pow_mat(a,k/2);
    }else{
        return pow_mat(a,k-1)*a;
    }
}

int main(){
    cin >> n;
    Matrix A(2,2);
    ll f0 = 2;
    ll f1 = 1;
    ll a = 1;
    ll b = 1;
    A.m[0][0]=a;
    A.m[0][1]=b;
    A.m[1][0]=1;
    A.m[1][1]=0;
    
    Matrix res(2,2);
    res = pow_mat(A,n);
    ll fn = res.m[1][0]*f1+res.m[1][1]*f0;
    put(fn);
    return 0;
}


Measured memory_bytes: 256
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    h, w, k = map(int, input().split())
    masu = [list(input()) for i in range(h)]
    ans = 0
    for i in range(w+1):
        for k1 in itertools.combinations(range(w), i):
            for j in range(h+1):
                for k2 in itertools.combinations(range(h), j):
                    sushi = 0
                    for y in k2:
                        for x in k1:
                            if masu[y][x] == "#":
                                sushi += 1
                    if sushi == k:
                        ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 79020
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2] || s[0] == s[2] && s[1] == s[3] && s[0] != s[1] || s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 2*acos(0)
#define ll long long
#define pii pair<int,int>
#define mx 100005
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    char ch;
    scanf(" %c",&ch);
    if(ch>='a' && ch<='z') cout<<"a";
    if(ch>='A' && ch<='Z') cout<<"A";
    return 0;
}


Measured memory_bytes: 3776
def alchemist(N: int, V: list)->float:
    V.sort()
    s = V[0]

    for v in V[1:]:
        s = (s + v) / 2

    return s


if __name__ == "__main__":
    N = int(input())
    V = list(map(int, input().split()))

    ans = alchemist(N, V)
    print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>

int main(void)
{
    char s[5];
    int ans=0;
    int i;

    for(i=0;i<4;i++){
        scanf("%c",&s[i]);//printf("s:%d,%c\n",s[i],s[i]);
        if(s[i]==43){
            ans+=1;//printf("ans:%d\n",ans);
        }else if(s[i]==45){
            ans-=1;//printf("ans:%d\n",ans);
        }
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<cctype>
#include<sstream>
#include<stack>
using namespace std;
typedef long long ll;

int main()
{
    ll a,b,c;
    while(~scanf("%lld%lld%lld",&a,&b,&c))
        printf("%lld",min(a*b,c));
    return 0;
}


Measured memory_bytes: 256
S = input()
correct_case1 = "".join(["0" if i%2 == 0 else "1" for i in range(len(S))])
correct_case2 = "".join(["0" if i%2 == 1 else "1" for i in range(len(S))])
c1 = 0
c2 = 0
for i in range(len(S)):
  if correct_case1[i] != S[i]:
    c1 += 1
  if correct_case2[i] != S[i]:
    c2 += 1
print(min([c1, c2]))

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

using namespace std;

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

  string s;
  cin >> s;
  for (char c : s) {
    if (c == '?') {
      c = 'D';
    }
    cout << c;
  }

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    int tmp;
    int ans=0;
    for(int i = 0; i < N; i++){
        cin >> P.at(i);
    }
    for(int i = 0; i < N; i++){
        if(i==0) tmp=P[0];
        if(P[i] <= tmp) ans += 1;
        tmp=min(tmp,P[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys
from functools import reduce

for line in sys.stdin:
    nums = list(map(lambda x: int(x), line.split()))
    menseki = reduce(lambda x, y: x * y, nums)
    syuu = reduce(lambda x, y: x + y, nums) * 2
    print(str(menseki) + " " + str(syuu))



Measured memory_bytes: 6276
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		Map<String, Integer> m = new HashMap<String, Integer>();
		long cnt = 0;
		for (int i = 0; i < N; i++) {
			String s = getRunLength(sc.next());
			if (m.containsKey(s)) {
				m.put(s, m.get(s) + 1);
			} else {
				m.put(s, 1);
			}
		}
		Iterator<Map.Entry<String, Integer>> itr2 = m.entrySet().iterator();
		while (itr2.hasNext()) {
			// nextを使用して値を取得する
			Map.Entry<String, Integer> entry = itr2.next();
			if (entry.getValue() != 0) {
				cnt += get(entry.getValue());
			}
		}
		System.out.println(cnt);

	}

	public static String getRunLength(String str) {
		char[] list = new char[str.length()];
		list = str.toCharArray();
		Arrays.sort(list);
		return new String(list);
	}

	public static long get(int n) {
		long ret = 0;
		for (int i = n - 1; i > 0; i--) {
			ret += i;
		}
		return ret;
	}

}

class FScanner {
	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: 51864
n, m, x = map(int, input().split())
lis = []
for i in range(n):
    lis.append(list(map(int, input().split())))
r = []    
for i in range(2**n+1):
    num = i
    a = [0 for _ in range(m)]
    p = 0
    for j in range(n):
        if num%2==1:
            p += lis[j][0]
            for s in range(m):
                a[s] += lis[j][s+1]
        num >>= 1
    if all(i>=x for i in a):
        r.append(p)
if len(r)==0:
    print(-1)
else:
    print(min(r))

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    string S;
    cin >> S;
    REP(i,S.size()){
        if(S[i] == '1') S[i] = '9';
        else S[i] = '1';
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,M;
    cin >> N >> M;
    int k[M];
    int p[M];
    vector<vector<int>> m(N);
    rep(i,M){
        cin >> k[i];
        rep(j,k[i]){
            int x;
            cin>>x;
            x--;
            m[x].push_back(i);
        }
    }
    rep(i,M) cin>>p[i];
    int cou=0;
    for(int bit=0;bit<(1<<N);bit++){
        int z[M]={};
        for(int i=0;i<N;i++){
            if(bit & (1<<i)){
                for(int j=0;j<m[i].size();j++){
                    z[m[i][j]]++;
                }
            }
        }
        bool ans=true;
        for(int i=0;i<M;i++){
            if(z[i]%2!=p[i]) ans=false;
        }
        if(ans) cou++;
    }
    cout << cou << endl;


}


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

using namespace std;

int main()
{
int N;
cin>>N;
vector<int> a(N);
for(int i=0;i<N;i++) cin>>a[i];

int ans=0,max_ans=0;
for(int i=1;i<N;i++)
{
	if(a[i]<=a[i-1])
	{
		ans++; max_ans=max(ans,max_ans);
	}
	else
		ans=0;
}
cout<<max_ans;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#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 <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;
using qul = queue<ll>;
using pql = priority_queue<ll>;

// ========================================================================



ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 

//#define int long long;


// ========================================================================


/*signed*/int main() {
	ll n; cin >> n;
	vl a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	ll ans = a[0];
	for (int i = 0; i < n; i++) {
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3972
def main():
    n, x, y = map(int, input().split())
    ans = [0] * (n+1)
    for i in range(1, n):
        for j in range(i+1, n+1):
            # x->yを通らない
            d1 = abs(j-i)
            # i->x->y->jの順 +1はx->yの分
            d2 = abs(x-i) + 1 + abs(j-y) 
            # i->y->x->jの順 +1はy->xの分
            d3 = abs(y-i) + 1 + abs(j-x)
            dist = min(min(d1, d2), d3)
            ans[dist] += 1
    print(*ans[1:n], sep='\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9284
package main

import "fmt"

func pow(a, n int) int {
	x := 1
	for i := n; i != 0; i >>= 1 {
		if i&1 == 1 {
			x *= a
		}
		a *= a
	}
	return x
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	fmt.Println(k * pow(k-1, n-1))
}


Measured memory_bytes: 512
while true
    n = gets.to_i
    break if n == 0
    arr = gets.chomp.split.map(&:to_i)
    count = 0
    while true
        h = Hash.new(0)
        arr.each{|x| h[x] += 1}
        arr2 = []
        arr.each{|x| arr2 << h[x]}
        break if arr == arr2
        arr = arr2
        count += 1
    end
    puts count
    puts arr.join(" ")
end


Measured memory_bytes: 7020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b;
    cin>>a>>b;
    if(a%2==b%2){
        cout<<a+(b-a)/2<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
int T,n,m;
int main() {
	string s;
	cin>>s;
	for(int i=0;i<s.length()-1;i++) 
		if(s[i]==s[i+1]){
			cout<<"Bad";
			return 0;
		}
	cout<<"Good";
    return 0;
}



Measured memory_bytes: 256
/*
*/
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <cstring>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
#define MOD 1000000007LL
typedef long long ll;
using namespace std;
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; }

int main() {
    ll N,M, ans[10]={};
    
    cin >> N >> M;
    // vector<ll> s(M);
    // vector<ll> c(M);

    for (ll i = 1; i <= M; i++) {
        ll s, c;
        cin >> s >> c;
        if(s == 1 && c == 0 && N > 1){
            cout << -1 << endl;
            return 0;
        }
        else if(ans[s-1] == 0 || ans[s-1] == c)
            ans[s - 1] = c;
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    if(N == 1)
        cout << ans[0];
    else {
        if(ans[0])
            cout << ans[0];
        else
            cout << 1;
        FOR(i, 1, N)
            cout << ans[i];
    }

    return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


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

	long double radius = 1e11;
	long double pi = acos(static_cast<long double>(-1.0));

	vector<int> v(n, 0);
	int ma = 3000000;
	for(int c = 0; c < ma; ++c){
		long double px = radius * cos(c * 2 * pi / ma);
		long double py = radius * sin(c * 2 * pi / ma);
		long double d_min = 1e40;
		int ind = 0;
		for(int i = 0; i < n; ++i){
			long double d = (px - a[i]) * (px - a[i]) + (py - b[i]) * (py - b[i]);
			if(d_min > d){
				ind = i;
				d_min = d;
			}
		}
		++v[ind];
	}

	for(auto& x : v)
		printf("%.20lf\n", 1.0 * x / ma);

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    int dp[n + 1][3];
    for (int i = 0; i <= n; i++) for (int j = 0; j < 3; j++) dp[i][j] = 0;
    for (int i = 0; i < n; i++) {
        int a, b, c; cin >> a >> b >> c;
        dp[i + 1][0] = max(dp[i][1] + a, dp[i][2] + a);
        dp[i + 1][1] = max(dp[i][0] + b, dp[i][2] + b);
        dp[i + 1][2] = max(dp[i][1] + c, dp[i][0] + c);
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
    return 0;
}


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

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

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int MAX=max({a,b,c});
  int ans=a+b+c-MAX;
  rep(i,k)
    MAX*=2;
  cout<<ans+MAX<<endl;

  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(0); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
// all_of
// partial_sum, adjacent_difference

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int n;
int main() {
	cin >> n;
	set<int> s;
	REP(i, 0, n) {
		int a;
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;
	return 0;
}

Measured memory_bytes: 764
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines


class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if x == y:
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


N, M = map(int, readline().split())
root = UnionFind(N)
ans = N * (N - 1) // 2
answer = []

for i in readlines()[::-1]:
    answer.append(ans)
    a, b = map(int, i.split())
    if root.isSameGroup(a, b):
        continue
    else:
        ans -= root.Count(a) * root.Count(b)
    root.Unite(a, b)

for i in answer[::-1]:
    print(i)

Measured memory_bytes: 18856
from collections import Counter
def p_factorization(n):
  p=[]
  for i in range(2,int(n**0.5)+1):
    while n%i==0:
      p.append(i)
      n//=i
  if n>1:
    p.append(n)
  return p
n=int(input())
ans=0
for pi in Counter(p_factorization(n)).items():
  x=pi[1]
  for i in range(50):
    if i*(i+1)//2<=x<(i+1)*(i+2)//2:
      ans+=i
      break
print(ans)

Measured memory_bytes: 9740
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f n = g n []
  where
    g 0 s = s
    g x s = g nq (nc:s)
      where
        (q,r) = divMod x 3
        nq = case r of
            2 -> q + 1
            _ -> q
        nc = case r of
            0 -> '0'
            1 -> '+'
            2 -> '-'


main = getInt >>= putStrLn . f



Measured memory_bytes: 3568
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
//LLONG_MIN

//同じ座標があったときにどうするか？？？


struct edge {ll u,v,cost;};

bool comp(const edge&e1, const edge&e2){
	return e1.cost < e2.cost;
}

int par[1000001];
int find(int x){
	if(par[x]==x)return x;
	return par[x]=find(par[x]);
}
bool same(int x,int y){
	return find(x)==find(y);
}
void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x==y)return;
	par[x]=y;
}

int main(void){
	vector<edge> es;
	int E,N;
	ll ans=0;
	ll x[100001],y[100001];
	ll x2[100001],y2[100001];
	map<ll,ll> x_index;
	map<ll,ll> y_index;
	cin>>N;
	rep(i,N)par[i]=i;//union-find初期化
	E = (N-1)*2;
	rep(i,N){
		cin>>x[i]>>y[i];
		if( x_index.end() != x_index.find(x[i]) ){//先客がいた場合
			unite(x_index[x[i]],i);
		}
		if( y_index.end() != y_index.find(y[i]) ){//先客がいた場合
			unite(y_index[y[i]],i);
		}
		x_index[x[i]]=i;
		y_index[y[i]]=i;
		x2[i]=x[i];
		y2[i]=y[i];
	}
	sort(x2,x2+N);
	sort(y2,y2+N);
	rep(i,N-1){
		es.push_back((edge){x_index[x2[i]],x_index[x2[i+1]],abs(x2[i]-x2[i+1]) } );
		es.push_back((edge){y_index[y2[i]],y_index[y2[i+1]],abs(y2[i]-y2[i+1]) } );
	}
	sort(es.begin(),es.end(),comp);
	rep(i,E){
		edge e = es[i];
		if(!same(e.u,e.v)){
			unite(e.u,e.v);
			ans+=e.cost;
		}
	}

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

Measured memory_bytes: 24560
def main():
    s = input()
    slen = len(s)
    cnt = 0
    last = 0
    if s[0] == "W":
        for i in range(slen-1):
            if s[i] == "W" and s[i+1] =="B":
                cnt += 1
        if s[-1] == "W":
            last = 1
    if s[0] == "B":
        for i in range(slen-1):
            if s[i] == "B" and s[i+1] =="W":
                cnt += 1
        if s[-1] == "B":
            last = 1        
    if cnt == 0:
        print(cnt)
    else:
        print(cnt*2 - 1 + last)
    

 
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<string, int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

int main(){
	
	string str, ans, S = " ";
	cin >> str;
	
	int n;
	cin >> n;
	
	for(int i = 0; i < str.size(); i += n){
		S[0] = str[i];
		ans += S;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

template<class T>
inline T read(T &a){
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    return a = x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 

int a, b, c;
int main() {
	read(a); read(b);
	int X = (b - 2 * a) / 2;
	int Y = a - X;
	if (X < 0 || Y < 0) {
		cout << "No" << endl; return 0;
	}
	if (4 * X + 2 * Y == b) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}



Measured memory_bytes: 3628
n,p = map(int, input().split())
a = list(map(int, input().split( )))
a = [a[i]%2 for i in range(n)]
dp0 = 1
dp1 = 0

for i in range(n):
    if a[i]%2:
        dp_0 = dp1 + dp0
        dp_1 = dp1 + dp0
    
        dp0,dp1 = dp_0,dp_1
    else:
        dp0*=2
        dp1*=2

if p:
    print(dp1)
else:
    print(dp0)



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

const int N = 8e5+5;

int func(string s, string t){
  int diff = 0;
  for(int i=0;i<s.size(); i++){
    diff += (s[i] != t[i]);
  }
  return diff;
}

void solve(){
 string s,t;
 cin>>s>>t;
 int ans = INT_MAX;
 for(int i=0;i<s.size()-t.size()+1; i++){
   ans = min(ans,func(s.substr(i,t.size()),t));
 }
 cout<<ans;
}
int main(){
  // freopen("input.txt", "r",stdin);
  // freopen("output.txt", "w", stdout);
  ll t;
  // cin>>t;
  t = 1;
  while(t--){
    solve();
  }
}
























/*
  1 2 3 4 5 6 7 8

  6 7 8 1 2 3 4 5


*/


Measured memory_bytes: 3620
N = int(input())
H = [int(i) for i in input().split()]
ct = 0
flag = True
for i in range(N-1):
  if(H[i+1]-H[i] <= -2):
    flag = False
    break
  elif(H[i+1]-H[i] == -1 and ct >= 1):
    flag = False
    break
  elif(H[i+1]-H[i] == -1 and ct == 0):
    ct += 1
  elif(H[i+1] -H[i] >= 1):
    ct = 0
if(flag):
  print("Yes")
else:
  print("No")

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

int main(){
	int N, M, C;
	cin >> N >> M >> C;

	vector<int> B(M);
	for(int i = 0; i < M; i++)
	{
		cin >> B[i];
	}
	
	int ans = 0;
	int sum;
	for(int i = 0; i < N; i++)
	{
		sum = C;
		for(int j = 0; j < M; j++)
		{
			int A;
			cin >> A;
			sum += A * B[j];
		}
		if(sum > 0) ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int c1, c5, c10, c50, c100, c500;
  
  scanf("%d%d%d%d%d%d",&c1 ,&c5 ,&c10 ,&c50 ,&c100 ,&c500);
    
    if(c1+c5*5+c10*10+c50*50+c100*100+c500*500 >= 1000)
      {
      printf("1\n");
    }
    else
      {
	printf("0\n");
      }
    return 0;
}

Measured memory_bytes: 584
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long L = sc.nextInt();
        long R = sc.nextInt();

        long minMod = 2019;
        if(R-L > 2020){
            System.out.println(0);
            System.exit(0);
        }

        for(long i =L;i< R;i++){
            for(long j= i+1;j< R +1;j++){
                minMod = Math.min(minMod,(i *j % 2019));
                if(minMod == 0){
                    System.out.println(0);
                    System.exit(0);
                }
            }
        }

        System.out.println(minMod);


    }



}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if(s.at(0)==s.at(1)){
    if(s.at(2)==s.at(3)&&s.at(1)!=s.at(2)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else if(s.at(0)==s.at(2)){
    if(s.at(1)==s.at(3)&&s.at(1)!=s.at(2)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else if(s.at(0)==s.at(3)){
    if(s.at(1)==s.at(2)&&s.at(0)!=s.at(2)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n, m;
    cin >> n >> m;
    vector<li> as(m);
    for (int i = 0; i < m; ++i) {
        cin >> as[i];
    }

    vector<li> costs = {n + 1,
                        2,
                        5,
                        5,
                        4,
                        5,
                        6,
                        3,
                        7,
                        6};

    map<li, string> dp;
    dp[0] = "";

    for (int i = 1; i <= n; ++i) {
        string best;
        bool empty = true;

        for (int j = 0; j < m; ++j) {
            li rev = i - costs[as[j]];
            if (dp.find(rev) != dp.end()) {
                string cand = string(1, '0' + as[j]) + dp[rev];
                if (empty || cand.size() > best.size() || (cand.size() == best.size() && cand > best)) {
                    best = cand;
                    empty = false;
                }
            }
        }
        if (not empty) {
            dp[i] = best;
        }
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 32512
from itertools import product
from collections import Counter

if __name__ == '__main__':
    n = input()
    length = len(n)
    facts = [0] * length
    facts[0] = 1
    for i in range(1, length):
        facts[i] = (i + 1) * facts[i - 1]

    ans = 0
    for m in range(3, length):
        for i in range(1, length):
            for j in range(1, length - i):
                k = m - i - j
                ans += facts[m - 1] // (facts[i - 1] * facts[j - 1] * facts[k - 1])

    for s in (''.join(list(t)) for t in product(*(['357'] * length))):
        if n < s:
            break
        if set(Counter(s).keys()) != {'3', '5', '7'}:
            continue
        ans += 1
    print(ans)


Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int dp[1000010][3];
int a[100010], b[100010], c[100010];
int main()
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for (int i = 1; i < N; i++) {
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
	}
	cout << max({ dp[N - 1][0],dp[N - 1][1],dp[N - 1][2] }) << endl;
}

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

int main() {

    int n; cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for (auto u : mp) {
        if (u.second % 2 == 1) ans++;
    }

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

Measured memory_bytes: 4992
#include <cstdio>
#include <memory.h>

int n;
int MAX_N=1000004;
bool DP[1000005] ;//素数リスト「素数じゃなかったらtrue」


int main()
{
	memset(DP,false,sizeof(DP));
	while(scanf("%d",&n)!=EOF)
	{
	 	int count=0;
		for(int i=1;i<=n;i++)
		{
			DP[0]=true;
			DP[1]=true;
			if(DP[i]==false)
			{
				count++;
				for(int j=i*2;j<MAX_N;j+=i)DP[j]=true;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 1740
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  string s; cin >> s;
  s[3]='8';
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
student = []

for _ in range(50):
    m, f, r = list(map(int, input().split()))
    if m == -1 and f == -1 and r == -1:
        break
    student.append([m, f, r])

for i in range(len(student)):
    if student[i][0] == -1 or student[i][1] == -1:
        print("F")
        continue

    sum_stu = student[i][0] + student[i][1]
    if sum_stu >= 80:
        print("A")
    elif 80 > sum_stu >= 65:
        print("B")
    elif 65 > sum_stu >= 50:
        print("C")
    elif 50 > sum_stu >= 30:
        if student[i][2] >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")



Measured memory_bytes: 5600
#!/usr/bin/env ruby
def dfs(idx, c, ary)
  if idx == N
    (0...M).each do |i|
      return 1e8 if ary[i] < X
    end
    return c
  end
  newary = ary.dup
  (0...M).each do |i|
    newary[i] += MAP[idx][i+1]
  end

  return [
      dfs(idx + 1, c, ary),
      dfs(idx + 1, c + MAP[idx][0], newary)
  ].min
end

N,M,X = gets.chomp.split.map(&:to_i)
MAP = N.times.map { gets.split.map(&:to_i) }
res = dfs(0, 0, Array.new(M, 0))
puts res == 1e8 ? -1 : res

Measured memory_bytes: 14412