akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}



signed main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    intl cnt = 0;
    intl ans = 0;
    intl len = s.length();
    rep(i,len){
        if(cnt > 0){
            ans += (s[i] == 'g');
            cnt--;
        }
        else{
            ans -= (s[i] == 'p');
            cnt++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int A, N;
    cin >> N >> A;
  if ( N % 500 != 0 && ( N % 500 ) > A) {
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;  
  }
}

Measured memory_bytes: 3532
N, M = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1) # 木の高さ
        self.n = [1] * (n+1)    # グループメンバー数
        
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def find_n(self, x):
        return self.n[self.find(x)]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.n[y] = self.n[x] + self.n[y]
        else:
            self.par[y] = x
            self.n[x] = self.n[x] + self.n[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def is_same(self, x, y):
        return self.find(x) == self.find(y) 
def main():
    uf = UnionFind(N)
    p = N * (N - 1) // 2
    ans = [p]
    for x, y in reversed(ab):
        px = uf.find(x)
        py = uf.find(y)
        if px != py:
            p -= uf.find_n(px) * uf.find_n(py)
            uf.unite(px, py)
        ans.append(p)
 
    for a in reversed(ans[:-1]):
        print(a)
 
 
main()


Measured memory_bytes: 24828
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
void generate_strings(ll n ,ll length, ll index, string s){
    fo(i,index+1){
        string str=s;
        str.pb('a'+i);
        if(length==n){cout<<str<<endl; continue; }
        if(i==index)generate_strings(n,length+1 , index+1 , str);
        else generate_strings(n,length+1 , index,str);
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
   
    //cin>>t;
    t=1;
    while(t--){
        cin>>n;
        string s;
        generate_strings(n,1,0,s);
    }

    return 0;
}


Measured memory_bytes: 1536
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], X = ip[2];
	if(!(A > X) && A + B >= X) "YES".writeln;
	else "NO".writeln;
}

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

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<vector>
#include<typeinfo>
#include<algorithm>
#define MAX_LEN 10000
#define MAX_NC 3333
using namespace std;

string s;

int find(int l){
  int cnt=1;
  int r=l;
  char temp;
  while(cnt){
    temp=s[++r];
    if(temp=='[')cnt++;
    else if(temp==']')cnt--;
  }
  return r;
}


int f(int from,int to){
  vector<int> nv;
  string temp1;
  int nd;
  int v=0;
  int l,r;

  if(s[from+1]=='['){
    nd=0;
    l=from+1;
    while(l<to){
      r=find(l);
      nv.push_back(f(l,r));
      nd++;
      l=r+1;
    }
    sort(nv.begin(),nv.end());
    for(int i=0;i<(nd+1)/2;++i){
      v+=nv[i];
    }
      return v;
  }else{
    while(s[from+1]!=']'){
      temp1+=s[from+1];
      from=from+1;
    }
    int a=stoi(temp1);
    temp1.clear();
    return (a+1)/2;
  }

}

int main(){
  int n;
  cin>>n;
  while(n--){
    int cnt=0;
    cin>>s;
    int ans=f(0,s.size()-1);
    cout<<ans<<endl;
  }
}

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

int main()
{
  int n, k, m;
  while (cin >> n >> k >> m && n != 0) {
    --m;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
      v[i] = i+1;
    }

    for (int c = 0; c < n-1; c++) {
      v.erase(v.begin()+m);
      m = (m-1 + k) % v.size();
    }
    cout << v.front() << endl;
  }
  return 0;
}

Measured memory_bytes: 940
abc = list(map(int, input().split()))
x = 0
y = 0
ans = 1
for i in range(3):
    if abc[i]%2==0:
        x+=1
    else:
        y+=1
if x==2:
    for i in range(3):
        if abc[i]%2==0:
            abc[i]+=1
elif y==2:
    for i in range(3):
        if abc[i]%2==1:
            abc[i]+=1
else:
    ans -= 1
abc.sort(reverse=True)
ans = ans + (abc[0]-abc[1])//2 + (abc[0]-abc[2])//2
print(ans)

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

const int N=190;
int n,m,s[N][N],f[N][N][N][2],g[N][N][N][2];
char ch[N][N];

void cmax(int& x,int y) {x=x>y?x:y;}

bool check(int x1,int y1,int x2,int y2)
{
	int tmp=s[x2][y2]-s[x1-1][y2]-s[x2][y1-1]+s[x1-1][y1-1];
	return (!tmp) || (tmp == (x2-x1+1)*(y2-y1+1));
}

