akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

int GCD(int a,int b){
  int r;
  
  while(b>0){
    r=a%b;
    a=b;
    b=r;
  }
  
  return a;
}

int main(){
  int x,y,tmp=0;

  std::cin>>x>>y;

  if(x<y){
    tmp=x;
    x=y;
    y=tmp;
  }
    
  std::cout<<GCD(x,y)<<'\n';

  return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
// #define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this


const ll MAXN = 1e5 + 5;
ll a[MAXN],dp[MAXN];
ll n;

ll rec(ll idx){
    if(idx == n) return 0;

    ll &ans = dp[idx];

    if(ans != -1) return ans;
    ans = 1e10;

    if(idx+2 <= n) ans = min(ans,rec(idx+2) + abs(a[idx+2]-a[idx]));
    ans = min(ans,rec(idx+1)+abs(a[idx+1]-a[idx]));

    return ans; 
}

void solve(){
    cin>>n;

    FOR(i,1,n) cin>>a[i];
    memset(dp,-1,sizeof(dp));

    ll ans = rec(1);

    cout<<ans<<endl;

}

signed main(){


    FastRead;    

    ll t;
    t = 1; 
    // cin>>t;
    while(t--) solve();
    
}

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

const long long INF = (long long) 1e16;

long long mul(long long a, long long b) {
    return b != 0 && a <= INF / b ? a * b : INF;
}

long long lcm(long long a, long long b) {
    return mul(a / __gcd(a, b), b);
}

int main() {
    long long n; cin >> n;
    for (int a = 1; a <= 3500; ++a) {
        for (int b = 1; b <= 3500; ++b) {
            long long deno = lcm(n, lcm(a, b));
            if (deno >= 3500LL * 3500 * 3500) continue;
            long long x = deno / n * 4 - deno / a - deno / b;
            if (x > 0 && deno % x == 0) {
                cout << deno / x << ' ' << a << ' ' << b << '\n';
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int MAX=100000;
static const int NIL=-1;

int n;
vector<int>G[MAX];
int color[MAX];

void dfs(int r,int c){
  stack <int>S;
  S.push(r);
  color[r]=c;
  while(!S.empty()){
    int u=S.top();
    S.pop();
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      if(color[v]==NIL){
        color[v]=c;
        S.push(v);
      }
    }
  }
}

void assignColor(){
  int id=1;
  for(int i=0;i<n;i++) color[i]=NIL;
  for(int u=0;u<n;u++){
    if(color[u]==NIL) dfs(u,id++);
  }
}

int main(){
  int s,t,m,q;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>s>>t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  assignColor();
  
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>s>>t;
    if(color[s]==color[t]){
      cout<<"yes"<<endl;
    }else cout<<"no"<<endl;
  }
  return 0;
}



Measured memory_bytes: 8976
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,k;
    cin>>a>>b>>k;
    ll t=min(a,k);
    a-=t;
    k-=t;
    t=min(b,k);
    b-=t;
    cout<<a<<" "<<b;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
   int a,b,c,d;
   string s;
   cin >> a >> b >> c >> d;
   if ((a+d-1)/d >= (c+b-1)/b) cout << "Yes" << endl;
   else cout << "No" << endl;

   return 0;
}


Measured memory_bytes: 3584
#include <cstdio>

int main(void)
{
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if((x >= r) && (((x+r) <= W)) && (y >= r) && ((y+r) <= H)) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 2700
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */



#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <limits>


#include <ostream>
#include <sstream>


using namespace std;

class A {
public:
  void solve(std::istream &in, std::ostream &out) {
    ios::sync_with_stdio(false);
    string a, b, c;
    in >> a >> b >> c;
    if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
      out << "YES" << endl;
    } else {
      out << "NO" << endl;
    }
  }
};


int main() {
  A solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 long long v;
 long long a;
 cin>>v>>a;
 long long sum=0;
 long long b;
 for(long long  i=1;i<=a;i++)
 {
     cin>>b;
     sum+=b;
 }
 if(sum>v)cout<<-1<<endl;
 else cout<<v-sum<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
i64 k;
i64 a[100010];
i64 b[100010];


i64 cal(int K)
{
    i64 value = 0;
    rep(i,0,n - 1)
    {
        if(!(a[i] & ~K))
        {
            value += b[i];
        }
    }
    return value;
}

int main()
{
    cin >> n >> k;
    rep(i,0,n - 1) cin >> a[i] >> b[i];

    i64 result = cal(k);
    int MAX = log2(k) + 1;
    rep(i,0,MAX)
    {
        if(k & (1 << i))
        {
            int temp = k;
            temp = temp & ~(1 << i);
            temp = temp | ((1 << i) - 1);
            result = max(result ,cal(temp));
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 5220
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int INF = 1 << 28;
		while (true) {
			int n = sc.nextInt();
			if(n==0)break;
			int m = 10;
			int time[][] = new int[m][m];
			for (int i = 0; i < m; i++) {
				Arrays.fill(time[i], INF);
				time[i][i] = 0;
			}
			int max = 0;
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int t = sc.nextInt();
				time[a][b] = time[b][a] = t;
				max = Math.max(max, a);
				max = Math.max(max, b);
			}
			for (int k = 0; k < m; k++) {
				for (int i = 0; i < m; i++) {
					for (int j = 0; j < m; j++) {
						time[i][j] = Math.min(time[i][j], time[i][k]
								+ time[k][j]);
					}
				}
			}
			int min = INF;
			int num = 0;
			for (int i = 0; i < max + 1; i++) {
				int sum = 0;
				for (int j = 0; j < max + 1; j++) {
					sum += time[i][j];
				}
				if (min > sum) {
					num = i;
					min = sum;
				}
			}
			System.out.println(num + " " + min);
		}
	}
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  double W, H, X, Y;
  cin >> W >> H >> X >> Y;

  cout << setprecision(16) << W * H / 2 << " ";

  if (X * 2 == W && Y * 2 == H) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vector<int> X(n);
  vector<int> Y(m);
  rep(i,0,n - 1) cin >> X[i];
  rep(i,0,m - 1) cin >> Y[i];
  i64 L = *max_element(all(X));
  i64 R = *min_element(all(Y));
  if(L < R && x < R && L < y){
    cout << "No War" << endl;
  }
  else{
    cout << "War" << endl;
  }
}


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



int main()
{
 string x , y , z;
 int a,b;
 cin >> x >> y;
 cin >> a >> b;
cin >> z;
if(z==x)
    a-=1;
else
    b-=1;
cout << a << " " <<b << endl;


}



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

#define int long long int
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define lb lower_bound
#define ub upper_bound
#define srt(a) sort(a.begin(),a.end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
#define mxe(a) *max_element(a.begin(),a.end())
#define mne(a) *min_element(a.begin(),a.end())
#define endl '\n'
#define mod 1000000007
#define INF64 1e18

void solve(){
  int n,m;cin>>n>>m;
  vvi dp(n,vi(m));
  vector<string> a(n);
  for(int i=0;i<n;i++)
    cin>>a[i];
  dp[n-1][m-1]=1;
  for(int i=m-2;i>=0;i--)
    if(a[n-1][i]=='.')dp[n-1][i]=dp[n-1][i+1];
  for(int i=n-2;i>=0;i--)
    if(a[i][m-1]=='.')dp[i][m-1]=dp[i+1][m-1];
  for(int i=n-2;i>=0;i--){
    for(int j=m-2;j>=0;j--)
      if(a[i][j]=='.')
        dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mod;
  }
  cout<<dp[0][0];
  
}

int32_t main(){
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif
  
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int T=1;
  //cin>>T;
  for(int TT=1;TT<=T;TT++){
    solve();
  }
}

Measured memory_bytes: 12376
N=int(input())
A = list(map(int, input().split()))

odd=0
even=0
even2=0

for num in A:
    if(num%2==1):
        odd+=1
    elif(num%4==0):
        even2+=1
    else:
        even+=1

if(even2>=odd):
    print("Yes")
elif((even==0)&(even2==(odd-1))):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020
n = int(input())

lista = input().split(' ')
lista = list(map(int, lista))

count = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if lista[i] != lista[j] and lista[j] != lista[k]  and lista[i] != lista[k]  and lista[i] + lista[j]  > lista[k] and lista[i] + lista[k]  > lista[j] and lista[k] + lista[j]  > lista[i]:
                count += 1



print(count)


Measured memory_bytes: 68228
import bisect
n=int(input())
A=sorted(list(map(int,input().split())))
B=list(map(int,input().split()))
C=sorted(list(map(int,input().split())))
lb,lc=len(B),len(C)
ans=0
for b in range(lb):
  ma = bisect.bisect_left(A, B[b])
  mc = lc-bisect.bisect_right(C, B[b])
  ans += ma*mc
print(ans)

Measured memory_bytes: 29452
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
long long r, d, x[2015];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> r >> d >> x[2000];
    for(int i = 2001; i <= 2010; i++){
        x[i] = x[i - 1] * r - d;
        cout << x[i] << endl;
    }
}


Measured memory_bytes: 256
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

const int N = 2e5 + 5;
int tym = 0;
v32 aRes,s(N,0),e(N,0);

void dfs(int ii,int pp,graph &g){
	tym++;
	s[ii] = tym;
	aRes.push_back(ii);
	for(auto jj : g[ii]){
		if(jj != pp)
			dfs(jj,ii,g);
	}
	e[ii] = tym;
}

int main()
{
	FASTIO;
	int n,q;
	cin >> n >> q;
	graph g;
	g.assign(n + 1,s32());
	v32 cnt(n + 1,0);
	for(int i = 1;i <= n - 1;i++){
		int u,v;
		cin >> u >> v;
		g[u].insert(v);
		g[v].insert(u);
	}
	int p,x;
	for(int i = 1;i <= q;i++){
		cin >> p >> x;
		cnt[p] += x;
	}
	dfs(1,0,g);
	v32 ans(n + 1,0);
	//print_container(aRes);
	for(int i = 1;i < n + 1;i++){
		ans[s[i] - 1] += cnt[i];
		ans[e[i]] -= cnt[i];
	}
	for(int i = 1;i < n;i++) ans[i] += ans[i - 1];
	v32 fi(n + 1,0);
	for(int i = 0;i < n;i++)
		fi[aRes[i]] = ans[i];
	for(int i = 1;i < n + 1;i++)
		cout << fi[i] << " ";
	cout << ln;
	return 0;
}


Measured memory_bytes: 47860
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define irep(i,a,b) for(int i=int(a);i>=int(b);i--)
using ll = long long;
using namespace std;

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	rep(i,0,s.length()-1){
		if (s[i] == s[i + 1]) {
			ans++;
			if (s[i + 1] == '1') s[i + 1] = '0';
			else s[i + 1] = '1';
		}
	}
	cout << ans;
}

Measured memory_bytes: 512
#pragma region Macros

#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;

#pragma endregion

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};

