akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

struct Team {
    int point;
    string name;
    Team(string name, int win, int lose, int draw) : name(name), point(win * 3 + draw) {}
    bool operator<(const Team& t){
        return point < t.point;
    }
};
bool operator<(const Team& a, const Team& b){
    return a.point < b.point;
}
bool operator>(const Team& a, const Team& b){
    return a.point > b.point;
}

int main()
{
    int n;
    bool space = false;
    while (n = in()){
        if (!space){
            space = true;
        }
        else puts("");

        vector<Team> ts;
        rep(i, n){
            string name;
            int win, lose, draw;
            cin >> name >> win >> lose >> draw;
            ts.push_back(Team(name, win, lose, draw));
        }
        stable_sort(ts.begin(), ts.end(), greater<Team>());
        rep(i, n){
            printf("%s,%d\n", ts[i].name.c_str(), ts[i].point);
        }
    }
    return (0);
}

Measured memory_bytes: 1276
#include<stdio.h>
#include<math.h>
#define INFINITY 1000000001
int merge(int*,int,int,int);
int mergeSort(int*,int,int);
int count=0;

int main(){
  int a,i,n;
  scanf("%d",&n);
  int S[n];
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  count=mergeSort(S,0,n);
  for(i=0;i<n-1;i++){
    printf("%d ",S[i]);
  }
  printf("%d\n",S[n-1]);
  printf("%d\n",count);
  return 0;
}

int merge(int *A,int left,int mid,int right){
  int n1,n2,i,j,k;
  n1 = mid - left;
  n2 = right - mid;
  int L[n1], R[n2];
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
      }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1] = INFINITY;
  R[n2] = INFINITY;
  i = 0;
  j = 0;
  for(k = left;k< right;k++){
    if( L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      count++;
    }
    else {
      A[k] = R[j];
      j = j + 1;
      count++;
    }
  }
  return count;
}
int mergeSort(int *A,int left,int right){
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
  return count;
}

Measured memory_bytes: 4504
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(){
  int S[100],top=0;
  string s;
  while(cin>>s){
    if(s=="+")
      {S[top-1]+=S[top];--top;}
    else if(s=="-")
      {S[top-1]-=S[top];--top;}
    else if(s=="*")
      {S[top-1]*=S[top];--top;}
    else
      {S[++top]=atoi(s.c_str());}
  }
  cout<<S[top]<<endl;
  return 0;
}

Measured memory_bytes: 3196
// https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_a
#include <bits/stdc++.h>
using namespace std;

