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

using namespace std;

const int G[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

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

    if (G[x] == G[y]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
using System;

class MainClass
{
	public static void Main (string[] args)
	{
		int a, b, S, Q;

		string[] str = Console.ReadLine ().Split (' ');
		a = int.Parse(str [0]);
		b = int.Parse(str [1]);
		S = a * b;
		Q = (a + b) * 2;
		Console.WriteLine ("{0} {1}", S, Q);
	}
}

Measured memory_bytes: 5628
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int ans = 0;
		int max = Integer.parseInt(sc.next());
		int min = max;
		boolean up = true;
		boolean down = true;
		for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			if (up) {
				if (a >= max)
					max = a;
				else
					up = false;
			}
			if (down) {
				if (a <= min)
					min = a;
				else
					down = false;
			}
			if (!up && !down) {
				ans++;
				max = a;
				min = a;
				up = true;
				down = true;
			}
		}
		ans++;
		System.out.println(ans);
	}
}

Measured memory_bytes: 42936
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
#print(a,b)

ans=0

if n==1:
  ans=sum(a)+sum(b)

else:
  for i in range(1,n):
    x=sum(a[:i])+sum(b[i-1:])
    if ans < x:
      ans=x
#print(a[:n],b[n-1:])

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <complex>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
#define X real()
#define Y imag()

typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> Pol;

const D INF = 1e40;
const D EPS = 1e-5;
const D PI = acos(-1);

int sign(D r){ return (r < -EPS) ? -1 : (r > EPS) ? 1 : 0; }
bool eq(D a, D b){ return abs(b - a) < EPS; }
bool near(P a, P b){ return abs(b - a) < EPS; }

D dot(P a, P b){ return a.X * b.X + a.Y * b.Y; }
D cross(P a, P b){ return a.X * b.Y - a.Y * b.X; }
P vec(L a){ return a.second - a.first; }

