akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << x2 + y1 - y2 << " " << y2 + x2 - x1 << " " << x1 + y1 - y2 << " " << y1 + x2 - x1;
}

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

int main()
{
	char x = 'A';
	string str;
	while(cin >> str)
	{
		if(str[0] == x)
		{
			x = str[2];
		}
		else if(str[2] == x)
		{
			x = str[0];
		}
	}
	
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 1172
import sys
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

def main():
    N = int(input())

    Ss = {}
    for x in range(N):
        tmp = ''.join(sorted(sys.stdin.readline().rstrip()))

        if tmp in Ss:
            Ss[tmp] += 1

        else:
            Ss[tmp] = 1


    ans = 0
    for i in Ss.values():
        if i != 1:
            ans += combinations_count(i, 2)

    print(ans)

main()

Measured memory_bytes: 18336
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
 
//  int a, b, c, d, e, X, Y;
  int a, b;
  //  double  c;
  long long  A[1000001]={};
  long long  B[1000001]={};
//  int  B[100003]={};
  int  L[1003]={};

  int  flag[10000003]={};

//  long long  a, b, c, d, X, Y;
  long long  c, d, X, Y;
  long long JPY;
  double BTC;
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
  int tmp=0;
//  int min=1000000;
  long long min=10000000001;
  int len=0;
  int cnt=0;
  int cnt0=0;
  int cnt1=0;
  int num=0;
//  double ans=0.0;
  long long ans=0;
  int max=0;
  int sum=0;
//  char alp[26]={'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'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%s", &s);
  if(s[0]=='A') printf("T\n");
  if(s[0]=='T') printf("A\n");
  if(s[0]=='C') printf("G\n");
  if(s[0]=='G') printf("C\n");


  //    if(max < cnt - max)  printf("Yes\n");
//    else  
  
return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var a = new int[4];
        for (int i = 0; i < 4; i++)
        {
            a[i] = int.Parse(ReadLine());
        }
        WriteLine(Math.Min(a[0], a[1]) + Math.Min(a[2], a[3]));
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define all(cont) cont.begin(), cont.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef set<int> si;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef pair<int, pair<int, int>> pipii;
 
const int INF = 1e9+1;
const int MAX_N = 1e8;
const int mod = 1000000007;
 
const double PI = acos(-1);
const double halfC = PI / 180;



void solve(){
	int n, k;
	cin >> n >> k;
	vi a(n+1);
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	vi dp(n+1, INF);
	dp[1] = 0;
	for(int i = 1; i <= n; ++i){
		if(i-k < 0){
			for(int j = i-1; j >= 0; --j){
				dp[i] = min(dp[i], dp[j]+abs(a[i]-a[j]));
			}
		} else {
			for(int j = i-1; j >= i-k; --j){
				dp[i] = min(dp[i], dp[j]+abs(a[i]-a[j]));
			}
		}	
	}
	cout << dp[n] <<"\n";
}
 
int main(){
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int i = 1, t = 1;
	//cin >> t;
	while(i <= t){
		//cout << "CASE #" << i << ": ";
		solve();
		i++;
	}	
	return 0;
}

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

using namespace std;

bool is_divisible_by(int n, int d) {
	return n%d == 0;
}

void process(int n) {
	vector<int> array(n);
	iota(array.begin(), array.end(), 1);
	
	long long sum = 0;
	for(auto a_i: array) {
		if(is_divisible_by(a_i, 3) && is_divisible_by(a_i, 5) || 
		   is_divisible_by(a_i, 3) ||
		   is_divisible_by(a_i, 5)) {
			continue;
		} else {
			sum += a_i;
		}
	}	
	
	cout << sum << "\n";
}

int main() {
	int n;
	cin >> n;
	process(n);
	return 0;
}

Measured memory_bytes: 7100
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;


int N, M;
vector<int> S, T;
mint dp[2100][2100];

int main() {
    cin >> N >> M;
    S.resize(N), T.resize(M);
    for (int i = 0; i < N; ++i) cin >> S[i];
    for (int i = 0; i < M; ++i) cin >> T[i];

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= M; ++j) {
            if (i-1 >= 0 && j-1 >= 0 && S[i-1] == T[j-1]) dp[i][j] += dp[i-1][j-1];
            if (i-1 >= 0) dp[i][j] += dp[i-1][j];
            if (j-1 >= 0) dp[i][j] += dp[i][j-1];
            if (i-1 >= 0 && j-1 >= 0) dp[i][j] -= dp[i-1][j-1]; // ダブルカウントを除く
        }
    }
    cout << dp[N][M] << endl;
}