int main(void){
  int M,D;
  cin >> M >> D;
  int num=0;
  for (int i = 1; i <= M; i++){
    for (int j = 1; j <= D; j++){
      int d1 = j % 10;
      int d10 = j / 10;
      if (i==d1*d10 && d1>1 && d10>1){
        num++;
      }
    }
  }

  cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <iterator>
#include <unordered_map>
#include <map>

using namespace std;

using ll = long long;

int main()
{
	int a;
	string s;
	cin >> a;
	cin >> s;

	if (a >= 3200)
	{
		cout << s << endl;
	}
	else
	{
		cout << "red" << endl;
	}
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,d;
  cin >> n >> d;
  vector<vector<int>> v(n,vector<int>(d));
  rep(i,n){
    rep(j,d) cin >> v[i][j];
  }
  int ans=0;
  rep(i,n){
    repp(j,i+1,n){
      int x=0;
      rep(k,d){
        x+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
      }
      rep(k,sqrt(x)+100){
        if(k*k==x){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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


int main() {
    string s;
    cin >> s;
    int min_diff = INT_MAX;
    for (int i = 0; i < s.size() - 2; i++) {
        int num = stoi(s.substr(i, 3)); 
        int diff = abs(num - 753);
        if (diff < min_diff) {
            min_diff = diff;
        }   
    }
    cout << min_diff << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int lot[100000];

int main(void) {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &lot[i]);

	long long max = 0;
	for (long long c = 1; c < n-1; c++) {
		long long sum = 0;
		for (long long k = 1; (k+1)*c < n-1; k++) {
			if ((n-1)%c == 0 && (n-1) < 2*k*c+c) break;
			sum += lot[n-1 - k*c] + lot[k*c];
			if (max < sum) max = sum;
		}
	}
	printf("%lld\n", max);
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;

const int mod=1e9+7;
const int inf=-1;
const int sz=2e5;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gap ' '
#define lb lower_bound
#define ub upper_bound
#define SIN(x) sin(x * pi / 180.0)
#define COS(x) cos(x * pi / 180.0)
#define clr(x) memset(x,0,sizeof(x))
#define all(x) sort(x.begin(),x.end())
#define rall(x) reverse(x.begin(),x.end())
#define dbg puts("finding wrong")
#define case(x,y) printf("Case %lld: %lld\n",++x,y)
#define fastio ios::sync_with_stdio(false);cin.tie(0)


ll ar[sz];
map<ll,ll>cnt;
 
ll par(ll z){
    if(ar[z]==z) return z;
    else return ar[z]=par(ar[z]);
}

int main()
{
  fastio;
  ll  i, n, m;
  
  cin>>n>>m;
  
  for(i=1; i<=n; i++)ar[i]=i;
  
  ll a, b;
  for(i=1; i<=m; i++)
  {
      cin>>a>>b;
      ar[par(a)]=par(b);
  }
  
  ll mx=0, ans;
  for(i=1; i<=n; i++)
  {
    ans=par(ar[i]);
    cnt[ans]++;
    mx=max(mx,cnt[ans]); 
  }
  
  cout<<mx<<endl;
  
  return 0;
}


Measured memory_bytes: 17568
from collections import deque
H, W = map(int, input().split())
C = [list(input()) for i in range(H)]
X = [1,0,-1,0]
Y = [0,-1,0,1]
Q = deque()
dist = [[99999]*W for i in range(H)]
for i in range(H):
  for j in range(W):
    if C[i][j] == "#":
      dist[i][j] = 0
      Q.append((i,j))

while Q:
  y,x = Q.popleft()
  for k in range(4):
    ny = y + Y[k]
    nx = x + X[k]
    if not (0 <= nx < W):
      continue
    if not (0 <= ny < H):
      continue
    if not (C[ny][nx] == "."):
      continue
    if not (dist[ny][nx] > dist[y][x]+1):
      continue
    Q.append((ny,nx))
    dist[ny][nx] = dist[y][x] + 1
ans = 0
for i in range(H):
  ans = max(ans,max(dist[i]))
print(ans)

Measured memory_bytes: 121436
// Program to count the numbers divisible by 
// M in a given range 
#include <bits/stdc++.h> 
using namespace std; 

int countDivisibles(int A, int B, int M) 
{ 

	int counter = 0; 

	for (int i = A; i <= B; i++) 
		if (i % M == 0) 
			counter++; 

	return counter; 
} 

// Driver code 
int main() 
{ 

	int l ,r,d;
	cin>>l>>r>>d;
	cout << countDivisibles(l, r, d) << endl; 

	return 0; 
} 


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/


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

    int n; cin >> n;
    vector <pair<int, int>> A(n);
    for (auto &i: A) cin >> i.first >> i.second;
    string ans = "No";
    for (int i = 0; i + 3 <= n; ++i) {
        bool ok = true;
        for (int j = 0; j < 3; ++j) {
            if (A[i+j].first != A[i+j].second) ok = false;
        }
        if (ok) ans = "Yes";
    }
    cout << ans;

    return 0;
}



Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<cmath>
#include<iomanip>
using namespace std;

int main(void){
	int A[1000],i,minj,N,a,j,count;
	count=0;
	cin>>N;
	for(a=0;N>a;a++){
		cin>>A[a];
	}for(i=0;i<N;i++){
		minj=i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}if(i!=minj){
			count++;
		}
				a=A[i];
				A[i]=A[minj];
				A[minj]=a;
	}
	for(a=0;N>a;a++){
		cout<<A[a];
		if(a!=N-1){
			cout<<" ";
		}
	}cout<<endl;
	cout<<count<<endl;
	return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>
int main(void){
    int n,a,b,ans=0 ;
    scanf ("%d%d%d",&n,&a,&b) ;
    
    for (int i=1; i<=n; i++ ){
        int i2 = i ;
        int i3 = 0 ;
        while (i2>0) {
            i3 += i2%10 ;
            i2 /= 10 ; 
        }
        if ( i3>=a && i3<=b ){
            ans += i ;
        }
    }
    
    printf ("%d\n",ans) ;
    
    return 0 ;
}

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

int main() {
  long long x;
  cin>>x;
  long long m=100;
  long long ans=0;
  long long task=0;
  while(x>m){
    task=m/100;
    m+=task;
    ans++;
  }
  cout<<ans<<endl;
}

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

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50

const LL MAX_N=(LL)1e5+3;

LL bit[MAX_N],n;

LL sum(int i){
    LL s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}


int add(int i,LL x){
    while(i<=n){
        bit[i]+=x;
        i+=i&-i;
    }
    return 0;
}
LL A[MAX_N];
int main(){
    int N;
    cin>>N;
    n=N;
    CLR(bit);
    REP(i,N)cin>>A[i];
    sort(A,A+N);
    REP(i,N)add(i+1,A[i]);
    int pos=0;
    REP(i,N-1){
        if(2*sum(i+1)<A[i+1]){
            // /cout<<"!"<<sum(i+1)<<" "<<A[i+1]<<endl;
            pos=i+1;
        }
    }
    cout<<N-pos<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string.h>
using namespace std;

int main () {
  string h;
  cin >> h;
  int T[h.size()];
  for (int i = 0; i < h.size(); i++) {
    T[i] = 0;  
  }  
  for (int i = 0; i < h.size(); i++) {
    if (i == 0) {
      if (h[0] == 'T') {
        T[i]++;   
      }  
    }  
    else {
      T[i] = T[i - 1];
      if (h[i] == 'T') {
        T[i]++;  
      }  
    }
  }
  int sum = T[h.size() - 1];
  int ans = h.size();
  for (int i = h.size() - 1; i >= 0; i--) {
    if (h[i] == 'S') {
      if (sum - T[i] >= 1) {
        sum--;
        ans = ans - 2;  
      }  
    }    
  }
  cout << ans << endl;
}

Measured memory_bytes: 1652
// Vicfred
// https://atcoder.jp/contests/abc162/tasks/abc162_f
// dynamic programming, cumulative sum
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    long n = readln.chomp.to!long;
    long[] b = readln.split.map!(to!long).array;
    long[] a;
    a ~= 0;
    a ~= b;

    long[] cumulative = new long[n+1];
    long[] dp = new long[n+1];
    cumulative[1] = a[1];

    for(long i = 3; i <= n; i++)
        cumulative[i] = cumulative[i-2]+a[i];

    for(long i = 2; i <= n; i++) {
        if(i%2 == 1)
            dp[i] = max(dp[i-1], dp[i-2]+a[i]);
        else {
            dp[i] = max(cumulative[i-1], dp[i-2]+a[i]);
        }
    }

    dp[n].writeln;
}



Measured memory_bytes: 16352
a, b = map(int, input().split())
if a != 1 and b != 1:
    if a > b:
        print("Alice")
    elif a < b:
        print("Bob")
    else:
        print("Draw")
else:
    if a == 1 and b == 1:
        print("Draw")
    elif a == 1:
        print("Alice")
    else:
        print("Bob")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    if (s[3] == '7') s[3] = '8';
    cout << s << endl;
}

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

int main() {

int P,Q,R;
cin >> P >> Q >> R;

    if(P <= Q) {
        if (Q <= R) {
        cout << P + Q <<endl;
        }
        
        else {cout << P + R << endl;
        }
        
    } 
    else { if (P <= R) {
    cout << Q + P << endl;
    }
    else {cout << Q + R << endl;
    }
    
    }
}


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

int main(int argc, char *argv[], char *envp[]){
	int N;
	int KAI=0;
	string s;
	cin >> N >> s;
	for(int i=0; i<s.size(); ++i){
		if(i == 0) {
			KAI += 1;
			continue;
		}
		if(s[i-1] != s[i]){
			KAI += 1;
		}
	}
	cout << KAI << endl;
	return 0;
}


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

int main() {
	int x, y; cin >> x >> y;

	int ans = abs(abs(x) - abs(y));
	if (((x >= 0 && y >= 0) || (x <= 0 && y <= 0)) && x <= y);
	else if ((x <= 0 && y >= 0) || (x >= 0 && y <= 0))ans++;
	else ans += 2;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	int n; cin>>n;
	vl a(n),b(n);
	rep(i,0,n)cin>>a[i];
	rep(i,0,n)cin>>b[i];
	ll k=0,l=0;
	rep(i,0,n){
		if(a[i]>b[i])k+=(a[i]-b[i]);
		else{
			ll c=b[i]-a[i];
			l+=(c+1)/2;
			if(c%2==1)k++;
		}
	}
	//cout<<k<<endl;
	//cout<<l<<endl;
	if(k<=l)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3772
#include <stdio.h>
#include <iostream>
using namespace std;

int n,m;
int a[1200][1200];
int p[4][2]={0,-1,1,0,0,1,-1,0};
int num[10005];
int r;
int sum=0;

void Init()
{
    int x,y;
    x=1;
    y=m+1;
    int k=0;
    int c=1;
    sum=num[1];
    for (int i=1;i<=n*m;i++)
        {
        x=x+p[k%4][0];
        y=y+p[k%4][1];
        if (x<1 || x>n || y<1 || y>m || a[x][y]!=0)
            {
            x=x-p[k%4][0];
            y=y-p[k%4][1];
            i--;
            k++;
            }
        else
            {
            a[x][y]=c;
            if (i==sum)
                {
                c++;
                sum+=num[c];
                }
            }
        }
}

int main()
{
    scanf ("%d %d",&n,&m);
    scanf ("%d",&r);
    for (int i=1;i<=r;i++)
        scanf ("%d",&num[i]);
    Init();
    for (int i=1;i<=n;i++)
        {
        for (int j=1;j<=m;j++)
            printf ("%d ",a[i][j]);
        printf ("\n");
        }
}


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 5)
        cout << 0 << endl;
    else if (a >= 13)
        cout << b << endl;
    else
        cout << b / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int x = scanner.nextInt();
		int[] m = new int[n];
		int min = 1000; 
		int count = n;
		for (int i = 0; i < n; i++) {
			m[i] = scanner.nextInt();
			if (m[i] < min) {
				min = m[i];
			}
			
			x -= m[i];
		}
		
		while(x >= 0) {
			x -= min;
			if(x < 0) break;
			count++;
		}
		
		System.out.println(count);
		scanner.close();

	}

}


Measured memory_bytes: 21716
N = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(N-2):
    p1, p2, p3 = P[i:i+3]
    if (p2 >= p1 and p2 <= p3) or (p2 <= p1 and p2 >= p3):
        count += 1
print(count)

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

int main() {
  int n,m;
  cin>>n;
  vector<string> blue;
  vector<string> red;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    blue.push_back(s);
  }
  cin>>m;
  for(int i = 0;i<m;i++){
    string s;
    cin>>s;
    red.push_back(s);
  }
   auto cal =[&](string s){
    int buff=0;
    for(string t:blue){
      if(t==s){
        buff++;
      }
    }
    for(string t:red){
      if(t==s){
        buff--;
      }
    }
    return buff;
  };
  int ans = 0;
  for(string t:blue){
    ans = max(ans,cal(t));
  }
  cout <<ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int m = sc.nextInt();
      int d = sc.nextInt();

      int d1;
      int d10;

      int ans = 0;

    if(d>=22 && m>=4){

      for(int i=4;i<=m;i++){
        for(int j=22;j<=d;j++){
          d1 = j%10;
          d10 = (j-d1)/10;
          if(d1>=2 && d10>=2 && d1*d10==i){
            ans++;
          }
        }
      }

    }

      System.out.println(ans);

    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a[3];
	REP(i, 3) cin >> a[i];
	sort(a, a + 3);
	if (a[0] + a[1] == a[2]) cout <<"Yes" << endl;
	else cout << "No" << endl;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl w(n);
  rep(i,n)cin>>w[i];
  ll sum=0;
  rep(i,n)sum+=w[i];
  sum-=w[0];
  ll count=w[0];
  ll MIN=abs(sum-count);
  for(int i=1;i<n-1;i++){
    sum-=w[i];
    count+=w[i];
    MIN=min(MIN,abs(sum-count));
  }
  cout<<MIN<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
int main(){
  int a,b,c;
  cin >> a>>b>> c;
  int Max = max(a,max(b,c));
  int Min = min(a,min(b,c));
  int Mid = a + b+ c - Max -Min;
  if(Max == Min) cout << 1 << endl;
  else if (Max == Mid || Mid == Min) cout << 2 << endl;
  else cout << 3 << endl;
  
}


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

int main(){
    int H,W;
    while(1){
        scanf("%d %d",&W,&H);
        if(W==0&&H==0) break;
        for (int i=0;i<W;i++){
            for(int j = 0; j < H; j++)
            {
                if((i+j)%2==0) {
                    printf("#");
                }else{
                    printf(".");
                }
            }
            

            printf("\n");
        }
        printf("\n");
    }
}


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

#define range 524289
#define mod 998244353
#define eps 1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <ll> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;


int e[8] = {1,-1,1, -1, 2,2,-2,-2};
int z[8] = {2, 2,-2, -2, 1,-1,1,-1};

int n, k;
vi w;
vi val;
vvi dp;

ll maxsum(int i, int j){
    if(i==n||j<=0) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    if(w[i]<=j){
        return dp[i][j] = max(val[i]+maxsum(i+1, j-w[i]), maxsum(i+1, j));
    }
    return dp[i][j] = maxsum(i+1, j);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--){
        cin>>n>>k;
        w = vi(n);
        val = vi(n);
        dp = vvi(n, vi(k+1, -1));
        for (int i = 0; i < n; ++i)
        {
            /* code */
            cin>>w[i]>>val[i];
        }
        cout<<maxsum(0, k)<<endl;

    }

}



Measured memory_bytes: 79488
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a;
	cin >> n >> a;
	long long dp[51][2501] = {};
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		for (int j = 50; j >= 1; j--) {
			for (int k = 2500 - x; k >= 0; k--) {
				dp[j][k + x] += dp[j - 1][k];
			}
		}
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += dp[i][i * a];
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
using namespace std;
long long a[100100];
int main(){
//	freopen("B.in","r",stdin);
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	long long ans=0;
	long long st=0,sum=0;
	for(int i=1;i<=k;i++)
		st=st+a[i];
	for(int i=k+1;i<=n;i++)
		sum=sum+(a[i]>0?a[i]:0);
	if((st>0?st:0)+sum>ans) ans=(st>0?st:0)+sum;
	for(int i=k+1;i<=n;i++){
		if(a[i]>0) sum=sum-a[i];
		if(a[i-k]>0) sum=sum+a[i-k];
		st=st+a[i]-a[i-k];
		if((st>0?st:0)+sum>ans) ans=(st>0?st:0)+sum;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

    string s;
    cin >> s;
    int n = s.length();
    
    vector<vector<int>> dp(n + 3, vector<int>(3, 0));
    dp[1][0] = dp[2][1] = 1;
    int res = 0;
    rep(i, n) {
        if (i >= 1 && s[i - 1] != s[i]) {
            chmax(dp[i + 1][1], dp[i][1] + 1);
        }
        if (i >= 2 && s[i - 2] != s[i] || s[i - 1] != s[i + 1]) {
            chmax(dp[i + 2][2], dp[i][2] + 1);
        }
        chmax(dp[i + 2][2], dp[i][1] + 1);
        chmax(dp[i + 1][1], dp[i][2] + 1);
    }

    cout <<  max(dp[n][1], dp[n][2]) << endl;

    return 0;
}

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

using namespace std;

int vx[100005], vy[100005], ans[100005];
int main(){
    int n, m, d;
    scanf("%d%d%d", &n, &m, &d);
    for(int i = 0; i < n; i++){
        for(int j = 0, tmp; j < m; j++){
            scanf("%d", &tmp);
            vx[tmp] = i;
            vy[tmp] = j;
        }
    }
    for(int i = d + 1; i <= n * m; i++){
        ans[i] += ans[i - d] + abs(vx[i] - vx[i - d]) + abs(vy[i] - vy[i - d]);
    }
    scanf("%d", &m);
    while(m--){
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", ans[r] - ans[l]);
    }
}

Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a, b;
  cin >> a >> b;

  long diff = b - a;
  cout << diff * (diff + 1) / 2 - b << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define rep(i , a , n) for (int i=a; i<(int)(n); i++)
#define re(i , n)     for (int i=0; i<(int)(n); i++)
#define pb push_back
#define em emplace_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define trace(a) cerr << #a << " = " << a << endl

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
typedef long double ld;

const int mod=7+1e9;
const int inf=1e9+5;
const ll  INF=1e18+5;
const int N=2e5+5;

int main()
{
    IOS;
    int n;
    cin>>n;
    std::vector<int> v(n);
    for(int& i:v)cin>>i;
    ll ans=0;
    re(i,n)
      rep(j,i+1,n)
      {
      	ans+=v[i]*v[j];
      }
     cout<<ans<<endl;

     return 0;   
}

Measured memory_bytes: 256
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

ll gcd(ll x, ll y)
{
    if (y > x)
    {
        ll t = x;
        x = y;
        y = t;
    }

    ll r = x % y;
    if (r == 0)
        return y;
    else
        return gcd(y, r);
}

ll lcm(ll x, ll y)
{
    return x * y / gcd(x, y);
}

ll count_mul(ll min_num, ll max_num, ll div)
{
    if (max_num < div)
        return 0;

    ll min_r = min_num % div;
    ll min_q = min_num / div;

    if (min_r == 0)
        min_q--;

    ll max_q = max_num / div;

    return max_q - min_q;
}

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll mul_c = count_mul(A, B, C);
    ll mul_d = count_mul(A, B, D);
    ll mul_lcm_cd = count_mul(A, B, lcm(C, D));

    ll ans = B - A + 1 - mul_c - mul_d + mul_lcm_cd;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a;
    u[1]=1;
    u[2]=2;
    u[3]=1;
    u[5]=1;
    u[7]=1;
    u[8]=1;
    u[10]=1;
    u[12]=1;

    cin>>n>>m;
   if(u[n]==u[m])
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
}


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

typedef long long ll;

const ll mod = 1e9 + 7;
ll fact[100005];
ll ans;
int main() {
  int n;
  cin >> n;
   ll last = 0;
  vector<ll> l;
  ll k = 1;
  fact[0] = 1;
  for(ll i = 1; i <= n + 1; i++) fact[i] = fact[i-1] * i % mod;

  for(int i = 0; i < n - 1; i++) {
    ll x;
    cin >> x;
    if(x >= 2 * k - 1) k++;
    else {
      // cout << x <<"  "<<2 * k - 1 << endl;
      l.push_back(k);
      last++;
    }
  }
  reverse(l.begin(),l.end());
  ll x;
  cin >> x;

  if(l.size() == 0) cout << fact[n] << endl;
  else {
    ll tmp = l[0] * fact[n-last] % mod;
    //  cout << l[0] <<"  "<<n - last << endl;
    for(ll i = 1; i < l.size(); i++) {
      tmp = l[i] * tmp % mod;
    }
    cout << tmp << endl;
  }
}
  


Measured memory_bytes: 1660
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();

        Dictionary<string, int> dicDay = new Dictionary<string, int>();
        dicDay.Add("A", 0);
        dicDay.Add("B", 1);
        dicDay.Add("C", 2);
        dicDay.Add("D", 3);
        dicDay.Add("E", 4);
        dicDay.Add("F", 5);
        dicDay.Add("G", 6);
        dicDay.Add("H", 7);
        dicDay.Add("I", 8);
        dicDay.Add("J", 9);
        dicDay.Add("K", 10);
        dicDay.Add("L", 11);
        dicDay.Add("M", 12);
        dicDay.Add("N", 13);
        dicDay.Add("O", 14);
        dicDay.Add("P", 15);
        dicDay.Add("Q", 16);
        dicDay.Add("R", 17);
        dicDay.Add("S", 18);
        dicDay.Add("T", 19);
        dicDay.Add("U", 20);
        dicDay.Add("V", 21);
        dicDay.Add("W", 22);
        dicDay.Add("X", 23);
        dicDay.Add("Y", 24);
        dicDay.Add("Z", 25);

        var ret = string.Empty;
        foreach(var c in s)
        {
            var a = (n + dicDay[c.ToString()])%26;
            var b = dicDay.First(p => p.Value == a).Key;
          
            ret = string.Format("{0}{1}",ret,b);
        }

        Console.WriteLine(ret);
    }
}

