akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N,C; cin >> N >> C;
    vector<vi> d(C,vi(C));
    rep(i,C) rep(j,C) cin >> d[i][j];
    vector<vi> c(N,vi(N));
    rep(i,N) rep(j,N){
        cin >> c[i][j];
        c[i][j]--;
    }

    vector<vi> cnt(3, vi(C,0));
    rep(i,N) rep(j,N){
        cnt[(i+j)%3][c[i][j]]++;
    }

    ll ans = LINF;
    rep(c0,C){
        rep(c1,C){
            if(c0 == c1) continue;
            rep(c2,C){
                if(c0 == c2 || c1 == c2) continue;

                ll cost = 0;
                rep(i,C){
                    cost += d[i][c0] * cnt[0][i];
                    cost += d[i][c1] * cnt[1][i];
                    cost += d[i][c2] * cnt[2][i];
                }

                chmin(ans,cost);
            }
        }
    }
    cout << ans << endl;
}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2==1)
        cout<<"No";
    else
    {
        for(int i = 0 ; i<n/2 ; i++)
        {
            if(s[i]!= s[i+(n/2)])
            {
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    }
    return 0;
}


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

using namespace std;
using ll = long long;

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

  int d, t, s;
  cin >> d >> t >> s;
  double tt = 1.0 * d / s;
  if (tt <= t) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}


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

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

int a[100010],dp[100010];

int main(void){
	int N,K;
	cin >> N >> K;
	REP(i,N) cin >> a[i];
	memset(dp, 0x7f, sizeof(dp));
	dp[0] = 0;
	REP(i,N)
		for(int j=i+1; j<=i+K; j++)
			if(j < N)
				dp[j] = min(dp[j] , dp[i] + abs(a[i] - a[j]));
	cout << dp[N-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
    #include <string>
    #include <vector>
    #include <bits/stdc++.h>
    #define ll long long
    #define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
     
    using namespace std;
     
    int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
     
    int main(){
        int N; cin >> N;
        set<string>S;
        ll ans = 1;
     
        for (int i = 0; i < N; i++){
          string a;  cin >> a;
          S.insert(a);
        }
        
        cout << S.size() << endl;
        
        return 0;
        
    }

Measured memory_bytes: 19132
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int n, v, cnt=0;
  long double ans;
  vector<int> num;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v;
    num.push_back(v);
  }
  
  sort(num.begin(), num.end());
  
  for(int i : num) {
    cnt++;
    if (cnt == 1) {
      ans += i;
    }else {
      ans = (ans + i) / 2;
    }
  }

  cout << ans << endl;
}

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

using namespace std;

char x[7][4][5] = {
  {
    "1100",
    "1100",
    "0000",
    "0000"
  },
  {
    "1000",
    "1000",
    "1000",
    "1000"
  },
  {
    "1111",
    "0000",
    "0000",
    "0000"
  },
  {
    "0100",
    "1100",
    "1000",
    "0000"
  },
  {
    "1100",
    "0110",
    "0000",
    "0000"
  },
  {
    "1000",
    "1100",
    "0100",
    "0000"
  },
  {
    "0110",
    "1100",
    "0000",
    "0000"
  }
};

int main(void) {
  vector<string> input(8);
  while (cin >> input[0]) {
    for (int i = 1; i < 8; i++) {
      cin >> input[i];
    }

    char s[11][11];
    memset(s, '0', sizeof(s));

    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        s[i][j] = input[i][j];
      }
    }

    int ans = -1;
    for (int i = 0; i < 7; i++) {
      for (int j = 0; j < 8; j++) {
        for (int k = 0; k < 8; k++) {
          bool find = true;
          for (int l = 0; l < 4; l++) {
            for (int m = 0; m < 4; m++) {
              find &= s[j + l][k + m] == x[i][l][m]; 
            }
          }
          if (find) ans = i;
        }
      }
    }

    cout << (char)(ans + 'A') << endl;
  }

  return 0;
}


Measured memory_bytes: 3120
fun main(args: Array<String>) {
    val N = nextInt()
    var X = listOfInt().sorted()
    val left = X.first()
    val right = X.last()
    val P = IntArray(right - left + 1)
    var p = left
    while (p <= right) {
        var s = 0
        X.forEach {
            val d = it - p
            s +=  d * d
        }
        P[p - left] = s
        p += 1
    }
    var ans = P.min()!!
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)


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

using namespace std;