void pre()
{
	for(int i=1;i<=m+1;++i)
		for(int l=1;l<=n;++l)
			for(int r=l;r<=n;++r)
			{
				if(i == m+1) {f[i][l][r][0]=m; continue;}
				int L=i,R=m,Mid;
				if(!check(l,i,r,L)) {f[i][l][r][0]=L-1; continue;}
				if(check(l,i,r,R)) {f[i][l][r][0]=m; continue;}
				while(L<R-1)
				{
					Mid=(L+R)>>1;
					if(check(l,i,r,Mid)) L=Mid;
					else R=Mid;
				}
				f[i][l][r][0]=L;
			}
	for(int i=1;i<=n+1;++i)
		for(int l=1;l<=m;++l)
			for(int r=l;r<=m;++r)
			{
				if(i == n+1) {g[i][l][r][0]=n; continue;}
				int L=i,R=n,Mid;
				if(!check(i,l,L,r)) {g[i][l][r][0]=L-1; continue;}
				if(check(i,l,R,r)) {g[i][l][r][0]=n; continue;}
				while(L<R-1)
				{
					Mid=(L+R)>>1;
					if(check(i,l,Mid,r)) L=Mid;
					else R=Mid;
				}
				g[i][l][r][0]=L;
			}
}
			
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%s",ch[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		{
			s[i][j]=s[i][j-1]+s[i-1][j]-s[i-1][j-1];
			if(ch[i][j] == '#') ++s[i][j];
		}
	pre();
	if(f[1][1][n][0]  == m) {puts("0"); return 0;}
	for(int k=1;;++k)
	{
		int o=k&1;
		for(int i=1;i<=m+1;++i)
			for(int l=1;l<=n;++l)
				for(int r=l;r<=n;++r)
				{
					cmax(f[i][l][r][o], i-1);
					cmax(f[i][l][r][o], f[f[i][l][r][o^1]+1][l][r][o^1]);
					cmax(g[l][i][f[i][l][r][o]][o], r);
				}
		for(int i=1;i<=n+1;++i)
			for(int l=1;l<=m;++l)
				for(int r=l;r<=m;++r)
				{
					cmax(g[i][l][r][o], i-1);
					cmax(g[i][l][r][o], g[g[i][l][r][o^1]+1][l][r][o^1]);
					cmax(f[l][i][g[i][l][r][o]][o], r);
				}
		for(int i=1;i<=m+1;++i)
			for(int l=1;l<=n;++l)
				for(int r=n;r>=l;--r) cmax(f[i][l][r][o],f[i][l][r+1][o]);
		for(int i=1;i<=n+1;++i)
			for(int l=1;l<=m;++l)
				for(int r=m;r>=l;--r) cmax(g[i][l][r][o],g[i][l][r+1][o]);
		if(f[1][1][n][o] == m) {printf("%d",k); return 0;}
	}
	return 0;
}

Measured memory_bytes: 106624
#include<stdio.h>
int max(int a[],int n){
  int big=a[0];
  for(int i=1;i<n;i++){
    if(big<a[i]){
      big=a[i];
    }
  }
  return big;
}

int min(int a[],int n){
  int small=a[0];
  for(int i=1;i<n;i++){
    if(small>a[i]){
      small=a[i];
    }
  }
  return small;
}

long long int sum(int a[],int n){
  long long int sum=0;
  for(int i=0;i<n;i++){
    sum += a[i];
  }
  return sum;
}
int main(){
  int n,a[12000];
  scanf("%d" ,&n);
  for(int i=0;i<n;i++){
    scanf("%d" ,&a[i]);
  }

  printf("%d ",min(a,n));
  printf("%d ",max(a,n));
  printf("%lld\n",sum(a,n));

}



Measured memory_bytes: 2144
//Radhe Radhe
#include<bits/stdc++.h>//157B
#define ll long long
#define fixed cout.setf(ios::fixed);
#define rep1    for( i=0; i<n; i++)
#define Precise cout.precision(7);
using namespace std;

int main()
{
    ll i,j,a,b,c,mini,maxi;
    cin>>a>>b>>c;
    mini=min(a,b);
    maxi=max(a,b);
    if(c>=mini&&c<=maxi){
    return cout<<"Yes"<<endl,0;
    }
    cout<<"No"<<endl;



    return 0;
}





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

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    ll INF=1e18;
    ll mn=INF;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        sum+=x;
        if(x>y) mn=min(mn,y);

    }
    if(mn==INF) mn=sum;
    cout<<sum-mn<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#define int long long
using namespace std;

int n, d;
int t[100001], f[100001];

int Abs(int x) {
	if (x > 0) return x;
	return -x;
}