Measured memory_bytes: 34816
#include <bits/stdc++.h>
using namespace std;using ll = long long int;int main(){int T,N,k;ll o,l,r;cin>>T;while(T){T--;o=0;cin>>N;vector<ll> P[N],S[N];priority_queue<ll, vector<ll>, greater<ll>> H,T;for(int n=0;n<N;n++){cin>>k>>l>>r;if(l>r){P[k-1].push_back(l-r);o+=r;}else{S[k-1].push_back(r-l);o+=l;}}for(int i=0;i<N;i++){for(int j:P[i])H.push(j);while(H.size()>i+1)H.pop();for(int j:S[N-1-i])T.push(j);while(T.size()>i)T.pop();}while(!H.empty()){o=o+H.top();H.pop();}while(!T.empty()){o=o+T.top();T.pop();}cout<<o<<endl;}}


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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}
    
int main()
{    
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        string s;

        cin>>s;

        li cnt=0,n=s.length();;

        f(i,0,(n-1)/2)
        {
            if(s[i]!=s[n-1-i])
                cnt++;
        }

        cout<<cnt;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A ,B, res;
	cin >> A >> B;
    res = 0;
    if (A >= B) {
        res += A;
        A--;
    }else{
        res += B;
        B--;
    }
    if (A >= B) {
        res += A;
        A--;
    }else{
        res+= B;
        B--;
    }
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
using namespace std;
bool sortAsc(char c, char d){
		return c < d;
}

int main(){
		long int N;
		cin >> N;
		vector<string> words(N);
		for(int i = 0; i < N; ++i){
				string str;
				cin >> str;
				words[i] = str;
		}
		for(int i = 0; i < N; ++i){
				sort(words[i].begin(),words[i].end(), sortAsc);
		}
		sort(words.begin(), words.end());
		/*
		for(int i = 0; i < N; ++i){
				cout << words[i] << endl;
		}
		*/
		long int answer = 0;
		long int i = 0;
		while(i < N - 1){
				long int count = 1;
				for(int j = i + 1; j < N; ++j){
						if(words[i] == words[j]){
								count += 1;
						} else {
								break;
						}
				}
				answer += count *(count - 1)/ 2;
				i = i + count;
		}
		cout << answer << endl;
}



Measured memory_bytes: 7296
import math

n,d = map(int,input().split())
x_list = []
count = 0
sum = 0
dist = 0
for i in range(n):
    x_list.append(list(map(int,input().split())))
for i in range(n-1):
    for j in range(i+1,n):
        for k in range(d):
            sum += (x_list[i][k] - x_list[j][k])**2
        if math.sqrt(sum) % 1 ==0:
            count += 1
        sum = 0    
print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }

  unordered_map<string, ll> m;
  ll ans = 0;
  rep(i, n) {
    ans += m[s[i]];
    m[s[i]]++;
  }
  cout << ans << endl;

  
  return 0;
}


Measured memory_bytes: 17700
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<climits>
#include<cassert>

#define IINF (INT_MAX)
#define MAX 70
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int H,W;
vector<string> G;
vector<string> rot[4];

vector<string> conv(const vector<string>& vec)
{
  int n,e,s,w;
  w = IINF, e = -IINF, n = IINF, s = -IINF;

  for(int y=0;y<vec.size();y++){
    for(int x=0;x<vec[y].size();x++){
      if(vec[y][x] == '.')continue;
      w = min(w,x);
      e = max(e,x);
      n = min(n,y);
      s = max(s,y);
    }
  }

  vector<string> ret;
  for(int y=n;y<=s;y++){
    ret.push_back(vec[y].substr(w,e-w+1));
  }
  return ret;
}

vector<string> rotate90(const vector<string>& piece){
  vector<string> ret;
  int h = piece[0].size(), w = piece.size();
  ret.resize(h);
  for(int i=0;i<h;i++)ret[i].resize(w);
  for(int y=0;y<ret.size();y++){
    for(int x=0;x<ret[0].size();x++){
      ret[y][x] = piece[ret[0].size()-1-x][y];
    }
  }
  return ret;
}