Measured memory_bytes: 38832
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans=0;
    for(int i=a;i<=b;i++){
    	if(i%c==0)
    	ans++;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <sstream>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, m;
	cin >> n >> m;

	if (n == m)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

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

#include <math.h>
#include <stdlib.h>


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


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    string ans = "";
    for(int i = 0; i < s.length(); i++) ans.append("x");
    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v,a,b) v.begin(a),v.end(b)
#define in cin>>
#define out cout<<
#define endl <<endl
constexpr auto INF = 100000000000000;

int main()
{
	int a;
	in a;
	bool z = false;
	rep(i, (a / 100)+1)
	{
		rep(j, (a / 101)+1)
		{
			rep(k, (a / 102)+1)
			{
				rep(l, (a / 103)+1)
				{
					rep(m, (a / 104)+1)
					{
						rep(n, (a / 105)+1)
						{
							int x = i * 100;
							x += j * 101;
							x += k * 102;
							x += l * 103;
							x += m * 104;
							x += n * 105;
							if (x > a)
							{
								break;
							}
							if (x == a)
							{
								i += 100000;
								j += 100000;
								k += 100000;
								l += 100000;
								m += 100000;
								z = true;
								break;
							}
						}
					}
				}
			}
		}
	}
	if (z)
	{
		out 1 endl;
	}
	else
	{
		out 0 endl;
	}
}


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