P pLL(L a, L b){ return a.first + vec(a) * (cross(vec(b), b.first - a.first) / cross(vec(b), vec(a))); }
int main(){
  int N;
  while(cin>>N && N){
    vector<L> l;
    REP(i, N){
      double a, b, c, d;
      cin>>a>>b>>c>>d;
      l.push_back(L(P(a, b), P(c, d)));
    }
    int ans = 1;
    for(int i = 0; i < N; i++){
      int cnt = 1;
      vector<P> crs;
      for(int j = 0; j < i; j++){
        if(!sign(cross(vec(l[i]), vec(l[j])))) continue;
        P p = pLL(l[i], l[j]);
        if(!(abs(p.X) < 100 - EPS && abs(p.Y) < 100 - EPS)) continue;
        bool ok = true;
        for(int k = 0; k < crs.size(); k++){
          if(eq(crs[k].X, p.X) && eq(crs[k].Y, p.Y)){
            ok = false;
            break;
          }
        }
        if(ok){
          crs.push_back(p);
          cnt++;
        }
      }
      ans += cnt;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; 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 ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int n,a,b; cin >> n >> a >> b;
    string s; cin >> s;
    int ab = a+b;
    bool ans;
    REP(i,n) {
        if(s[i]=='a') {
            ans = (ab>0);
            if(ab>0) {
                ab --;
            }
        }
        else if(s[i]=='b') {
            ans = (ab>0 && b>0);
            if(ab>0 && b>0) {
                ab --;
                b--;
            }
        }
        else ans = false;
        cout << (ans ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
typedef unsigned long long ll;

ll gcd(ll a, ll b){
	if(a==0) return b;
  	else return gcd(b%a, a);
}

ll lcm(ll a, ll b) { return a*b/gcd(a,b);}

ll find(ll a, ll b, ll c){
	return c-c/a-c/b+c/lcm(a,b);
}
int main(){
	ll A,B,C,D; cin>>A>>B>>C>>D;
  	cout<< find(C, D, B)- find(C, D, A-1)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, dp[222222];
int cnt;
string s;
signed main() {
	cin >> n >> s;
	dp[0] = 1;
	int memo = 0;
	rep(i, 2 * n) {
		if (s[i] == 'B') {
			if (cnt % 2 == 0) {
				cnt++; dp[i + 1] = dp[i]; memo++;
			}
			else {
				dp[i + 1] = dp[i] * cnt % mod;
				cnt--;
			}
		}
		else {
			if (cnt % 2 == 0) {
				if (cnt == 0) {
					cout << 0 << endl; return 0;
				}
				dp[i + 1] = dp[i] * cnt % mod;
				cnt--;
			}
			else {
				cnt++; dp[i + 1] = dp[i]; memo++;
			}
		}
	}
	if (cnt) {
		cout << 0 << endl; return 0;
	}
	for (int i = 1; i <= memo; i++) {
		dp[2 * n] *= i;
		dp[2 * n] %= mod;
	}
	cout << dp[2 * n] << endl;
}

Measured memory_bytes: 2180
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	int A, B;
	cin >> A >> B;
	int ans;
	if ((B - A) % 2 == 0) {
		ans = (B - A) / 2;
	} else {
		ans = min(A + (B - A - 1) / 2, N - B + 1 + (N - (A + (N - B + 1))) / 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll k=(b/c-(a-1)/c);
	    ll l=(b/d-(a-1)/d);
	    ll m=lcm(c,d);
	    ll n=(b/m-(a-1)/m);
	    ll o=k+l-n;
      cout<<b-a-o+1;
    } 
    return 0;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, W;
string s;

int main() {
    cin >> n >> W;

    VVi dp(n+1, Vi(W+1, 0));
    REP2(i, 1, n+1) {
        int v, w; cin >> v >> w;
        REP(j, W+1) {
            dp[i][j] = dp[i-1][j];
            if (j >= w) {
                dp[i][j] = max({dp[i][j], dp[i-1][j-w] + v, dp[i][j-w] + v});
            }
        }
    }
    std::cout << dp[n][W] << '\n';

    return 0;
}



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

int main()
{
    int a , b , c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i = a ; i <=b;i++)
    {
        if(c % i == 0)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		
		int dx = x2 - x1;
		int dy = y2 - y1;
		
		int x3 = x2 - dy;
		int y3 = y2 + dx;
		
		dx = x3 - x2;
		dy = y3 - y2;
		
		int x4 = x3 - dy;
		int y4 = y3 + dx;
		
		System.out.printf("%d %d %d %d\n", x3, y3, x4, y4);
		
		sc.close();
	}
}




Measured memory_bytes: 27016
N = int(input())

Name = []
Initial = {}
for n in range(N):
    name = input()
    Name.append(name)
    if name[0] in Initial:
        Initial[name[0]] += 1
    else:
        Initial[name[0]] = 1

ans = 0

# 5C3=5*4*3/3*2*1=10
ans += Initial.get("M", 0) * Initial.get("A", 0) * Initial.get("R", 0)
ans += Initial.get("M", 0) * Initial.get("A", 0) * Initial.get("C", 0)
ans += Initial.get("M", 0) * Initial.get("A", 0) * Initial.get("H", 0)
ans += Initial.get("M", 0) * Initial.get("R", 0) * Initial.get("C", 0)
ans += Initial.get("M", 0) * Initial.get("R", 0) * Initial.get("H", 0)
ans += Initial.get("M", 0) * Initial.get("C", 0) * Initial.get("H", 0)
ans += Initial.get("A", 0) * Initial.get("R", 0) * Initial.get("C", 0)
ans += Initial.get("A", 0) * Initial.get("R", 0) * Initial.get("H", 0)
ans += Initial.get("A", 0) * Initial.get("C", 0) * Initial.get("H", 0)
ans += Initial.get("R", 0) * Initial.get("C", 0) * Initial.get("H", 0)

print(ans)


Measured memory_bytes: 9776
#include<stdio.h>
int main(void)
{
	int n,i;
	double a,sum;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf",&a);
		sum+=1/a;
	}
	printf("%lf\n",1/sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int Q;

    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int c, a, n;
        int ans = 0;

        cin >> c >> a >> n;
        int tmp = min(min(a, c), n);
        ans += tmp;
        c -= tmp;
        a -= tmp;

        tmp = min(c / 2, a);
        ans += tmp;
        c -= 2 * tmp;
        ans += c / 3;

        cout << ans << endl;
    }

    return 0;
}

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

int sumofeach(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}

int main(){
  int n;
  cin>>n;
  int ans;
  
  ans=sumofeach(n);
  
  if(n%ans==0){
     cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}
  
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvll            vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define wh(x)           int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
#define deb(x)          cout <<#x << " is "<<x<<endl;
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}
int x,y;
bool help(){
	if(y<2*x) return false;
	if((y-2*x)%2!=0) return false;
	int b=(y-2*x)/2;
	int a=x-b;
	if(a<0) return false;
	return true;
}
int main(){
	fio
  i_o();
  cin>>x>>y;
  if(help()) d1("Yes");
  else d1("No");

  return 0;

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define mod 1000000007
#define lol 200005
#define debug(x) cout<<#x<<" is "<<x<<endl;
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=b;i>=a;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vp vector<pair<double,double>>
#define vpp vector<pair<int, pair<int,int>>>
#define pp pair<int,int>

long long int knapsack(vector<pair<int,int>> &v,int n, int w)
{
	long long int dp[n+1][w+1];

    ffor(i,0,w+1) dp[0][i]=0;
    ffor(i,0,n+1) dp[i][0]=0;

    // ffor(i,0,n)
    //  cout<<v[i].ff<<" "<<v[i].ss<<endl;

    ffor(i,1,n+1)
    {
    	ffor(j,1,w+1)
    	{
    		if(j>=v[i-1].ff)
    		 dp[i][j] = max(dp[i-1][j-v[i-1].ff] + v[i-1].ss, dp[i-1][j]);
    		else 
    		 dp[i][j] = dp[i-1][j];
    	}
    }

    return dp[n][w];
}

int main()
{
  int n,w;
  cin>>n>>w;
  vector<pair<int,int>> v;
  ffor(i,0,n)
  {
  	 int a,b;
  	 cin>>a>>b;
     v.pb(mp(a,b));
  }
  cout<<knapsack(v,n,w);
}

Measured memory_bytes: 82500
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  double l;
  cin >> l;
  double m = l/3;
  printf("%.10f\n", m*m*m);
  return 0;
}

Measured memory_bytes: 256
import math
from heapq import heapify, heappush, heappop

n, m = map(int, input().split(' '))

# invert sign of p to get max value
prices = [ -p for p in map(int, input().split(' ')) ]
heapify(prices)

for _ in range(m):
    p = heappop(prices)
    heappush(prices, p / 2)

total = 0
while prices:
    total += math.floor(-heappop(prices))
print(total)

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
using ll = long long;
int main() {
  
   int A,B,C;
  cin >> A >> B >> C;
  
  cout << C  <<" "<< A << " "<< B << endl;
  
    return 0;
}

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

int main(){
	string number;
	int sum;
	
	while(1){
		cin>>number;
		if(number=="0"){
			break;
		}
		sum=0;
		for(int i=0;i<number.size();i++){
			sum+=number[i]-'0';
		}
		cout<<sum<<endl;
 	}
  	return 0;
}

Measured memory_bytes: 3172
from bisect import bisect_left, bisect_right

INF = int(1E18)
A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]
S.insert(0, -INF)
T.insert(0, -INF)
S.append(INF)
T.append(INF)

for x in X:
    i = bisect_left(S, x)
    j = bisect_left(T, x)
    s1, s2 = S[i-1], S[i]
    t1, t2 = T[j-1], T[j]
    s1 = abs(s1-x)
    s2 = abs(s2-x)
    t1 = abs(t1-x)
    t2 = abs(t2-x)
    l1 = max(s1, t1)
    l2 = min(s1, t1)
    r1 = max(s2, t2)
    r2 = min(s2, t2)
    E = [l1, r1]
    if (s1-t1)*(s2-t2) < 0:
        E.extend([2*l2+r2, 2*r2+l2])
    print(min(E))

Measured memory_bytes: 16168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int X,N,pi;
 cin >> X >> N;
 set<int> S;
 for(int i = 0;i < N;i++){
  cin >> pi;
  S.insert(pi);
 }
 
 for(int i = 0; i < 100;i++){
  if(!S.count(X-i)){
   cout << X - i << endl;
   break;
  }
  if(!S.count(X+i)){
   cout << X + i << endl;
   break;
  }
 }
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

struct mint {
    ll x;
    mint(ll x=0) : x(x%mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x -= a.x) < 0) x += mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) {
        mint res(*this);
        return res*=a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n; std::cin >> n;
    map<int, int> cnt;
    rrep(x, n) {
        int tmp = x;
        for (int i = 2; i*i <= tmp; i++) {
            while (tmp % i == 0) tmp /= i, cnt[i]++;
        }
        if (tmp != 1) cnt[tmp]++;
    }


    mint ans = 1;
    for (auto &p : cnt) {
        ans *= p.se+1;
    }
    std::cout << ans.x << "\n";
}


Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n;
    cin>>n;
    long long ans=0;
    if(n%2==0){
        long long x=5;
        n/=2;
        while(n>=x){
            ans+=n/x;
            x*=5;
        }
    }
    cout<<ans;
    return 0;
}


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

int main(){

  long long i,j;
  long long min = 10000000;
  long long l,r;

  scanf("%lld %lld", &l, &r);

  for(i = l;i <= r;i++){
    for(j = l;j < i;j++){
      if(min > (i*j) % 2019) min = (i*j) % 2019;

      if(min == 0){
        printf("0\n");
        return 0;
      }
    }
  }

  printf("%lld\n", min);
  return 0;
}


Measured memory_bytes: 128
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
ll dp[401][401];
int n;
vector<ll> a, sum;

ll sum_(int i, int j){
  if(i > 0)return sum[j-1] - sum[i-1];
  else return sum[j-1];
}

ll calc(int i, int j){
  if(j == i + 1)return 0;
  if(dp[i][j] >= 0)return dp[i][j];
  ll res = linf;
  FOR(k, i+1, j){
    res = min(res, calc(i, k) + calc(k, j) + sum_(i, j));
  }
  return dp[i][j] = res;
}

int main(int argc, char const* argv[])
{
  cin >> n;
  a = vector<ll>(n, 0);
  sum = vector<ll> (n, 0);
  rep(i, n){
    cin >> a[i];
    sum[i] = a[i];
    if(i > 0)sum[i] += sum[i-1];
  }
  rep(i, n+1){
    rep(j, n+1){
      dp[i][j] = -1;
    }
  }
  cout << calc(0, n) << endl;
	return 0;
}


Measured memory_bytes: 1536
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

n,a,b,c = map(int, input().split())
l = [int(input()) for _ in range(n)]

ans = float("inf")
for i in range(4**n):
    cnt = Base_10_to_n(i,4)
    cnt = cnt.rjust(n,"0")

    num_a = cnt.count("1")
    num_b = cnt.count("2")
    num_c = cnt.count("3")

    if num_a >= 1 and num_b >= 1 and num_c >= 1:
        bb_a = [l[j] for j in range(n) if cnt[j] == "1"]
        bb_b = [l[j] for j in range(n) if cnt[j] == "2"]
        bb_c = [l[j] for j in range(n) if cnt[j] == "3"]

        temp = 10 * (len(bb_a) + len(bb_b) + len(bb_c) -3) + abs(a-sum(bb_a)) + abs(b-sum(bb_b)) + abs(c-sum(bb_c))

        ans = min([ans, temp])

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,m;
long long s;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){cin>>m;s+=m;}
	cout<<s/n<<endl;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

int main(void){
    ll k;
    cin>>k;
    ll ans = 0;
    for(ll i=1;i<=k;i++){
        for(ll j=1;j<=k;j++){
            for(ll l=1;l<=k;l++){
                ll t = gcd(i,j);
                t=gcd(t,l);
                ans+=t;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n)-1; i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int calc(int n, int d){
  int pos = 0, res = 0;;
  for(;pos<n;pos+=2*d+1){ res++; }
  return res;
}

int main(){
  int n, d;  cin >> n >> d;
  cout << calc(n, d)  << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define abs(x) ((x)<0 ? -(x) : (x))
#define min(x, y) ((x)>(y) ? (y) : (x))

int main(){
  int n;  scanf("%d", &n);
  long a[200005] = {0};
  for(int i=1; i<=n; i++){
    long t;  scanf("%ld", &t);
    a[i] = a[i-1] + t;
  }

  long ans = ((long)1)<<62;
  for(int i=2; i<=n; i++){
    long sa = abs(a[n]-a[i-1]-a[i-1]);
    ans = min(ans, sa);
  }

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

  return 0;
}


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


int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		int n;
		cin>>n;
		int a[n][3];
		for(int i=0;i<n;i++)
		{
			cin>>a[i][0]>>a[i][1]>>a[i][2];
		}
		int dp[n][3];
		memset(dp,0,sizeof(dp));
		dp[0][0]=a[0][0],dp[0][1]=a[0][1],dp[0][2]=a[0][2];
		for(int i=1;i<n;i++)
		{
			dp[i][0]+=max({dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]});
			dp[i][1]+=max({dp[i-1][2]+a[i][1],dp[i-1][0]+a[i][1]});
			dp[i][2]+=max({dp[i-1][0]+a[i][2],dp[i-1][1]+a[i][2]});
		}
		cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
	}
		
}


Measured memory_bytes: 5868
#include <stdio.h>
#define MAX_LENGTH 2000002
#define MAX_NUM 10001
int Aoriginal[MAX_LENGTH]={0};
int Binsert[MAX_LENGTH]={0};
int Ccount[MAX_NUM]={0};
void CountingSort(int A[MAX_LENGTH], int B[MAX_LENGTH], int C[MAX_NUM], int n)
{
    for(int i=1;i<n+1;i++){Ccount[Aoriginal[i]]+=1;}
    for(int j=1;j<MAX_NUM+1;j++){Ccount[j]+=Ccount[j-1];}
    for(int i=n;i>0;i--)
    {
        Binsert[Ccount[Aoriginal[i]]]=Aoriginal[i];
        Ccount[Aoriginal[i]]-=1;
    }
}
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=1;i<n+1;i++){scanf("%d ", &Aoriginal[i]);}
    CountingSort(Aoriginal, Binsert, Ccount, n);
    for(int i=1;i<n+1;i++)
    {
        if(i!=n){printf("%d ", Binsert[i]);}
        else{printf("%d\n", Binsert[i]);}
    }
    return 0;
}