signed main()
{
	int i;
	
	cin >> n >> d;
	for (i = 1; i <= n; i++) {
		cin >> t[i] >> f[i];
		f[i]--;
	}
	
	int ninzu = 0, j;
	int ans = 0;
	
	for (i = 1; i <= n; i++) {
		int x = t[i] - t[i - 1];
		if (x >= f[i - 1] + f[i]) {
			for (j = i - ninzu; j < i; j++) {
				ans += t[i - 1] + f[i - 1] - t[j];
			}
			ninzu = 1;
		}
		else if (x >= Abs(f[i] - f[i - 1]) && ninzu < d) {
			ninzu++;
		}
		else {
			break;
		}
	}
	
	for (j = i - ninzu; j < i; j++) {
		ans += t[n] + f[n] - t[j];
	}
	
	if (i <= n) { cout << -1 << endl; }
	else { cout << ans << endl; }
	return 0;
}

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

int a, b, k, c, d;

int main() {
	scanf("%d%d%d", &a, &b, &k);
	c = min(a + k - 1, b); d = max(b - k + 1, a);
	(c >= d) && (d = c + 1);
	for (register int i = a; i <= c; ++i)
		printf("%d\n", i);
	for (register int i = d; i <= b; ++i)
		printf("%d\n", i);
	return 0;
}

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

int main(){
  int n,m,l,r, max_l=-1, min_r=100001;
  int cnt = 0;
  cin >> n >> m;
  for(int i=0; i<m; i++){
    cin >> l >> r;
    max_l = max(l, max_l);
    min_r = min(r, min_r);
  }
  cnt = - max_l + min_r + 1;
  if(cnt<0)cnt = 0;
  cout << cnt << endl;

  return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n;
    cin >> n;
    vint v(n);
    rep(i, n) cin >> v[i];
    sort(ALL(v));
    double ans = v[0];
    REP(i, 1, n)
    {
        ans = (ans + v[i]) / 2.;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define int long long
using namespace std;

const int N = 100 * 1000 + 5;
int x, y, z;

vector <int> adj[N];
int part[N];
bool dfs(int v) {
	bool b = true;
	for (auto u : adj[v]) {
		if (part[u] == part[v])
			b = false;
		if (part[u] == 0) {
			part[u] = 3 - part[v];
			if (!dfs(u)) {
				b = false;
			}
		}
	}
	return b;
}
void check(int v) {
	if (part[v] != 0)
		return;
	part[v] = 1;
	if (adj[v].size() == 0) {
		z++;
		return;
	}
	if (dfs(v)) {
		y++;
	}
	else {
		x++;
	}
}
int32_t main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		check(i);
	}
//	cout << x << " " << y << " " << z << endl;
	long long ans = (long long) 1ll * (x + y) * (x + y) + 1ll * y * y + 2ll * n * z - 1ll * z * z;
	cout << ans << endl;
	return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong N;
	vector<llong> B;

	cin >> N;
	B.resize(N-1);
	for (int i = 0; i < N-1; ++i)
		cin >> B[i];

	vector<llong> A(N, inf);
	llong ans = 0;
	for (int i = 0; i < N-1; ++i) {
		A[i] = min(A[i], B[i]);
		A[i+1] = min(A[i+1], B[i]);
		ans += A[i];
	}

	cout << ans + A[N-1] << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		while(true) {
			int n = sc.nextInt();
			if(n == -1) break;
			double x = n/2.0;
			while(true) {
				x = x - (Math.pow(x, 3) - n) / (3*Math.pow(x, 2));
				if(Math.abs(Math.pow(x, 3) - n) < 0.00001 * n) {
					out.println(x);
					break;
				}
			}
		}
		out.flush();

	}
}
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); 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() {
    	return (int)nextLong();
    }
    

}

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

using namespace std;

#define N 3200

int n,mx,a[N],f[N];
vector<int> g[N];

void dfs(int u,int fa){
	f[u]=0;
	for (int v:g[u])
		if (v!=fa){
			dfs(v,u);
			if (!f[v]&&a[u]>a[v]) f[u]=1;
		}
}

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",a+i);
	for (int i=1;i<n;++i){
		int x,y; scanf("%d%d",&x,&y);
		g[x].push_back(y); g[y].push_back(x);
	}
	dfs(1,0); mx=f[1];
	for (int i=1;i<=n;++i){
		dfs(i,0);
		if (f[i]) printf("%d ",i);
	}
	puts("");
	
	return 0;
}
			

Measured memory_bytes: 640
#include<stdio.h>

int isPrime(int x) {
  int i;
  if ( x < 2 ) return 0;
  else if ( x == 2 ) return 1;
  if ( x % 2 == 0 ) return 0;
  for ( i = 3; i*i <= x; i+=2 )
    if ( x % i == 0) return 0;
  return 1;
}

int main() {
  int n, x, i;
  int cnt = 0;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &x);
    if ( isPrime(x) ) cnt++;
  }
  printf("%d\n", cnt);

  return 0;
}