int main() {
    int n;
    cin >> n;
    string march = "MARCH";
    long long cnt[5] = {};
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < 5; ++j) {
            if (s[0] == march[j]) {
                ++cnt[j];
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < 5; ++i) {
        for (int j = i + 1; j < 5; ++j) {
            for (int k = j + 1; k < 5; ++k) {
                ans += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int t, x;

	cin>>t>>x;

	cout<<(double)t/(double)x<<endl;
}


Measured memory_bytes: 256
S = input()

def dfs(s):
    if len(s) == len(S) - 1:
        index = 0
        sum_v = 0
        for i, bl in enumerate(s):
            if bl == "1":
                sum_v += int(S[index:i + 1])
                index = i + 1
        sum_v += int(S[index:])
        return sum_v
    else:
        return dfs(s + "0") + dfs(s + "1")

print(dfs(""))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
        string s; cin >> s;
        long long int k; cin >> k;
        if (s[0] != '1') cout << s[0] << endl;
        else{
            int one_cnt = 0;
            for (auto x : s){
                if (x == '1') ++one_cnt;
                else break;
            }
            if (k <= one_cnt) cout << 1 << endl;
            else cout << s[one_cnt] << endl;
        }
    return 0;
}

Measured memory_bytes: 3588
N, M, L = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]
Q = int(input())
X = [list(map(int, input().split())) for _ in range(Q)]

INF = 10 ** 9 + 6
graph = [[INF] * N for _ in range(N)]

for i in range(N):
    graph[i][i] = 0

for u, v, l in edges:
    graph[u - 1][v - 1] = l
    graph[v - 1][u - 1] = l

for k in range(N):
    for i in range(N):
        if graph[i][k] == INF:
            continue
        for j in range(N):
            if graph[k][j] == INF:
                continue
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

cnt = [[INF] * N for _ in range(N)]

for i in range(N):
    cnt[i][i] = 0

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        if graph[i][j] <= L:
            cnt[i][j] = 1
            cnt[j][i] = 1

for k in range(N):
    for i in range(N):
        if cnt[i][k] == INF:
            continue
        for j in range(N):
            if cnt[k][j] == INF:
                continue
            cnt[i][j] = min(cnt[i][j], cnt[i][k] + cnt[k][j])

for s, t in X:
    if cnt[s - 1][t - 1] == INF:
        print(-1)
    else:
        print(cnt[s - 1][t - 1] - 1)


Measured memory_bytes: 84056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();

		String nstr=String.valueOf(n);
		int fx=0;
		for(int i=0;i<nstr.length();i++) {
			fx+=Character.getNumericValue(nstr.charAt(i));
		}
		System.out.println((n%fx==0)? "Yes":"No");
	}

}

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