Measured memory_bytes: 17384
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn=200050;
struct node{
	int tot1,tot2;
	node(int tot1=0,int tot2=0):tot1(tot1),tot2(tot2){}
};
bool operator < (node nd1,node nd2){
	return nd1.tot1<nd2.tot1||(nd1.tot1==nd2.tot1&&nd1.tot2<nd2.tot2);
}
node nd[maxn];
int c[maxn];
int n;

int lowbit(int x){
	return x&-x;
}
void update(int k,int val){
	while(k<maxn){
		c[k]+=val;k+=lowbit(k);
	}
}
int query(int k){
	int sum=0;
	while(k){
		sum+=c[k];k-=lowbit(k);
	}
	return sum;
}
void solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		double x;
		scanf("%lf",&x);
		ll tmp=(ll)round(x*1000000000.0);
		while(tmp%2==0){
			tmp/=2;nd[i].tot1++;
		}
		while(tmp%5==0){
			tmp/=5;nd[i].tot2++;
		}
	}
	sort(nd+1,nd+n+1);
	int r=n;
	ll res=0;
	for(int i=1;i<=n;i++){
		while(r>i&&nd[r].tot1+nd[i].tot1>=18)	update(nd[r--].tot2+1,1);
		while(r<i)	update(nd[++r].tot2+1,-1);
		res+=query(maxn-1)-query(max(18-nd[i].tot2,0));
	}
	printf("%lld\n",res);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 3824
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((ll)2e5+5)
#define MOD ((ll)1e9 + 7)
#define INF ((ll)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<ll,ll>
#define mid ((l+r)/2)