void InitPiece(const vector<string>& piece){
  for(int i=0;i<4;i++){
    vector<string> tmp = piece;
    for(int j=0;j<i;j++){
      tmp = rotate90(tmp);
    }
    rot[i] = tmp;
  }
}

int calc(int sx,int sy,int type){
  int ret = 0;
  int h = rot[type].size(), w = rot[type][0].size();
  if(sx+w-1 >= W)return -1;
  if(sy+h-1 >= H)return -1;
  for(int y=sy;y<sy+h;y++){
    bool ok = true;
    for(int x=0;x<W;x++){
      if(sx <= x && x < sx+w){
	if(G[y][x] == '#' && rot[type][y-sy][x-sx] == '#'){
	  return -1;
	}
	else if(G[y][x] == '.' && rot[type][y-sy][x-sx] == '.'){
	  ok = false;
	}
      }else{
	if(G[y][x] != '#'){
	  ok = false;
	}
      }
    }
    if(ok)ret++;
  }
  return ret;
}

void compute(){
  int ans = -1;
  for(int y=0;y<H;y++){
    for(int x=0;x<W;x++){
      for(int type=0;type<4;type++){
	int res = calc(x,y,type);
	ans = max(ans,res);
      }
    }
  }
  cout << ans << endl;
}

int main(){
  int T,h,w;

  cin >> T;
  while(T--){
    cin >> h >> w;

    vector<string> tmp(h);
    for(int i=0;i<h;i++){
      cin >> tmp[i];
    }

    vector<string> piece = conv(tmp);
    InitPiece(piece);

    cin >> H >> W;
    G.resize(H);
    for(int i=0;i<H;i++){
      cin >> G[i];
    }
    compute();
  }
  return 0;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    for (int i = 0; i < n; ++i)
    	cout << a[i] << b[i];
}

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


int main(void){
    // Your code here!
    int n, m;
    cin>>n>>m;
    
    vector<int> cnt(m, 0);
    
    for(int i=0; i<n; i++){
        int k;
        cin>>k;
        
        for(int j=0; j<k; j++){
            int t;
            cin>>t;
            cnt[t-1]++;
        }
    }
    
    int sum=0;
    for(int i=0; i<m; i++){
        if(cnt[i]==n){
            sum++;
        }
    }
    cout<<sum<<endl;
}


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

using namespace std;

#define ll long long

const ll mod  = 1e9 + 7;
const ll INF = 1e14;

void solve(){

    int n; cin >> n;
    int arr[n];
    for(int i = 0; i < n; ++i) cin >> arr[i];

    ll sm = 0, pr = 0;

    for(int i = n-1; i >= 0; --i){
        pr += (ll)arr[i] * sm;
        sm += arr[i];
        pr %= mod;
        sm %= mod;

        //cout << pr << " " << sm << endl;
    }
    cout << pr;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}



Measured memory_bytes: 4428
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    for (ll b = K + 1; b <= N; b++) {
        ll x = N / b;
        // ll y = max(0LL, ((N % b) - K));
        ll y = max(0LL, (N % b) - max(0LL, (K - 1)));
        ll z = x * (b - K);
        // printf("b: %lld, x: %lld, y: %lld, z: %lld\n", b, x, y, z);
        ans += y;
        ans += z;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  string s;
  cin >> s;

  vector<string> a = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
  int ans;
  if (s == "SUN") {
    ans = 7;
  }
  if (s == "MON") {
    ans = 6;
  }
  if (s == "TUE") {
    ans = 5;
  }
  if (s == "WED") {
    ans = 4;
  }
  if (s == "THU") {
    ans = 3;
  }
  if (s == "FRI") {
    ans = 2;
  }
  if (s == "SAT") {
    ans = 1;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

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

vector<string> board;
int h, w;

void dfs(int x, int y, char c) {
	board[y][x] = '.';
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (board[ny][nx] == c) {
			dfs(nx, ny, c);
		}
	}
}

int solve() {
	int ret = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (board[i][j] == '.') {
				continue;
			}
			dfs(j, i, board[i][j]);
			ret++;
		}
	}

	return ret;
}

int main() {
	string str;

	while (1) {
		cin >> h >> w;
		if (w == 0 && h == 0) {
			break;
		}
		board.assign(h, "");
		for (int i = 0; i < h; i++) {
			cin >> str;
			board[i] = "." + str + ".";
		}
		board.insert(board.begin(), string(w+2, '.'));
		board.push_back(string(w+2, '.'));

		cout << solve() << endl;
	}

	return 0;
}