int main() {
	
	long long	x;
	long long l;
	long long t;
	
	cin >> x;
	
	l = x;
	
	if ( x == 1 ) {
		cout << 1 << endl;
		return 0;
	}
	
	for ( t = 1; t < 1000000000; t++ ) {
		
		l -= t;
		
		if ( l - t - 1 <= 0 ) {
			break;
		}
	}
	
	t++;
	
	cout << t << endl;
	
	
	
	return 0;
}

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

int main(){
  int n,t;
  int d[100000];
  cin.tie(0); std::ios::sync_with_stdio(false);
  cin >> n >> t;
  for(int i=0;i<n;i++)cin >> d[i];

  sort(d,d+n);
  long long ans = 1, m = 1000000007;
  for(int i=0;i<n;i++){
    int prv = lower_bound(d,d+n,d[i]-t) - d;
    ans *= i-prv+1; ans %= m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);

		int a[] = new int[2];

		for (int i = 0; i < a.length; i++)
			a[i] = input.nextInt();

		if (!(a[1] >= 2 * a[0] && a[1] <= 4 * a[0] && a[1]%2==0)) {
			System.out.println("No");
			return;
		}
		int crane = ((4 * a[0]) - a[1]) / 2;
		int turtle = (a[1] - (2 * a[0])) / 2;
		if (crane + turtle == a[0])
			System.out.println("Yes");
	}

}