ll n,m;
ll sum,a;

priority_queue <ll> q;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> m;
	for (ll i = 0; i < n; ++i)
	{
		cin >> a;
		q.push(a);
	}

	while(m--)
	{
		auto tmp = q.top();
		q.pop();
		q.push(tmp/2);
	}

	while(!q.empty())
	{
		sum += q.top();
		q.pop();
	}

	cout << fixed << sum << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using  namespace std;
int main(){
    long long n, a, ans=0;
    cin >> n;
    map<long long, long long> A;
    for(int i=0;i<n;i++){
        cin >> a;
        A[a]++;
    }
    for(auto itr = A.begin();itr!=A.end();itr++){
        if(itr->second%2==1){
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int n,m,X,Y,x,y;
	cin>>n>>m>>X>>Y;
	rep(i,n){
		cin>>x;X=max(x,X);
	}
	rep(i,m){
		cin>>y;Y=min(y,Y);
	}
	if(X<Y) cout<<"No War"<<endl;else cout<<"War"<<endl;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 1; i < n; ++i) {
    cin >> b[i];
  }
  int ret = b[1] + b[n - 1];
  for (int i = 1; i < n - 1; ++i) {
    ret += min(b[i], b[i + 1]);
  }
  cout << ret << endl;
  return 0;
}


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


int main() {
  int N, M;
  cin >> N >> M;
  int A[N];
  float total = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    total += A[i];
  }
  int cnt = 0;
  for(int j = 0; j < N; j++) {
    if(A[j] >= total/(4*M)) {
      cnt++;
    }
  }
  if(cnt >= M) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n,wt;
    cin>>n>>wt;
     vector<int>w(n,0),v(n,0);
     int sum=0;
     for(int i=0;i<n;i++){
          cin>>w[i];
          cin>>v[i];
          sum+=v[i];
     }
     vector<ll>dp(sum+1,INT_MAX/2);
     // for(int i=0;i<n;i++){
     //      dp[v[i]]=w[i];
     // }
     dp[0]=0;
     for(int i=0;i<n;i++){
          for(int j=sum-v[i];j>=0;j--){
          // for(int j=0;j<=sum-v[i];j++){
               dp[j+v[i]]=min(dp[j+v[i]],dp[j]+(ll)w[i]);
               // if(dp[j+v[i]]<=100)
               // cout<<i<<" "<<j+v[i]<<" "<<dp[j+v[i]]<<endl;
          }
     }
     // cout<<"hi"<<endl;
     int ans=INT_MIN;
     for(int i=0;i<=sum;i++){
          if(dp[i]<=wt){
               ans=max(ans,i);
          }
     }
     cout<<ans<<endl;
}

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

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