Measured memory_bytes: 4068
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t,i,sum=100,x;
    cin>>x;
    for(i=1;i<=10000;i++)
    {
        if(sum>=x)
        {
            cout<<i-1;
            break;
        }
        sum=sum+(sum*0.01*1);
        sum=sum/1;
    }
}

Measured memory_bytes: 3636
# include <iostream>
# include <cstring>
using namespace std;
char t[120];
int v[120],n,m,nr,sol,i,j,ok,poz;
int main () {
    sol=1000000;
    cin>>t+1;
    n=strlen(t+1);
    for(j=1;j<=26;j++){
        for(i=1;i<=n;i++)
            v[i]=t[i]-'a'+1;
        ok=0;
        nr=0;
        for(i=1;i<=n;i++)
            if(v[i]==j)
                ok=1;
        if(!ok)
            continue;
        m=n;
        for(;;nr++,m--){
            ok=0;
            for(i=1;i<=m;i++)
                if(v[i]!=j)
                    ok=1;
            if(!ok)
                break;
            for(i=1;i<=m;i++)
                if(v[i]!=j){
                    poz=i;
                    break;
                }
            for(i=poz;i<m;i++)
                if(v[i]==j&&v[i+1]!=j)
                    v[i]=j;
                else
                    v[i]=v[i+1];
        }
        sol=min(sol,nr);
    }
    cout<<sol<<"\n";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var (
		n int
	)

	fmt.Scan(&n)
	max := 1000000000000000000
	a := make([]int, n)
	sum := 1
	for i := range a {
		fmt.Scan(&a[i])
		if a[i] == 0 {
			fmt.Print(0)
			return
		}
	}
	for _, j := range a {
		if j <= max/sum {
			sum *= j
		} else {
			fmt.Print(-1)
			return
		}
	}
	fmt.Print(sum)
}


Measured memory_bytes: 6300
#include<iostream>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	int a[100001], i;
	char c;
	for (i = 0; i < n; i++) {
		cin >> c;
		if (c == 'L')
			a[i] = 1;
		if (c == 'R')
			a[i] = 0;
	}
	int p1 = 0, p2 = n - 1;
	while (a[p1] == a[p1 + 1]) 
		p1++;
	while (a[p2] == a[p2 - 1]) 
		p2--;
	if (p1 + 1 >= p2) {
		cout << n - 1 << endl;
		return 0;
	}
	int p3, p4;
	for (i = p1 + 1; i < p2; ) {
		p3 = i;
		while (a[p3] == a[0])
			p3++;
		p4 = p3 + 1;
		while (a[p4] ==a[p3])
			p4++;
		if (k > 0) {
			k--;
			for (int j = p3; j < p4; j++) {
				a[j] = (a[j] + 1) % 2;
			}
		}
		i = p4 + 1;
		if (k == 0)
			break;
	}
	int m = 0;
	for (int q = 1; q < n; q++) {
		if (a[q] == a[q - 1])m++;
		
	}
	p1 = 0, p2 = n - 1;
	while (a[p1] == a[p1 + 1])
		p1++;
	while (a[p2] == a[p2 - 1])
		p2--;
	if ((p1 + 1 == p2) && k > 0)m++;
	cout << m << endl;
	return 0;
}

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

int main(){
  long n, a, b,c, res = 0;
  cin >> n >> a >> b;
  long base = n /(a+b);
  c = n % (a+ b);
  if(c > a)
    c = a;
  res = base*a + c;
  cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var A = int.Parse(s[0]);
            var B = int.Parse(s[1]);

            Console.WriteLine(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0 ? "Possible" : "Impossible");
        }
    }
}

