akhauriyash/Code-Regression huggingface dataset:
/*input
100 50 4
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX 1501

template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(ll a, ll b) {a += b; if (a < 0) a += mod; return a;}
inline int sub(ll a, ll b) {a -= b; if (a < 0) a += mod; return a;}
inline int mul(ll a, ll b) {return (a * 1ll * b) % mod;}
inline int pwr(ll x, ll y) {
    int ans = 1 % mod;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        x = mul(x, x);
        y >>= 1;
    }
    return ans;
}
inline int inv(int a) {return pwr(a, mod - 2);}


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

    int a, b, k;
    cin >> a >> b >> k;
    vector <int> vec;
    for (int i = 1; i * i <= a; i++) {
        if (a % i == 0) {
            vec.pb(i);
            if (i != a / i) vec.pb(a / i);
        }
    }
    sort(allr(vec));
    int ans = 0;
    for (auto it : vec) {
        if (a % it == 0 && b % it == 0) {
            ans++;
        }
        if (ans == k) {
            cout << it << endl;
            break;
        }
    }
    
    return 0;
}


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

using namespace std;


long insertionSort(vector<long>& A, int n, int g)
{
    long cnt = 0;
    for(int i = g; i < n; i++){
	int v = A.at(i);
	int j = i - g;
	while(j >= 0 && A.at(j) > v){
	    A.at(j+g) = A.at(j);
	    j = j - g;
	    cnt++;
	}
	A.at(j+g) = v;
    }
    return cnt;
}

long shellSort(vector<long>& A, int n, int m, vector<int>& G)
{
    long cnt = 0;
    for(int i = 0; i < m; i++){
	cnt += insertionSort(A, n, G.at(i));
    }
    return cnt;
}

void print(int m, vector<int>& G){
    cout << m << endl;
    string sep = "";
    for(int g: G){
	cout << sep << g;
	sep = " ";
    }
    cout << endl;
}
    
int main()
{
    int N;
    cin >> N;
    vector<long> A(N);
    for(int i = 0; i < N; i++){
	cin >> A.at(i);
    }

    int upper = ceil(pow(N, 3.0/2.0));

    vector<int> G;
    int m = 0;
    int v = 1;
    for(;;){
	if(m+1 > 100) break;
	if(v > N) break;
	m++;
	G.push_back(v);
	v = 3 * v + 1;
    }
    reverse(G.begin(), G.end());
    
    long cnt = shellSort(A, N, m, G);

    print(m, G);
    
    cout << cnt << endl;
    
    for(int a: A){
	cout << a << endl;
    }
    
    
}



Measured memory_bytes: 10672
/*
ID: mm.khan1
PROG: beads
LANG: C++14
*/
#include <bits/stdc++.h>

using namespace std;

//#pragma GCC target ("sse4.2")
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE_IO ifstream cin ("beads.in"); ofstream cout ("beads.out");
#define pii pair<int, int>
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const int MAX_I = 1e5*3;
const int N = 1e6;
const ll mud = 1e9 + 7;
ll a[N];