using namespace std;

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

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

int dig(int n);

int main() {
	int n;
	cin >> n;

	int sum = 0;
	int minv = INF;
	int a, b;
	for(int i=1;i<n;i++){
		a = i;
		b = n - i;
		//cout << i << " " << a << " " << b << endl;

		a = dig(a);
		b = dig(b);

		if (min(minv, (a + b)) == (a + b)) {
			minv = a + b;
		}
	}
	cout << minv << endl;
}

int dig(int n) {
	int sum = 0;
	if (n < 10) {
		return n;
	} else {
		while (1) {
			sum += n % 10;
			if (n < 10)break;
			n /= 10;
		};
		return sum;
	}

}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define debug(var) cout << #var << ": " << var << endl;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
using ll = long long;
using ull = unsigned long long;
using vvint = vector<vector<int>>;
constexpr ll mod = 1e9 + 7;

int main() {

  string S, T;
  cin >> S >> T;
  int ans = 0;
  rep(i, 3)if (S[i] == T[i])ans++;
  cout << ans;

  return 0;
}

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  vector<int> x(110000),y(110000),t(110000);
  t.at(0)=x.at(0)=y.at(0)=0;

  cin>>N;
  for(int i=0;i<N;i++) cin>>t.at(i+1)>>x.at(i+1)>>y.at(i+1);

  bool can =true;
  for(int i=0;i<N;i++){
    int dt   = t.at(i+1)-t.at(i);
    int dist = abs(x.at(i+1)-x.at(i))+abs(y.at(i+1)-y.at(i));
    if (dist>dt) can = false;
    if (dist%2 != dt%2) can = false;
    }
  if (can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}




Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