Measured memory_bytes: 13140
N, K = [int(x) for x in input().split()]
mod = 1000000007
l = [pow(K//x, N, mod) for x in range(1, K+1)]
l.insert(0, 0)
ans = 0
for i in range(K, 0, -1):
    t = i * 2
    while(t <= K):
        l[i] -= l[t]
        t += i
for i in range(K+1):
    ans = (ans + l[i] * i) % 1000000007
if ans < 0:
    ans = 1000000007 - ans
print(ans)

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

int main(){
int N,K;
cin >> N >> K;
int d;
set<int> S;
for(int i=0;i<K;i++){
cin >> d;
vector<int> vec(d);
for(int j=0;j<d;j++){
    cin >> vec.at(j);
}
for(int x : vec){
    S.insert(x);
} 
}
cout << N - S.size() << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

void solve() {

	string S;

	cin >> S;
	int ans = 0;
	REP(i, S.size()) {
		if (S[i] == '+') ans++;
		else ans--;
	}

	out(ans);

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 256
S = input()
N = len(S)
dp = [[0] * 2 for _ in range(N + 1)]

if N == 1:
    print(1)
    exit()

if S[0] == S[1]:
    dp[0][0] = 0
    dp[1][1] = 1
    dp[0][1] = 1
    dp[1][0] = 1
else:
    dp[0][0] = 0
    dp[0][1] = 1
    dp[1][0] = 1
    dp[1][1] = 2

for i in range(2, N):
    if S[i - 1] != S[i]:
        dp[i][1] = dp[i - 1][1] + 1
        dp[i][0] = dp[i - 2][1] + 1
    else:
        dp[i][1] = dp[i - 1][0] + 1
        dp[i][0] = dp[i - 2][1] + 1
print(max(dp[N - 1][0], dp[N - 1][1]))


Measured memory_bytes: 36384
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    int a, b;
    cin >> a >> b;
    if((a+b)%2==1) {
        print((a+b-1)/2+1);
    } else {
        print((a+b)/2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN];
vector<int> comp;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) cin>>A[i], comp.pb(A[i]);
	sort(all(comp));
	for (int i=1; i<=n; i++) A[i]=lower_bound(all(comp), A[i])-comp.begin()+1;
	for (int i=2; i<=n; i+=2) ans+=(A[i]&1);
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 1148
#include<bits/stdc++.h>
#define int long long int
#define inf 1000000000000
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    string s;
    cin>>s;
    string res="";
    res.append(s.length(),'x');
    cout<<res;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

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

    int ans = 1;
    for(int i=1; i<N; i++){
        if(S[i] != S[i-1]) ans++;
    }
    cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    
    int gcd_all = 0;
    for (int i = 0; i < n; i++) {
        gcd_all = gcd(gcd_all, a.at(i));
    }
    if (gcd_all != 1) {
        puts("not coprime");
        return 0;
    }

    bool pairwise = true;
    vector<int> count(1000001);
    for (int i = 0; i < n; i++) {
        count.at(a.at(i))++;
    }

    for (int i = 2; i <= 1000000; i++) {
        int s = 0;
        for (int j = i; j <= 1000000; j += i) {
            s += count.at(j);
        }
        if (s >= 2) {
            pairwise = false;
        }
    }

    if (pairwise) {
        puts("pairwise coprime");
    } else {
        puts("setwise coprime");
    }
}


Measured memory_bytes: 11100
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

import math
import decimal

ctx = decimal.Context(prec=100, rounding=decimal.ROUND_CEILING)

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    _max = (int(((decimal.Decimal(b, context=ctx) - decimal.Decimal(r, context=ctx)) / decimal.Decimal(g, context=ctx)).to_integral_exact(context=ctx)) * g) + r - g
    #_max = ((math.ceil((b - r) / g)) * g) + r - g
    #_max = ((b - r + g - 1)//g) * g + r - g
    if c < _max:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 74220
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] a = new int[n];
        Arrays.setAll(a, i -> sc.nextInt());
        sc.close();
        int[] v = new int[n+1];
        Arrays.fill(v, -1);
        ArrayList<Integer> list = new ArrayList<>();
        int c = 1;
        int l = 0;
        {
            int m = 1;
            while(v[m] == -1) {
                v[m] = list.size();
                list.add(m);
                m = a[m-1];
            }
            c = list.size() - v[m];
            l = v[m];
        }
        
        int res;
        if (k < (long)l) {
            res = list.get((int)k);
        } else {
            k -= l;
            k %= c;
            res = list.get(l+(int)k);
        }
        
        System.out.println(res);
    }
}

Measured memory_bytes: 62284
import sys
from collections import deque,defaultdict