int main(){
	FAST_IO;
	//FILE_IO;	
	
	ll n;
	cin >> n;
	for (ll i=0;i<n;i++) cin>>a[i];

	bool ans=1;
	for (ll i=n-2;i>=0;i--){
		if (a[i]<max(0LL, a[i+1]-1) || a[i]>i){
			ans=0;
			break;
		}
	}
	if (!ans || a[0]){
		cout << "-1\n";
		return 0;
	}

	ll cnt=0, cur=0;
	for (ll i=n-1;i>=0;i--){
		if (cur<a[i]){
			cur=a[i];
			cnt+=a[i];
		}
		cur = max(0LL, cur-1);
	}

	cout << cnt << '\n';

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char ch[110],s[110];
int n;
int get(char k){
	memcpy(s,ch,sizeof ch); int m=n,ans=0;
	for (int i=1;i<=n;i++) if (ch[i]!=k) ans=1;
	if (ans==0) return 0; ans=0;
	while (1){
		int flag=0; ans++;
		for (int i=1;i<m;i++)
			if (s[i]==k||s[i+1]==k) s[i]=k;
			else flag=1;
		m--;
		if (flag==0) return ans;
	}
}
int main(){
	scanf("%s",ch+1);
	int ans=1e9; n=strlen(ch+1);
	for (int i=1;i<=n;i++) ans=min(ans,get(ch[i]));
	cout<<ans<<endl;
	return 0;
}

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

int main(int argc, char **argv) {
  int A, B;
  cin >> A >> B;

  int ans;

  ans = A + B;
  ans = max(ans, A - B);
  ans = max(ans, A * B);

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


Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
    int n, d, x;
    int a[102];
    cin >> n;
    cin >> d >>x;
    int ans;
    REP(i, n)cin >> a[i];
    REP(i, n){
        ans += (d - 1) / a[i] + 1;
    }
    print(ans + x);
}

Measured memory_bytes: 256
A,B,C,D;main(i){scanf("%1d%1d%1d%1d",&A,&B,&C,&D);for(i=0;i<8;i++)if(A+(i/4%2?-B:B)+(i/2%2?-C:C)+(i%2?-D:D)==7){char p[]={'+','-'};printf("%d%c%d%c%d%c%d=7\n",A,p[i/4%2],B,p[i/2%2],C,p[i%2],D);return 0;}}

Measured memory_bytes: 128
h, w = gets.chomp.split.map(&:to_i)
s = Array.new(h) { gets.chomp }
res = 0

h.times do |i|
  w.times do |j|
    next if s[i][j] == "#"

    q = [[i, j]]
    dp = Array.new(h) { Array.new(w, -1) }
    dp[i][j] = 0
    used = Hash.new(false)
    dxy = [[0, 1], [1, 0], [0, -1], [-1, 0]]

    while !q.empty?
      cx, cy = q.shift

      dxy.each do |dx, dy|
        nx = cx + dx
        ny = cy + dy
        next if nx < 0 || nx >= h || ny < 0 || ny >= w
        next if s[nx][ny] == "#"
        next if dp[nx][ny] != -1

        dp[nx][ny] = dp[cx][cy] + 1
        q << [nx, ny]
      end
    end
    res = [res, dp.flatten.max].max
  end
end
puts res

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
      
  
  
  
  


int main(){
  ll i, j;
  string s;
  cin >> s;
  ll n = s.size();
  vector<ll> a(n + 1),ab(n + 1), abc(n + 1),x(n+1);
  x[0]=1;
  for(i = 1; i < n + 1;i++){
    x[i]=x[i-1];
    a[i] = a[i - 1];
    ab[i] = ab[i - 1];
    abc[i] = abc[i - 1];
    switch(s[i - 1]){
      case 'A':
        a[i] += x[i];
        break;
      case 'B':
        ab[i] += a[i - 1];
        break;
      case 'C':
        abc[i] += ab[i - 1];
        break;
      case '?':
        abc[i] = 3 * abc[i - 1] + ab[i - 1];
        ab[i] = 3 * ab[i - 1] + a[i - 1];
        //cout << "tsts" << endl;
        a[i] = 3 * a[i - 1] + x[i-1];
        x[i]=x[i-1]*3;
        
        break;
    }
    //cout << a[i] spa ab[i] spa abc[i] << endl;
    a[i] %= MOD;
    ab[i] %= MOD;
    abc[i] %= MOD;
    x[i]%=MOD;
  }
  cout << abc[n] << endl;
    
        
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#define pb push_back()
double r;
int main()
{
	scanf("%lf",&r);
	printf("%.10f\n",2.0*acos(-1)*r);
return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <utility>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 100000
#define MAXL 100
typedef long long int lli;

int main(){
    string s, t;
    cin >> s >> t;
    vector<int> s_vec, t_vec;
    for(int i = 0; s[i] != '\0'; i++){
        s_vec.push_back(s[i]);

    }

    for(int i = 0; t[i] != '\0'; i++){
        t_vec.push_back(t[i]);
    }

    sort(s_vec.begin(), s_vec.end());
    sort(t_vec.begin(), t_vec.end(), greater<int>());

    for(int i = 0; i < s_vec.size(); i++){
        s[i] = s_vec[i];
    }

    for(int i = 0; i < t_vec.size(); i++){
        t[i] = t_vec[i];
    }

    string ans = (s < t)? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////

int main() {
	int N;
	cin >> N;
	vector<pii>X(N);
	vector<pii>Y(N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		X[i].first = b;
		X[i].second = a;
	}
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		Y[i].first = a;
		Y[i].second = b;
	}
	sort(X.begin(), X.end(), greater<pii>());
	sort(Y.begin(), Y.end());
	int count = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < Y.size(); ++j) {
			if (X[i].first < Y[j].second&&X[i].second < Y[j].first) {
				count++;
				Y.erase( Y.begin() + j );
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int d,r,i,n,ar[100009];
ll cnt=0;
int main ()
{
   cin>>n;
   r=n+1;
   for (i=1;i<=r; i++)
   cin>>ar[i];
   
   for (i=1; i<=n; i++)
   {
   	cin>>d;
   	
   	if (ar[i]>=d) 
   	{
   		cnt+=d; continue;
   	}
   	cnt+=ar[i];
   	r=d-ar[i];
   	if (r>=ar[i+1]) 
  {cnt+=ar[i+1]; ar[i+1]=0; continue;	}
   	cnt+=r;
   	ar[i+1]-=r;
   }	
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define MAX 20001

typedef struct Index{
 int idx;
 int S;
}Index;


void push1(int S[],int x,int *top){
 S[*top] = x;
 (*top)++;
return;
}

void push2(Index S[],int idx,int s,int *top){
 S[*top].idx = idx;
 S[*top].S = s;
 (*top)++;
return;
}

int pop(int S[],int *top){
 (*top)--;
 return S[*top];
}

void Uni(Index S[],int *top){
 int i;

 for(i = (*top) - 1 ; i > 0 ; i--){

   if(S[i].idx < S[i-1].idx){
     (*top)--;
     S[i-1].idx = S[i].idx;
     S[i-1].S += S[i].S;
   }

 }

return;
}

int main(){
  int i, j, idx, top1 = 0, top2 = 0, sum = 0;
  char str[MAX];
  int Stack1[MAX];
  Index Stack2[MAX];

 scanf("%s", str);

 for(i = 0 ; i < strlen(str) ; i++){

  switch(str[i]){
   case '\\':push1(Stack1, i, &top1);
             break;
   case '/' :if(top1 == 0)break;
             idx = pop(Stack1, &top1);
             sum += (i-idx);
             push2(Stack2, idx, i - idx, &top2);
             Uni(Stack2, &top2);
             break;
  }

 }

 printf("%d\n", sum);
 if(top2 == 0) printf("%d\n", top2);
 else {
   printf("%d ", top2);
   for(i = 0 ; i < top2 - 1 ; i++) printf("%d ", Stack2[i].S);
   printf("%d\n", Stack2[top2-1].S);
 }

return 0;
}


Measured memory_bytes: 2108
S=str(input())
p=0
L=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(26):
    check=L[i] in S
    if check==True:
        p+=1
    else:
        print(L[i])
        break
if p==26:
    print('None')


Measured memory_bytes: 3188
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n,m,k=MI()
	mod=10**9+7

	f=[1]
	for i in range(1,n*m+10):
		f.append((f[-1]*i)%mod)
	#print(f)

	finv=[]
	for i in f:
		finv.append(pow(i,mod-2,mod))
	#print(finv[:10])


	ans=0

	cnt=0
	for i in range(1,m):
		cnt+=i*(m-i)
		cnt%=mod
	ans+=n*n*cnt

	cnt=0
	for i in range(1,n):
		cnt+=i*(n-i)
		cnt%=mod
	ans+=m*m*cnt

	ans%=mod
	#print(ans)

	ans*=k*(k-1)
	ans%=mod

	ans*=f[n*m-2]*finv[n*m-2-(k-2)]
	ans*=finv[k]

	print(ans%mod)


















if __name__ == "__main__":
	main()


Measured memory_bytes: 24672
import Foundation

let input = readLine()!
let N = input.count

let firstString  = input
let endString = input

let firstPalindrome = input.dropLast((N - 1) / 2 + 1).map{ String($0)}
let endPalindrome = input.dropFirst((N + 3) / 2 - 1).map{ String($0)}

let StringNums = firstString.count
let halfNums = StringNums / 2

var firstReversed: [String] = []
var endReversed: [String] = []



for i in (0...halfNums - 1).reversed() {
    firstReversed.append(firstPalindrome[i])
    endReversed.append(endPalindrome[i])
}

if firstPalindrome == firstReversed && endPalindrome == endReversed && firstReversed == endPalindrome {
    print("Yes")
} else {
    print("No")
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  cin >> n;

  ll s = 1;
  re(i, n) {
    s = s * (i + 1) % mod;
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int  a, b, c;
	scanf("%d %d", &a, &b);
	if (b % a == 0) {
		c = a + b;
		printf("%d", c);
	}
	else {
		c = b - a;
		printf("%d", c);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n; cin >> n;
    cout << n+n*n+n*n*n;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int n, x, cnt = 0;
    
    while(1){
        cin >> n >> x;
        
        if(n == 0 && x == 0)
            break;
        else{
            for(int i=1; i <= n; i++){
                for(int j=1; j <= i; j++){
                    if(j == i) continue;
                    for(int k=1; k <= j; k++){
                        if(k == j || k == i) continue;
                        else if(k+j+i == x) cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
        cnt = 0;
    }
    
    return 0;
}



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
signed main(){
    fast;
    long double r = 0.01;
    int year = 0;
    int a = 100;
    int x;
    cin>>x;
    while(a<x){
        year++;
        a = a + (r*a);
    }
    cout<<year;
}


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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair
# define int long long 

using namespace std;

const int inf = 1e9 + 7;
const int N = 1e5 + 5;

typedef long long ll;

int n, a[N], b[N], c[N], ans;
int dp[6][N], pos;

 main()
{
      cin >> n;

      for(int i = 1; i <= n; i ++)
            cin >> a[i];
      for(int i = 1; i <= n; i ++)
            cin >> b[i];
      for(int i = 1; i <= n; i ++)
            cin >> c[i];

      sort(a + 1, a + n + 1);
      sort(b + 1, b + n + 1);
      sort(c + 1, c + n + 1);

      pos = n;
      for(int i = n; i >= 1; i --)
      {
            while(pos > 0 && c[pos] > b[i])
                  pos --;
            dp[2][i] += n - pos;
            dp[2][i] += dp[2][i + 1];
      }
      pos = n;

      for(int i = n; i >= 1; i --)
      {
            while(pos > 0 && b[pos] > a[i])
                  pos --;
            dp[1][i] += dp[2][pos + 1];
            dp[1][i] += dp[1][i + 1];
      }

      cout << dp[1][1] << endl;
}


Measured memory_bytes: 6528
ball_1,ball_2 = input().split()
ball_1_count,ball_2_count = map(int , input().split())
getted_str = input()
if getted_str == ball_1:
    ball_1_count -= 1
else:
    ball_2_count -= 1
print(str(ball_1_count) + " " + str(ball_2_count))

Measured memory_bytes: 2940
def black_jack():
    # 入力
    A1, A2, A3 = map(int, input().split())
    # 初期処理
    sum = A1 + A2 + A3
    # 判別処理
    if sum >= 22:
        return 'bust'
    elif sum <= 21:
        return 'win'

result = black_jack()
print(result)

Measured memory_bytes: 9104
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func solve(n, a, b int) int {
	if (b-a)%2 == 0 {
		return (b - a) / 2
	}

	minv := min(b-1, n-a)
	minv = min(minv, a+(b-a-1)/2)
	minv = min(minv, n-b+1+(b-a-1)/2)
	return minv
}

func main() {
	n, _ := strconv.Atoi(input())
	a, _ := strconv.Atoi(input())
	b, _ := strconv.Atoi(input())
	fmt.Println(solve(n, a, b))
}


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


int main(){
  ll a,b,c,x;
  cin>>a>>b>>c>>x;
  ll ans = 0;
  REP(i,a+1){
    REP(j,b+1){
      REP(k,c+1){
        if((500*i+100*j+50*k)==x){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
  
  return 0;
}

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

bool calc(int n){
	string str;
	while(n){
		str.push_back(n%10);
		n /= 10;
	}
	string s = str;
	reverse(s.begin(), s.end());
	return s == str;
}

int main(){
	int a, b, ans = 0;
	scanf("%d%d", &a, &b);
	for(int i = a;i <= b;i++){
		ans += calc(i);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int n;
	int N[100010];
	double Na[100010];
	scanf("%d", &n);
	double ans=0.0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &N[i]);
		Na[i] = (double)1 / N[i];
		ans += Na[i];
	}
	printf("%lf", 1 / ans);


	return 0;
}


Measured memory_bytes: 128
N = list(input())
if N[-1] =='2' or N[-1] =='4' or N[-1] =='5' or N[-1] =='7' or N[-1] =='9':
    print('hon')
elif N[-1] =='0' or N[-1] =='1' or N[-1] =='6' or N[-1] =='8':
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9056
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>

#define ll long long

int main()
{
    std::string N;
    std::cin >> N;

    ll sum = 0;
    for(ll i=0; i < N.size(); i++) {
        //int num = atoi(N[i]);
        uint8_t c = N[i];
        sum += c - '0';
    }
    if(sum % 9 == 0) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 3724
#include<stdio.h>
#define N 100
int bubbleSort(int*,int);

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

  count=bubbleSort(a,n);
  for(i=0; i<n; i++) {
    printf("%d",a[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}

int bubbleSort(int a[],int n)
{
  int flag = 1; 
  int i=0,j,tmp,count=0;
  
  while(flag) {
    flag = 0;
    for(j=n-1; j>i; j--) {
      if(a[j]<a[j-1]) {
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	flag = 1;
	count++;
      }
    }
    i++;
  }
  return count;
}

Measured memory_bytes: 604
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key){
	int left =0;
	int right = n;
	int mid;
	while(left<right){
		mid = (left + right)/2;
		if(key == A[mid]){
			return 1;
		}
	if(key > A[mid]){
		left = mid+1;
	}
	else if(key <A[mid]){
		right = mid;
	}}
	return 0;

}

int main(void){
	int i, q, k, sum = 0;
	
	scanf("%d", &n);
	for(i = 0;i<n;i++){
		scanf("%d", &A[i]);
	}
	
	scanf("%d", &q);
	for(i = 0;i<q;i++){
		scanf("%d", &k);
		if(binarySearch(k)){
			sum++;
		}
	}
	
	printf("%d\n", sum);
	
	return 0;

}


Measured memory_bytes: 2108
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int H, N;
  cin >> H >> N;

  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  for (int i = 0; i < N; i++) H -= A[i];

  if (H <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int Mod=1e9+7,MAXN=1e3+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline ll read(){
	ll x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
struct Mat{
	int a[2][2];
	inline int*operator[](int x){return a[x];}
	inline Mat(){memset(a,0,sizeof(a));}
	inline friend Mat operator*(Mat a,Mat b){
		Mat c;
		Rep(i,0,1)Rep(j,0,1)Rep(k,0,1)c[i][j]=(c[i][j]+1ll*a[i][k]*b[k][j])%Mod;
		return c;
	}
}coef;
int h,w,a,b,c,d;char s[MAXN][MAXN];ll k;
inline int Fp(int x,ll k){int ans=1;for(;k;k>>=1,x=1ll*x*x%Mod)if(k&1)ans=1ll*ans*x%Mod;return ans;}
inline Mat Fp(Mat x,ll k){Mat ans;for(ans[0][0]=ans[1][1]=1;k;k>>=1,x=x*x)if(k&1)ans=ans*x;return ans;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	h=read(),w=read(),k=read();
	Rep(i,1,h){
		scanf("%s",s[i]+1);
		Rep(j,1,w)if(s[i][j]=='#')a++;
	}Rep(i,1,w)if(s[1][i]=='#')c+=s[1][i]==s[h][i];Rep(i,1,h)if(s[i][1]=='#')d+=s[i][1]==s[i][w];
	if(c&&d)puts("1");else if(!c&&!d)cout<<Fp(a,k-1);else{
		if(c)Rep(i,1,h)Rep(j,1,w){if(s[i][j]=='#'&&s[i+1][j]=='#')b++;}
		else Rep(i,1,h)Rep(j,1,w){if(s[i][j]=='#'&&s[i][j+1]=='#')b++;}
		coef[0][0]=a,coef[0][1]=0,coef[1][0]=b,coef[1][1]=c+d,coef=Fp(coef,k-1);
		cout<<(coef[0][0]-coef[1][0]+Mod)%Mod<<'\n';
	}
	return 0;
}




Measured memory_bytes: 4756
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    int a,b;

    scanf("%d %d", &a, &b);
    for( i=1; i<=3; i++)
    {
        if( i!=a && i!=b )
        {
            printf("%d\n", i);
            break;
        }
    }


    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/   \/_________/\/__/   \/__/
//


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

#define LEFT 'W'
#define RIGHT 'E'

const long MAX_N = 3*10e5;

int main() {
	int N;
	char S[MAX_N] = {0};
	cin >> N;
	scanf("%s", S);

	int save = 0;
	int sum = 0;
	for (int i = 1; i < N; i++)
		if (S[i] == RIGHT)
			save++;
	sum = save;

	for(int i = 1; i < N; i++) {
		if (S[i] == RIGHT)
			save--;
		if (S[i-1] == LEFT)
			save++;
		sum = min(sum, save);
	}
	cout << sum << endl;
}


Measured memory_bytes: 3200
#include <iostream>
using namespace std;
long long n, a[200002];
int main()
{
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }
    long long aim = a[1], sum = 0;
    for(int i = 2;i <= n;i++)
    {
        if(aim > a[i]) sum += aim - a[i];
        else if(aim < a[i]) aim = a[i];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 5156
a = input().split(" ")
N = eval(a[0])
K = eval(a[1])
dic = {}
b = input().split(" ")
n_lst = [-1]
for i in range(1, N + 1):
    dic[i] = eval(b[i - 1])
    n_lst.append(-1)
ans = 1
lst = []
length = 0
while K > 0:
    if n_lst[ans] != -1:
        left = n_lst[ans]
        zq = length - left
        K = K % zq
        if K == 0:
            break
    else:
        n_lst[ans] = length
        length += 1
    ans = dic[ans]
    K -= 1

print(ans)


Measured memory_bytes: 52260
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
#define loopj(n)	for(int j=0;j<n;j++)
ll mod=1e9+7;
const int N=2e5+7, M =53;

int L[N],R[N],Q[N];
map<int,int>mp;
map<int,int>mp1;
int main()
{
      //freopen ("output.txt","w",stdout);
        ios_base::sync_with_stdio(0), cin.tie(0),cout.tie(0);
int t,n,m;
cin >> n >> m;
mp[1]=1;
ll tot=0;
int x,y;
while(m--){
    cin >> x >> y;
    mp1[y]++;
    mp1[x]--;
    if(mp[x]){
        mp[y]=1;
        if(mp1[x]<0){
            mp[x]=0;
        }
    }
    
}
for(auto it: mp)
    tot+=it.second;
cout <<tot <<endl;
}


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

void Main() {
  int N, K;
  cin >> N >> K;
  int A[N];
  memset(A, 0, sizeof(A));
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      A[a - 1]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == 0) ans++;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#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)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    vector<ll> b(m);
    rep(i,n)cin >> a[i];
    rep(i,m)cin >> b[i];
    vector<ll> as(n+1);
    vector<ll> bs(m+1);
    rep(i,n){
        as[i+1]=as[i]+a[i];
    }
    rep(i,m){
        bs[i+1]=bs[i]+b[i];
    }
    int ok = 0;
    int ng = n+m+1;
    auto check =[&](int num){
        rep(i,num+1){
            if(i>n||(num-i)>m)continue;
            if(as[i]+bs[num-i]<=k)return true;
        }
        return false;
    };
    while(abs(ng-ok)>1){
        int mid = (ok+ng)/2;
        //cout << ok << " " << mid << " " << ng << endl;
        if(check(mid))ok=mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 9188
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

const lint BIG = 100000000012LL;

lint pow(lint x, int k)
{
    lint ret = 1LL;
    while(k--) {
        if (ret > BIG / x)
            return BIG + 1;
        ret *= x;
    }

    return ret;
}

VEC(lint) factorize(lint n)
{
    VEC(lint) ret;
    for(lint d = 1;d <= n / d; d++)
        if (n % d == 0) {
            ret.push_back(d);
            ret.push_back(n / d);
        }

    return ret;
}

lint digitsum(lint n, lint base)
{
    lint ret = 0;
    while (n > 0) {
        ret += n % base;
        n /= base;
    }

    return ret;
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    lint n, s;
    cin >> n >> s;

    lint ret = -1;
    if (n == s)
        ret = n + 1;

    if (n > s) {
        VEC(lint) f = factorize(n - s);
        for (lint t : f) {
            lint base = t + 1;
            if (digitsum(n, base) == s)
                if (ret > base || ret < 0)
                    ret = base;
        }
    }

    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint N, D;
	cin >> N >> D;
	lint cnt = 0;
	lint X, Y;
	rep(i, N) {
		cin >> X >> Y;
		if (X * X + Y * Y <= D*D) {
			cnt++;
		}
	}
	cout << cnt << enld;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  int sum = 0;
  rep(i, n){
    int a; cin >> a; a--;
    sum += a;
  }

  cout << sum << endl;

  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,X[3];
int C[101010][2];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>X[0]>>X[1]>>X[2];
	
	string T;
	FOR(i,N) {
		cin>>s;
		if(s=="AB") {
			C[i][0]=0,C[i][1]=1;
		}
		else if(s=="BC") {
			C[i][0]=1,C[i][1]=2;
		}
		else {
			C[i][0]=2,C[i][1]=0;
		}
	}
	
	FOR(i,N) {
		if(X[C[i][0]]==0 && X[C[i][1]]==0) return _P("No\n");
		if(X[C[i][0]]==1 && X[C[i][1]]==1) {
			if(i==N-1 || C[i][0]==C[i+1][0]) goto pat0;
			if(C[i+1][1]==C[i][0]) goto pat0;
			goto pat1;
			
		}
		else if(X[C[i][0]]>=X[C[i][1]]) {
			pat1:
			T+='A'+C[i][1];
			X[C[i][0]]--;
			X[C[i][1]]++;
		}
		else {
			pat0:
			T+='A'+C[i][0];
			X[C[i][0]]++;
			X[C[i][1]]--;
		}
	}
	cout<<"Yes"<<endl;
	FORR(c,T) cout<<c<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4552
#include<bits/stdc++.h>
using namespace std;
typedef long long hey;
#define hi string
#define pi 3.141592653589793238
#define fi first
#define mod 1000000007
#define se second
#define pb push_back 
#define pop pop_back 
#define bs binary_search
#define mp make_pair
#define ma map< hey,hey >
#define vi vector < hey > 
#define all(v) v.begin(),v.end()
#define qu priority_queue< hey >
#define endl '\n'
#define forn(i, n) for (hey i = 0; i <hey(n); ++i)
#define yorn(i, n) for (hey i = 1; i <=hey(n); ++i)
#define vp vector< pair<hey,hey> >
// lower bound - first element equal to or greater than given value.
// upper bound - first element greater than given value.
hey frog(hey n,hey w,hey a[],hey b[])
{
    hey dp[n+1][w+1];
    forn(i,n+1)
    forn(j,w+1)
    {
        if(i==0||j==0)
        dp[i][j]=0;
        else if(a[i-1]>j)
        dp[i][j]=dp[i-1][j];
        else
        dp[i][j]=max(dp[i-1][j],b[i-1]+dp[i-1][j-a[i-1]]);
    }
    return dp[n][w];
}
void hellogadhi()
{
    hey n,w;
    cin>>n>>w;
    hey a[n],b[n];
    forn(i,n)
    cin>>a[i]>>b[i];
    cout<<frog(n,w,a,b);
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	    hellogadhi();
	}
	return 0;
}


Measured memory_bytes: 79104
N = int(input())
A = [int(_) for _ in input().split()]

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a

A.sort()

x = A[0]
for y in A[1:]:
    x = gcd(x, y)

print(x)



Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
long long n, m;
long long mod(const long long &a){
  if (a >= 0)return a % 1000000007;
  return 1000000007 - (-a) % 1000000007;
}
int mod(const int &a){
  if (a >= 0)return a % 1000000007;
  return 1000000007 - (-a) % 1000000007;
}

int main()
{
  ll ans=1;
  cin >> n;
  VI a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  VLL me(3, 0);
  for (int i = 0; i < n; i++)
  {
    ll cnt = 0;
    for (int j = 0; j < 3; j++)
    {
      if(me[j]==a[i])
        cnt++;
    }
    for (int j = 0; j < 3; j++)
    {
      if (me[j] == a[i])
      {
        me[j]++;
        break;
      }
    }
    ans = mod(ans * cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>

constexpr size_t MAX_HEAP_SIZE = 500000;;
int H[MAX_HEAP_SIZE + 1];

int parent(int i) { return i / 2; }

int left(int i) { return i * 2; }

int right(int i) { return i * 2 + 1; }

int MaxHeapify(int *H, int i, int heap_size) {
    int l = left(i);
    int r = right(i);
    int largest;
    if ((l <= heap_size) && (H[l]) > H[i]) {
        largest = l;
    }else{
        largest = i;
    }
    if ((r <= heap_size) && (H[r] > H[largest])) {
        largest = r;
    }
    if (largest != i) {
        std::swap(H[i], H[largest]);
        MaxHeapify(H, largest, heap_size);
    }
    return 0;
}

int BuildMaxHeap(int *H, int heap_size) {
    for (int i = heap_size / 2; i > 0; i--) {
        MaxHeapify(H, i, heap_size);
    }
    return 0;
}


int main() {
    int n;
    std::cin >> n;
    for (int i = 1; i <= n; i++) std::cin >> H[i];
    BuildMaxHeap(H, n);
    for (int i = 1; i <= n; i++) {
        std::cout << " ";
        std::cout << H[i];
    }
    std::cout << std::endl;
}


Measured memory_bytes: 5048
h,w=map(int,input().split())
SW=[input() for _ in range(h)]

for i in range(1,h-1):
  for j in range(1,w-1):
    if SW[i][j]=='#':
      if SW[i-1][j]=='#' or SW[i+1][j]=='#' or SW[i][j-1]=='#' or SW[i][j+1]=='#':
        pass
      else:
        print('No')
        exit()
print('Yes')

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int a,b,t;
    cin >> a >> b >> t;
    cout << b*(t/a) << endl;
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

def main():
	N = int(input())
	hpp = []
	for _ in range(N):
		a, b, c = map(int, input().split())
		hpp.append((a, b, c))
			
	DP = [[-1 for _ in range(3)] for _ in range(N+1)]
	DP[0][0] = 0
	DP[0][1] = 0
	DP[0][2] = 0
	
	for i, val in enumerate(hpp):
		a, b, c = val
		DP[i+1][0] = max(DP[i][1], DP[i][2]) + a
		DP[i+1][1] = max(DP[i][0], DP[i][2]) + b
		DP[i+1][2] = max(DP[i][0], DP[i][1]) + c
	
	#print(DP)
	print(max(DP[N][2], DP[N][0], DP[N][1]))
	
if __name__ == "__main__":
	main()


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

int wa (int t){
  int ans = 0;
  while(t){
    ans = ans + t % 10;
    t = t / 10;
  }
  return ans;
}

int main (void){
  int n = 0,a = 0,b = 0,c = 0,d = 0;

  cin >> n >> a >> b;

  for(int i = 1;i <= n;i++){
    c = wa(i);
    if(c >= a && c <= b){
      d = d + i;
    }
  }

  cout << d << endl;

  return 0;
}

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


int main() {

    int n;
    cin >> n;
    int a[100010];
    rep(i,n) cin >> a[i];
    int tmp = a[0];
    int cnt = 1;
    for (int i = 0; i < n; ++i) {
        if (tmp == 2) {
            cout << cnt << endl;
            return 0;
        }
        tmp = a[tmp-1];
        ++cnt;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  string a,b;
  for(;;){
    cin >> a >> b;
    if(cin.eof()) break;

    int l=max(a.size(),b.size());
    vector<int> c(l,0),d(l,0);
    for(int i=a.size()-1,j=0; i>=0; i--,j++)
      c[j] = a[i]-'0';
    for(int i=b.size()-1,j=0; i>=0; i--,j++)
      d[j] = b[i]-'0';

    /*    for(int i=0; i<l; i++)
      cout << c[i] << " ";
    cout << endl;

    for(int i=0; i<l; i++)
      cout << d[i] << " ";
      cout << endl; */


    int flag=0;
    for(int i=0; i<l; i++){
      if(c[i]+d[i]+flag>9)
	flag=1;
      else
	flag=0;
    }
    
    cout << l+flag << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <numeric>
#include <map>
#include <set>
#include <limits>

using namespace std;

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


set<piii> s;

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int t=0;
    while(1)
    {
        
        if(s.count(make_pair(a,make_pair(b,c))))
        {
            cout<<"-1"<<endl;
            break;
        }
        s.insert(make_pair(a, make_pair(b, c)));
        if(a%2||b%2||c%2)
        {
            cout<<t<<endl;
            break;
        }
        int da=a/2;
        int db=b/2;
        int dc=c/2;
        a+=dc+db;
        b+=da+dc;
        c+=da+db;
        t++;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  string S;
  cin >> S;
  int count=0;
  if(S.length() == 1){
    cout << "0" << endl;
    return 0;
  } 
  if(S.length()%2 == 0){
    for(int i=0;i<S.length()/2;i++){
      char S2 = S[(S.length()/2)-1-i];
      char S3 = S[i+(S.length()/2)];
      if(S2 != S3){
	count++;
      }
    }
    cout << count <<endl;
  }
  else{
    for(int i=0;i<S.length()/2;i++){
      char S2 = S[(S.length()/2)-1-i];
      char S3 = S[i+1+(S.length()/2)];
      if(S2 != S3){
	count++;
      }
    }
     cout << count <<endl;
  }
  
}


Measured memory_bytes: 256
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()
template <class T>
void chmin(T& ans, const T& b)
{
	if (ans > b) {
		ans = b;
	}
}

template <class T>
void chmax(T& ans, const T& b)
{
	if (ans < b) {
		ans = b;
	}
}

int main()
{
	lolo N, M;
	cin >> N >> M;
	vec A(N + 2, 0);

	lolo be, en;
	be = 1;
	en = N;
	FOR(i, M) {
		lolo L, R;
		cin >> L >> R;
		chmax(be, L);
		chmin(en, R);
	}
	if (en < be) {
		cout << 0 << endl;
	}
	else {
		cout << en - be + 1 << endl;
	}
	
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

namespace Otoshidama
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> listValue = new List<int>();
            listValue.AddRange(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));

            int moneyCnt = listValue[0];
            int moneySum = listValue[1];

            var money = new Money();
            int x = 0;
            int y = 0;
            int z = 0;

            money.utiwake(moneyCnt, moneySum, ref x, ref y, ref z);
            string result = x + " " + y + " " + z;

            // 結果出力
            Console.Write(result);
        }
    }

    class Money
    {
        /// <summary>
        /// お札の内訳
        /// </summary>
        /// <param name="cntMoney">お札数</param>
        /// <param name="sumMoney">合計金額</param>
        /// <param name="itimanCnt">一万円札の数</param>
        /// <param name="gosenCnt">五千円札の数</param>
        /// <param name="senCnt">千円札の数</param>
        public void utiwake(int cntMoney, int sumMoney, ref int itimanCnt, ref int gosenCnt, ref int senCnt)
        {
            itimanCnt = -1;
            gosenCnt = -1;
            senCnt = -1;

            const int itiman = 10000;
            const int gosen = 5000;
            const int sen = 1000;

            // 合計金額がMaxの金額より高い場合、もしくは、Minの金額より低い場合、組み合わせは存在しない
            if ((sumMoney > cntMoney * itiman) || (sumMoney < cntMoney * sen))
            {
                return;
            }

            // 端数分の千円札の枚数を求める
            int hasu = sumMoney % gosen;
            int nokoriCnt = 0;
            int nokoriSum = 0;

            // 端数分の千円の枚数
            int senHasu = 0;

            senHasu = hasu / sen;
            nokoriCnt = cntMoney - senHasu;
            nokoriSum = sumMoney - hasu;

            // 端数を差し引いた枚数、金額で組み合わせを調査する
            for (int itimanSatu = 0; itimanSatu <= nokoriCnt; itimanSatu++)
            {
                int nokoriSatu = nokoriCnt - itimanSatu;
                int maxKingaku = nokoriSatu * gosen;
                int nokori = nokoriSum - (itimanSatu * itiman);

                if (nokori < 0)
                {
                    return;
                }

                if (nokori > maxKingaku)
                {
                    continue;
                }

                for (int gosenSatu = 0; gosenSatu <= nokoriSatu; gosenSatu++)
                {
                    int nokoriSen = nokoriSatu - gosenSatu;
                    int maxKingaku2 = nokoriSen * sen;
                    int nokori2 = nokori - gosenSatu * gosen;

                    if(nokori2 == maxKingaku2)
                    {
                        itimanCnt = itimanSatu;
                        gosenCnt = gosenSatu;
                        senCnt = nokoriSen + senHasu;

                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const LL P = 998244353;

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#endif
	int n;
	string s;
	cin >> n >> s;
	for(int i = 0; i < n * 3; ++i) {
		if(s[i] == 'R') s[i] = 'A';
		else if(s[i] == 'G') s[i] = 'C';
	}
	int a[] = {0, 0, 0}, b[] = {0, 0, 0};
	LL ans = 1;
	for(int i = 0; i < n * 3; ++i) {
		int c = s[i] - 'A';
		if(b[c]) ans = ans * (b[c]--) % P;
		else if(a[c]) a[c]++;
		else if(a[0] + a[1] + a[2] == 0) a[c]++;
		else {
			int qwq = 0;
			for(int i = 0; i < 3; ++i) if(a[i]) {
				++qwq;
				assert(i != c);
				ans = ans * (a[i]--) % P;
				b[3 - i - c]++;
			}
			assert(qwq == 1);
		}
	}
	for(int i = 1; i <= n; ++i) ans = ans * i % P;
	cout << ans << endl;
	return 0;
}


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

int main(){
  int i,j,cnt=0;
  int n,k;
  cin>>n>>k;
  int a[min(k-1,n)+1];
  int p,q;
  for(i=1;i<=min(k-1,n);i++){
    p=i;
    a[i]=0;
    while(p<k){
      p*=2;
      a[i]++;
    }
  }
  ld sum=0;
  for(i=min(k-1,n);i>=1;i--){
    p=1;
    for(j=0;j<a[i];j++)p*=2;
    sum+=1/(ld)p;
  }
  if(k-1<n)printf("%.12llf",sum/(ld)n+(n-k+1)/(ld)n);
  else printf("%.12llf",sum/(ld)n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define ALL(x) begin(x),end(x)
#define ll long long
#define ld long double

int main(){
  string a,b; cin >> a >> b;
  int c = stoi(a+b);
  bool flag = false;
  rep(i,320) if(i*i==c) flag = true;
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3604