Measured memory_bytes: 2680
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int h,n;
  cin>>h>>n;
  VI a(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }

  if(sum>=h) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}

Measured memory_bytes: 640
#include<iostream>
int gcd(int x,int y){
	if(y==0)return x;
	else return gcd(y,x%y);
}
int lcm(int x,int y){
	return ((x/gcd(x,y))*y); 
}
int main(){
	int a,b;
	while(1){
		std::cin>>a>>b;
		if(std::cin.eof())break;
		std::cout<<gcd(a,b)<<" "<<lcm(a,b)<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
def find_lcm(a, b):
    """lcm = least common multiple
    """
    large_num = max(a, b)
    small_num = min(a, b)

    count = 1
    while True:
        
        if large_num * count % small_num == 0:
            break
        count += 1
    
    return large_num * count

if __name__ == "__main__":
    A, B = map(int, input().split())
    print(find_lcm(A, B))

Measured memory_bytes: 3064
n = int(input())
w = [0] * n
for i in range(n):
    w[i] = input()

done = []

for i in range(n):
    if i == 0:
         before = str(w[i])
         done.append(w[i])
    else:
        target = str(w[i])
        if before[-1] != target[0]:
            print("No")
            exit()
        else:
            if w[i] in done:
                print("No")
                exit()
        before = target
        done.append(w[i])
print("Yes")


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

namespace kyopro {
    class Program {
        static void Main(string[] args) {
            var n = int.Parse(Console.ReadLine());
            var ts = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var m = int.Parse(Console.ReadLine());
            var dic = new List<KeyValuePair<int, int>>();
            foreach (var a in Enumerable.Range(1, m)) {
                var kv = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                dic.Add(new KeyValuePair<int, int>(kv[0], kv[1]));
            }
            var sum = ts.Sum();
            foreach (var kv in dic) {
                var diff = ts[kv.Key - 1] - kv.Value;
                Console.WriteLine(sum - diff);
            }
        }
    }
}


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

int main()
{
	std::vector<int> v;
	int n;
	while (std::cin >> n, n)
	{
		v.push_back(n);
	}
	for (int i = 0; i < v.size(); i++)
	{
		std::cout << "Case " << i+1 << ": " << v.at(i) << "\n";
	}
}

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

int main(void)
{
    int N,K; cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i < N; ++i) cin >> A[i];
    
    int left = 0;
    int right = *max_element(A.begin(), A.end());

    while (right - left > 1){
        int mid = (left + right) /2;
        long long jk = 0;
        for(int j=0; j < N; j++){
            jk += A[j] / mid - 1;
            if(A[j] % mid != 0) jk++;
        }
        if(jk <= K) right = mid;
        else left = mid;
    }

    cout << right <<endl;
}


Measured memory_bytes: 4028
n, a, b = gets.strip.split.map(&:to_i)

# 各桁の和を求める
def digit_sum n
    sum = 0
    while n > 0 do
        sum += n % 10
        n /= 10
    end
    sum
end

ans = (1..n)
        .map { |i| [i, digit_sum(i)] }
        .select { |d| a <= d[1] && d[1] <= b }
        .inject(0) { |sum, d| sum + d[0] }

puts ans


Measured memory_bytes: 2172
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;
bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 1010;
clock_t START, END;
int T[NUM][NUM];

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	};
	int f;
	string s1, s2;
	cin >> s1 >> s2;
	int l1 = s1.size(), l2 = s2.size();
	for (int i = 0; i <= l1; i++)
		T[0][i] = i;
	for (int i = 0; i <= l2; i++)
		T[i][0] = i;
	for (int i = 1; i <= l2; i++) {
		for (int j = 1; j <= l1; j++) {
			if (s1[j - 1] == s2[i - 1])
				f = 0;
			else
				f = 1;
			T[i][j] = min(T[i - 1][j] + 1, min(T[i][j - 1] + 1, T[i - 1][j - 1] + f));
		}
	}
	cout << T[l2][l1] << endl;
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define MOD         (1000000007LL)
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define se          second
#define fi          first

using LL  = long long;

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

vector<vector<int>> g;
vector<bool> visited;
deque<int> ans;
bool flag = true;