template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

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

  int N;
  cin >> N;
  UnWeightedGraph G(N);
  vector<int> deg(N, 0);
  REP(i, N) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    G[s].emplace_back(t);
    G[t].emplace_back(s);
    deg[s]++;
    deg[t]++;
  }

  queue<int> que;
  REP(i, N) {
    if (deg[i] == 1) {
      que.emplace(i);
    }
  }
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (auto nv : G[v]) {
      deg[nv]--;
      if (deg[nv] == 1) {
        que.emplace(nv);
      }
    }
  }

  int Q;
  cin >> Q;
  REP(i, Q) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    if (deg[s] > 1 and deg[t] > 1) {
      cout << "2\n";
    } else {
      cout << "1\n";
    }
  }

  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        List<int> b = new List<int>(a.Length);
        int index = n - 1;
        int vec = -1;
        for (int i = 0; i < n; i++)
        {
            b.Add(a[index]);

            index = index + (vec * 2);
            if (index < 0)
            {
                if (n % 2 == 1)
                {
                    index = 1;
                }
                else
                {
                    index = 0;
                }
                vec = +1;
            }
        }

        string dest = string.Join(" ", b);
        Console.WriteLine(dest);
    }
}


Measured memory_bytes: 48440
n,d=list(map(int,input().split()))
a=[list(map(int, input().split())) for i in range(n)]
cnt=0