Measured memory_bytes: 35784
n=int(input())
lst=list(map(int,input().split()))
dist=[[] for _ in range(n)]
for i in range(n):
    dist[lst[i]].append(i)
if len(dist[0])!=1:
    print(0)
    exit()
if not 0 in dist[0]:
    print(0)
    exit()

switch=0
for i in range(-1,-n-1,-1):
    if switch==0:
        if len(dist[i])>=1:
            switch=1
    if switch==1:
        if len(dist[i])==0:
            print(0)
            exit()
ans=1
rem=1
for i in range(n):
    num=len(dist[i])
    ans*=pow(rem,num,998244353)
    ans%=998244353
    rem=num
print(ans)

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

#define um unordered_map
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sc static_cast

#define has(a, b) (a.find(b) != a.end())
#define all(x) (x).begin(), (x).end()
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a,b) a = min(a,b)
#define imax(a,b) a = max(a,b)
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, l, r) for(int i = l; i <= r; i++)
#define fore(i, n) for(int i = n-1; i >= 0; --i)
#define pvec(v) copy(all(v), ostream_iterator<decltype(v)::value_type>(cout, " "))

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vii;
typedef vector<vll> vlll;
typedef um<int,int> umii;

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

void display (const vector<vector<int> >& vy) {  
    fora(i, (int) vy.size()) {
        fora(j, (int) vy[i].size()) cout << vy[i][j] << " ";
        cout << endl;
    }
}