void solve(int to) {
    if(flag){
        ans.push_front(to);
    }else{
        ans.push_back(to);
    }
    visited[to] = true;
    for(auto next : g[to]){
        if(!visited[next]){
            solve(next);
            break;
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m;cin >> n >> m;
    g.resize(n);
    visited.resize(n, false);
    inc(i, 0, m){
        int a, b;cin >> a >> b;a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    visited[0] = true;
    visited[g[0][0]] = true;
    solve(0);
    flag = false;
    solve(g[0][0]);

    cout << ans.size() << endl;
    bool f = true;
    for(auto a : ans){
        if(f){
            f = false;
        }else{
            cout << " ";
        }
        cout << a+1;
    }
    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)
typedef pair<double,double> P;
#define N 1001
double d[1<<15][15][15];
vector<int> G[N],rG[N],g;
bool u[N];
int n,cmp[N];
  
void add_edge(int x,int y){G[x].push_back(y);rG[y].push_back(x);}
void dfs(int x){u[x]=1;rep(i,G[x].size())if(!u[G[x][i]])dfs(G[x][i]);g.push_back(x);} 
void rdfs(int x,int k){u[x]=1;cmp[x]=k;rep(i,rG[x].size())if(!u[rG[x][i]])rdfs(rG[x][i],k);}
int scc() {
  memset(u,0,sizeof(u));g.clear();rep(i,n)if(!u[i])dfs(i);memset(u,0,sizeof(u));
  int k=0;rrep(i,g.size())if(!u[g[i]])rdfs(g[i],k++);return k;
}
void init() {
  rep(i,n) G[i].clear(),rG[i].clear();
  g.clear();
}
int rev(int x) {return (x+n/2)%n;}
int two_sat(vector<P> v) {
  init();
  rep(i,v.size()) {
    add_edge(v[i].F,rev(v[i].S));
    add_edge(v[i].S,rev(v[i].F));
  }
  scc();
  rep(i,n/2) {
    if(cmp[i]==cmp[i+n/2]) return 0;
  }
  return 1;
}
double D(P a,P b) {
  return sqrt((a.F-b.F)*(a.F-b.F)+(a.S-b.S)*(a.S-b.S));
}

int main() {
  int m;
  cin >> n >> m;
  P a[n][2],b[m];
  rep(i,n)rep(j,2) cin >> a[i][j].F >> a[i][j].S;
  rep(i,m) cin >> b[i].F >> b[i].S;
  rep(t,1<<m)rep(i,m)rep(j,m) d[t][i][j]=1<<30;
  rep(k,m) {
    d[1<<k][k][k]=0;
    rep(t,1<<m) {
      rep(i,m) {
        if(!(t&(1<<i))) continue;
        rep(j,m) {
          if(!(t&(1<<j))) d[t|(1<<j)][k][j]=min(d[t|(1<<j)][k][j],d[t][k][i]+D(b[i],b[j]));
        }
      }
    }
  }
  double c[n][n][4];
  n*=2;
  rep(i,n/2) {
    REP(j,i+1,n/2) {
      rep(k,4) c[i][j][k]=1<<30;
      rep(k,m)rep(l,m)rep(s,2)rep(t,2)c[i][j][s+t*2]=min(c[i][j][s+t*2],D(a[i][s],b[k])+d[(1<<m)-1][k][l]+D(b[l],a[j][t]));
    }
  }
  double l=0,r=10000;
  rep(t,50) {
    double mid=(l+r)/2;
    vector<P> v;
    rep(i,n/2) {
      REP(j,i+1,n/2) {
        if(c[i][j][0]>mid) v.push_back(P(i,j));
        if(c[i][j][1]>mid) v.push_back(P(rev(i),j));
        if(c[i][j][2]>mid) v.push_back(P(i,rev(j)));
        if(c[i][j][3]>mid) v.push_back(P(rev(i),rev(j)));
      }
    }
    if(two_sat(v)) r=mid;
    else l=mid;
  }
  printf("%.10f\n",l);
  return 0;
}


Measured memory_bytes: 66560
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    for (int i = 0; i < b; i++) {
      if ((i * a) % b == c) {
        System.out.println("YES");
        return;
      }
    }

    System.out.println("NO");
  }

}

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

using namespace std;

int main(){
    string S,T;
    cin >> S >> T;
    int i=0, cnt=0;
    while(i<S.length()){
        if (S[i]!=T[i]) cnt ++;
        i++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9;
int fee=0,minfee=inf;
int n,m,X,c[113],can[113],use[113]={0},a[113][113];

void dfs(int x,int y)
{
	if(x>n)
	{
		fee=0;
		memset(can,0,sizeof(can));
		for(int i=1;i<=n;i++)
		{
			if(use[i]==1)
			{
				fee+=c[i];
				for(int j=1;j<=m;j++)
					can[j]+=a[i][j];

			}
		}
		int fff=0;
		for(int i=1;i<=m;i++)
			if(can[i]>=X)fff++;
		if(fff>=m)
		{
			/*for(int i=1;i<=m;i++)
			{
				cout<<i<<" "<<can[i]<<endl;
			}*/
			minfee=min(fee,minfee);
			/*for(int i=1;i<=n;i++)
			{
				cout<<i<<" "<<use[i]<<endl;
			}*/
			return;
		}
		return;
	}
	use[x]=y;
	dfs(x+1,0);
	dfs(x+1,1);
	return;
	/*fee-=c[x];
	for(int i=1;i<=m;i++)
		can[i]-=a[x][m];*/
}
int main()
{
	cin>>n>>m>>X;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	}
	for(int j=1;j<=m;j++)
	{
		int sum=0;
		for(int i=1;i<=n;i++)
			sum+=a[i][j];
		if(sum<X)
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	dfs(1,0);
	dfs(1,1);
	cout<<minfee<<endl;
	return 0;
}


Measured memory_bytes: 3640
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi 	 vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;


int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	// #endif
	int i,j,k,l,n,test_case,a,b,c;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		int ans=0;
		cin>>a>>b>>c;
		ans=b/a;
		cout<<min(ans,c);



	}
	
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    ll Ai;
    vector<ll> A;
    ll sum = 0;
    ll sumO = 0;
    for(int i=0;i<N;i++){
        cin >> Ai;
        A.push_back(Ai);
        sum += Ai;
        if(i%2==0) sumO += Ai;
    }
    ll res = sumO - sum/2;
    cout<<2*res<<endl;
    for(int i=0;i<N-1;i++){
        res = A[i] - res;
        cout<<2*res<<endl;
    }

    return 0;
}

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

int main(){
    int N,Y;cin>>N>>Y;
    int k,temp;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            k=N-i-j;
            temp=10000*i+5000*j+1000*k;
            if(temp==Y){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  cout << (N+1)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var donuts, availablePowderWeight, powderWeight int
	fmt.Scan(&donuts, &availablePowderWeight)

	minPowderWeight := availablePowderWeight
	usedPowderWeight := 0
	countDonuts := 0
	for i := 0; i < donuts; i++ {
		fmt.Scan(&powderWeight)
		if minPowderWeight > powderWeight {
			minPowderWeight = powderWeight
		}
		countDonuts++
		usedPowderWeight += powderWeight
	}
	availablePowderWeight -= usedPowderWeight
	countDonuts += availablePowderWeight / minPowderWeight

	fmt.Println(countDonuts)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	// diverta 2019 Programming Contest 2-B, 1041, 
	int n; cin >> n;
	int p, q;
	vector<P> points(n);
	rep(i, n) {
		cin >> points[i].first >> points[i].second;
	}
	sort(points.begin(),points.end());

	int ans = 0;
	rep(i, n) {
		rep(j, n) {
			if (i == j) continue;
			int tmpAns = 0;
			vector<int> counted(n, false);
			p = points[j].first - points[i].first;
			q = points[j].second - points[i].second;
			if (p == 0 && q == 0) continue;
			if (p < 0) {
				p *= -1; q *= -1;
			}
			rep(k, n) {
				counted[k] = true;
				for (int l = k + 1; l < n; ++l) {
					if (counted[l] == true) continue;
					if (points[l].first - points[k].first == p &&
						points[l].second - points[k].second == q) {
						tmpAns++;
						counted[l] = true;
					}
				}
			}
			ans = max(ans, tmpAns);
		}
	}
	cout << n - ans << endl;
	return 0;
}

Measured memory_bytes: 3604
//struct cmp {bool operator()(const pair<int, char> &a, const pair<int, char> &b) {if (a.first == b.first) {return a.second > b.second;} else {return a.first > b.first;}}};
#include<bits/stdc++.h>
#define endl "\n"
#define _  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define min_heap priority_queue <int, vector<int>, greater<int> >
#define max_heap priority_queue <int>
#define ll long long
//#define int long long
#define MOD 1000000007
#define DEBUG cout<<"Hello1\n";
#define deb(x) cout << #x << " " << x << endl;
#define deb2(x,y) cout << #x << "=" << x << "\t\t"<<#y<<"="<<y<<endl;
#define deb3(x,y,z) cout << #x << "=" << x << "\t"<<#y<<"="<<y<< "\t"<<#z<<"="<<z<<endl;
#define all(v) (v).begin(),(v).end()
#define clear(x) memset(x,0,sizeof(x))
const int N = 1e5 + 5;
using namespace std;
template<class T>
void print_container(T &container) {for (auto &t : container) {cout << t << " ";} cout << endl;}

vector<int> adj[N];
vector<int> dp(N, -1);
vector<bool> visited(N, 0);

int dfs(int x) {
	visited[x] = 1;
	if (dp[x] != -1)return dp[x];
	if (!adj[x].size()) {
		dp[x] = 1;
	}

	for (auto u : adj[x]) {
		dp[x] =  max(dp[x], 1 + dfs(u));
	}
	return dp[x];
}

void solve() {
	int n, m, ans = -1;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
	}

	for (int i = 1; i <= n; i++) {
		if (!visited[i]) {
			ans = max(ans, dfs(i));
		}
	}

	cout << ans - 1 << endl;

}

int32_t main() {
	_

	solve();
}




Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, k, c, f[200005], b[200005], fe, be;
char s[200005];
int main(){
	scanf("%d%d%d\n%s", &n, &k, &c, s);
	f[0] = -300000; b[k+1] = 600000; be = k+1;
	rep(i,n) if(f[fe]+c<i && s[i] == 'o') f[++fe] = i;
	for(int i=n-1; i>=0 && be>0; i--) if(b[be]-c>i && s[i] == 'o') b[--be] = i;
	for(int i=1; i<=k; i++) if(f[i] == b[i]) printf("%d\n", f[i]+1);
}

Measured memory_bytes: 3200
program main
  implicit none
  integer :: i, j, k, n, a(1:3,1:3)
  integer, allocatable :: b(:)
  logical :: judge = .false.
  do i = 1, 3
    read *, a(i, :)
  end do
  read *, n
  allocate (b(n))
  do i = 1, n
    read *, b(i)
  end do

  do i = 1, n
    do j = 1, 3
      do k = 1, 3
        if (a(j, k) == b(i)) then
          a(j, k) = 0
        end if
      end do
    end do
  end do
  do j = 1, 3
    if (a(j, 1) + a(j, 2) + a(j, 3) == 0) then
      judge = .true. 
    else if (a(1, j) + a(2, j) + a(3, j) == 0) then
      judge = .true.
    end if
    if (judge) exit
  end do
  if (.not. judge) then
    if (a(1,1) + a(2,2)+ a(3,3) == 0) then
      judge = .true.
    else if (a(1,3) + a(2,2) + a(3,1) == 0) then
      judge = .true.
    end if
  end if

  if (judge) then
    print '(a)', "Yes"
  else
    print '(a)', "No"
  end if

end program

Measured memory_bytes: 768
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<map>
#include<tuple>
using namespace std;
#define INF 1LL<<62
#define MAX 1100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
//__builtin_popcount(S)

//https://kyopro-friends.hatenablog.com/entry/2019/01/12/231035

vector<int> V[110000];
ll dp[110000][2];
bool flag[110000];

void f(int x){
    if(flag[x]) return;
    flag[x]=true;
    dp[x][0]=1;
    dp[x][1]=1;
    for(int i=0;i<(int)V[x].size();i++){
        int next=V[x][i];
        if(flag[next]) continue;
        f(next);
        dp[x][0]=(dp[x][0]*(dp[next][0]+dp[next][1])%MOD)%MOD;
        dp[x][1]=(dp[x][1]*dp[next][0])%MOD;
    }
}

int main(){
    for(int i=0;i<110000;i++) flag[i]=false;
    int N;
    cin>>N;
    for(int i=0;i<N-1;i++){
        int x,y; cin>>x>>y;
        V[x].push_back(y);
        V[y].push_back(x);
    }
    f(1);
    /*for(int i=0;i<=N;i++){
        cout<<i<<endl;
        cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
    }*/
    cout<<(dp[1][0]+dp[1][1])%MOD<<endl;
}



Measured memory_bytes: 13184
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define DEBUG 0

using namespace std;
const int mod = 100000;

int dp[55][3005];
 
int main(void)
{
//	freopen ("testcase.bingo", "r", stdin );
	int n, m, s;	// n: êÓÌ·³ m: g¦éÌãÀ s: lÌa

	while (cin >> n >> m >> s && n && m && s ){ 
		memset (dp, 0, sizeof (dp ) );
		dp[0][0] = 1;
		m = min (m, s );
		rep (i, m ){
//			for (int i = 1; i <= n*n; i++ ){
			for (int j = n*n; j > 0; j-- ){
				for (int k = s; k >= n*n - j + 1; k-- ){
					dp[j][k] = dp[j-1][k - (n*n-j+1)]+dp[j][k - (n*n-j+1)];
					if (dp[j][k] >= mod ) dp[j][k] -= mod;
				} // end for
			} // end for
		} // end rep
		cout << dp[n*n][s] << endl;
//		cout << (dp[n*n][s] - dp[n*n-1][s] + mod) % mod << endl;
//		cout << dp[n*n][s] << endl;
#if DEBUG
		rep (i, n*n+1 ){
			rep (j, s+1 ){
				cout << setw(3) << dp[i][j];
			} // end rep
			cout << endl;
		} // end rep
#endif
	} // end while
     
    return 0;
}

Measured memory_bytes: 1512
# coding: utf-8
# Your code here!
w, a, b = map(int,input().split())
if a < b:
    if a <= b <= a + w:
        print(0)
    else:
        print(abs(a+w-b))
    
else:
    if b <= a <= b + w:
        print(0)
    else:
        print(abs(b+w-a))

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   string s;
   cin>>s;
   string ans="Good";
   for(int i=1;i<s.size();i++){
       if(s[i]==s[i-1])ans="Bad";
   }
   cout<<ans<<endl;
}

   