def f(x,y):
  cal=0
  for i in range(d):
    cal+=abs(x[i]-y[i])**2
  return cal**0.5

for i in range(n-1):
  for j in range(i+1,n):
    if f(a[i],a[j]).is_integer()==True:cnt+=1

print(cnt)

Measured memory_bytes: 3188
#include "iostream"
#include "algorithm"
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	long long int a[1000][3];
	for (int i = 0; i < n; i++)
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	long long int c[8], b[1000];

	for (int i = 0; i < 8; i++)
		c[i] = 0;

	for (int i = 0; i < n; i++)
		b[i] = a[i][0] + a[i][1] + a[i][2];
	sort(b, b + n);
	for (int i = 0; i < m; i++)
		c[0] += b[n - 1 - i];

	for (int i = 0; i < n; i++)
		b[i] = a[i][0] + a[i][1] - a[i][2];
	sort(b, b + n);
	for (int i = 0; i < m; i++)
		c[1] += b[n - 1 - i];

	for (int i = 0; i < n; i++)
		b[i] = a[i][0] - a[i][1] + a[i][2];
	sort(b, b + n);
	for (int i = 0; i < m; i++)
		c[2] += b[n - 1 - i];

	for (int i = 0; i < n; i++)
		b[i] = -a[i][0] + a[i][1] + a[i][2];
	sort(b, b + n);
	for (int i = 0; i < m; i++)
		c[3] += b[n - 1 - i];

	for (int i = 0; i < n; i++)
		b[i] = a[i][0] - a[i][1] - a[i][2];
	sort(b, b + n);
	for (int i = 0; i < m; i++)
		c[4] += b[n - 1 - i];

	for (int i = 0; i < n; i++)
		b[i] = -a[i][0] + a[i][1] - a[i][2];
	sort(b, b + n);
	for (int i = 0; i < m; i++)
		c[5] += b[n - 1 - i];

	for (int i = 0; i < n; i++)
		b[i] = -a[i][0] - a[i][1] + a[i][2];
	sort(b, b + n);
	for (int i = 0; i < m; i++)
		c[6] += b[n - 1 - i];

	for (int i = 0; i < n; i++)
		b[i] = -a[i][0] - a[i][1] - a[i][2];
	sort(b, b + n);
	for (int i = 0; i < m; i++)
		c[7] += b[n - 1 - i];

	sort(c, c + 8);

	cout << c[7] << endl;

	return 0;
}