ll power(ll a, ll n) {
     if (n == 0) return 1;
     ll x = power(a, floor(n/2));
     if (n & 1) return a*x*x;
     else return x*x;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);   
    
    int a; cin >> a;

    cout << 3*a*a << "\n";
    return 0;
}



Measured memory_bytes: 256
def counting_roads(N: int, M: int, roads: list)->list:
    d = {i: 0 for i in range(N)}
    for u, v in roads:
        d[u-1] += 1
        d[v-1] += 1

    return d.values()


if __name__ == "__main__":
    M = 0
    N, M = map(int, input().split())
    roads = [tuple(map(int, input().split())) for _ in range(M)]
    ans = counting_roads(N, M, roads)
    print('\n'.join(map(str, ans)))


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(N);
    }
}

class Solver {
    public void solve(long N) {
        long min = Long.MAX_VALUE;
        for (long i = 1; i * i <= N; i++) {
            if (N % i == 0) {
                min = Math.min(min, (i - 1) + (N / i - 1));
            }
        }
        System.out.println(min);
    }
}



Measured memory_bytes: 24916
#include<stdio.h>
    int vec[100001][100];
    int cnt[100001];
    int reached[100001];
     
    void search(int s,int d[]){
        int i,j;
        reached[s]=1;
     
        for(i=0;i<cnt[s];i++){
    	if(reached[vec[s][i]]==0){
    	    d[vec[s][i]]=d[s]+1;
    	    search(vec[s][i],d);
    	}
        }
    }
        
    int main(void){
        int n,a,b;
        int i,j;
        int d1[100001],dn[100001];
        int c1,c2;
     
        scanf("%d",&n);
        for(i=0;i<n-1;i++){
    	scanf("%d%d",&a,&b);
    	vec[a][cnt[a]++]=b;
    	vec[b][cnt[b]++]=a;
        }
     
        d1[1]=0;
        search(1,d1);
     
        for(i=1;i<=n;i++) reached[i]=0;
     
        dn[n]=0;   
        search(n,dn);
     
        c1=c2=0;
        for(i=1;i<=n;i++){
    	if(d1[i]<=dn[i]) c1++;
    	else c2++;
        }
     
        if(c1==c2) printf("Snuke\n");
        else if(c1>c2) printf("Fennec\n");
        else printf("Snuke\n");
     
     
        return 0;
    }