double memo[310][310][310];
int n;

double  dp(int i,int j,int k){
    if (memo[i][j][k]!=0.0) return memo[i][j][k];
    if (i==0 && j==0 && k==0) return 0.0;
    
    double res=0.0;
    if (i>0) res+=dp(i-1,j,k)*i;
    if (j>0) res+=dp(i+1,j-1,k)*j;
    if (k>0) res+=dp(i,j+1,k-1)*k;
    res+=n;
    res/=(i+j+k);
    
    return memo[i][j][k]=res;
}


int main(){
    int one=0,two=0,three=0;
    cin>>n;
    rep(i,n){
        int a;cin>>a;
        if (a==1) one++;
        else if (a==2) two++;
        else if (a==3) three++;
    }
    
    
    printf("%.10f",dp(one,two,three));
    
    return 0;
    
    
    
   
}

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

main() {
  vector<int> v;
  for(int tc = 0; tc < 10; ++tc) {
    int h;
    cin >> h;
    v.push_back(h);
  }
  sort(v.begin(), v.end(), greater<int>());
  for(int i = 0; i < 3; ++i) cout << v[i] << endl;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
    static final int MOD = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] counts = new long[k + 1];
        long total = 0;
        for (int i = k; i >= 1; i--) {
            long value = pow(k / i, n);
            for (int j = 2; j * i <= k; j++) {
                value -= counts[j * i];
                value += MOD;
                value %= MOD;
            }
            counts[i] = value;
            total += value * i;
            total %= MOD;
        }
        System.out.println(total);
    }
    
    static long pow(long base, int p) {
        if (p == 0) {
            return 1;
        }
        long ans = pow(base, p / 2);
        ans *= ans;
        ans %= MOD;
        if (p % 2 == 1) {
            ans *= base;
            ans %= MOD;
        }
        return ans;
    }
}

