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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
      ll flags;
      rrep(i,1,n+1){
        sum+=i;
        if(sum>=n){
          flags=i;
          if(sum==n){
            rrep(j,1,flags+1){
              Cout(j);
            }
            return 0;
          }
          break;
        }
      }
      sum=0;
      rrrep(i,flags,1){
        sum+=i;
        Cout(i);
        if(n-sum<=i-1){
          if(n-sum==0)return 0;
          Cout(n-sum);
          return 0;
        }
      }
     

       
return 0;
}


Measured memory_bytes: 256
//c++

#include <iostream>

using namespace std;

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
	map<int,int> m;
	vector<int> v;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(m[x]==0)
		v.push_back(x);
		m[x]++;
	}
	int ans=0;
	for(int i=0;i<v.size();i++)
	if(v[i]>m[v[i]])
	ans+=m[v[i]];
	else
	if(v[i]<m[v[i]])
	ans+=m[v[i]]-v[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5112
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#define l first
#define r second
#define int long long

const int maxn = 1e7 + 1, maxk = 1500101;

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int x; cin >> x;
    cout << (x / 500) * 1000 + ((x % 500) / 5) * 5;
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    int n;
    while (cin >> n, n) {
        vp yui(n);
        rep(i, n) {
            cin >> yui[i].fir >> yui[i].sec;
            yui[i].sec *= -1;
        }
        Int(m);
        rep(i, m) {
            i_i kyoko;
            cin >> kyoko.fir >> kyoko.sec;
            kyoko.sec *= -1;
            yui.pb(kyoko);
        }

        sort(all(yui));
        vi funami(1010, 0);
        rep(i, n+m) {
            int yuikyo = 0;
            rep(j, -yui[i].sec) {
                yuikyo = max(yuikyo, funami[j]);
            }
            funami[-yui[i].sec] = yuikyo+1;
        }
        int yuruyuri = 0;
        rep(i, 1010) {
            yuruyuri = max(yuruyuri, funami[i]);
        }
        cout << yuruyuri << endl;
    }

    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define mii map<int,int>
#define sf1(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define log2(x) (31 - __builtin_clz(x))
#define lcm(x,y) (x*y) / __gcd(x,y)
int inf = (1e9) + 7;
int mod = 998244353;



int occ[200005];

int main(){


	int n,k;
	sf2(n,k);


	for (int i = 0; i < n; ++i)
	{
		int x;
		sf1(x);
		occ[x]++;
	}

	vii v;

	for (int i = 1; i <  200005; ++i)
	{
		if(occ[i])
		{
			v.pb(mp(occ[i],i));
		}
	}

	if(v.size() <= k)
	{
		printf("0\n");
	}
	else
	{
		sort(v.begin(),v.end());
		
		int ans = 0;
		for (int i = 0; i < v.size() - k; ++i)
		{
			ans += v[i].ff;
		}

		printf("%d\n",ans );
	}


}

Measured memory_bytes: 4212
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
import std.math;
int main() {
	
	string l;
	while((l = readln().chomp, l.length)){
		string l2;
		
		foreach(char c; l){
			if(c >= 'a' && c <= 'z') l2 ~= c + ('A' - 'a');
			else l2 ~= c;
			}
		
		write(l2 ~ "\n");
		}
	return 0;
	}

Measured memory_bytes: 1104
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;

const int N=200005;
const int M=100;
const int C=26;

int app[N][C];
LL cnt[M][C];
int nxt[N];
LL len[M];
char s[N];
LL l,r;
int n,tot;

void pre()
{
	len[0]=n-nxt[n-1],len[1]=n;
	for (int i=2;len[i-1]<=r;++i)
	{
		len[tot=i]=len[i-1]+len[i-2];
		for (int c=0;c<C;++c) cnt[i][c]=cnt[i-1][c]+cnt[i-2][c];
	}
}

LL calc(LL m,int c,int cur)
{
	if (m<=n) return app[m][c];
	for (;len[cur]>m;--cur);
	return cnt[cur][c]+calc(m-len[cur],c,cur-1);
}

int main()
{
	//freopen("ss.in","r",stdin),freopen("ss.out","w",stdout);
	scanf("%s",s),n=strlen(s)>>1,scanf("%lld%lld",&l,&r);
	for (int i=1,ptr=0;i<n;++i)
	{
		for (;ptr&&s[i]!=s[ptr];ptr=nxt[ptr-1]);
		nxt[i]=ptr+=s[i]==s[ptr];
	}
	for (int i=1;i<=n;++i)
	{
		for (int c=0;c<C;++c) app[i][c]=app[i-1][c];
		++app[i][s[i-1]-'a'];
	}
	for (int c=0;c<C;++c) cnt[0][c]=app[n-nxt[n-1]][c],cnt[1][c]=app[n][c];
	pre();
	for (int c=0;c<C;++c) printf("%lld%c",calc(r,c,tot)-calc(l-1,c,tot),"\n "[c+1<C]);
	//fclose(stdin),fclose(stdout);
	return 0;
}

Measured memory_bytes: 12160
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    int t = 0;
    cin >> a;
    cin >> b;
    if(b>=a)
    {
        cout << a;

    }
    if(b<a)
    {
        cout << a-1;
    }
    return 0;
}


