akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  vector<int> ans;

  int mn = a[0];
  int mx;
  if(a[0] < a[1]){
    mx = a[1];
    ans.push_back(mx - mn);
  } else {
    mn = a[1];
    mx = a[1];
  }

  for(int i=2;i<N;i++){
    if(a[i] < mn){
      mn = a[i];
      mx = a[i];
    }
    if(mx < a[i]){
      mx = a[i];
      ans.push_back(mx - mn);
    }
  }

  /*for(int i=0;i<ans.size();i++){
    cout << ans[i] << endl;
  }*/

  int ans_mx = *max_element(ans.begin(),ans.end());
  int cnt = 0;
  for(int i=0;i<ans.size();i++){
    if(ans[i] == ans_mx) cnt++;
  }

  cout << cnt << endl;
  return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
T gcd(T x, T y){
    T r = x % y;
    while(r != (T)0){
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

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

    int n;
    cin >> n;

    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    int ans = a[0];
    REP(i, 1, n){
        ans = gcd(ans, a[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import itertools

N, M, X = map(int, input().split())

lst = []

for i in range(N):
    tmp = list(map(int, input().split()))
    lst.append(tmp)


min_num = float("inf")
for i in range(N):
    a = itertools.combinations([i for i in range(N)], i+1)

    for j in a:
        tmp = [0 for _ in range(M)]
        for k in j:
            for r in range(M):
                tmp[r] += lst[k][r+1]
        for t in tmp:
            if t < X:
                break
        else:
            cnt = 0
            for c in j:
                cnt += lst[c][0]
            if cnt <= min_num:
                min_num = cnt

if min_num == float("inf"):
    print(-1)
else:
    print(min_num)

           
        


Measured memory_bytes: 9228
n=int(input())
b=list(map(int,input().split()))

ans=b[0]+b[n-2]
for i in range(n-2): # bの要素数-1
    if b[i]<b[i+1]:
        ans+=b[i]
    else:
        ans+=b[i+1]

print(ans)


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

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

using namespace std;

typedef long double ld;
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-8, pi = acos(-1.0);

#define EQ(a,b) (abs((a)-(b))<eps)

ld dot (P a, P b) { return real(conj(a) * b); }
ld cross (P a, P b) { return imag(conj(a) * b); }

namespace std {
  bool operator<(const P &lhs, const P &rhs) {
    return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag() : lhs.real() < rhs.real();
  }
}

// Line
class L{
public:
  P a, b;
  L (P aa, P bb) { a = aa; b = bb; }
  L (ld ax, ld ay, ld bx, ld by) { a = P(ax, ay); b = P(bx, by); }
};

P is_ll(L s, L t){
  P sv = s.b - s.a, tv = t.b - t.a;
  return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

int main() {
  int n;
  cin>>n;
  VP vp;
  REP(i,n){
    ld x,y;
    cin>>x>>y;
    vp.emplace_back(x,y);
  }
  if (n%2) {
    cout<<"NA"<<endl;
    return 0;
  }
  L l1(vp[0],vp[n/2]), l2(vp[1],vp[n/2+1]);
  P p = is_ll(l1, l2);
  bool ok = true;
  REP(i,n/2) if (!EQ(p-vp[i],vp[n/2+i]-p)) ok = false;
  if (!ok)
    cout << "NA"<< endl;
  else
    cout <<setprecision(10)<<fixed<< real(p) <<' '<<imag(p) << endl;
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	string a,b,c;
    	char cc;
    	cin>>a;
    	cin>>m;
    	ll p=0,t;
    	while(m--)
    	{
    		cin>>t;
    		t--;
    		if(t==0)
    			p=1-p;
    		else
    		{
    			ll f;
    			cin>>f>>cc;
    			f--;
    			if(p)
    				f=1-f;
    			if(f==0)
    				b.pb(cc);
    			else
    				c.pb(cc);
    		}
    	}
    	string ans;
    	reverse(all(b));
    	ans=b;
    	for(auto i:a)
    		ans.pb(i);
    	for(auto i:c)
    		ans.pb(i);
    	if(p)
    		reverse(all(ans));
    	cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 1312
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().split(" ").map(_.toInt)
  
  // 100^1 * 1
  // 100^1 * 2
  // 100^1 * 3
  // 100^n(0) * n(1)
  
  val base = if(n(1) == 100) 101 else n(1)
  println((scala.math.pow(100, n(0))*base).toInt)
  
}


Measured memory_bytes: 25540
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=998244353;

void solve(){
	ll k;
	cin>>k;
	string s;
	cin>>s;

	if(s.size()<=k){
		cout<<s<<endl;
	}
	else{
		cout<<s.erase(k)<<"..."<<endl;
	}
	
}


int main(){
	
	solve();
	
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

typedef long long ll;

ll n,m,d;

int main(){
	cin>>n>>m>>d;
	if (d==0){
		printf("%.8f\n",(double)(m-1)/n);
	}else{
		ll a;
		if (1+d<=n-d){
			a=d+(n-2*d)*2+d;
		}else{
			a=(n-d)*2;
		}
		printf("%.8f\n",(double)a*(m-1)/n/n);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int N, K;
    cin >> N >> K;
    int ans = (N - K);
    if (K == 1)
        ans = 0;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;
}


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

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;

#define mp make_pair
#define pb push_back
#define fir first
#define sec second

#define fo0(i,a,b) for(int i=(a);i<(b);i++)
#define fo1(i,a,b) for(int i=(a);i<=(b);i++)
#define fd0(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define fd1(i,a,b) for(int i=(a);i>=(b);i--)
#define mset(a,b) memset(a,(b),sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))

#define max(a,b) (a > b ? a : b)
#define min(a,b) (a < b ? a : b)
#define abs(a) (a < 0 ? -a : a)
#define fabs(a) (a < 0 ? -a : 0)

template<typename T> inline void in(T &x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9')
{if(ch=='-')fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T> void out(T x){if(x<0){putchar('-');x=-x;}if(x/10)out(x/10);putchar(x%10+'0');}
template<typename T> inline void outln(T x){out(x);putchar(10);}
template<typename T> inline void outsp(T x){out(x);putchar(' ');}
template<typename T> inline T gcd(T a, T b){T t;if(a>b){while(b){
t=b;b=a%b;a=t;}return a;}else{while(a){t=a;a=b%a;b=t;}return b;}}
template<typename T> inline T lcm(T a, T b){return a/gcd(a,b)*b;}

map<string, bool> m;
string a, b;
int n;

int main(){
	in(n);
	cin >> a;
	m[a] = 1;
	fo0(i, 1, n){
		cin >> b;
		if(m[b] == 1)	return puts("No"), 0;
		if(b[0] != a[a.size()-1])	return puts("No"), 0;
		m[b] = 1;
		a = b;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

su = 0
S = [0]
for i in range(n):
    su += A[i]
    S.append(su)

# print(S)

D = {}
for i in range(len(S)):
    try:
        D[S[i]] += 1
    except:
        D[S[i]] = 1

# def kai(x):
#     ans = 1
#     for i in range(1, x+1):
#         ans *= i
#     return ans

ans = 0
for i in D.values():
    ans += i * (i-1) // 2
print(ans)

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

int main()
{
    int n;
    cin>>n;
    int A[n];
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }
    
    int c=0;
    map<pair<int,pair<int,int>>,int> m;
    if(n<3)
    {
        cout<<0<<endl;
    }
    
    else
    {
        for(int i=0;i+2<n;i++)
        {
            for(int j=i+1;j+1<n;j++)
            {
                for(int k=j+1;k<n;k++)
                {
                    int s=A[i]+A[j]+A[k];
                    int mi=min(A[i],min(A[j],A[k]));
                    int ma=max(A[i],max(A[j],A[k]));
                    int tr=s-mi-ma;
                    if(mi+tr>ma && A[i]!=A[j] && A[j]!=A[k] && A[i]!=A[k])
                    {

                        
                        c++;
                        //cout<<A[i]<<" "<<A[j]<<" "<<A[k]<<endl;

                    } 
                    
                }
            }
        }
        cout<<c<<endl;
    }
    
}

Measured memory_bytes: 3536
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000009;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110000];
int gcd(int a,int b){
    while(a){
        b%=a;swap(a,b);
    }
    return b;
}
int main(){
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i=0;i<a;i++)scanf("%d",p+i);
    std::sort(p,p+a);
    int g=p[0];
    for(int i=1;i<a;i++)g=gcd(g,p[i]);
    if(b%g||b>p[a-1]){
        printf("IMPOSSIBLE\n");
    }else printf("POSSIBLE\n");
}

Measured memory_bytes: 512
#include <iostream>
#include <stdlib.h>

using namespace std;

int judge(int a){
    if(a == 2){
        return 0;
    }
    else if(a == 4 || a == 6 || a==9 || a==11){
        return 1;
    }
    return 2;
}

int main(void){
    int X, Y;
    cin >> X >> Y;
    if(judge(X) == judge(Y)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;   
}

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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cnt=0;
  rep(i,0,n){
    cnt+=s[i]-'0';
  }
  if(cnt==0){
    rep(i,0,n){
      cout<<1<<endl;
    }
    return 0;
  }
          
  int a[n];
  a[0]=1;
  rep(i,0,n-1){
    a[i+1]=a[i]*2%(cnt+1);
  }
  int suma=0;
  rep(i,0,n){
    suma+=(s[n-1-i]-'0')*a[i];
    suma%=(cnt+1);
  }
  int b[n];
  int sumb=0;
  if(cnt!=1){
    b[0]=1;
    rep(i,0,n-1){
      b[i+1]=b[i]*2%(cnt-1);
    }
    rep(i,0,n){
      sumb+=(s[n-1-i]-'0')*b[i];
      sumb%=(cnt-1);
    }
  }
  int cur[n];
  rep(i,0,n){
    if(s[i]=='0'){
      cur[i]=(suma+a[n-1-i])%(cnt+1);
    }
    else{
      if(cnt==1){
        cur[i]=-1;
      }
      else{
        cur[i]=(sumb-b[n-1-i])+(cnt-1);
        cur[i]%=(cnt-1);
      }
    }
  }
  rep(i,0,n){
    if(cur[i]==-1){
      cout<<0<<endl;
      continue;
    }
    int ans=1;
    while(cur[i]!=0){
      int c=cur[i];
      int d=0;
      while(c!=0){
        d+=c%2;
        c/=2;
      }
      cur[i]=cur[i]%d;
      ans++;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 6068
s = input()
alp = [ 0 for _ in range(27) ]
for ss in s:
    alp[ord(ss)-ord("a")] += 1

for i in range(27):
    if i == 26:
        print("None")
        break
    if alp[i] == 0:
        print(chr(ord("a")+i))
        break

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
//#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
  //    freopen("q.gir","r",stdin);
  //    freopen("q.cik","w",stdout);
      int n,m;
      cin>>n>>m;
      vector<vector<vector<bool>>>dp(n+1,vector<vector<bool>>(m+1,vector<bool>(82*82,0)));
      vector<vector<int>>A(n+1,vector<int>(m+1));
      for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                  int x;
                  cin>>x;
                  A[i][j]=x;
            }
      }
      for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                  int x;
                  cin>>x;
                  A[i][j]=abs(A[i][j]-x);
            }
      }
      dp[0][1][0]=true;
      dp[1][0][0]=true;
      for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                  for(int k=0;k<82*82-A[i][j];k++){
                        dp[i][j][k]=(dp[i-1][j][abs(k-A[i][j])]|dp[i][j-1][abs(k-A[i][j])]|dp[i-1][j][k+A[i][j]]|dp[i][j-1][k+A[i][j]]);
                  }
            }
      }
      int mn=1e9;
      for(int i=0;i<82*82;i++){
            if(dp[n][m][i])mn=min(mn,i);
      }
      cout<<mn;
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, S, ans = 0;
	cin >> n >> S;
	vector<vector<int> > dp(n + 1, vector<int>(S + 1, 0));

	for(int i = 1; i <= n; i++){
		dp[i] = dp[i - 1];
		int x;
		cin >> x;
		for(int j = x; j <= S; j++){
			dp[i][j] = (dp[i][j] + dp[i - 1][j - x]) % mod;
		}
		if(x <= S) dp[i][x] = (dp[i][x] + i) % mod;
		ans = (ans + dp[i][S]) % mod;
	}
	cout << ans;
}

Measured memory_bytes: 70784
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(tokenizer.nextToken());
		int m = Integer.parseInt(tokenizer.nextToken());
		List<Pair>[] lists = new ArrayList[n];
		for (int i = 0; i < n; i++)
			lists[i] = new ArrayList<Pair>();
		while (true) {
			tokenizer = new StringTokenizer(reader.readLine());
			int a = Integer.parseInt(tokenizer.nextToken());
			int b = Integer.parseInt(tokenizer.nextToken());
			int c = Integer.parseInt(tokenizer.nextToken());
			if ((a | b | c) == 0)
				break;
			lists[a - 1].add(new Pair(b - 1, c));
		}
		int r = Integer.parseInt(reader.readLine());
		StringBuilder builder = new StringBuilder();
		while (r-- > 0) {
			int[] b = new int[m];
			tokenizer = new StringTokenizer(reader.readLine());
			for (int i = 0; i < m; i++)
				b[i] = Integer.parseInt(tokenizer.nextToken());
			int res = 0;
			for (Pair p : lists[0]) {
				res += b[p.b] * p.cost;
			}
			builder.append(res);
			for (int i = 1; i < n; i++) {
				res = 0;
				for (Pair pair : lists[i]) {
					res += b[pair.b] * pair.cost;
				}
				builder.append(' ').append(res);
			}
			builder.append('\n');
		}
		System.out.print(builder);
	}

	class Pair {
		int b, cost;

		public Pair(int b, int cost) {
			super();
			this.b = b;
			this.cost = cost;
		}

		@Override
		public String toString() {
			return "Pair [b=" + b + ", cost=" + cost + "]";
		}

	}
}

Measured memory_bytes: 103596
#include <stdio.h>

int main() {
  int N[4];
  int check[4];
  for (int i = 0; i < 4; i++) {
    check[i] = 0;
  }
  scanf("%d %d %d %d",&N[0],&N[1],&N[2],&N[3]);
  for (int i = 0; i < 4; i++) {
    if (N[i] == 1) check[0] = 1;
    if (N[i] == 9) check[1] = 1;
    if (N[i] == 7) check[2] = 1;
    if (N[i] == 4) check[3] = 1;
  }
  for (int i = 0; i < 4; i++) {
    if (check[i] == 0) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}


Measured memory_bytes: 128
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a,b;
  cin  >> a >> b;
  cout << a*b << endl;
  return 0;
}

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

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

const int INF = 1e9;
ll n;

int main() {
  cin >> n;
  ll ans = n*(n-1)/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    long long int n1, n2, hcf, temp, lcm;
    cin >> n1 >> n2;
    hcf = n1;
    temp = n2;
    
    while(hcf != temp)
    {
        if(hcf > temp)
            hcf -= temp;
        else
            temp -= hcf;
    }
    lcm = (n1 * n2) / hcf;
    cout<< lcm;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DBG(V) for (auto v : V) cout << v << " "; cout << endl

int N, A, B, C, D;
string S;

int
main()
{
  cin >> N >> A >> B >> C >> D;
  cin >> S;

  --A; --B; --C; --D;

  bool flg = true;
  bool flg3 = false;

  if (C < D) { flg3 = true; } else { 
    if (S[D-1] == '.' && S[D+1] == '.') { flg3 = true; } else { flg3 = false; }
  }
  for (int i = A+1; flg && (i <= C || i <= D); ++i) {
    if (S[i-1] == '#' && S[i] == '#') { flg = false; }
    if (!flg3 && (B <= i && (i <= C && i <= D))) {
      if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') flg3 = true;
    }
  }
  
  if (flg && flg3) { ANS("Yes"); } else { ANS("No"); }
  
  return 0;
}


Measured memory_bytes: 640
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
    template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=5e2+10;

    ll fac[N],facinv[N];ll C(int n,int m){return (n<0 or n<m)?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
    int ct[N],pw[N][N];
    int f[N][N],g[N][N];
    void main()
	{
        fac[0]=1;fo(i,1,N-1) fac[i]=fac[i-1]*i%MOD;
        facinv[N-1]=invm(fac[N-1]);fd(i,N-1,1) facinv[i-1]=facinv[i]*i%MOD;
        int n=qread(),X=qread();fo(i,1,n) ct[qread()]++;g[0][0]=1;
        fo(i,0,X) fo(j,0,n) pw[i][j]=qpower(i,j);
        fd(now,X,1)
        {
            // Debug;
            fo(cnt,0,X) 
            fo(len,0,X) if(g[cnt][len]) 
            fo(i,0,(X-len)/now)
                add(f[cnt+i][len+i*now],1ll*g[cnt][len]*pw[(len+i*now)+(cnt+i)*(-now+1)][ct[now]]%MOD*facinv[i]%MOD );
            swap(f,g);mem(f,0);
            // fo(cnt,0,X) fo(len,0,X) if(g[cnt][len]) printf("f[%d][%d][%d]=%d\n",now,cnt,len,g[cnt][len]);
        }
        ll ans=0;fo(cnt,0,X) fo(len,0,X) 
            add(ans, fac[cnt]*g[cnt][len]%MOD*C(X-len+2-1,cnt)%MOD*((X-len)&1?MOD-1:1)%MOD );write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

int main() {
  string S;
  cin>>S;
  int count1=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0' && i%2==0){
      count1++;
    }
    if(S.at(i)=='1' && i%2==1){
      count1++;
    }
    
    
  }
  int count2=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='1' && i%2==0){
      count2++;
    }
    if(S.at(i)=='0' && i%2==1){
      count2++;
    }
    
    
  }
  cout<<min(count1,count2)<<endl;
  
}

Measured memory_bytes: 512
#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];

  vector<int> exist(8, 0);
  int r = 0;
  rep(i, n) {
    rep(j, 8) if (a[i] >= 400 * j && a[i] < 400 * (j+1)) exist[j] = 1;
    if (a[i] >= 3200) ++r;
  }

  int m = 0;
  rep(i, 8) m += exist[i];
  int M = m + r;
  if (m == 0) m = 1;
  printf("%d %d\n", m, M);
  return 0;
}

Measured memory_bytes: 3728
#include <iostream>

using namespace std;

int main()
{
   
    double n,m,a[100000],sum=0;
    cin>>n>>m;
    for(int i=1; i<=n; i++) cin>>a[i],sum+=a[i];


    double cnt=0;
    double x=sum/(4*m);
    for(int i=1; i<=n; i++){
        if (a[i]>=x) cnt++;
    }
    //cout<<x<<" "<<cnt;
    if (cnt>=m) cout<<"Yes"; else cout<<"No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<cmath>
#include<stack>
#include <map>
#define ll long long int
#define skip cin>>ws;
#define vll vector<ll> 
#define vb vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define vs vector<string>
#define vvpll vector<vector<pair<ll, ll>>>
#define pb push_back
#define pob pop_back()
#define MOD (ll)(1e9 + 7)
#define test ll t; cin>>t; while(t--)

using namespace std;

void enter(vll &ar)
{
    ll n = ar.size();

    for(ll i=0;i<n;i++)
    {
        cin>>ar[i];
    }
}

void show(vll &a)
{
    ll n = a.size();

    for(ll i=0;i<n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<"\n";
}

void SieveOfErat1sthenes(int n, vll &pri) 
{ 
    vb prime(n+1, true); 
   
    for (int p=2; p*p<=n; p++) 
    { 
        
        if (prime[p] == true) 
        { 
            pri.pb(p);
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll mo(ll a)
{
    return a%MOD;
}

bool compare(pll a, pll b)
{
    return a.first>b.first;
}


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

    ll n, k;
    cin>>n>>k;

    vll h(n);
    enter(h);

    vll ans(n, 1e9);
    ans[0] = 0;

    for(ll i=1;i<n;i++)
    {
        for(ll j=i-1;j>=max(0LL, i-k);j--)
        {
            ans[i] = min(ans[i], ans[j]+abs(h[i]-h[j]));
        }
    }

    cout<<ans[n-1]<<"\n";

    return 0;
}


Measured memory_bytes: 4776
import sys
import bisect
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]


ans = 10 ** 18
for i in range(-100, 101):
    t = 0
    
    for v in L:
        t += (v - i) ** 2

    ans = min(ans, t)

print(ans)

Measured memory_bytes: 3064
#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 count = 0;
  int same = 0;
  vector <int> b(N + 1,0);
  for(int i = 0; i < N; i++){
    for(int k = 0; k < N; k++){
      if(i != k && a[i] > a[k]) {
        count++;
      }
      else if (i != k && a[i] == a[k]){
        same++;
      }
    }
    for(int j = 0; j < same + 1; j++){
    b[count + j] = a[i];
    }
    count = 0;
    same = 0;
  }
  int M = N / 2;
  int sum_a = 0,sum_b = 0;
  if(N % 2 == 0){
    for(int i = 0; i < M; i++){
      sum_a += b[2 * i + 1];
      sum_b += b[2 * i];
    }
  }
  if(N % 2 != 0){
    for(int i = 0; i < M + 1; i++){
      sum_a += b[2 * i];
      sum_b += b[2 * i + 1];
    }
  }
  cout << sum_a - sum_b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m,i,j,ans,k,a[100005];
    while(cin>>n)
    {
        ll o=0,e=0,f=0;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        for(i=0;i<n;i++)
        {
            if(a[i]%2==1)
            {
                o++;
            }
            else if(a[i]%4==0)
            {
                f++;
            }
            else e++;
        }
        if(e==0)
        {
            if(o-1<=f)
            {
                printf("Yes\n");
            }
            else printf("No\n");
        }
        else
        {
            if(o<=f)
                printf("Yes\n");
            else printf("No\n");
        }

    }
    return 0;

}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;

int r, c;
vector<vector<bool>> table(10, vector<bool>(10000));
int ans;

int calc(vector<bool> A) {
	int ret = 0;
	Loop(j, c) {
		int a = 0, b = 0;
		Loop(i, r) {
			bool judge = table[i][j];
			if (A[i]) judge = !judge;
			if (judge) a++;
			else b++;
		}
		ret = ret + max(a, b);
	}
	return ret;
}

void allenum(vector<bool> A, int m){
	if (m == r) {
		ans = max(ans, calc(A));
	}
	else {
		allenum(A, m + 1);
		A[m] = 1;
		allenum(A, m + 1);
	}
}


void solve() {
	vector<bool> A(10, 0);
	allenum(A, 0);
}


int main() {
	while (cin >> r >> c, r&&c) {
		Loop(i, r) {
			Loop(j, c) {
				bool x;
				cin >> x;
				table[i][j] = x;
			}
		}
		ans = 0;
		solve();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll N;
    cin >> N;
    if(N==1) cout << "Hello World" << endl;
    else{
        ll A,B;
        cin >> A >> B;
        cout << A+B << endl;
    }
    return 0;
}



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

int main (){
    int N,D;
    double E;
    cin>>N>>D;
    E=N/(2*D+1.0);
    if(N%(2*D+1)==0){
        cout<<N/(2*D+1)<<endl;
    }
    else{cout<<ceil(E)<<endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100005
int n,v[N],d[N],r,k;
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    d[n-1]=abs(v[n]-v[n-1]);
    d[n]=0;
    for(int i=n-2;i>=1;i--)
    {
        int j;
        if(i+k>=n) j=n;
            else j=i+k;
        d[i]=d[j]+abs(v[j]-v[i]);
        j--;
        for(;j>i;j--)
        if(d[j]+abs(v[j]-v[i])<d[i])
            d[i]=d[j]+abs(v[j]-v[i]);
    }
    cout<<d[1];
}


Measured memory_bytes: 1024
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;

public class Remainder
{
    static long N;
    static long A;
    static long B;
    static long C;
    static long ans = long.MaxValue;
    static public void Main()
    {
        var NABC = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        N = NABC[0];
        A = NABC[1];
        B = NABC[2];
        C = NABC[3];

        var L = new List<long>();
        for (int i = 0; i < N; i++)
        {
            L.Add(long.Parse(Console.ReadLine()));
        }

        SearchAll(L);

        Console.WriteLine(ans);

    }

    static long CountMP(List<long> L)
    {
        long res = long.MaxValue;
        L.Sort();
        int p = 0;
        for (int i = p; i + 2 < L.Count(); i++)
        {
            if (i == L.Count() - 3 || Math.Abs(C - L[i]) < Math.Abs(C - L[i + 1]))
            {
                res = Math.Abs(C - L[i]);
                p = i;
                break;
            }
        }

        for (int i = p + 1; i + 1 < L.Count(); i++)
        {
            if (i == L.Count() - 2 || Math.Abs(B - L[i]) < Math.Abs(B - L[i + 1]))
            {
                res += Math.Abs(B - L[i]);
                p = i;
                break;
            }
        }

        for (int i = p + 1; i < L.Count(); i++)
        {
            if (i == L.Count() - 1 || Math.Abs(A - L[i]) < Math.Abs(A - L[i + 1]))
            {
                res += Math.Abs(A - L[i]);
                break;
            }
        }
        return res;
    }

    static void SearchAll(List<long> Kadomatu, long MP = 0)
    {
        var tmp = MP + CountMP(Kadomatu);
        if (tmp < ans)
        {
            ans = tmp;
        }
        if (Kadomatu.Count() <= 3)
        {
            return;
        }

        for (int i = 0; i < Kadomatu.Count(); i++)
        {
            for (int j = i + 1; j < Kadomatu.Count(); j++)
            {
                var list2 = new List<long>(Kadomatu);
                list2[j] += list2[i];
                list2.RemoveAt(i);
                SearchAll(list2, MP+10);
            }
        }
    }

}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    int sum = 0, mi = 1e9;
    int dis;
    rep(i,n){
        a[i] = l + i;
        sum += a[i];
        if(mi > abs(a[i])){
            mi = abs(a[i]);
            dis = a[i];
        }
    }
    int ans = sum - dis;
    cout << ans << endl;
    return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    
    vector<vector<int>> v(N-1, vector<int>(3));
    REP(i, N-1) REP(j, 3) cin >> v[i][j];

    REP(i, N) {
        if (i == N-1) {
            print(0);
        } else {
            int time = v[i][0] + v[i][1];
            for (int j = i+1; j < N-1; j++) {
                if (v[j][1] >= time) {
                    time = v[j][1];
                } else {
                    time = v[j][2] * ceil(float(time - v[j][1]) / v[j][2]) + v[j][1];
                }
                time += v[j][0];
            }
            print(time);
        }
    }

}

signed main() {
    solve();
}


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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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



int main(){
    
	string s,t;
	cin>>s>>t;
	int ans=INT_MAX;
	int diff=0;

	for(int i=0;i<=sz(s)-sz(t);++i){
		for(int j=0;j<sz(t);++j){
			if(t[j]!=s[i+j]){
				diff++;
			}
		}

		ans=min(ans,diff);
		diff=0;
	}

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

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3664
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination
int dist[2020];

int main(void) {
  int N,X,Y; cin >> N >> X >> Y;
  
  reps(i,N){
    for(int j = i+1; j <= N; j++){
      if (j <= X) dist[j-i]++;
      else dist[min(j-i, abs(X-i)+1+abs(Y-j))]++;
    }
  }
  reps(i,N-1) cout << dist[i] << "\n";
  return 0;
}


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

int main(int argc,char* argv[]){
  long W,H,x,y;
  long double sum;
  int check = 0;
  cin >> W >> H >> x >> y;
  if(W==2*x&&H==2*y) check = 1;
  else check = 0;
  sum = (long double) W*H/2;
  cout << sum << " " << check << endl;
  return 0;
}


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

int main(){

    int n; cin >> n;
    int a, b; cin >> a >> b;
    vector<int> c(3, 0);
    for(int i = 0; i < n; i++){
        int p; cin >> p;
        if(p <= a) c[0]++;
        else if(p <= b) c[1]++;
        else c[2]++;
    }

    int ans = min(c[0], min(c[1], c[2]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,u,v = inm()
u -= 1
v -= 1
dst = [ [] for i in range(n) ]
for i in range(n-1):
    a,b = inm()
    dst[a-1].append(b-1)
    dst[b-1].append(a-1)
# dist from v
dist = [-1]*n
q = [(v,0)]
while len(q)>0:
    i,d = q.pop()
    dist[i] = d
    for j in dst[i]:
        if dist[j] == -1:
            q.append((j,d+1))
# from u to mid(r)
r = dist[u]//2+1
t = dist[u]
w = u
while t>r:
    for z in dst[w]:
        if dist[z] == t-1:
            w = z
            t -= 1
            break
# longest path from w
searched = [-1]*n
searched[w] = True
mx = t
q = [w]
while len(q)>0:
    x = q.pop()
    for y in dst[x]:
        if dist[y]>dist[x]:
            q.append(y)
            mx = max(mx,dist[y])
print(mx-1)


Measured memory_bytes: 66924
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <atcoder/all>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=100005;
//i_am_noob
int n,m,u,v;
dsu d(maxn);
set<int> st;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> m;
    rep(m){
        cin >> u >> v;
        u--,v--;
        d.merge(u,v);
    }
    rep(n) st.insert(d.leader(i));
    print1(sz(st)-1);
    return 0;
}


Measured memory_bytes: 7508
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main(){
  int N;
  int M;
  scanf("%d%d",&N,&M);
  int lm;
  lm=(int)sqrt(M);
  int m[2*lm+1];

  int i;
  int k=0;
  for(i=1;i<=lm+1;i++){
    if(M%i==0){
      m[k]=i;
      m[k+1]=M/i;
      k=k+2;
    }
  }
  qsort(m,k+2,sizeof(int),compare_int);  
  for(i=0;i<=k+1;i++){
    if(N<=m[i]){
      printf("%d",M/m[i]);
      return 0;
    }
  }
}
  


Measured memory_bytes: 252
#include <iostream>
using namespace std;
 
int main() {
  int N,m;
  cin >> N;
  
  m=N%10;
  
  if(m==3){
    cout << "bon";
  }else if(m==0 || m==1 || m==6 || m==8){
    cout << "pon";
  }else{
    cout << "hon";
  }
  return 0;
}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */

public class Main {
    public static void main(String[] args) {
        InputStream    inputStream    = System.in;
        OutputStream outputStream = System.out;
        InputReader    in                      = new InputReader(inputStream);
        PrintWriter      out                    = new PrintWriter(outputStream);
        Task                 solver               = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	String S = in.next();
        	int count = 0;
        	if(S.charAt(0) == ('1')) {
        		count++;
        	}
        	if(S.charAt(1) == ('1')) {
        		count++;
        	}
        	if(S.charAt(2) == ('1')) {
        		count++;
        	}
        	out.println(count);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) cerr << "[(" << __LINE__ << ") " << (#__VA_ARGS__) << "]: " << __VA_ARGS__ << endl;

int gcd(int a, int b) {
    if (a > b)
        swap(a, b);
    int c;
    while (b != 0) {
        c = a%b;
        a = b;
        b = c;
    }
    return a;
}

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

    ll sm=0;

    for (int i=1; i<k+1; i++) {
        for (int j=1; j<k+1; j++) {
            for (int l=1; l<k+1; l++) {
                sm += gcd(gcd(i, j), l);
            }
        }
    }
    cout << sm << "\n";

}


Measured memory_bytes: 3604