Measured memory_bytes: 768
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    a.sort()
    if a[0]+a[1] == a[2]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,n,m=0,a,b=0;
    cin >> n;
    int l[n];
    for(i=0; i<n; i++){
        cin >> l[i];
    }
    for(i=0;i<n;i++){
        if(l[i]>m){
            m = l[i];
        }
    }
    for(i=0;i<n;i++){
        if(l[i]==m){
            a = i;
            break;
        }
    }
    for(i = a+1; i<n; i++){
        b =  b + l[i];
    }
    for(i = a-1; i>=0; i--){
        b =  b + l[i];
    }
    if(m<b){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int all = n;
		int sum = 0;
		ArrayList<Integer> array = new ArrayList<Integer>();
		while(n-- > 0) {
			int temp = sc.nextInt();
			array.add(temp);
			sum += temp;
		}
		long roundavg = Math.round((double)sum/all);
		int ans = 0;
		for(int i = 0; i < array.size(); i++) {
			ans += (array.get(i) - roundavg) * (array.get(i) - roundavg);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35936
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
//size無し
class UnionFind {
private:
    int sz;
    vector<int> par, nrank;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), nrank(sz, 0){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(nrank[x] < nrank[y]) swap(x,y);
        par[y] = x;
        if(nrank[x] == nrank[y]) nrank[x]++;
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};
struct edge{
    int a,b;
    ll cost;
    edge(int a,int b,ll cost):a(a),b(b),cost(cost){}
    bool operator<(const edge&b) const{
        return cost < b.cost;
    }
};
vector<ll>a;
vector<edge>e;
ll d;
void dfs(int l,int r){
    if(l==r)return;
    int mid = (l+r)/2;
    int id = - 1;
    ll mi = 1LL<<60;
    for(int i = l; i <= mid; i++){
        if(mi > -d*i+a[i]){
            mi = -d*i+a[i];
            id = i;
        }
    }
    for(int i = mid + 1; i <= r; i++){
        e.emplace_back(id,i,mi+a[i]+d*i);
    }
    mi = 1LL<<60;
    for(int i = mid + 1; i <= r; i++){
        if(mi > d*i+a[i]){
            mi = d*i+a[i];
            id = i;
        }
    }
    for(int i = l; i<= mid; i++){
        e.emplace_back(id,i,mi+a[i]-d*i);
    }
    dfs(l,mid);
    dfs(mid+1,r);
}
int main(){
    int n;
    cin >> n;
    cin >> d;
    a.resize(n);
    rep(i,n)cin >> a[i];
    dfs(0,n-1);
    sort(e.begin(),e.end());
    UnionFind uf(n);
    ll ans = 0;
    for(auto &x:e){
        if(!uf.same(x.a,x.b)){
            uf.unite(x.a,x.b);
            ans += x.cost;
        }
    }
    cout << ans << endl;
    return 0;
}

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


int dp[100001][20];

vector<int> e[100001];


void dfs(int x,int p){
	for(int it:e[x]){
		if(it!=p){
			dfs(it,x);
			for(int i=0;i<=19;i++)
				dp[x][i]+=dp[it][i];
		}
	}
	int who;
	for(who=19;who>=0;who--)
		if(dp[x][who]>1)
			break;
	who++;
	while(dp[x][who])	who++;
	dp[x][who]++;
	for(int i=0;i<who;i++)
		dp[x][i]=0;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	dfs(1,0);
	for(int i=19;;i--)
		if(dp[1][i]){
			cout<<i<<endl;
			return 0;
		}
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    int sum=0;
    REP(i, 5){
        IN(int, k);
        sum += k;
    }
    COUT(15-sum);
}


Measured memory_bytes: 3576
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random  # randome is not available at Codeforces
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

import sys
sys.setrecursionlimit(10**7)
mo=998244353

class PERM_COMB_MOD():
    # http://drken1215.hatenablog.com/entry/2018/06/08/210000
    def __init__(self, max_n=510000, mod=10**9+7):
        self.fac = [0]*max_n
        self.finv = [0]*max_n
        self.inv = [0]*max_n
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        self.max = max_n
        self.mod = mod
        self._maesyori()
 
    def _maesyori(self):
        for i in range(2,self.max):
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod
 
    def comb(self, n, k):
        if n < k : return 0
        if n < 0 or k < 0:return 0
        return self.fac[n] * (self.finv[k] * self.finv[n-k] % self.mod) % self.mod

n,a,b,k=LI()
com=PERM_COMB_MOD(mod=mo)

show_flg=False
show_flg=True

if a<b:
    a,b=b,a
ans=0
for i in range(min(n+1,k//a+1)):
    j=(k-a*i)//b
    if (k-a*i)%b!=0 or j<0 or j>n:
        continue
    try:
        ans+=com.comb(n,i)*com.comb(n,j)
    except:
        0
    ans%=mo

print(ans%mo)



Measured memory_bytes: 53740
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cassert>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define FOR(j,k,n) for (int j = k; j < (int)(n); j++)
#define MAXN 100000000000000000
#define newl printf("\n")
#define test(t)  int t; cin>>t; for(int tes = 0; tes < t; tes++)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int lli;
const int MM = 220000;
lli m,n,k,p1,p2,p3,p,f,a[MM];
string s,s1,s2;
set<lli> g[MM];
bool chec()
{
    for (int i=0; i<n; i++) {
        if(a[i] > n-1)
            return 1;
    }
    return 0;
}
lli mpos(lli val)
{
    for (int i=0; i<n; i++) {
        if(a[i] == val)
        {
            return i;
        }
    }
    return 0;
}
int main(){
    fio;
        // Have you solved the problem completely?
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>a[i];
    }
    lli ans = 0;
    
    while (chec()) {
        lli mx = *max_element(a, a+n);
        lli pos = mpos(mx);
        lli red = mx-n+1;
        lli inc = red/n;
        if(red%n > 0)
            inc++;
//        cout<<a[pos]<<" -> ";
        a[pos] -= inc * n;
        for (int i=0; i<n; i++) {
            if(i != pos)
                a[i] += inc;
        }
//        cout<<a[pos]<<endl;
        ans += inc;
//        cout<<inc<<" "<<mx<<" "<<pos<<endl;
//        for (int i=0; i<n; i++) {
//            cout<<a[i]<<" ";
//        }
//        cout<<endl;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 10624
#!/usr/bin/env python3
# 単純にスタートとゴールが固定（1,1) (h,w)のBFSで
# 最短経路を求めたら、h*w - cnt - 最初の黒マスの数　を返す
# inputで黒マスを数える
h,w = map(int,input().split())
board = [["#"]*(w+2) for _ in range(h+2)]
num_black = 0
for i in range(h):
    s = input()
    for j in range(w):
        board[i+1][j+1] = str(s[j])
        if s[j] == "#":
            num_black += 1
path = 0 # 最短経路のパス数
from collections import deque
mv = ((1,0),(-1,0),(0,1),(0,-1))
visit = deque()
start_pos = (1,1)
visit.append(start_pos)
cnt = [[-1]*(w+2) for _ in range(h+2)] # -1埋め
cnt[1][1] = 0 #スタート地点は0
while visit:
    point = visit.popleft()
    #print(point[0], point[1])
    for k in mv:
        pos = (point[0]+k[0],point[1]+k[1])
        #print(pos)
        if board[pos[0]][pos[1]] == ".":
            if cnt[pos[0]][pos[1]] == -1: #unvisited
                #print(i,j,"yes")
                cnt[pos[0]][pos[1]] = cnt[point[0]][point[1]] + 1
                visit.append((pos[0],pos[1]))
                if pos[0] == h and pos[1] == w:
                    path = cnt[pos[0]][pos[1]]
                    break
if path == 0: print(-1)
else: print(h*w - path - num_black -1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
ll mod= 1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll n,cnt=0;
ll f(ll g,ll a,ll b, ll c){
  if(g>n)return 0;
  if(a*b*c==1)cnt++;
  f(g*10+3,1,b,c);
  f(g*10+5,a,1,c);
  f(g*10+7,a,b,1);
  return cnt;
}
main(){
    cin>>n;
    cout<<f(0,0,0,0);
}


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

int main(){
	int n,k;
	cin>>n>>k;
	int p[n]={};
	rep(i,n) cin>>p[i];
	sort(p,p+n);
	int ans=0;
	rep(i,k) ans+=p[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
use std::mem::swap;
use std::cmp::min;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
    n: usize,
    m: usize,
    c: [usize; m]
    }
    let mut dp = vec![-1; n + 1];
    dp[0] = 0;
    for i in 0..m {
        let mut prev = vec![-1; n + 1];
        swap(&mut prev, &mut dp);
        let cc = c[i];
        for j in 0..n + 1{
            if j >= cc {
                if prev[j] >= 0 {
                    dp[j] = min(prev[j], dp[j - cc] + 1);
                } else {
                    dp[j] = dp[j - cc] + 1;
                }
            } else {
                dp[j] = prev[j];
            }
        }
    }
    let ans = dp[n];
    println!("{}", ans);
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  rep(i,a,b) for(i=a;i<b;i++)
#define endl "\n"
#define ll long long int
#define ld long double
using namespace std;
int main()
{
IOS;
string s;
cin>>s;
if(s[0]=='S')
    cout<<"Cloudy";
else
    if(s[0]=='C')
    cout<<"Rainy";
else
    cout<<"Sunny";
return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll a,b,x,ans=0;
  cin>>a>>b>>x;
  if(a==0) ans = 1 + (b/x);
  else ans = (b/x) - ((a-1)/x);
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3580
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  vector<vector<int>> left(h + 1, vector<int>(w + 1)), right(left);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '.') left[i][j + 1] += left[i][j] + 1;
      else left[i + 1][j] = 0;
    }
  }
  for (int i = 0; i < h; i++) {
    reverse(s[i].begin(), s[i].end());
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '.') right[i][j + 1] += right[i][j] + 1;
      else right[i][j + 1] = 0;
    }
    reverse(s[i].begin(), s[i].end());
    reverse(right[i].begin(), right[i].end());
  }
  vector<vector<int>> top(h + 1, vector<int>(w + 1)), bottom(top);
  for (int j = 0; j < w; j++) {
    for (int i = 0; i < h; i++) {
      if (s[i][j] == '.') top[i + 1][j] += top[i][j] + 1;
      else top[i + 1][j] = 0;
    }
  }
  for (int j = 0; j < w; j++) {
    for (int i = h - 1; i >= 0; i--) {
      if (s[i][j] == '.') bottom[i][j] += bottom[i + 1][j] + 1;
      else bottom[i][j] = 0;
    }
  }
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') continue;
      ans = max(ans, left[i][j + 1] + right[i][j] + top[i + 1][j] + bottom[i][j] - 3);
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    map<Int, Int> mp;
    for (Int i = 2; i <= n; i++) {
        Int base = i;
        for (Int j = 2; j * j <= i; j++) {
            while (base % j == 0) {
                base /= j;
                mp[j]++;
            }
        }
        if (base > 1) {
            mp[base]++;
        }
    }
    // 2 4 4
    // 2 24
    // 4 14
    // 74
    Int a = 0;
    Int b = 0;
    Int c = 0;
    Int d = 0;
    Int e = 0;
    for (auto i : mp) {
        if (i.se >= 2) {
            a++;
        }
        if (i.se >= 4) {
            b++;
        }
        if (i.se >= 74) {
            c++;
        }
        if (i.se >= 24) {
            d++;
        }
        if (i.se >= 14) {
            e++;
        }
    }
    dump(b * (b - 1) * (a - 2) / 2 + c + d * (a - 1) + e * (b - 1));
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N=int(input())
A=list(map(int, input().split()))
for i in range(len(A)):
    A[i]%=4
# print(A)
cnt=dict(Counter(A).items())
# print(cnt)
num0=0
if 2 in cnt:
    cnt[2]=1
if 0 in cnt:
    num0=cnt[0]
    cnt.pop(0)
num1=sum(list(cnt.values()))
print("Yes" if num1<=num0+1 else "No")


Measured memory_bytes: 14636
import sys
sys.setrecursionlimit(1<<30)

idx = 'ABC'
N, *vals = map(int, input().split())
evs = [tuple(map(idx.index, input())) for _ in range(N)]

def f(i, vals, path):
	if i == len(evs):
		print('Yes')
		print('\n'.join(path))
		raise SystemExit

	k, j = evs[i]
	for add, sub in ((k, j), (j, k)):
		if vals[sub] == 0: continue
		vals[add] += 1
		vals[sub] -= 1
		path.append(idx[add])

		f(i+1, vals, path)

		vals[add] -= 1
		vals[sub] += 1
		path.pop()

f(0, vals, [])

print('No')



Measured memory_bytes: 542212
import scala.io.{ StdIn => in}

object Main extends App {
  val Array(k, s) = in.readLine.split(" ").map(_.toInt)

  val ans = {
    var res = 0
    for(x <- 0 to k; sx = s - x; y <- 0 to k) {
      val z = sx - y
      if(0 <= z && z <= k) res += 1
    }
    res
  }

  println(ans)
}

Measured memory_bytes: 26020
#include<bits/stdc++.h>
using namespace std;
#define w(t) int t;cin>>t;while(t--)
#define pb   push_back
#define mk   make_pair
#define prDouble(x) cout<<fixed<<setprecision(10)<<x
typedef long long ll;
const ll mod=1e9+7;
string solve(vector<int>&v,int k){
	bool dp[k+1];
	memset(dp,0,sizeof dp);
	for(int i=1;i<=k;i++){
		for(int move: v){
			if(move >i)continue;
			if(dp[i-move]==0)
				dp[i]=1;
		}
	}
	return dp[k] ? "First" : "Second";
}
int main()
{

	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr);
    int n;cin>>n;
    int k;cin>>k;
    vector<int>A(n);
    for(int i=0;i<n;i++)cin>>A[i];
    	cout<<solve(A,k);
    return 0; 
}

/*
dp[0] =0 means losing state

dp[i]=1 if dp[x-ai]=0 for all ai

else
dp[i]=0 lossing state

Since Iam playing first,here I am checking that if I can reach lossing state from any ith state then I can make second
person lose,so i will win dp[i]=1, if I can't then i am losing dp[i]=0
*/


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

struct edge{
    int to, cost;
};

vector<vector<edge>> tree;
vector<int> color;

void dfs(int u, int p){
    int n = tree[u].size();
    for(int i=0; i<n; i++){
        int v = tree[u][i].to;
        int w = tree[u][i].cost;
        if(v==p) continue;

        if(w%2==0){
            color[v] = color[u];
        }else{
            color[v] = 1 - color[u];
        }
        dfs(v, u);
    }
}

int main(){
    int N;
    cin >> N;
    tree = vector<vector<edge>>(N+1, vector<edge>());
    for(int i=0; i<N-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        edge e;  e.to = v;  e.cost = w;
        tree[u].push_back(e);
        e.to = u;
        tree[v].push_back(e);
    }

    int root = 1;
    color = vector<int>(N+1, 0);
    color[root] = 0;
    dfs(root, 0);
    for(int i=1; i<=N; i++){
        cout << color[i] << endl;
    }
}

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

int main()
{
    int N;
    cin >> N;
    
    if(N<1200){
        cout << "ABC" << endl;
    }
    else if(N<2800) {
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
}



Measured memory_bytes: 3640
N = int(input())
A = list(map(int, input().split()))

ans = [0]*N

#TLE解
# for i in range(N):
#     if i%2 == 0:
#         ans[i] = sum(A[0:i:2])-sum(A[1:i:2])+A[i]+sum(A[i+1::2])-sum(A[i+2::2])
#     else:
#         ans[i] = -sum(A[0:i:2])+sum(A[1:i:2])+A[i]+sum(A[i+1::2])-sum(A[i+2::2])
# ans.insert(0, ans.pop(-1))

ans[0] = sum(A)-sum(A[1::2])*2
for i in range(1, N):
    ans[i] = A[i-1]*2-ans[i-1]
print(*ans)

Measured memory_bytes: 14092
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int N;
	cin >> N;

	Int sum = 0;
	Int temp = N;
	while (temp) {
		sum += temp % 10;
		temp /= 10;
	}

	if (N%sum==0) cout << "Yes" << "\n";
	else cout << "No" << "\n";
}


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

struct UnionFind {
    UnionFind(int n) {
        parent = vector<int>(n, -1);
        weight = vector<int>(n, 0);
    }
    int find(int x) {
        if (parent[x] < 0)
            return x;
        else
            return parent[x] = find(parent[x]);
    }
    bool isSame(int x, int y) { return find(x) == find(y); }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            weight[x]++;
            return;
        }
        if (parent[x] < parent[y])
            swap(x, y);
        parent[x] += parent[y];
        parent[y] = x;
        weight[x] += weight[y] + 1;
    }
    int getSize(int x) { return -parent[find(x)]; }
    int getWeight(int x) { return weight[find(x)]; }

private:
    vector<int> parent;
    vector<int> weight;
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind uf(N);
    map<int, int> cnt;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
        cnt[a]++;
        cnt[b]++;
    }

    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        ans[i] = uf.getSize(i) - 1 - cnt[i];
    }
    for (int i = 0; i < K; i++) {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        if (uf.isSame(c, d)) {
            ans[c]--;
            ans[d]--;
        }
    }

    for (int a : ans) {
        cout << a << " ";
    }
    cout << endl;
}