Measured memory_bytes: 3564
def main():
    N = int(input())
    a = list(map(int, input().split()))

    sum_a = sum(a)
    min_diff = float('inf')
    sum_first = 0
    for i in range(N-1):
        sum_first += a[i]
        if min_diff > abs(sum_a - 2 * sum_first):
            min_diff = abs(sum_a - 2 * sum_first)

    print(min_diff)

main()

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

int main() {
  int N;
  cin >> N;
  vector<int>P(N);
  vector<int>Q(N);
  for(int i=0; i<N; i++)cin >> P.at(i);
  for(int i=0; i<N; i++)cin >> Q.at(i);
  
  int Pjun =0; int Qjun =0;
  int count=0;
  while(count<N){
    int num = N-count-1;
    int kaijo=1;
    while(num-1>0){
      kaijo *= num;
      num--;
    }
    
    Pjun += (P.at(count)-1)*kaijo;
    for(int i=0; i<N; i++){
      if(P.at(count)<P.at(i))P.at(i) --;
    }
    
    count ++;
  }
  
   count=0;
  while(count<N){
    int num = N-count-1;
    int kaijo=1;
    while(num-1>0){
      kaijo *= num;
      num--;
    }
    
    Qjun += (Q.at(count)-1)*kaijo;
    for(int i=0; i<N; i++){
      if(Q.at(count)<Q.at(i))Q.at(i) --;
    }
    
    count ++;
  }
 
  if(Pjun>Qjun)cout << Pjun -Qjun << endl;
  else cout << Qjun - Pjun << endl;
}