Measured memory_bytes: 45440
//#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <queue>
#include <stack>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define umap unordered_map
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

void solve() {
  string a, b;
  cin >> a >> b;
  string g = "GREATER", l = "LESS", eq = "EQUAL";
  if (a.size() > b.size()) {
    cout << g << endl;
    return;
  } else if (a.size() < b.size()) {
    cout << l << endl;
    return;
  }
  for (size_t i = 0; i < a.size(); ++i) {
    if (a[i] > b[i]) {
      cout << g << endl;
      return;
    } else if (a[i] < b[i]) {
      cout << l << endl;
      return;
    }
  }
  cout << eq << endl;
  return;
}

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



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   ll x, y;
   cin >> x >> y;
   ll z = abs(x - y);
   if (z == 0 || z == 1) {
      puts("Brown");
   } else {
      puts("Alice");
   }

   return 0;
}

Measured memory_bytes: 256
#n,k=gets.split(' ').map(&:to_i)
#h=gets.split(' ').map(&:to_i)
#tajigen = Array.new(4) { Array.new(2,0) }
n=gets.to_i
a=gets.split(' ').map(&:to_i)
s=0
a.each do |i|
  s = s ^ i
end
#puts s
ans=Array.new(n-1)
for i in 0..n-1
  ans[i]=s^a[i]
end
puts ans


Measured memory_bytes: 35116