Measured memory_bytes: 36528
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e16;
const double EPS=1e-8;
const ll mod = 1000000007;

int main(){
	ll n;
	cin>>n;
	vector<ll> a;
	for(ll i1=0;i1<n;i1++){
		ll temp;
		cin>>temp;
		a.push_back(temp);
	}
	ll d_count=0;
	for(ll i1=0;i1<n;i1++){
		if(a[i1]!=i1+1){
			d_count++;
		}
	}
	if(d_count == 0 || d_count==2){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
#include<set>
#include<queue>
#include<utility>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<numeric>
#include<functional>
#include<string>
#include<iostream>
using namespace std;
const long long int one = 1;
const long long int big = (one<<20);
typedef long long int llint;

//	. 0x2e	X 0x58	S 0x53	1~ 0x31~
int main(void){
	int H,W,N,h,i,j,x,y,t,ans=0;
	queue<tuple<int,int,int>> que;
	static char Chezu[1002][1002];//??°?????¨???????????????????????????
	static int time[1002][1002];
	int Cx[10];
	int Cy[10];
	scanf("%d %d %d",&H,&W,&N);
	for(j=0;j<=W+1;j++){Chezu[0][j]=0x58;}
	for(i=1;i<=H;i++){Chezu[i][0]=0x58;scanf(" %s",Chezu[i]+1);Chezu[i][W+1]=0x58;}
	for(j=0;j<=W+1;j++){Chezu[H+1][j]=0x58;}

	for(i=1;i<=H;i++){
		for(j=1;j<=W;j++){
			if(Chezu[i][j]==0x53){
				Cx[0]=i;Cy[0]=j;
			}
			if(0x31<=Chezu[i][j]&&Chezu[i][j]<=0x39){
				Cx[Chezu[i][j]-0x30]=i;
				Cy[Chezu[i][j]-0x30]=j;
			}
		}
	}
	for(h=0;h<N;h++){
		while(!que.empty()){que.pop();}
		for(i=0;i<H+2;i++){
			for(j=0;j<W+2;j++){
				time[i][j]=big;
			}
		}
		que.push(make_tuple(Cx[h],Cy[h],0));
		while(!que.empty()){
			x=get<0>(que.front());
			y=get<1>(que.front());
			t=get<2>(que.front());
			que.pop();
			if(x==Cx[h+1]&&y==Cy[h+1]){break;}
			if(time[x][y]<=t){ continue; }
			time[x][y]=t;
			if(Chezu[x+1][y]!=0x58){ que.push(make_tuple(x+1,y,t+1)); }
			if(Chezu[x-1][y]!=0x58){ que.push(make_tuple(x-1,y,t+1)); }
			if(Chezu[x][y+1]!=0x58){ que.push(make_tuple(x,y+1,t+1)); }
			if(Chezu[x][y-1]!=0x58){ que.push(make_tuple(x,y-1,t+1)); }
		}
		ans+=t;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll x,ans=0;
    cin>>x;
    while(x>=5){
        if(x>=500){
            x-=500;
            ans+=1000;
        }else{
            x-=5;
            ans+=5;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#pragma warning( disable : 6031)

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
//const long long mod = 1000000007;
const long long mod = 998244353;
using std::vector;
using std::pair;
using std::string;
using std::map;
vector<long long> getDiv(long long N) {
	map<long long, int> p;
	for (long long i = 2; i * i <= N;) {
		if (N % i == 0) {
			p[i]++;
			N /= i;
		}
		else {
			i++;
		}
	}
	p[N]++;
	long long i = 1;
	vector<long long> div;
	div.push_back(1);
	while (p.upper_bound(i) != p.end()) {
		i = p.upper_bound(i)->first;
		int n = p[i];
		int size = div.size();
		long long a = i;
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < size; k++) {
				div.push_back(div[k] * a);
			}
			a *= i;
		}
	}
	std::sort(div.begin(), div.end());
	return div;
}
int main() {
	long long N;
	scanf("%lld", &N);
	vector<long long> div = getDiv(N);
	vector<long long> div2 = getDiv(N - 1);
	int res = div2.size() - 1;
	for (int i = 1; i < div.size(); i++) {
		long long n = N;
		long long p = div[i];
		while (n % p == 0)n /= p;
		if (n % p == 1)res++;
	}
	printf("%d", res);
	return 0;
}

Measured memory_bytes: 384
class BIT_index:
    def __init__(self, n):
        self.BIT_prev = [n] * (n + 1)
        self.BIT_next = [n] * (n + 1)
        self.n = n

    def __addElement(self, BIT, idx):
        value = idx
        idx += 1
        while idx > 0:
            BIT[idx] = min(BIT[idx], value)
            idx -= idx & -idx

    def addElement(self, idx):
        self.__addElement(self.BIT_prev, self.n - 1 - idx)
        self.__addElement(self.BIT_next, idx)

    def __getIndex(self, BIT, idx):
        idx += 1
        ans = self.n
        while idx <= self.n:
            ans = min(ans, BIT[idx])
            idx += idx & -idx
        return ans

    def getIndexPrev(self, idx):
        return self.__getIndex(self.BIT_prev, self.n - 1 - idx)

    def getIndexNext(self, idx):
        return self.__getIndex(self.BIT_next, idx)


N = int(input())
As = list(map(int, input().split()))

Bs = [i for A, i in sorted([(As[i], i) for i in range(N)])]

BIT = BIT_index(N)
ans = 0
for i, B in enumerate(Bs):
    iN = BIT.getIndexNext(B)
    iP = BIT.getIndexPrev(B)
    BIT.addElement(B)
    ans += (i + 1) * (iN - B) * (B - (N - 1 - iP))

print(ans)


Measured memory_bytes: 98896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int a,b;
  cin >> a >> b;
  
  int ans =0;
  if(a+b==5)ans=1;
  if(a+b==4)ans=2;
  if(a+b==3)ans=3;
  
  cout << ans << endl;
}


Measured memory_bytes: 256