Measured memory_bytes: 3596
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main(){
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long a, b; cin >> a >> b;

    long long ans = 0;

    auto isPalindrome = [&](long long n) {
        string s = to_string(n), t = s;
        reverse(t.begin(), t.end());
        return s == t;
    };

    for(long long i = a; i <= b; i++) {
        if(isPalindrome(i)) {
            ans++;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3588
data = input().split()

W = int(data[0])
H = int(data[1])
x = int(data[2])
y = int(data[3])
r = int(data[4])

re = "No"

if x >= r and x <= W-r:
    if y >= r and y <= H-r:
        re = "Yes"
        
print(re)


Measured memory_bytes: 5596
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    std::string S;
    std::cin >> S;

    int check[26] = {0};

    for (int i = 0; i < S.size(); i++) {
        check[S[i] - 'a']++;
    }

    bool flag = true;
    int count = 0;
    for (int i = 0; i < 26; i++) {
        if (check[i] == 0) {
            std::cout << char(i + 'a') << std::endl;
            flag = false;
            break;
        }
    }

    if (flag) {
        std::cout << "None" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 512
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException{
	BufferedReader br =
	    new BufferedReader(new InputStreamReader(System.in));

	String str = br.readLine();
	int seconds = Integer.parseInt(str);
	int hours = 0;
	int minutes = 0;
	for (int i = 0; seconds >= (60*60); i++) {
	    hours++;
	    seconds -= (60*60);
	}
	for (int i = 0; seconds >= 60; i++) {
	    minutes++;
	    seconds -= 60;
	}
	System.out.println(hours+":"+minutes+":"+seconds);


    }
}

Measured memory_bytes: 24308
# return x where
#   (when trueside<falseside)
#     [trueside,falseside) and yield(x)==true and (yield(x+tol)==false or falseside <= x+tol)
#   (when falseside<trueside)
#     (falseside,trueside] and yield(x)==true and (yield(x-tol)==false or x-tol <= falseside) 
# if trueside and falseside and tol is integer then do integer binary search
# note: neither yield(trueside) nor yield(falseside) were not called
def bsearch(trueside,falseside,tol=10**(-9))
  ok,ng=trueside,falseside
  div=2
  while((ok-ng).abs>tol) do
      mid=(ng+ok)/div
      if(yield(mid))
          ok=mid
      else
          ng=mid
      end
  end
  return ok
end


def solve(a,b)
  target=a*b
  y=bsearch(0,2*10**9+1,tol=1){|x|
    (x/2)*((x+1)/2)<target
  }
  if a==b
    return 2*a-2
  end
  return y-2
end

N=gets.to_i
ans=[]
N.times do
  ans << solve(*(gets.split.map(&:to_i)))
end
puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
using namespace std ;
int main(int argc, char** argv) {
	int n , m ;
	cin >> n >> m ;
	if ( ( n > 0 && m < 0 ) or ( n < 0 && m > 0 ) ) {
		cout << "Zero" ;
	}
	else if ( n > 0 && m > 0 ) {
		cout << "Positive" ;
	}
	else if ( n < 0 && m < 0 ) {
		int a = abs ( n ) - abs ( m ) + 1 ;
		if ( a % 2 == 0 ) {
			cout << "Positive" ;
		}
		else {
			cout << "Negative" ;
		}
	}
	return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    vector<int> A(N),B(N),C(N-1);
    rep(i,N){
        cin >> A[i];
        A[i]--;
    }
    rep(i,N) cin >> B[i];
    rep(i,N-1) cin>>C[i];
    
    //-----------------------------------
    int ans=0;
    rep(i,N){
        ans+=B[A[i]];
            //cout<<"   "<<ans<<endl;
        if(i!=0){
            if(A[i-1]+1==A[i])ans+=C[A[i-1]];
        }
        //cout<<ans<<endl;
    }


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

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll A, B;
    cin >> A >> B;
    ll ans = A * B;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nab = readln.split.to!(long[]);
    auto N = nab[0];
    auto A = nab[1];
    auto B = nab[2];

    if ((B-A)%2 == 0) {
        writeln((B-A)/2);
    } else {
        writeln(min(A + (B-A)/2, N-B+1 + (B-A-1)/2));
    }
}

Measured memory_bytes: 256
let f st op =
  let x1 = Stack.pop st and
      x2 = Stack.pop st in
  Stack.push (op x2 x1) st;
  st;;

let () =
  let st:int Stack.t = Stack.create () and
      l = read_line () |> Str.split (Str.regexp_string " ")
  in
  let rec loop ops = function
      [] -> Stack.pop ops
    | h::t ->
       let result =
         match h with
           "+" -> f ops (+)
         | "-" -> f ops (-)
         | "*" -> f ops ( * )
         | h -> Stack.push (int_of_string h) ops;ops
       in
       loop result t
  in Printf.printf "%d\n" (loop st l)
;;

Measured memory_bytes: 2320
#include<stdio.h>
#define INFTY 100000000

int n,d[105][105],color[105];

void bfs(int G,int s)
{
  int i;
  for(i=0;i<n;i++)
    {
      if(d[G][i+1]==1 && color[i+1]>s)
        {
          color[i+1]=s;
          bfs(i+1,s+1);
        }
    }
}

int main()
{
  int i,j,k,m,l;
  for(i=0;i<100;i++)
    {
      color[i+1]=INFTY;
    }
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&k,&m);
      for(j=0;j<m;j++)
        {
          scanf("%d",&l);
          d[k][l]=1;
        }
    }
  color[1]=0;
  bfs(1,1);
  for(i=0;i<n;i++)
    {
      printf("%d ",i+1);
      if(color[i+1]==INFTY)
        printf("-1");
      else printf("%d",color[i+1]);
      printf("\n");
    }
  return 0;
}



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

using namespace std;

int main()
{
    int n ;
    cin>>n ;
    int arr[n] , arr1[n] , arr2[n] ;
    for(int i = 0 ; i < n ; ++i)
        cin>>arr[i]>>arr1[i]>>arr2[i] ;
    int dp[n][3] ;
    for(int i = 0 ; i < n ; ++i)
    {
        if(i == 0)
            dp[i][0] = arr[i] , dp[i][1] = arr1[i] , dp[i][2] = arr2[i];
        else
        {
            dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + arr[i] ;
            dp[i][1] = max(dp[i-1][0] , dp[i-1][2]) + arr1[i] ;
            dp[i][2] = max(dp[i-1][0] , dp[i-1][1]) + arr2[i] ;
        }
    }
    return cout<<max(dp[n-1][0] , max(dp[n-1][1] , dp[n-1][2]))<<"\n" , 0 ;
}


Measured memory_bytes: 2560
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

phai = 1
cnt = 0
loop_hantei = {1}

for _ in range(N):
    phai = A[phai-1]
    cnt += 1
    if phai in loop_hantei:
        print('-1')
        break
    else:
        loop_hantei.add(phai)
    if phai == 2:
        print(cnt)
        break

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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

ll f(ll b, ll n){
  if(n < b) return n;
  else return f(b, n / b) + (n % b);
}

main(){
  ll n,s; cin >> n >> s;

  if(n == s){
    cout << n + 1 << endl;
    return 0;
  }

  ll m = sqrt(n);

  for(ll i = 2; i <= m + 1; i++){
    if(f(i, n) == s){
      cout << i << endl;
      return 0;
    }
  }

  for(ll i = m - 1; i > 0; i--){
    ll b = (n - s) / i + 1;
    if(b < 2) continue;
    if(f(b, n) == s){
      cout << b << endl;
      return 0;
    }
  }

  cout << "-1\n";
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  string input;
  cin>>input;
  for(auto c:input){
    if(c=='7'){
      cout<<"Yes"<<"\n";  
      return 0;
    }
  }
  cout<<"No"<<"\n";  
 
  
  return 0;
}

Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 21:14:23 2020

@author: Kanaru Sato
"""

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sum = 0

for i in range(n):
    if a[i] <= b[i] and a[i+1] <= b[i]-a[i]:
        sum += a[i] + a[i+1]
        a[i] = 0
        a[i+1] = 0
    elif a[i] <= b[i] and a[i+1] > b[i]-a[i]:
        sum += b[i]
        a[i+1] = a[i+1]-b[i]+a[i]
        a[i] = 0
    elif a[i] > b[i]:
        sum += b[i]
        a[i] -= b[i]
        a[i+1] = a[i+1]

print(sum)

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

using namespace std;

int main(){
    string s;
    cin >> s;
    for (int i = 0 ; i <s.length();i++){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" <<endl;


    return 0;
}


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

void convert(string& target, string before, string after) {
    while(target.find(before) != string::npos) {
        target.replace(target.find(before), before.length(), after);
    }
}

int main(void) {
    int num;
    cin >> num;
    cin.ignore();
    for(int r = 0; r < num; r++) {
        string input; getline(cin, input);
        convert(input, "Hoshino", "Hoshina");
        cout << input << endl;
    }
    return(0);
}

Measured memory_bytes: 1220
import java.util.*;

class Main{

    public static void main(String args[]) throws Exception{
        Main main = new Main();
    }

    public Main(){
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());

        long[][] C = new long[9][9];
        int L, U, D;
        for(int i=1;i<=N;i++){
            L = i % 10;
            if(L == 0)continue;
            D = 1;
            while(i>=D*10) D=D*10;
            U = i/D;

            C[L-1][U-1] += 1L;
        }

        long R=0;
        for(int i=0;i<9;i++){
            for(int j=0;j<9;j++){
                R += C[i][j] * C[j][i];
            }
        }

        System.out.println(R);
    }
}


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

using namespace std;

const int MAX_N = 1e5 + 10;

int p[MAX_N];

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if (p[i]!=i+1) continue;
		if (i==n-1) swap(p[i],p[i-1]);
		else swap(p[i], p[i+1]);
		ans++;
	}

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

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int A[3];

int main()
{
  scanf( "%d%d%d", A, A+1, A+2 );

  std::sort( A, A+3 );

  puts( (A[0]==A[1] && A[1]!=A[2]) || (A[0]!=A[1] && A[1]==A[2]) ? "Yes" : "No" );

  return 0;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int a, b, k;

int main(){
	cin >> a >> b>> k;
	
	for(int i = 0; i < k; i++){
		if(i%2){
			a += b/2;
			b /= 2;
		}
		else{
			b += a/2;
			a /= 2;
		}
	}
	
	cout << a << " " << b << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define Max 100

int output(int y, int m, int d){
  int count=0;
  while(1){
    if(y == 1 && m == 1 && d == 1)break;
    count++;
    d--;
    if(d<1){
      m--;
      if(m<1){
	y--;
	m=10;
      }
      if(m%2==1 || y%3 == 0)d=20;
      else d=19;
    }

  }
  return count;
}

int main(){
  int year[Max],month[Max],day[Max];
  int i,n;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d %d %d",&year[i],&month[i],&day[i]);
  }

  for(i = 0; i < n; i++){
    printf("%d",  196470-output(year[i],month[i],day[i]));
    puts("");
  }
  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <map>


using CountMap = std::map<std::string, int>;


void AppendString(CountMap& map, std::string val)
{
    if (map.find(val) == map.end())
    {
        map.insert(std::make_pair(val, 1));
    }
    else
    {
        ++map.at(val);
    }
}

int main()
{
    int n = 0;
    std::cin >> n;

    CountMap strings;

    for (int count = 0; count < n; ++count)
    {
        std::string val;
        std::cin >> val;
        AppendString(strings, val);
    }

    int max = 0;
    for (auto& val : strings)
    {
        if (max < val.second)
        {
            max = val.second;
        }
    }

    for (auto& val : strings)
    {
        if (val.second == max)
        {
            std::cout << val.first << std::endl;
        }
    }
    return 0;
}

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

using namespace std;
const int N = 1e5 + 1;
int a[N];

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int h, n, sum = 0, res = 0;
    cin >> h >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    res = h - sum;
    if (res <= 0)
        cout << "Yes\n";
    else
        cout << "No\n";

}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

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

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

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

int main()
{
	ll n,k,c,cnt=1;
	vll ans;
	string s;
	cin >> n >> k >> c >> s;
	vll a(n),b(n);
	rep(i,n){
		if(s[i]=='o'){
			a[i]=cnt;
			i+=c;
			cnt++;
		}
		if(cnt==k+1) break;
	}
	cnt=k;
	repr(i,n){
		if(s[i]=='o'){
			b[i]=cnt;
			i-=c;
			cnt--;
		}
		if(cnt==0) break;
	}
	cerr << a << b;
	rep(i,n){
		if(a[i] && a[i]==b[i]) ans.pb(i+1);
	}
	for(auto&& e:ans) cout << e << endl;
	return 0;
}

Measured memory_bytes: 6516
function main(input) {
  var inputList = input.split(" ");
  var charge = Number(inputList[0]);
  var have = Number(inputList[1]);
  var max = Number(inputList[2]);
  var listenMax = Math.floor(have / charge);

  const ans = max > listenMax ? listenMax : max;
  console.log(ans);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int main(){
	string o, e, result;
	cin >> o >> e;
	for (int i = 0; i < e.size(); ++i){
		result += o[i];
		result += e[i];
	}
	if (o.size() != e.size()){
		result += o.back();
	}
	cout << result << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        String S = sc.nextLine();
        sc.close();
        
        int count = 0;
        S = S.replace("ABC", "*");
        for(int i = 0; i < S.length(); i++){
            char a = S.charAt(i);
            String s = String.valueOf(a);
            if(s.equals("*")){
                count++;
            }
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;

int main() {
	int n,tmp;
	map<int, int> mp;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		if (mp.count(tmp))mp.erase(tmp);
		else mp[tmp] = 1;
	}
	cout << mp.size() << endl;
	return 0;
}

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

int sort(int A[], int N){
    int x = 0;
    bool flag = 1;
    for ( int i = 0; flag;i++){
        flag = 0;
        for(int j = N - 1; j >= i + 1; j--){
            if(A[j] < A[j - 1]){
                swap(A[j], A[j - 1]);
                flag = 1;
                x++;
            }
        }
    }
    return x;
}
int main(){
    int A[100], N, a;
    cin >> N;
    for (int i = 0;i < N;i++) cin >> A[i];
    a = sort(A, N);
    for (int i = 0; i < N ;i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << a << endl;
    return 0;
    
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    double n, ans=0, cnt=0;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i, n)cin >> x.at(i) >> y.at(i);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i==j)continue;
            ans += sqrt(pow(x[i]-x[j], 2)+pow(y[i]-y[j], 2));
            cnt++;
        }
    }
    cout << setprecision(15) << ans/n;
}  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int main(){
  double d;
  cin>>d;
  double ans = (int)d+1.0;
  ans = max(ans,sqrt(2)*d);

  printf("%.12lf\n",ans);

  return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <string, string> P;

const ll MOD=1000000007;
map<P,ll> m;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    string s;
    cin>>s;
    rep(i,0,1<<N){
        string c;
        string d;
        rep(j,0,N){
            if(i&(1<<j)){
                c+=s[j];
            }
            else d+=s[j];
        }
        m[P(c,d)]++;
    }
    ll ans=0;
    rep(i,0,1<<N){
        string c;
        string d;
        rep(j,0,N){
            if(i&(1<<j)){
                c+=s[2*N-1-j];
            }
            else d+=s[2*N-1-j];
        }
        ans+=m[P(c,d)];
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 91904
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
const int INF=0x3f3f3f3f;
int n,k,tot,a[N],pos[N],deg[N],ans[N];
set<int> L,R;
vector<int> G[N];

priority_queue<int> q;
void toposort() {
    for (int i=1;i<=n;i++)
        if (deg[i]==0) q.push(-i);
    while (!q.empty()) {
        int x=-q.top(); q.pop();
        a[++tot]=x;
        for (int i=0;i<G[x].size();i++) {
            int y=G[x][i];
            if (--deg[y]==0) q.push(-y);
        }
    }    
}

int Min[N<<2];
void build(int rt,int l,int r) {
    Min[rt]=INF;
    if (l==r) return;
    int mid=l+r>>1;
    build(rt<<1,l,mid); build(rt<<1|1,mid+1,r);
}

void update(int rt,int l,int r,int q,int v)
{
    if (l==r) {Min[rt]=min(Min[rt],v); return;}
    int mid=l+r>>1;
    if (q<=mid) update(rt<<1,l,mid,q,v);
    if (q>mid) update(rt<<1|1,mid+1,r,q,v); 
    Min[rt]=min(Min[rt<<1],Min[rt<<1|1]);
}

int query(int rt,int l,int r,int ql,int qr) {
    if (ql<=l && r<=qr) return Min[rt];
    int mid=l+r>>1;
    int ret=INF;
    if (ql<=mid) ret=min(ret,query(rt<<1,l,mid,ql,qr));
    if (qr>mid) ret=min(ret,query(rt<<1|1,mid+1,r,ql,qr));
    return ret; 
}

int main()
{
    cin>>n>>k;
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=1;i<=n;i++) pos[a[i]]=i;
    
    build(1,1,n);
    for (int i=n;i;i--)
	{
        int t1=query(1,1,n,max(1,pos[i]-k+1),pos[i]);
        if (t1<=n) G[pos[i]].push_back(pos[t1]),deg[pos[t1]]++;
        int t2=query(1,1,n,pos[i],min(n,pos[i]+k-1));
        if (t2<=n) G[pos[i]].push_back(pos[t2]),deg[pos[t2]]++;
        update(1,1,n,pos[i],i);
    }
    
    toposort();
    for (int i=1;i<=n;i++) ans[a[i]] = i;
    for (int i=1;i<=n;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 46592
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    int odd = (n + 1)/2;
    int even = n/2;
    OUT(even*odd)

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
using ll=long long ;
int main(){
	long long n,i;
	cin >> n;
	for(i=1;n>0;i++)	n-=i;
	cout << i-1 << endl;
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

#[allow(unused_macros)]
macro_rules! dbg { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; }

#[fastout]
fn main() {
    input! {
        n: usize,
        d: [(usize, usize); n],
    }
    let mut ans = 0;
    let mut now = 0;
    for (a, b) in d {
        if a == b {
            now += 1;
            ans = max(now, ans);
        } else {
            now = 0;
        }
    }
    if ans > 2 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2184
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0 ; i < n ; i++ ){
            a[i] = sc.nextInt();
        }
        sc.close();
        for(int i = 0 ; i < n - k ; i++ ){
            if(a[i] < a[i + k]){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 60156
#include<stdio.h>

int main(void){
    int a, b, d, r;
    double f;
    
    scanf("%d %d", &a, &b);
    
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    
    printf("%d %d %f\n", d, r, f);
    
    return 0;
}

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

//maerd, remaerd, esare, resare
 
int main(){
  int a, b;
  char s;
  cin >> a >> s >> b;
  if(s=='+') cout << a+b << endl;
  else cout << a-b << endl;
  return 0;
}



Measured memory_bytes: 256
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
k = ni()

if k%2==0 or k%5==0:
    print(-1)
    exit()
if k%7==0:
    L=9*k//7
else:
    L=9*k
tmp=1
for i in range(1,10**6):
    tmp = tmp*10 %L
    if tmp==1:
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 9412
import math

a,b,h,m=map(int, input().split())

th1=(30*h+0.5*m)/180*math.pi
th2=6*m/180*math.pi

ax=a*math.sin(th1)
ay=a*math.cos(th1)
bx=b*math.sin(th2)
by=b*math.cos(th2)

d=((ax-bx)**2+(ay-by)**2)**0.5
print(d)



Measured memory_bytes: 9508
from collections import deque

H,W,K=map(int,input().split())
A=["" for i in range(H)]
for i in range(H):
    A[i]=input()

for i in range(H):
    for j in range(W):
        if A[i][j]=="S":
            s=(i,j)

move=[(0,1),(1,0),(0,-1),(-1,0)]
start=set([s])
que=deque([(0,s[0],s[1])])
while que:
    count,posx,posy=que.popleft()
    if count==K:
        continue

    for i,j in move:
        nx=posx+i;ny=posy+j
        if H-1>=nx>=0 and W-1>=ny>=0 and A[nx][ny]!="#" and (nx,ny) not in start:
            start.add((nx,ny))
            que.append((count+1,nx,ny))


ans=float("inf")
for x,y in start:
    test=1+min((abs(x-0)-1)//K+1,(abs(H-1-x)-1)//K+1,(abs(y-0)-1)//K+1,(abs(W-1-y)-1)//K+1)
    ans=min(ans,test)

if s[0]==0 or s[0]==H-1 or s[1]==0 or s[1]==W-1:
    ans=0
print(ans)

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

using namespace std;
typedef long long ll;

int main(){
  ll k;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> v = vector<int>(k, -1);
  v[0] = 0;
  ll a = 0;
  ll idx = 1;
  while(true){
    a = a * 10 + 7;
    a %= k;
    if (v[a] != -1) {
      cout << idx - v[a] << endl;
      return 0;
    } else {
      v[a] = idx;
    }
    idx ++;
  }
  return 0;
}


Measured memory_bytes: 7116
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
typedef long long ll;
const int mod = 1e+9 + 7;

// dpテーブルは 1-indexed
ll dp[200005];

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> c(n);
    vector<vector<int>> pos(200005);     // 色がどの位置にあるか (0-indexed)
    for(int i = 0; i < n; ++i){
        cin >> c[i];
        --c[i];
        pos[c[i]].push_back(i);
    }
    
    dp[0] = 1;
    for(int i = 0; i < n; ++i){
        // 何も操作しない
        dp[i+1] = (dp[i+1] + dp[i]) % mod;

        // 今見ている c[i] が何番目であるか
        int id = lower_bound(pos[c[i]].begin(), pos[c[i]].end(), i) - pos[c[i]].begin();
        
        if(id > 0){
            // 同じ色が隣り合っていないか確認
            if(i - pos[c[i]][id-1] <= 1)    continue;
            // 反転操作
            dp[i+1] = (dp[i+1] + dp[pos[c[i]][id-1] + 1]) % mod;
        }
    }
    cout << dp[n] << endl;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF= 1e20;

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
	LL a, b, x;
	cin >> a >> b >> x;
	if (x >= a && x <= a + b)COUT("YES");
	else COUT("NO");
	return 0;
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e6+5;
const ll mod = 1e9+7;
ll f[N];
ll inv(ll x)
{
    ll ret=1,y=mod-2;
    while(y)
    {
        if(y&1)ret=1ll*ret*x%mod;
        y>>=1;
        x=1ll*x*x%mod;
    }
    return ret;
}
ll C(ll n,ll m)
{
    if(n<m)return 0;
    ll ret=1ll*f[n]*inv(f[m])%mod;
    ret=1ll*ret*inv(f[n-m])%mod;
    return ret;
}
ll lucas(ll n,ll m)
{
    if(m == 0) return 1;
    return 1ll*C(n % mod, m % mod) * lucas(n / mod, m / mod) % mod;
}
void init()
{
    f[0]=1;
    for(ll i=1; i<=N-5; ++i)f[i]=1ll*i*f[i-1]%mod;
}
ll qd(ll a,ll b)
{
    ll ans=1;
    a%=mod;
    while(b)
    {
        if(b&1)
        {
            ans=ans*a%mod;
            b--;
        }
        b>>=1;
        a=a*a%mod;
    }
    return ans;
}
int main()
{
    init();
    ll a,b,h,w,ans=0;
    scanf ("%lld%lld%lld%lld",&h,&w,&a,&b);
    for (ll i=0; i<=h-a-1; i++)
    {
        ll xia=i,you=a;
        ans=(ans+(lucas(b-1+i,i)*lucas(w+h-2-i-b,w-b-1)%mod))%mod;
//        printf ("%lld,%lld*%lld,%lld\n",b-1+i,i,w+h-2-i-a,w-b-1);
    }
    printf ("%lld\n",ans);
    return 0;
}




Measured memory_bytes: 8064
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s=STR()
    sn=0
    for i in s:
        sn+=int(i)
    if int(s)%sn==0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
//https://atcoder.jp/contests/abc122/tasks/abc122_c
#include<iostream>
#include<string>
using namespace std;

int main() {
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    int *l = new int[Q];
    int *r = new int[Q];
    int *ac = new int[N-1];
    for(int i=0;i<N-1;i++)ac[i]=0;
    for(int i=0;i<Q;i++)cin>>l[i]>>r[i];
    for(int i=0;i<N-1;i++)if(S[i]=='A'&&S[i+1]=='C')ac[i]=1;
    int *sum = new int[N];
    sum[0]=0;
    for(int i=1;i<N;i++)sum[i]=sum[i-1]+ac[i-1];
    for(int i=0;i<Q;i++)cout<<sum[r[i]-1]-sum[l[i]-1]<<endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int pre_x = 0;
  int pre_y = 0;
  int pre_t = 0;

  string ans = "Yes";

  rep(i,n){
    int t,x,y;
    cin >> t >> x >> y;

    //時刻と座標の和の偶奇が一致するか
    if(t%2!=(x+y)%2){
      ans = "No";
      continue;
    }

    //前の時刻から間に合う範囲内か
    if(t-pre_t<abs(x-pre_x)+abs(y-pre_y)){
      ans = "No";
      continue;
    }

    //前の時刻からちょうど到達できる場所か
    if((t-pre_t)%2!=(abs(x-pre_x)+abs(y-pre_y))%2){
      ans = "No";
      continue;
    }

    //更新
    pre_x = x;
    pre_y = y;
    pre_t = t;
  }

  cout << ans << endl;

  return 0;
}

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

const int maxn = 100005;

int root[maxn];

int dsu_find (int u) {
    if (u == root[u])
        return u;
    return root[u] = dsu_find(root[u]);
}

void dsu_unite (int u, int v) {
    u = dsu_find(u), v = dsu_find(v);
    if (u != v) {
        if (rand() & 1)
            swap(u, v);
        root[u] = v;
    }
}

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, m;
    cin >> n >> m;
    for (int i = 0; i <= n; ++i)
        root[i] = i;
    vector < int > p(n + 1, 0);
    for (int i = 1; i <= n; ++i)
        cin >> p[i];
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        dsu_unite(x, y);
    }
    map < int, pair < set < int >, set < int > > > roadmap;
    for (int i = 1; i <= n; ++i) {
        roadmap[dsu_find(i)].first.insert(i);
        roadmap[dsu_find(i)].second.insert(p[i]);
    }
    int ans = 0;
    for (auto pr: roadmap) {
        for (auto x: pr.second.first) {
            if (pr.second.second.find(x) != pr.second.second.end())
                ++ans;
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 24448
n = int(input());
ans = 1;
lis = list(map(int,input().split()))
flag = False
flag2 = False
for i in range(n):
    if lis[i]==0:
        flag = True
    if ans*lis[i]>=1000000000000000001:
        flag2 = True
    else:
        ans *= lis[i]

if flag:
    print(0)
elif flag2:
    print(-1)
else:
    print(ans)

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

ll p(ll n){
   if(n == 0)return 1;
   return (p(n-1)*(n%MOD))%MOD;
}

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

   int N,M;
   cin>>N>>M;
   if(N==M){
      cout<<(2*p(N)*p(N))%MOD;
   }
   else if(abs(N-M)==1){
      cout<<(p(N)*p(M))%MOD;
   }
   else{
      cout<<0<<endl;
   }
   return 0; 
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	long long int l,r,i,j,range,start,ans=2019;
	cin>>l>>r;
	if (r-l+1>=2019) 
	{
		cout<<0<<endl;
		return 0;
	}
	for (i=l;i<r;i++)
	{
		for (j=i+1;j<=r;j++)
		{
			ans=min(ans,(i*j)%2019);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a, b, c;
	long long k;
	a = b = c = 0;
	cin>>a>>b>>c>>k;
	if(k % 2 == 0){
		cout<<a - b<<endl;
	}
	else{
		cout<<b - a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;
    cout << min({min(X,Y)*2*C+(X-min(X,Y))*A+(Y-min(X,Y))*B,max(X,Y)*2*C,A*X+B*Y}) << endl;
}

Measured memory_bytes: 256
def cmb(n, r, p):
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
n = 7*10**5  # N は必要分だけ用意する
N = 2*n
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    if i <= n:
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
X, Y = map(int, input().split())
if (X+Y)%3 != 0:
    result = 0
else:
    n = Y-(X+Y)//3
    m = X-(X+Y)//3
    if n<0 or m<0:
        result = 0
    else:
        result = cmb(n+m, n, p)
print(result)


Measured memory_bytes: 114164