int main(){
	#ifdef EVAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	string S;
	cin >> S;
	sort(S.begin(),S.end());
	if(S[0] == S[1] && S[2] == S[3] && S[1] != S[2]){
		cout << "Yes";
	}else{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=200000+10;

int n,k,a[N]; ll s[N];
ll S[N]; int top=0;

int c[N];
void add(int x,int y) { for (;x<=top;x+=x&-x) c[x]+=y; }
int sum(int x) { int s=0; for (;x;x-=x&-x) s+=c[x]; return s; }

int main() {
	n=read(),k=read();
	for (int i=1;i<=n;++i) a[i]=read();
	for (int i=1;i<=n;++i) s[i]=s[i-1]+a[i];
	for (int i=0;i<=n;++i) S[++top]=s[i]-1ll*k*i;
	sort(S+1,S+top+1); top=unique(S+1,S+top+1)-S-1;
	ll ans=0;
	for (int i=0;i<=n;++i) {
		int p=lower_bound(S+1,S+top+1,s[i]-1ll*k*i)-S;
		if (i) ans+=sum(p);
		add(p,1);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  //cout << fixed << setprecision(15);
  int h,w;cin>>h>>w;
  vector<string> vec1(h);
  rep(i,h)cin>>vec1[i];
  rep(i,h){
    cout<<vec1[i]<<endl;
    cout<<vec1[i]<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

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

    int s1=0, s0 = 0;

    rep(i, s.size()) {
        if(s[i] == '1') s1++;
        else s0++; 
    }

    cout << min(s1, s0) * 2 << endl;

    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    for(int i=1;i<10;i++){
        if(N%i == 0 && N/i < 10){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[100005];
char s[100005];
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i=k-n+1;i<=k+n-1;i++) printf("%d ", i);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


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

	for (int i = 1; i < 10000; ++i) {
		int num = 0;
		for (int j = 1; j <= i; ++j) {
			if (i%j == 0)num++;
		}
		if (num == N) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
    int main(void){
        int N;
            cin >> N;
        for(int i = 0; i <= 25; i++){
            for(int j = 0; j <= 14; j++){
                if(N == 4*i + 7*j){
                    cout << "Yes" << endl;
                        return 0;
                }
            }
        }
            cout << "No" << endl;
    return 0;}


Measured memory_bytes: 256
a500 = int(input())
b100 = int(input())
c50 = int(input())
x = int(input())
count = 0
for i in range(a500 + 1):
  for j in range(b100 + 1):
    for k in range(c50 +1 ):
      if 500*i + 100*j + 50*k == x:
        count = count + 1
print(count)
      

Measured memory_bytes: 9012
n = int(input())
l = []
for i in range(n-1):
    tmp = list(map(int,input().split()))
    l.append(tmp)
import math
for i in range(n):
    time=0
    now=i
    while now < n-1:
        if time > l[now][1]:
            tmp = math.ceil((time - l[now][1]) / l[now][2])
            wait = tmp * l[now][2]  - (time - l[now][1])
            time+= wait + l[now][0]
        else:
            time+=l[now][1] - time + l[now][0]
        now+=1

    print(time)

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int sum = a[0] + a[1] + a[2];
    if (sum >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut ans: u8 = 0;

    for i in 0..s.len()/2 {
        if s[i] != s[s.len() - 1 - i] {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

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

        int n = stdIn.nextInt();

        int [] a = new int [n];

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

        int acc = 1;

        Outer:
            for(int i=1; i<a.length; i++){
                for(int j=0; j<i; j++){
                    if(a[i]<a[j]){
                        continue Outer;
                    }
                }
                acc++;
            }

        System.out.println(acc);
    }
}

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

int main() {
  ll a;
  cin >> a;
  for (int i = 1; i <= 3500; i++) {
    for (int j = 1; j <= 3500; j++) {
      ll t1 = a * i * j;
      ll t2 = - (a * i) - (a * j) + (4 * i * j);
      if (t2 == 0) continue;
      if (t1 % t2 == 0) {
        if (t1/ t2 < 0) continue;
        cout << i << " " << j << " " << (t1 / t2) << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

vector<ll> divisor(ll n){
    vector<ll> v;
    for(ll i=1; i*i<=n; i++){
        if(n % i == 0){
            v.emplace_back(i);
            v.emplace_back(n / i);
        }
    }

    sort(v.begin(), v.end());

    return v;
}

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

    ll a, b; cin>>a>>b;
    auto div = divisor(a);

    vector<ll> v;
    for(auto i : div){
        if(b % i == 0) v.emplace_back(i);
    }

    int ans = 1;
    for(auto i : v){
        if(i == 1) continue;
        bool prime = true;
        for(ll j=2; j*j<=i; j++){
            if(i % j == 0){
                prime = false;
            }
        }

        if(prime) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#define rep(i,n) for(int i=0;i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
        int a,b;
        cin >> a >> b;
        cout << 2*b -a << endl;
}

Measured memory_bytes: 256
import math
n = int(input())
if n == 1:
  print(0)
  exit()

arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        arr.append([i, cnt])

if temp!=1:
    arr.append([temp, 1])
if arr==[]:
    arr.append([n, 1])

ans = 0
for i in arr:
  if i[1] == 1 or i[1] == 2:
    ans += 1
  else:
    ans = ans + int(-1/2 + math.sqrt(1+8*i[1])/2)
print(ans)

Measured memory_bytes: 9492
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll mod     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 10000 + 10;
const ll N2      = 70;
const ld PI      = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE  
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main(){
    fastio();
    //cout<<fixed<<setprecision(20);
    string s; 
    cin>>s; 
    ll ans=0;
    for(ll i=0;i<s.length();i++){
      ans+=(s[i]-'0');
    }
    if(ans%9==0){
      cout<<"Yes";
    }
    else{
      cout<<"No";
    }
    //printclock;
    return 0;
}
    

Measured memory_bytes: 3768
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    String in_number_str;
    long   in_number;
    int    digit_num;
    int    digit_sum;
    int    cnt;


    try
    {
      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      in_number_str = in_str_split[0];
      in_number     = Integer.parseInt(in_number_str);


      digit_num = in_number_str.length();
      digit_sum = 0;
      for(cnt=0; cnt<digit_num; cnt++)
      {
        digit_sum += Integer.parseInt(in_number_str.substring(cnt, cnt+1));
      }

      if(0 == (in_number % digit_sum))
      {
        UtilLog.ans_f("Yes");
      }
      else
      {
        UtilLog.ans_f("No");
      }


    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
string number;
 
while(1){
cin >> number;
if (number == "0") break;
int a=0,b=0,i;
for(i=0 ;i < number.length(); ++i){
a=number[i]-'0';
b=b+a;
}
cout << b << endl;
}
    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;


int main(){
    
    string s; cin>>s;
    int st,gt;
    for(st=0;st<s.size();st++)if(s[st]=='A')break;
    for(gt=(int)s.size()-1;gt>=0;gt--)if(s[gt]=='Z')break;
    
    cout<<abs(st-gt)+1<<endl;
    
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#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 FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;

    ll res = 1;
    FOR(i, 1, N) {
        if (S[i-1] != S[i]) {
            res += 1;
        }
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string s;
int mod = 998244353;
map < string , int > f;
map < string , int > g;
int F( string s );
int G( string s ){
	if ( g.find( s ) != g.end() )
    	return g[s];
    if ( s.size() == 1 )
    	return g[s] = s[0] - '0' + 1;
    for ( int i = 1 ; i < s.size() ; ++i )
    {
        if ( s.size() % i == 0 )
        {
            string t;
            for ( int j = 0 ; j < i ; ++j )
            {
                int r = 1;
                for ( int k = 0 ; k < s.size() / i ; ++k )
                if ( s[i*k+j] == '0' )
                r = 0;
                t += ( char ) ( r + '0' );
            }
            g[s] = ( g[s] + F( t ) ) % mod;
        }
    }
    return g[s];
}
int F( string s ){
	if ( f.find( s ) != f.end() )
    	return f[s];
    for ( int i = 1 ; i <= s.size() ; ++i )
    f[s] = ( f[s] + 1ll * F( s.substr( 0 , s.size() - i ) ) * G( s.substr( s.size() - i , i ) ) %mod ) % mod;
    return f[s];
}
int main(){
	cin >> s;
	f[""] = 1;
	cout << F( s ) << endl;
	return 0;
}

Measured memory_bytes: 13056
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<int> facts;
    for (int i = 1; i * i <= m; i++) {
        if (i * i == m) {
            facts.push_back(i);
        } else if (m % i == 0) {
            facts.push_back(i);
            facts.push_back(m / i);
        }
    }
    sort(all(facts));
    int ans = 1;
    for (int i : facts) if (i <= m / n) chmax(ans, i);
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<vector<int>> dp(n + 1, vector<int>(n + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (s[i - 1] == s[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
    }
  }
  int r = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      r = max(r, min(abs(i - j), dp[i][j]));
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 98176
#include<stdio.h>

int main(){
  int H, W, N;
  int sum, cnt;
  
  scanf( "%d %d %d", &H, &W, &N);
  sum = 0;
  cnt = 0;
  while (sum < N)
  {
    if( H >= W){
      sum += H;
      W--;
    } else {
      sum += W;
      H--;
    }
    cnt++;
  }
  
  printf("%d", cnt);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

using namespace std;

void solve()
{
   int n,k;
   cin>>n>>k;
   vector<int> dp(n),v(n);

   for(int i=0;i<n;i++)
   {
    cin>>v[i];
   }
   dp[0]=0;

   for(int i=1;i<n;i++)
   {
    dp[i] = INT_MAX;
    for(int j=1;j<=k;j++)
    if(i-j>=0)
    dp[i] = min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
    else
    break;
   

   }

   cout<<dp[n-1]<<endl;



}
signed main()

{
    FAST_IO;
    int t = 1;

    // cin>>t;

    while(t--)
    {
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
typedef long double ld;
const int MAXN = 305;

ld dp[MAXN][MAXN][MAXN];

ld f(int a, int b, int c, int N) {
	if(dp[a][b][c]) return dp[a][b][c];
	if(a+b+c == 0) return 0;
	dp[a][b][c] = N;
	if(a) dp[a][b][c] += a * f(a - 1, b, c, N);
	if(b) dp[a][b][c] += b * f(a +1, b - 1, c, N);
	if(c) dp[a][b][c] += c * f(a, b + 1, c - 1, N);
	dp[a][b][c] /= (a + b + c);
	return dp[a][b][c];
}

int main() {
	int N;
	cin >> N;
	vector<int> F(4);
	for(int i=0; i<N; i++) {
		int a;
		cin >> a;
		F[a]++;
	}
	
	cout << fixed << setprecision(21) << f(F[1], F[2], F[3], N) << endl;
	
	return 0;
}

Measured memory_bytes: 436480
import java.util.Scanner;

//Run Length
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[] s = sc.next().toCharArray();
			StringBuilder sb = new StringBuilder();
			int i = 0;
			while(i<s.length){
				if(s[i]=='@'){
					int x = s[++i]-'0';
					i++;
					while(x--!=0)sb.append(s[i]);
				}
				else sb.append(s[i]);
				i++;
			}
			System.out.println(sb);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
 
int main(){
  string s;
  cin>>s;
  int dp[200000][2]={0};
  dp[0][0]=1;
  if (s[0]==s[1]) dp[1][1]=1;
  for (int i(0);i<s.size();i++){
    if (s[i]!=s[i+1] && i <= s.size()-2) dp[i+1][0] = max(dp[i+1][0],dp[i][0]+1);
    dp[i+1][0] = max(dp[i+1][0],dp[i][1]+1);
    if (i == 0){
      dp[i+2][1] = max(dp[i+2][1],dp[i][0]+1);
      continue;
    }
    if (i <= s.size()-3&& s[i-1]+s[i] != s[i+1]+s[i+2]){
      dp[i+2][1] = max(dp[i+2][1],dp[i][1]+1);
    }
    dp[i+2][1] = max(dp[i+2][1],dp[i][0]+1);
  }
  cout << max(dp[s.size()-1][0],dp[s.size()-1][1]) << endl;
  return 0;
}

Measured memory_bytes: 2180
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
	long long a,b;
}sh[100000+36];
bool cmp(node x,node y)
{
	return x.a<y.a;
}
int main()
{
	long long n,i,j;
	long long m;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&sh[i].a,&sh[i].b);
	}
	long long ans=0;
	sort(sh+1,sh+n+1,cmp);
	for(i=1;i<=n;i++)
	{
		if(sh[i].b>=m)
		{
			ans+=m*sh[i].a;
			cout<<ans<<endl;
			return 0;
		}
		else 
		{
			ans+=sh[i].a*sh[i].b;
			m-=sh[i].b;	
		}
	}
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
const int INF = 10000;
int main() {
  vector<int> food(5);
  rep(i, 5) cin >> food[i];
  vector<int> idx = {0, 1, 2, 3, 4};
  int ans = INF;
  do {
    int et = 0;
    rep(i, 5) {
      et = 10 * ((et + 9) / 10);
      et += food[idx[i]];
    }
    ans = min(ans, et);
  } while(next_permutation(all(idx)));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

bool check(ll n4,ll n3,ll n2,ll n1) {
  if(n1==0) {
    if((n2==1&&n3==2)||(n2==1&&n4==2)||(n3==1&&n4==2)||(n2==2&&n3==1)) return true;
  }
  if(n2==0) {
    if((n3==1&&n4==2)||(n1==1&&n3==2)||(n3==2&&n4==1)) return true;
  }
  if(n3==0) {
    if(n2==1&&n4==2) return true;
  }
  return false;
}

int main() {
  ll n;
  cin >> n;
  vector<vector<mat>> dp(n+1,vector<mat>(5,mat(5,vec(5))));
  map<char,ll> ch;
  dp[0][4][4][4]=1;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<4;j++) {
      for(ll k=0;k<5;k++) {
        for(ll l=0;l<5;l++) {
          for(ll m=0;m<5;m++) {
            if(check(j,k,l,m)) continue;
            dp[i+1][j][k][l]=(dp[i+1][j][k][l]+dp[i][k][l][m])%mod;
          }
        }
      }
    }
  }
  ll ans=0;
  for(ll i=0;i<4;i++) {
    for(ll j=0;j<4;j++) {
      for(ll k=0;k<4;k++){
        ans=(ans+dp[n][i][j][k])%mod;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  string s;
  cin >> s;

  int m = n / 2;

  if (m * 2 < n) {
    cout << "No" << endl;
    return 0;
  }


  string t = s.substr(0, m);
  if ((t + t) == s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
while True:
    N=int(input())
    if N== -1:
        break
    S=1150
    if N>30:
        S=S+(N-30)*160
        N-=N-30
    if N>20:
        S=S+(N-20)*140
        N-=N-20
    if N>10:
        S=S+(N-10)*125
    print(4280-S)


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

int main() {
	int N;
	static long long ans = -1145141919810364364, A[300000], SumL, SumR, Left[100010], Right[100010];
	priority_queue<long long, vector<long long>, greater<long long> > PQ1;
	priority_queue<long long> PQ2;
	cin >> N;
	for (int i = 0; i < N * 3; i++) {
		cin >> A[i];
		if (i < N) PQ1.push(A[i]), SumL += A[i];
		if (N * 2 <= i) PQ2.push(A[i]), SumR += A[i];
	}
	Left[0] = SumL, Right[0] = SumR;
	for (int i = 1; i <= N; i++) {
		if (PQ1.top() < A[N + i - 1]) {
			SumL -= PQ1.top();
			SumL += A[N + i - 1];
			PQ1.pop();
			PQ1.push(A[N + i - 1]);
		}
		Left[i] = SumL;
	}
	for (int i = 1; i <= N; i++) {
		if (PQ2.top() > A[N * 2 - i]) {
			SumR -= PQ2.top();
			SumR += A[N * 2 - i];
			PQ2.pop();
			PQ2.push(A[N * 2 - i]);
		}
		Right[i] = SumR;
	}
	for (int i = 0; i <= N; i++) {
		ans = max(ans, Left[i] - Right[N - i]);
	}
	cout << ans;
}

Measured memory_bytes: 5876
import sys

#+++++
		
def main():
	n,t = map(int, input().split())
	tl=list(map(int, input().split()))
	
	counter=0
	pre_end=0
	for ti in tl:
		if ti < pre_end:
			counter+=t+ti-pre_end
		else:
			counter+=t
		
		pre_end=ti+t
	
	print(counter)
	
	
#+++++


if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 26708
n,k = map(int,input().split())

if k == 0:
    print(n ** 2)
    exit()

ans = 0
for b in range(k+1,n+1):
    ans += (b - k)*(n//b)
    if n % b >= k > 0:
        ans += n%b - k + 1
    elif n%b >= k:
        ans = n%b - k
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
typedef long long ll;
using namespace std;

int main(void){
    int n,T,ans=2000;cin>>n>>T;
    for(int i=0;i<n;i++){
        int c,t;cin>>c>>t;
        if(t<=T){
            ans=min(ans,c);
        }
    }
    if(ans==2000)cout<<"TLE\n";
    else cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
ll dp[41][401][401];

int main(int argc, char const* argv[])
{
  int n, ma, mb;
  cin >> n >> ma >> mb;
  vector<int> a, b, c;
  int asum = 0, bsum = 0;
  for(int i = 0; i < n; i++){
    int x, y, z;
    cin >> x >> y >> z;
    a.pb(x);
    b.pb(y);
    c.pb(z);
    asum += x;
    bsum += y;
  }
  for(int i = 0; i <= asum; i++){
    for(int j = 0; j <= bsum; j++){
      dp[0][i][j] = inf;
    }
  }
  dp[0][0][0] = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j <= asum; j++){
      for(int k = 0; k <= bsum; k++){
        dp[i + 1][j][k] = dp[i][j][k];
        if(j - a[i] >= 0 && k - b[i] >= 0)dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j - a[i]][k - b[i]] + c[i]);
      }
    }
  }
  int res = inf;
  for(int i = 1; ma * i <= asum; i++){
    int A = i * ma;
    int B = i * mb;
    if(B <= bsum)res = min((ll)res, dp[n][A][B]);
  }
  if(res == inf)cout << -1 << endl;
  else cout << res << endl;
	return 0;
}


Measured memory_bytes: 50944
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn],f[maxn][2];
int n;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	f[1][0]=f[1][1]=1;
	for(int i=2;i<=n;i++){
		f[i][0]=f[i][1]=0;
		if(a[i]>=a[i-1])f[i][0]|=f[i-1][0],f[i][1]|=f[i-1][1];
		if(a[i]-1>=a[i-1])f[i][1]|=f[i-1][0];
		if(a[i]>=a[i-1]-1)f[i][0]|=f[i-1][1];
	}
	puts((f[n][0]||f[n][1])?"Yes":"No");
	return 0;
}

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

int main(void)
{
    int n, k;
    cin >> n >> k;
    vector<int> loc(n);
    rep (i, n) cin >> loc[i];
    int total = 0;
    rep (i, n) total += min(loc[i], k-loc[i]);
    cout << total * 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[4]; 
int main()
{
	int n=3,i,s=0;
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(i=0;i<n-1;i++)
		s+=abs(a[i]-a[i+1]);
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
		int B = sc.nextInt();
		int  ans = 0;


		if(A > 9) {
			System.out.println("-1");
		}else if( B > 9) {
			System.out.println("-1");
		}else {
			System.out.println(A*B);
		}
		
		
		

   		sc.close();
        return ;

    }
    
}



Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int MAXN = 3e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-9;
const double PI=3.1415926535897932;

LL v[200009][2];
int taken[200009][2];
vector<pair<LL,PII> > dc;

int main(){
	DRI(n);
	if(n==1){puts("0");return 0;}
	REP(i,n){
		scanf("%lld %lld",&v[i][0],&v[i][1]);
		if(v[i][0]>v[i][1])swap(v[i][0],v[i][1]);
	}
	REP(i,n){
		dc.PB(MP(v[i][0],MP(i,0)));
		dc.PB(MP(v[i][1],MP(i,1)));
	}
	sort(ALL(dc));//dc[0].F is BLUE
	LL ans=INF;
	int fb=0,lb=SZ(dc)-1;
	int fr=0,lr=0;
	if(dc[fb].S.F!=dc[lb].S.F){
		REP(i,SZ(dc)){
			if(dc[i].S.F==dc[fb].S.F&&dc[i].S.S!=dc[fb].S.S)fr=i;
			if(dc[i].S.F==dc[lb].S.F&&dc[i].S.S!=dc[lb].S.S)lr=i;
		}
		if(fr>lr)swap(lr,fr);
		//printf("%d %d %d %d\n",fb,lb,fr,lr);
		int r=-1;
		int rtaken=0;//reds taken!
		REPP(l,1,fr+1){
			r=max(l-1,r);
			while(r+1<lr){
				r++;
				if(r==lb)continue;
				taken[dc[r].S.F][dc[r].S.S]=1;
				rtaken+=(!taken[dc[r].S.F][dc[r].S.S^1]);
			}
			while(r+1<SZ(dc)&&rtaken<n){
				r++;
				if(r==lb)continue;
				taken[dc[r].S.F][dc[r].S.S]=1;
				rtaken+=(!taken[dc[r].S.F][dc[r].S.S^1]);
			}
			/*REP(i,n){
				REP(j,2)printf("%d",taken[i][j]);puts("");
			}puts("");*/
			if(rtaken==n){
				ans=min(ans,(LL)(dc[lb].F-dc[fb].F)*(dc[r].F-dc[l].F));
			}
			taken[dc[l].S.F][dc[l].S.S]=0;
			rtaken-=(!taken[dc[l].S.F][dc[l].S.S^1]);
		}
	}
	LL minmax=1<<30,maxmin=-1<<30;
	REP(i,n){
		maxmin=max(maxmin,v[i][0]);
		minmax=min(minmax,v[i][1]);
	}
	ans=min(ans,(LL)(maxmin-dc[0].F)*(LL)(dc.back().F-minmax));
	printf("%lld",ans);
}


Measured memory_bytes: 13548
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    int sum = 0;
	string N;
	cin >> N;
    for (int i = 0; i < N.length(); ++i){
        sum += (int)N[i] - 48;
    }

    cout << (sum % 9 == 0 ? "Yes" : "No") << endl; 
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		ArrayList<Integer> x1=new ArrayList<Integer>();
		ArrayList<Integer> y1=new ArrayList<Integer>();
		ArrayList<Integer> x2=new ArrayList<Integer>();
		ArrayList<Integer> y2=new ArrayList<Integer>();
		int count=0;
		int a[][] =new int[H][W];
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				a[i][j]=in.nextInt();
			}
		}
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				if(W>1&&a[i][j]%2==1&&W-1>j) {
					a[i][j]-=1;
					a[i][j+1]+=1;
					count++;
					x1.add(i+1);
					y1.add(j+1);
					x2.add(i+1);
					y2.add(j+2);
					
				}else if(H>1&&a[i][j]%2==1&&H-1>i){
					a[i][j]-=1;
					a[i+1][j]+=1;					
					count++;
					x1.add(i+1);
					y1.add(j+1);
					x2.add(i+2);
					y2.add(j+1);
				}
			}
		}
		System.out.println(count);
		for(int i=0;i<x1.size();i++) {
			System.out.println(x1.get(i)+" "+y1.get(i)+" "+x2.get(i)+" "+y2.get(i));
		}
		
	}
}

Measured memory_bytes: 121488
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (b < a) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(1e6) + 5;
const ll oo = 1e18;
int s[N];
vector < pii > g[N];
struct st
{
    ll ans;
    int color;
    st(void)
    {
        ans = oo;
        color = -1;
    }
    st(ll a,int b) : ans(a),color(b) {}
};
const st OO = st(oo,-1);
st operator + (st a,ll b)
{
    return st(a.ans + b,a.color);
}
bool operator < (st a,st b)
{
    if (a.ans != b.ans)
        return (a.ans < b.ans);
    return a.color < b.color;
}
pair < st , st > dp[N];
pair < st , st > operator + (pair < st , st > a,st b)
{
    if (a.fi.color == b.color)
        smin(a.fi.ans,b.ans);
    else
    if (a.se.color == b.color)
        smin(a.se.ans,b.ans);
    else
        a = min({a,mp(a.fi,b),mp(b,a.fi)});
    if (a.fi.ans > a.se.ans)
        swap(a.fi,a.se);
    return a;
}
int f[N];
int get(int k)
{
    return k == f[k] ? k : f[k] = get(f[k]);
}
void dfs(int node,int prev)
{
    for (auto it : g[node])
        if (it.fi != prev)
            dfs(it.fi,node),dp[node] = dp[node] + (dp[it.fi].fi + it.se) + (dp[it.fi].se + it.se) + st(s[it.fi] + it.se,get(it.fi));
}
int n;
st D[N];
ll answer = 0;
void pr(st ans)
{
    cerr << ans.ans << ' ' << ans.color << '\n';
}
void DFS(int node,int prev)
{
    for (auto it : g[node])
        if (it.fi != prev)
            dp[it.fi] = dp[it.fi] + (dp[node].fi + it.se) + (dp[node].se + it.se) + st(s[node] + it.se,get(node)),DFS(it.fi,node);
}
void go(void)
{
    for (int i = 1;i <= n;++i)
        dp[i] = mp(OO,OO),D[i] = OO;
    dfs(1,0);
    DFS(1,0);
    for (int i = 1;i <= n;++i)
        smin(D[get(i)],(dp[i].fi.color == get(i) ? dp[i].se : dp[i].fi) + s[i]);
    for (int i = 1;i <= n;++i)
        if (i == get(i) && get(i) != get(D[i].color))
            answer += D[i].ans,f[get(i)] = get(D[i].color);
    for (int i = 1;i <= n;++i)
        f[i] = get(i);
}
int main(void)
{
    cin>>n;
    for (int i = 1;i <= n;++i)
        cin>>s[i];
    for (int i = 1;i < n;++i)
    {
        int a,b,c;
        cin>>a>>b>>c;
        g[a].pb(mp(b,c));
        g[b].pb(mp(a,c));
    }
    for (int i = 1;i <= n;++i)
        f[i] = i;
    while (*min_element(f + 1,f + 1 + n) != *max_element(f + 1,f + 1 + n))
        go();
    cout << answer << '\n';
    return 0;
}


Measured memory_bytes: 125952
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

template <ll Modulus = 1000000007>
class modint {
 public:
  ll a;

  constexpr modint(const ll x = 0) noexcept : a(x % Modulus) {}
  constexpr ll& value() noexcept { return a; }
  constexpr const ll& value() const noexcept { return a; }
  constexpr modint operator+(const modint& rhs) const noexcept { return modint(*this) += rhs; }
  constexpr modint operator-(const modint& rhs) const noexcept { return modint(*this) -= rhs; }
  constexpr modint operator*(const modint& rhs) const noexcept { return modint(*this) *= rhs; }
  constexpr modint operator/(const modint& rhs) const noexcept { return modint(*this) /= rhs; }
  constexpr modint& operator+=(const modint& rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint& operator-=(const modint& rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint& rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    ll exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
using mint = modint<>;

mint kaijo(mint a) {
  mint ans = 1;
  for (ll i = 1; i <= a.a; i++) {
    ans *= i;
  }
  return ans;
}

int main() {
  ll X, Y;
  cin >> X >> Y;

  // 1:2, 2:1以内の比が成立すること
  if (X > Y) swap(X, Y);  // Yを大きくする
  if ((double)Y / (double)X > 2.0) {
    // 成立しない。
    cout << 0 << endl;
    return 0;
  }

  // 合計が3の倍数であること
  if ((X + Y) % 3 != 0) {
    // 成立しない。
    cout << 0 << endl;
    return 0;
  }

  // 足して見て3で割るとパスカル三角形の階層深さが出る。
  ll depth = (X + Y) / 3;
  // 差分を出す
  ll diff = Y - X;
  // 差分とdepthの差を2で割ればコンビネーションの値
  ll combi_value = (depth - diff) / 2;

  // nCm の計算。n=depth、m=combi_valueでよい。
  mint bunshi = kaijo(depth);
  mint bunbo = kaijo(combi_value) * kaijo(depth - combi_value);
  mint ans = bunshi / bunbo;
  cout << ans.a << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define endl '\n'
#define mod (int)(1e9+7)
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;
int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
int fibonacci(int n){
    double phi = (1 + sqrt(5))/(double)2;
    int nth_fib = round(pow(phi,n)/sqrt(5));
    return nth_fib;
}
int inv_mod(int a){
    int res = 1;
    int mod_temp = mod-2;
    while(mod_temp){
        if(mod_temp&1){
            res = ((res%mod)*(a%mod))%mod;
        }
        a = ((a%mod)*(a%mod))%mod;
        mod_temp >>= 1;
    }
    return res%mod;
}
signed main(){

#ifndef ONLINE_JUDGE
    //freopen("input.txt","r", stdin);
#endif
    fastIO

    int h, a;
    cin >> h >> a;
    int ans = h/a +1;
    if(h%a == 0) ans--;
    cout << ans;




    return 0;
}


Measured memory_bytes: 256
N,K = map(int ,input().split())
D = []
A = []
for _ in range(K):
  D.append(int(input()))
  A.append(list(map(int, input().split())))

# 各人ごとに、持っているお菓子の個数を数え、個数0の人数を出力する
l = [0]*N
for i in range(K):
  for j in range(D[i]):
    l[A[i][j]-1] +=1

print(l.count(0))

Measured memory_bytes: 9128
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(K+A[0])

l = []
for i in range(1, N+1):
    l.append(abs(A[i-1] - A[i]))
l.pop(l.index(max(l)))
print(sum(l))

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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI v(n);
    REP(i, n) cin >> v[i];
    sort(ALL(v));

    double ans = (double)v[0] / pow(2, n - 1);
    FOR(i, 1, n - 1) ans += (double)v[i] / pow(2, n - i);
    cout << fixed << setprecision(10) << ans << ln;
    return 0;
}


Measured memory_bytes: 4112
#include <cstdio>

inline int min(int x, int y) {return x < y ? x : y;}

inline int dist(int x, int y) {return x < y ? y - x : x - y;}

int ans[2005];

int main()
{
    //freopen("a.in", "r", stdin);
    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);
    for(int i = 1; i < n; i++)
    for(int j = i + 1; j <= n; j++)
    {
        int w = min(min(dist(i, x) + 1 + dist(y, j), dist(i, y) + 1 + dist(x, j)), dist(i, j));
        ans[w]++;
    }
    for(int i = 1; i < n; i++)
        printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 128