Measured memory_bytes: 7424
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  int n;cin>>n;
  //エラトステネスの篩
  vector<int> val(10000001,0),f(10000001,0);
  rep2(i,1,n+1)val[i]=i,f[i]=1;
  int c;
  rep2(p,2,n+1){
    for(int x=p;x<=n;x+=p){
      c=0;
      while(val[x]%p==0)val[x]/=p,c++;
      f[x]*=c+1;
    }
  }
  ll res=0;
  rep2(i,1,n+1)res+=ll(i)*f[i];
  cout<<res<<endl;
}

Measured memory_bytes: 81324
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  abs(x-a) > abs(x-b) ? cout << 'B' << endl : cout << 'A' << endl;
  return 0;
}

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

using namespace std;

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (T &i: v) os << i << ",";
  os << "]";
  return os;
}

template<class TH> void _dbg(const char *sdbg, TH h){ cout<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cout<<*sdbg++;
  cout<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef __DJKIM613
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

const int MAXN = 2e5 + 10;

int N;
vector<int> ADJ[MAXN];
int L[MAXN];

void dfs(int here, int par){
  L[here] = L[par] + 1;
  for(int there : ADJ[here]) if(there != par) dfs(there, here);
}

int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  cin >> N;
  for(int x, y, i = 1 ; i <= N - 1 ; i++) cin >> x >> y, ADJ[x].push_back(y), ADJ[y].push_back(x);

  dfs(1, 0);
  int pos = 1;
  for(int i = 1 ; i <= N ; i++) if(L[pos] < L[i]) pos = i;

  dfs(pos, 0);
  for(int i = 1 ; i <= N ; i++) if(L[pos] < L[i]) pos = i;

  if(L[pos] % 3 == 2) cout << "Second\n";
  else cout << "First\n";
  return 0;
}