A = defaultdict(deque)
sys.stdin.readline().split()
ans =[]
for query in sys.stdin:
    if query[0] == "0":
        t,x = query[2:].split()
        A[t].append(x)
    elif query[0] == "1":
        ans.append(" ".join(A[query[2:-1]]) + "\n")
    else:
        s,t = query[2:].split()
        if A[t]:
            if len(A[s]) == 1:
                A[t].append(A[s][0])
            elif len(A[t]) == 1:
                A[s].appendleft(A[t][0])
                A[t] = A[s]
            else:
                A[t].extend(A[s])
        else:
            A[t] = A[s]
        A[s] = deque()
sys.stdout.writelines(ans)



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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int ctoi(char c) {
  return c - '0';
}

template <class C>
void printContainer(C &container, const char *delim=",") {
  for(const auto &e : container) {
    std::cout << e << delim;
  }
  std::cout << "\n";
}

// Greatest common divisor
template<class T>
T gcd(T x, T y) {
  if(x < y) {
    std::swap(x, y);
  }
  T r = x % y;
  while(r != 0) {
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

// Least common multiple
template<class T>
T lcm(T x, T y) {
  return (x*y)/gcd(x,y);
}

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout<<(a+b)*h/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;                                                         int main(){                                                                    int a,b;
  cin >> a >> b;
  if(a<=5) cout << 0 << "\n";
  else if(a<=12) cout << b/2 << "\n";
  else cout << b << "\n";
  return 0;                                                                  }


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

int main(){
  int n;
  cin>>n;
  for(int i=0;i<26;i++){
    for(int j=0;j<15;j++){
      if(n==i*4+j*7){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
W=87,i,n;char a[100002],s[100002];f(x,y){*a=x;a[1]=y;for(i=0;++i<=n;)a[i+1]=a[i]==W^a[i-1]==W^s[i]=='o'?83:W;*a==a[n]&a[1]==a[n+1]?a[n]=0,puts(a),exit(0):0;}main(){scanf("%d%s",&n,&s);s[n]=*s;s[n+1]=s[1];f(83,83);f(83,W);f(W,83);f(W,W);puts("-1");}

Measured memory_bytes: 384
#!/usr/bin/python
# -*- coding: utf-8 -*-

def main():
    while(True):
        # 入力
        N = int(raw_input())
        if N == 0:
            break

        inp = []
        for x in range(N):
            input_list = map(int, raw_input().split())
            inp.append(input_list)

        printAns(inp)

def printAns(num_list):
    add_list = []
    for x in num_list:
        x.append(sum(x))
        add_list.append(x)

    total_list = [sum(x) for x in zip(*add_list)]
    add_list.append(total_list)
    print5digit(add_list)

def print5digit(num_list):
    for x in num_list:
        print "".join(map(lambda x_: str(x_).rjust(5), x))
        # for y in x:
        #     print("{0:4d}".format(y)),
        # else:
        #     print

if __name__=='__main__':
    main()

Measured memory_bytes: 4236
#include <iostream>
using namespace std;
 
int main(){
    string s, t;
    cin >> s >> t;
 
    int match = 0;
    for (int i = 0; i < s.length() - t.length() + 1; i++)
    {
        int match_ = 0;
        for (int j = 0; j < t.length(); j++)
        {
            if (s[i+j] == t[j]) match_ ++;
        }
        match = max(match, match_);
    }
    cout << t.length() - match << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#define debug(a) {for (int i=1; i<=nn; i++) cout << a[i] << ' '; cout << endl;}
using namespace std;
const int maxn = 100010;
const int modd = 1000000007;
int ok[maxn], f[maxn], nn, n;
/*void inarr()
{
    cin >> n;
    for (int i=1; i<=n; i++) cin >> a[i];
}*/
int main()
{
    //freopen("inp.txt","r",stdin);
    cin >> nn >> n;
    int tmp;
    for (int i=1; i<=n; i++) cin >> tmp, ok[tmp] = 1;
    f[0] = 1;
    for (int i=1; i<=nn; i++){
        if (!ok[i-1]) f[i] += f[i-1] % modd;
        if (i >= 2 && !ok[i-2]) f[i] = (f[i] + f[i-2]) % modd;
    }
    cout << f[nn];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll ans=0;
  FOR(D,1,n){
    ll cnt=0;
    rep(i,n-D){
      if(s[i]==s[i+D]&&cnt<D){
        cnt++;
      }
      else{
        cnt=0;
      }
      ans=max(ans,cnt);
    }
  }
  cout << ans << endl;
}


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

int main(){
  int n;
  int a[100];
  int mini;
  int temp;
  int cnt=0;

  cin >> n;

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

  for(int i=0;i < n;i++){
    mini = i;
    for(int j=i;j < n;j++){
      if(a[j] < a[mini]){
	mini = j;
      }
    }
    temp = a[mini];
    a[mini] = a[i];
    a[i] = temp;
    if(mini != i) cnt++;
  }
  
  for(int i=0;i < n;i++){
    if(i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> x, y;
    int _x, _y;

    while (1)
    {
        cin >> _x >> _y;
        if (_x > _y)
        {
            swap(_x, _y);
        }
        if (_x == 0 && _y == 0)
        {
            break;
        }
        x.push_back(_x);
        y.push_back(_y);
    }
    for (int i = 0; i < x.size(); i++)
    {
        cout << x[i] << " " << y[i] << endl;
    }
    //system("pause");
    return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>
int main(void)
{
  int n, m, i;
  scanf("%d%d", &n, &m);
  for (i = 1; i < 1250; i++)
  {
    if (((int)(i * 0.08) == n) && ((int)(i * 0.1) == m))
    {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string S;
    cin>>N>>S;
    vector<char>T(0);
    bool D =true;
    if (N%2==1)
    {
        cout << "No"<<endl;
    }
    else
    {
        for (int i = 0; i < N/2; i++)
        {
            T.push_back(S[i]);
        }
        for (int i = 0; i < N/2; i++)
        {
            T.push_back(S[i]);
        }
        for (int i = 0; i < N; i++)
        {
            if (T[i]!=S[i])
            {
                D = false;
            }
            
        }
        if (D)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
        
        
    }
    
}

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

#define int long long
const int INF = LLONG_MAX/10;

int K, S;

signed main()
{
	cin >> K >> S;
	int ans = 0;
	for (int i = 0; i <= K; i++)
	{
		for (int j = 0; j <= K; j++)
		{
			int k = S - i - j;
			ans += 0 <= k && k <= K;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      vector<int> path(6);
      cin >> path.at(0) >> path.at(1);
      cin >> path.at(2) >> path.at(3);
      cin >> path.at(4) >> path.at(5);
      sort(path.begin(), path.end());
     if(path.at(0)==path.at(2) || path.at(1)==path.at(3) || path.at(2)==path.at(4) || path.at(3)==path.at(5)) {
     cout << "NO" << endl;
     }
     else { cout << "YES" << endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define LL long long
using namespace std;
template<typename T>void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if (c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-48;
	x*=f;
}
int n,m;
int gcd(int a,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
char s[100010],t[100010];
int main(){
	read(n);read(m); 
	LL ans=1ll*n*m/gcd(n,m);
	scanf("%s",s);scanf("%s",t);
	for(int i=0,j=0;i<n&&j<m;){
		if(i*ans/n==j*ans/m){
			if(s[i]!=t[j]){puts("-1");return 0;}
			i++;j++;
		}
		else if(i*ans/n<j*ans/m) i++;
		else j++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
void main() {
	auto N = ri;
	ulong m, s;
	foreach(i; 0..N) {
		auto ip = readAs!(int[]), A = ip[0], B = ip[1];
		if(m < A) {
			m = A;
			s = B;
		}
	}
	(m+s).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 1276
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    a, b, k = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(list)
    d[a]
    d[b]
    for i in range(a, min(a + k, b)):
        d[i]
    for i in range(b, max(b - k, a), -1):
        d[i]
    d = sorted(d.keys())
    print(*d, sep='\n')


if __name__ == '__main__':
    slove()


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

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

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;

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

    int n, a;
    cin >> n >> a;

    cout << n * n - a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long answer=0;
  int N,K;
  cin>>N>>K;
  unordered_map<int,long long> mp;
  for(int i=1;i<=N;i++){
    mp[i%K]++; 
  }
  for(int i=1;i<=N;i++){
    if((2*i)%K==0){
      answer+=mp[(K-i%K)%K]*mp[(K-i%K)%K];
    }
  }
  cout<<answer<<endl;
}

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

using namespace std;

#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define int long long
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define MOD 1000000007

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

signed main()
{
    fast_IO;
    int test = 1;
    // cin >> test;
    while(test--)
    {
        string s;
        cin >> s;
        int cnt = 0;
        for(auto x: s)
            cnt += x - '0';
        if(cnt % 9 == 0)
            cout << "Yes";
        else cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;


int main() {
    ll n,ans = 0;
    cin >> n;
    if(n%2 == 1) cout << 0 << endl;
    else{
        n /= 2;
        while(n){
            ans += n/5;
            n /= 5;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def fact(n, k, mod):
    res = 1
    for i in range(k):
        res = res * (n - i) % mod
    return res

def c(x, y, mod):
    y = min(y, x - y)
    return (fact(x, y, mod) * pow(fact(y, y, mod), mod - 2, mod)) % mod

P = 10**9 + 7
n, a, b = map(int, input().split())
print((pow(2, n, P) - 1 - c(n, a, P) - c(n, b, P)) % P)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}

const double pi=acos(-1);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    double A,B; int H,M; cin >> A >> B >> H >> M;
    double diff=5.5*(60*H+M);
    while(diff>360) diff-=360;
    if (diff>180) diff=360-diff;
    cout << sqrt(A*A+B*B-2*A*B*cos(diff/360*2*pi)) << '\n';
}

Measured memory_bytes: 4180
#include<stdio.h>
#include<algorithm>
int main()
{
	int a,b,A[9],B[9],i,x,y,T;
	double s;
	for(scanf("%d",&T);T--;)
	{
		for(i=0;i<9;++i)scanf("%d",&A[i]);
		for(i=0;i<9;++i)scanf("%d",&B[i]);
		std::sort(B,B+9);
		s=a=b=0;
		do
		{
			for(i=x=y=0;i<9;++i)
				if(A[i]>B[i])x+=A[i]+B[i];
				else y+=A[i]+B[i];
			if(x>y)++a;
			else if(x<y)++b;
			++s;
		}while(std::next_permutation(B,B+9));
		printf("%.5f %.5f\n",a/s,b/s);
	}
	return 0;
}

Measured memory_bytes: 788
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Plan[] plan = new Plan[n];

        for(int i = 0; i<n; i++) {
            plan[i] = new Plan(sc.nextInt(), sc.nextInt());
        }

        Arrays.sort(plan, (ca,cb)->(ca.b - cb.b));

        long total = 0;
        for(int i = 0; i<n; i++) {
            total += plan[i].a;
            if(plan[i].b<total) {
                System.out.println("No");
                return;
            }
            if(total > 1000000000) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");

    }
}
class Plan {
    int a,b;
    public Plan(int a, int b) {
        this.a = a;
        this.b = b;
    }
}

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

int main() {
  int a, b;
  cin >> a >> b;

  int difference = b - a; //difference番目と(diference - 1)番目の塔の話と分かる
  int height = 0;
  for(int i = 1; i < difference + 1; i++){
    height += i; //difference番目の塔の高さ
  }
  int snow_height = height - b;

  cout << snow_height << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll a,b,c,d;
int32_t main(){
CODE_START;
cin>>a>>b>>c>>d;
ll x,y;
x=(a+d-1)/d;
y=(c+b-1)/b;
if(x>=y){
    cout<<"Yes"<<endl;
}else cout<<"No"<<endl;
}



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

int main() {
  int n;
  cin >> n;
  int a[n];
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> result;
  for (i = 0; i < n; i++) {
    if ((i % 2 == 0) ^ (n % 2 != 0)) {
      result.push_back(a[i]);
    } else {
      result.insert(result.begin(), a[i]);
    }
  }
  for (i = 0; i < n; i++) {
    cout << result[i] << ' ';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3828
aa, bb, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

couponMin = float("INF")
for i in range(m):
    x, y, c = map(int, input().split())
    cc = a[x - 1] + b[y - 1] - c
    couponMin = min(couponMin, cc)

print(min(min(a) + min(b), couponMin))




Measured memory_bytes: 18608
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//10000は100で2回割り切れてしまうので、D==1のときはいれない
int main(){
  ll A,B,C;
  cin >> A >> B >> C;
  ll K;
  cin >> K;

  //Aが最大
  if(A >= B && A >= C)
  {
    REP(i,K)A *= 2;

  }
  else if(B >= A && B >= C)
  {
    REP(i,K)B *= 2;
  }
  else
  {
    REP(i,K)C *= 2;
  }

  cout << A + B + C << endl;

  return 0;

}

Measured memory_bytes: 256