Measured memory_bytes: 888
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int N, x; cin >> N >> x;
    VI a(N);
    REP(i, N) cin >> a[i];
    SORT(a);
    int cnt(0);
    REP(i, N){
        if(x < a[i]) break;
        ++cnt;
        x -= a[i];
    }
    if(cnt == N && x > 0) --cnt;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return list(set(a))
x=int(input())
p=prime(x)
s=0

for j in p:
    i=1
    while x%(j**i)==0:
        x=x//(j**i)
        s+=1
        i+=1
print(s)

Measured memory_bytes: 9212
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

min = float('inf')

for i in range(1<<n): # 1<<n == 2**n
    study = [0 for _ in range(m)]
    cost = 0

    for j in range(n):
        if i&(1<<j):
            cost += a[j][0]
            study = [study[k]+a[j][k+1] for k in range(m)]

    if(all([s >= x for s in study])):
        if min > cost:
            min = cost

if float('inf') > min:
    print(min)
else:
    print(-1)



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

using namespace std;
typedef long long ll;
typedef pair<pair<int, int>, int> P;

ll MOD = 1000000007;
char filed[2000][2000];

int main() {
	int H, W;
	cin >> H >> W;
	vector<P> sum1[2000] = {}, sum2[2000] = {};
	//sum1 = yoko sum2 = tate
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++)cin >> filed[i][j];

	for (int i = 0; i < H; i++) {
		int cnt = 0;
		int begin = 0;
		for (int j = 0; j < W; j++) {
			if (filed[i][j] == '.') {
				cnt++;
			}
			else {
				if (cnt != 0) {
					sum1[i].push_back(make_pair(make_pair(begin, j), cnt));//[)で考えた
				}
				begin = j + 1;
				cnt = 0;
			}
		}
		if (cnt != 0 && W != begin) {
			sum1[i].push_back(make_pair(make_pair(begin, W), cnt));//[)で考えた
		}
		
	}
	for (int i = 0; i < W; i++) {
		int cnt = 0;
		int begin = 0;
		for (int j = 0; j < H; j++) {
			if (filed[j][i] == '.') {
				cnt++;
			}
			else {
				if (cnt != 0) {
					sum2[i].push_back(make_pair(make_pair(begin, j), cnt));//[)で考えた
				}
				begin = j + 1;
				cnt = 0;
			}
		}
		if (cnt != 0 && H != begin) {
			sum2[i].push_back(make_pair(make_pair(begin, H), cnt));//[)で考えた
		}
		
	}
	
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (filed[i][j] == '.') {
				int v1 = 0, v2 = 0;
				for (int k = 0; k < sum1[i].size(); k++) {
					if (sum1[i][k].first.first <= j && sum1[i][k].first.second > j) {
						v1 = sum1[i][k].second;
						break;
					}
				}

				for (int k = 0; k < sum2[j].size(); k++) {
					if (sum2[j][k].first.first <= i && sum2[j][k].first.second > i) {
						v2 = sum2[j][k].second;
						break;
					}
				}

				ans = max(ans, v1 + v2 - 1);

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

Measured memory_bytes: 30336
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  long long A[7];
  FOR(i,0,7){
    cin>>A[i];
  }
  long long K=0,L=0;
  L+=A[0]/2*2;
  L+=A[3]/2*2+A[4]/2*2;
  if(A[0]&&A[3]&&A[4]){
    K+=3;
    A[0]--;
    A[3]--;
    A[4]--;
    K+=A[0]/2*2;
    K+=A[3]/2*2+A[4]/2*2;
  }
  cout<<max(K,L)+A[1]<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(float,input().split()))

dp = [[0]*(N+1) for _ in range(N+1)]
dp[0][0] = 1
#dp[i][j] i枚投げた時 j枚 表が出る確率
for i in range(1,N+1):
    for j in range(i+1):
        dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1])
print(sum(dp[N][(N+1)//2:]))

Measured memory_bytes: 263688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

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

  cout << min(n*a, b) << endl;

  return 0;
}


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

int main(){
    int n;
    cin>>n;
    int temp=n;
    int sum=0;
    while(temp!=0){
        sum+=temp%10;
        temp=temp/10;
    }
    if(n%sum==0)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256