Measured memory_bytes: 21376
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
        int data;
        struct node *next;
        struct node *prev;
}stack;
stack *head = NULL;
stack *last = NULL;
void Push_back(int);
int Pop_back(void);
main()
{
        char x[101];
        scanf("%s", x);
        do{
                if(x[0] == '+' || x[0] == '-' || x[0] == '*'){
                        int a, b;
                        b = Pop_back();
                        a = Pop_back();
                        switch(x[0]){
                        case '+':
                                Push_back(a + b);
                                break;
                        case '-':
                Push_back(a - b);
                break;
                        case '*':
                Push_back(a * b);
                break;
                        }
                }else{
                        int temp = atoi(x);
                        Push_back(temp);
                }
        }while(scanf(" %s", x) != EOF);
        printf("%d\n", Pop_back());
}
void Push_back(int data)
{
        stack *p;
        if((p = (stack*)malloc(sizeof(stack))) == NULL){
                fprintf(stderr, "Memory cannot allocate\n");
                exit(0);
        }
        p -> data = data;
        p -> next = NULL;
        p -> prev = last;
        last = p;
        if(head == NULL){
                head = p;
        }
}
int Pop_back(void)
{
        int pop_data;
        stack *p = last;
        if(head == NULL){
                return EOF;
        }
        pop_data = last -> data;
        if(last -> prev == NULL){
                head = NULL;
        }else{
                last -> prev -> next = NULL;
        }
        p = last;
    last = last -> prev;
        free(p);
        return pop_data;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int a,b,c,d;cin>>a>>b>>c>>d;

  if(a*b>=c*d)out(a*b)
  else if(a*b<c*d)out(c*d)

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
N += 1

bk = set()
for i in range(M):
    bk.update([int(input())])

DP = [0]*N
DP[0] = 1
if 1 not in bk:
    DP[1] = 1

for i in range(2, N):
    if i not in bk:
        DP[i] = DP[i-1] + DP[i-2]

# print(DP)
print(DP[-1] % 1000000007)


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

int main(){
  int a,b;
  while(cin>>a>>b){
    int sum=a+b;
    int count=0;
    do{
      count++;
      sum*=0.1;
    }while(sum!=0);
      cout<<count<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160