akhauriyash/Code-Regression huggingface dataset:
// YOU THINK YOU KNOW ME.//


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int                      long long
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define countbit                __builtin_popcount
#define loop(i,a,n)				for(int i=a;i<n;i++)
#define pb                      push_back
#define pf                      push_front
#define mp                      make_pair
#define f                       first
#define s                       second
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define boost                   ios_base::sync_with_stdio();cin.tie(0);cout.tie(0);
#define cases                   int tests;cin>>tests;while(tests--)
#define all(s)                  s.begin(),s.end()
#define line                    cout<<endl;
#define watch(x)                cout<<(#x)<<" is "<<x<<endl
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rich_set;
bool isprime(int n){if(n==1)return false;if(n==2)return true;for(int i=2;i<=sqrt(n);i++){if(n%i==0){ return false;}}return true;}
int poww(int b,int e){if(e==0)return 1;else if(e%2==0){int a=pow(b,e/2);return a*a;}else {int a=pow(b,e/2);return b*a*a;}}
int powm(int x,int y,int m=MOD){x=x%m;int res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
int modInverse(int a, int m=MOD) { return powm(a, m-2, m);}
void print(vector<int>v){for(int i=0;i<v.size();i++){cout<<v[i]<<" ";}}
void print(int arr[]){int size = *(&arr + 1) - arr; for(int i=0;i<size;i++){cout<<arr[i]<<" ";}}
string to_bin(int n){string res="";int i=0;while(n>0){if(n%2==1){res=res+'1';}else{res=res+'0';}n/=2;i++;}reverse(all(res));return res;}
int to_dec(string s){int n=s.size(),ans=0,temp=1;for(int i=n-1; i>=0; i--){int x=s[i]-'0';ans+=x*temp;temp*=2;}return ans;}
void result(bool f){if(f)cout<<"YES"<<endl;else cout<<"NO"<<endl;}



void solve(){
	int n;
    cin>>n;
    int arr[n];
    loop(i,0,n){
        cin>>arr[i];
    }
    int dp[n+5];
    dp[0]=0;
    for(int i=1;i<n;i++){
        int one = abs(arr[i]-arr[i-1])+ dp[i-1];
        int two = inf;
        if(i!=1){
            two = abs(arr[i]-arr[i-2]) + dp[i-2];
        }
        dp[i]=min(one ,two);
    }
    cout<<dp[n-1]<<endl;
}
int32_t main(){
	boost
  //cases
	solve();	
	
	//return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

//順列を入力し、条件を満たす数を計算するクラス
class DividetheProblems{
    vector<int> vec; //入力された数列を格納する配列
    int answer; //整数Kの選び方の数
    void func0(); //変数answerを求める関数
public:
    DividetheProblems(vector<int> vec0);
    void print(); //変数answerを出力
};

DividetheProblems::DividetheProblems(vector<int> vec0) : vec(move(vec0)){
    //vec = move(vec0); //引数の配列をメンバ変数に格納
    func0(); 
}

//変数answerを求める関数
void DividetheProblems::func0(){
    sort(vec.begin(),vec.end()); //配列の値を昇順で並べ替え
    int centerIndex = vec.size() / 2; //配列の中心右のインデックスを求める
    answer = vec[centerIndex] - vec[centerIndex - 1]; //中心の2つの整数の差が答え 
}

void DividetheProblems::print(){
    cout << answer << endl;
}

int main(void){
    int N = 0;
    vector<int> vec;
    cin >> N; //配列の要素数を決定
    //配列の要素を入力
    vec.reserve(N + 1);
    for(int i = 0; i < N; i++){
        int value;
        cin >> value;
        vec.push_back(value);
    }
    DividetheProblems dp(move(vec));
    dp.print();
    return 0;
}


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

using namespace std;

#define long long long
#define INF ((long) 1e18)
#define MOD 1000000007
#define mll map<long, long>
#define pll pair<long, long>
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)
#define PRINTV(v) \
  FOR (_i, 0, v.size()) \
    cout << v[_i] << " "; \
  cout << "\n";

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

  long n;
  cin >> n;

  long x0 = 0, y0 = 0, t0 = 0;
  while (n--) {
    long t, x, y;
    cin >> t >> x >> y;
    long dt = t - t0;
    long dx = abs(x - x0);
    long dy = abs(y - y0);
    long d = dx + dy;
    if (not (dt >= d and (dt - d) % 2 == 0)) {
      puts("No");
      return 0;
    }
    t0 = t;
    x0 = x;
    y0 = y;
  }
  puts("Yes");
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int count,sum,max,min;
	int result[5];
	while(cin >> count){
		if(count == 0) break;
		max = 0; 
		min = 500;
		for(int k=0;k<count;k++){
			sum = 0;
			for(int i=0;i<5;i++){
				cin >> result[i];
				sum += result[i];
			}
			if(sum > max){
				max = sum;
			}
			if(sum < min){
				min = sum;
			}
		}
		cout << max << " " << min << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<class T>//ex) auto dp = make_vec(4,4,4,INF);
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

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


int main() {

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

	Int N, T;
	cin >> N >> T;

	vector<vector<Int>> ab(N, vector<Int>(2));
	for (Int i = 0; i < N; i++) {
		cin >> ab[i][0] >> ab[i][1];
	}

	auto dp = make_vec(N + 1, T, 2,0LL);//dp[i+1][j][k]: i番目までの料理の中で時間j以内となる最大うまさ k=1の時、既にT-1分時点で注文する商品が決まっている
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < T; j++) {
			for (Int k = 0; k < 2; k++) {
				if (k==0) {
					//i番目を取らない場合
					chmax(dp[i + 1][j][k], dp[i][j][k]);

					//i番目をT-1分に取る場合
					chmax(dp[i + 1][j][1], dp[i][j][k] + ab[i][1]);

					//i番目を普通に取る場合
					if (j + ab[i][0] < T) {
						chmax(dp[i + 1][j + ab[i][0]][k], dp[i][j][k] + ab[i][1]);
					}
				}
				else {
					//i番目を取らない場合
					chmax(dp[i + 1][j][k], dp[i][j][k]);

					//i番目を普通に取る場合
					if (j + ab[i][0] < T) {
						chmax(dp[i + 1][j + ab[i][0]][k], dp[i][j][k] + ab[i][1]);
					}
				}
			}
		}
	}


	Int ans = 0;
	for (Int k = 0; k < 2; k++) {
		chmax(ans, dp[N][T-1][k]);
	}

	cout << ans << "\n";
}


Measured memory_bytes: 493056
/*
生の整数xのの各桁をすべて足して得られる数の3乗がxになるとき、この数xをデュードニー数といいます。たとえば、
512は8の3乗で、5+1+2=8となるので512はデュードニー数です。
この問題では、デュードニー数と似た数を考えて、その個数をもとめます。
負でない整数a、2以上の整数n、および上限値mが与えられる。このとき、xの各桁をすべて足して得られる数についてyについて、
x=(y+a)n乗となるm以下の正の整数xの個数を入力するプログラムを作りなさい。
<入力>
a n m
0<=a<=50
2<=n<=10
1000<=m<=100000000(1e8)
*/
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
long long val(long long x){
	long long sum=0;
	while(x){
		sum+=x%10;
		x/=10;
	}
	return sum;
}
int main(void){
	long long a,n,m;
	cin>>a>>n>>m;
	int cnt=0;
	for(int y=1;y<=72;y++){
		long long x=1;
		for(int t=1;t<=n;t++){
			x*=(y+a);
		}
		if(x<=m&&val(x)==y)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<stdio.h>
#include<ctype.h>
using namespace std;
int main()
{
	double a, b, p, q, r;
	cin >> a >> b >> p >> q >> r;
double x = b * p;
	double y = (b - a) * q;
	double ans = (x - y) / (q + r);
	cout << ans + b << endl;
}



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

int main(void){
  vector<int> x(5);
  for(int i=0;i<5;i++){
    cin>>x.at(i);
  }
  int ans;
  for(int j=0;j<5;j++){
    if(x.at(j)==0) ans=j+1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
# ABC044 B - 美しい文字列 / Beautiful Strings
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()
SS = set()
for s in S:
    SS.add(s)

for ss in SS:
    if S.count(ss)%2==1:
        print('No')
        exit()
print('Yes')


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

int main(){
  string S;
  cin >> S;
  if(S.at (2)==S.at (3)&&S.at (4)==S.at (5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

signed main(){
  int N;
  cin>>N;
  std::vector<int> a(N),b(N);
  for(int i=0;i<N;i++)cin>>a[i];
  for(int i=0;i<N;i++)cin>>b[i];
  int ans=0;
  std::vector<int> va(N),vb(N);
  int pp=2;
  for(int k=0;k<30;k++){
    for(int i=0;i<N;i++){
      va[i]=a[i]%pp;
      vb[i]=b[i]%pp;
    }
    int f=0;
    sort(vb.begin(),vb.end());
    for(int i=0;i<N;i++){
      int m=-1;
      int A=pp/2-va[i];
      if(vb[0]>=A)m=0;
      if(vb[N-1]<A)m=N;
      if(m==-1){
        int l=1;
        int r=N-1;
        m=(l+r)/2;
        while(vb[m]<A||vb[m-1]>=A){
          if(vb[m]<A)l=m+1;
          else r=m;
          m=(l+r)/2;
        }
      }
      int m1=m;//cout<<m1<<" ";
      m=-1;
      A=pp-va[i];
      if(vb[0]>=A)m=0;
      if(vb[N-1]<A)m=N;
      if(m==-1){
        int l=1;
        int r=N-1;
        m=(l+r)/2;
        while(vb[m]<A||vb[m-1]>=A){
          if(vb[m]<A)l=m+1;
          else r=m;
          m=(l+r)/2;
        }
      }
      int m2=m;//cout<<m2<<" ";
      f+=m2-m1;
      m=-1;
      A=pp/2+pp-va[i];
      if(vb[0]>=A)m=0;
      if(vb[N-1]<A)m=N;
      if(m==-1){
        int l=1;
        int r=N-1;
        m=(l+r)/2;
        while(vb[m]<A||vb[m-1]>=A){
          if(vb[m]<A)l=m+1;
          else r=m;
          m=(l+r)/2;
        }
      }
      m1=m;//cout<<m1<<" ";
      m=-1;
      A=pp-va[i]+pp;
      if(vb[0]>=A)m=0;
      if(vb[N-1]<A)m=N;
      if(m==-1){
        int l=1;
        int r=N-1;
        m=(l+r)/2;
        while(vb[m]<A||vb[m-1]>=A){
          if(vb[m]<A)l=m+1;
          else r=m;
          m=(l+r)/2;
        }
      }
      m2=m;//cout<<m2<<endl;
      f+=m2-m1;
    }
    ans+=(f%2)*pp/2;
    pp*=2;
    //cout<<f<<" "<<ans<<endl;
  }
  cout<<ans<<endl;
}


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

using ll = long long;

bool f(ll x, vector<ll> a) {
  ll v = a.at(x);
  for(int i = 0; i < a.size(); i++){
    if(i == x) continue;
    if(a.at(i) <= 2 * v) v += a.at(i);
    else return false;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  int left = -1, right = n - 1, mid;
  while(left + 1 < right){
    mid = (left + right) / 2;
    if(f(mid, a)) right = mid;
    else left = mid;
  }
  
  cout << n - right << '\n';
}

Measured memory_bytes: 1792
n, m = map(int, input().split())

ab = []
for _ in range(n):
    ab.append(list(map(int, input().split())))

cd = []
for _ in range(m):
    cd.append(list(map(int, input().split())))

tmp = []
for i in range(n):
    ans = 10**9 +7
    ta = 0
    for j in range(m):
        x  = abs(ab[i][0] - cd[j][0])
        y =  abs(ab[i][1] - cd[j][1])
        if ans > x+y:
            ans = x+y
            ta = j+1
    print(ta)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int n;
    int a[2010];
    cin >> n;
    REP(i,n) cin >> a[i];
    sort(a,a+n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (a[i] + a[j] > a[k]) {
                    ans++;
                } else {
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int A,B,C;
	int S[3];

	scanf("%d %d %d",&S[0],&S[1],&S[2]);

	int tmp,i,j,count=0;
	int delta1;

	//soart
	for(i=0;i<3;i++){
		for(j=i+1;j<3;j++){
			if(S[i]>S[j]){
				tmp=S[i];
				S[i]=S[j];
				S[j]=tmp;
			}
		}
	}


	delta1 = S[2]-S[1];
	count+=delta1;
	S[0] += delta1;
	while(S[0]<S[2]){
		S[0]+=2;
		count++;
	}
	if(S[2]<S[0])	count++;

	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

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

int main(){
    ll n; cin >> n;
    ll a[n]; rep(i,0,n) cin >> a[i];

    // 因数に2を含むなら、隣の因数は2じゃないと4の倍数にならない
    // 因数に4を含むなら、隣の因数は1でも4の倍数になる
    // 各a[i]の因数をチェック
    // 因数に2も4も含まないのがn/2より多くある = 構成不可能
    //                     n/2より少ない = それをkとすると4の因数を持つものもk必要
    //実は、nが奇数ならinsu[0]の条件は緩和される
    //n=3のとき、insu[0]は2まで許容されるし、insu[2]はinsu[0]-1まで許容される
    ll insu[3] = {0,0,0}; //因数に2も4も含まない、2は含む、4も含むa[i]の数
    rep(i,0,n){
        if(a[i] % 4 == 0) insu[2]++;
        else if(a[i] % 2 == 0) continue;
        else insu[0]++;
    }
    if(insu[0] > (n+1)/2) cout << "No" << ednl;
    else if(insu[0] <= insu[2] + (n % 2 == 1 ? 1 : 0)) cout << "Yes" << ednl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 1024
N, M, C = gets.split(' ').map(&:to_i)
B = gets.split(' ').map(&:to_i)
A = []

for n in 0..(N-1) do
 A[n] = gets.split(' ').map(&:to_i)
end

count = 0
A.each.with_index do |a, i|
  sum = 0
  for n in 0..(M-1) do
    sum = sum + a[n] * B[n]
  end
  count = count + 1 if (sum+C) > 0
end

puts count


Measured memory_bytes: 1788
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt();

        while (w != -1) {
            int total = 0;
            if (w > 10) {
                if (w <= 20) {
                    total += (w - 10) * 125;
                 
                } else {
                    total += 1250;
                    if (w > 20) {
                        if (w <= 30) {
                            total += (w - 20) * 140;
                           
                        } else {
                            total += 1400;
                            if (w > 30) {
                                total += (w - 30) * 160;
                            }
                        }
                    }

                   
                }

            }
                        System.out.println(4280 - (1150 + total));
                    w = scan.nextInt();
        }
    }
}


Measured memory_bytes: 26164
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
#include <map>
#include <list>
#include <set>

using namespace std;

typedef long long ll;
#define rep(i, s, n) for(int i=(s); i<(int)(n); i++)
#define endl "\n"

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p=-1){
    for(int u : to[v]){
        if(u == p){
            continue;
        }
        ans[u] += ans[v];
        dfs(u, v);
    }
}

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

    int n, q;
    cin >> n >> q;

    rep(i, 0, n-1){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i, 0, q){
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);

    rep(i, 0, n-1){
        cout << ans[i] << " ";
    }
    cout << ans[n-1] << endl;

    return 0;
}

Measured memory_bytes: 23552
#include <stdio.h>
#include <algorithm>
#include <deque>
#include <vector>
using namespace std;


int a[(int)1e5 + 2];
int c[(int)1e5 + 2];

main()
{
	int n, ans = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]), c[a[i]]++;
	sort(a + 1, a + 1 + n);
	for(int i = 1; i <= n; i++)
		ans = max(ans, c[a[i]] + c[a[i] - 1] + c[a[i] + 1]);
	printf("%d", ans);
}


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

int main(){
  int A,B;
  cin >> A >> B;

  rep(i,10000){
    if(floor(i*0.08)==A && floor(i*0.1)==B){
      cout << i <<endl;
      return 0;
    }
  }
  cout << -1 <<endl;


  return 0;
}





Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<String,Set<Integer>> list = new TreeMap<>();
        while (sc.hasNext()) {
            String word = sc.next();
            int number = sc.nextInt();

            if(list.containsKey(word)) {
                list.get(word).add(number);
            }else {
                list.put(word, new TreeSet<Integer>(Arrays.asList(number)));
            }
        }
        list.entrySet().stream().map(e->e.getKey()+"\n"+e.getValue().stream().map(Object::toString).collect(Collectors.joining(" "))).
        forEach(System.out::println);
    }
}



Measured memory_bytes: 32780
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp
import itertools
import functools

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

N=rs()
Ni = int(N)
S=sum(int(s) for s in N)
print(YN[Ni%S==0])

Measured memory_bytes: 4212
#include <iostream>
#include <string>
using namespace std;
long long sumbet(long long a, long long b){
    long long c = b-a+1;
    if(c%2==0){
        return (b+a)*c/2;
    }else{
        return (b+a)*(c-1)/2 + (a+(c-1)/2);
    }
}
int main(){
    int n, k;
    cin >> n >> k;
    long long count=0;
    long long a, b;
    for(a=k;a<=n+1;a++){
        count += sumbet(n-a+1, n) - sumbet(0, a-1)+1;
        if(count > 1000000007) count = count %1000000007;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

using namespace std;

int main(){

  int n, check = 0;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++){ cin >> a[i];}
  for(int i=0; i<n; i++){
    if(a[i]%2==0){
      if(a[i]%3!=0){
        if(a[i]%5!=0){
          check = 1;
        }
      }
    }
  }

  if(check ==0){
    cout << "APPROVED";
  } else {
    cout << "DENIED";
  }

}


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

long long M;

long long BigMod(long long b, long long m) {
	if(m == 0) return 0;
	long long a = 2;
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return res;
}

long long f(long long n)
{
	long long step = 0;
	while(__builtin_popcount(n)) {
		step++;
		int x = __builtin_popcount(n);
		n %= x;
	}
	return step;
}

int main()
{
	int n;
	scanf("%d", &n);
	string x;
	cin >> x;
	long long num_of_one = 0;
	for(int i = 0; i < x.size(); i++) {
		num_of_one += x[i] == '1';
	}
	reverse(x.begin(), x.end());

	long long mod_zero[300000];
	long long mod_one[300000];
	memset(mod_zero, 0, sizeof(mod_zero));
	memset(mod_one, 0, sizeof(mod_one));
	for(int i = 0; i < n; i++) {
		if(x[i] == '1') {
			mod_zero[i] = BigMod(i, num_of_one+1);
			mod_one[i] = BigMod(i, num_of_one-1);
		}
		if(i > 0) {
			mod_zero[i] += mod_zero[i-1];
			mod_zero[i] %= (num_of_one+1);
			mod_one[i] += mod_one[i-1];
			if(num_of_one > 1) {
				mod_one[i] %= (num_of_one-1);
			}
		}
	}
	long long m_1 = mod_zero[n-1];
	long long m_2 = mod_one[n-1];

	long long les = num_of_one-1;
	long long gre = num_of_one+1;

	long long ans[300000];
	for(int i = 0; i < n; i++) {
		if(x[i] == '1') {
			if(les > 0) {
				long long k = BigMod(i, les);
				long long z = (m_2-k)%les;
				if(z < 0) z += les;
				ans[i] = 1 + f(z);
			} else {
				ans[i] = 0;
			}

		} else {
			long long k = BigMod(i, gre);
			long long z = (m_1+k) % gre;
			ans[i] = 1 + f(z);
		}
	}
	for(int i = n-1; i>=0; i--) {
		printf("%lld\n", ans[i]);
	}
}


Measured memory_bytes: 10096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m;cin>>n>>m;
  string s;cin>>s;
  VV<int> e(n,V<int>(0));
  V<int> a(n,0),b(n,0);
  rep(i,0,m){
    int x,y;cin>>x>>y;
    x--;y--;
    e[x].pb(y);
    e[y].pb(x);
    if(s[x]=='A'){
      a[y]++;
    }else{
      b[y]++;
    }

    //if(x==y)continue;

    if(s[y]=='A'){
      a[x]++;
    }else{
      b[x]++;
    }
  }

  queue<int> q;
  V<bool> used(n,false);
  rep(i,0,n){
    if(!a[i] || !b[i]){
      q.push(i);
      used[i]=true;
    }
  }

  while(q.size()){
    int now=q.front();
    q.pop();
    if(s[now]=='A'){
      rep(i,0,siz(e[now])){
        a[e[now][i]]--;
      }
    }else{
      rep(i,0,siz(e[now])){
        b[e[now][i]]--;
      }
    }

    rep(i,0,siz(e[now])){
      if(!used[e[now][i]] && (!a[e[now][i]] || !b[e[now][i]])){
        q.push(e[now][i]);
        used[e[now][i]]=true;
      }
    }
  }


  int ans=0;
  rep(i,0,n){
    //cout<<a[i]<<" "<<b[i]<<ENDL;
    if(a[i] && b[i]){
      ans++;
    }
    //assert(a[i]>=0 && b[i]>=0);
  }
  if(ans){
    cout<<"Yes"<<ENDL;
  }else{
    cout<<"No"<<ENDL;
  }
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?


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

int main(){
  int N;
  cin >> N;
  set<int64_t> aset;
  bool ans =true;
  for (int i=0;i<N;i++){
    int64_t a =0;
    cin >>a;
    if (aset.count(a)){
      cout <<"NO" << endl;
      ans = false;
      break;
    }
    else{
      aset.insert(a);
    }
  }
  if (ans){
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 9600
#include <stdio.h>
int main(void)
{
  int m,n;
  int jdg;
  int s[20]={};
  int p;
  int i,j;
  scanf("%d %d",&m,&n);

  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      scanf("%d",&jdg);
      s[i]+=jdg;
    }
  }
  p=s[0];
  for(i=0;i<m;i++){
    if(s[i]>p)
      p=s[i];
  }

  printf("%d\n",p);

  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int x=sc.nextInt();
				int y=sc.nextInt();
				int s=sc.nextInt();
				if(x==0 && y==0 && s==0) break;
				int max=0;
				for(int i=1; i<1000; i++) {
					for(int j=1; j<1000; j++) {
						//System.out.println(Math.floor((i*(100+x)/100+j*(100+x)/100)));
						if(Math.floor((i*(100+x)/100+j*(100+x)/100))==s) {
							max=Math.max((int)Math.floor((i*(100+y)/100+j*(100+y)/100)), max);
						}
					}
				}
				System.out.println(max);
			}
			
		}
	}
}


Measured memory_bytes: 28996
#include <cstdio>
typedef long long ll;
ll N,A,B,C,D,E,F,G,H;
int main(){
  scanf("%lld%lld%lld%lld%lld",&N,&A,&B,&C,&D);
  N--;
  for(ll i=0;i<N;i++){
    if((N-i)*C-i*D<=A-B&&A-B<=(N-i)*D-i*C){
      printf("YES");
      return 0;
    }
    if((N-i)*C-i*D<=B-A&&B-A<=(N-i)*D-i*C){
      printf("YES");
      return 0;
    }
  }
  printf("NO");
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  string s;
  string t = "CODEFESTIVAL2016";

  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) {
      ++cnt;
    }
  }

  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200000+5;
ll a,b,c;
int main()
{
    while(~scanf("%lld%lld%lld",&a,&b,&c))
    {
        printf("%lld\n",min(a+b+1,c)+b);

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, L; cin >> N >> L;
  string S = ""; vector<string> s(N);
  for(int i = 0; i < N; i++) cin >> s[i];
  sort(s.begin(), s.end());
  for(int i = 0; i < N; i++) S += s[i];
  cout << S << endl;
}


Measured memory_bytes: 256
void main(){
	string s = readln().chomp();
	string t = readln().chomp();
	if( s==t[0..s.length] && t[s.length..$].length==1 ){
		writeln("Yes");
	}else{
		writeln("No");
	}
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
bool dbg = false;
int N, D, x[100][100];
void solve()
{
    int ans = 0;
    FOR(i, 0, N)
    {
        FOR(j, i + 1, N)
        {
            int t = 0;
            FOR(k, 0, D)
            {
                t += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            int s;
            s = sqrt(t);
            if (s * s == t) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> D;
    FOR(i, 0, N)
    {
        FOR(j, 0, D)
        {
            cin >> x[i][j];
        }
    }
    solve();
    return 0;
}


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

int main()
{
  int N, D, X, Y, i, cnt = 0;

  if (scanf("%d %d", &N, &D) == 1)
    ;

  double dist;

  for (i = 0; i < N; i++)
  {
    if (scanf("%d %d", &X, &Y) == 1)
      ;
    dist = sqrt(pow((double)X, 2.0) + pow((double)Y, 2.0));
    if (dist <= (double)D)
    {
      cnt++;
    }
  }

  printf("%d", cnt);

  return (0);
}


Measured memory_bytes: 2092
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

Plus, Whole = [0], [0]
for i in range(N):
    Plus.append(Plus[-1] + max(A[i], 0))
    Whole.append(Whole[-1] + A[i])

Score = max(max(0, Whole[K] - Whole[0]) + Plus[N] - Plus[K], Plus[N-K] - Plus[0] + max(0, Whole[N] - Whole[N-K]))
for i in range(1, N-K):
    temp = Plus[i] + max(0, Whole[i+K] - Whole[i]) + Plus[N] - Plus[i+K]
    Score = max(Score, temp)

print(Score)

Measured memory_bytes: 17532
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vint a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    vll sa(n+1), sb(m+1);
    rep(i, n) sa[i+1] = sa[i]+a[i];
    rep(i, m) sb[i+1] = sb[i]+b[i];

    int ans = 0;
    rep(i, n+1) {
        ll rm = k-sa[i];
        if (rm < 0) break;
        int id = lower_bound(all(sb), rm+1)-sb.begin();
        ans = max(ans, i+id-1);
    }

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

Measured memory_bytes: 8004
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残すな
//数値計算 基本はdouble
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}   // 

int main() {
	int N; cin >> N;
	vector<int> L(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		sum += L[i];
	}

	sort(ALL(L));

	sum -= L[N - 1];

	if (L[N - 1] < sum) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007

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

    if(s.at(2)==s.at(3) && s.at(4)==s.at(5))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 100100100;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int main(){
    int h, w; cin >> h >> w;
    vector<str> grid;
    rep(i, h){
        str s; cin >> s;
        rep(i, w){
            if(s[i] == '#'){
                grid.push_back(s);
                break;
            }
        }
    }
    vector<int> okay;
    rep(i, w){
        rep(j, grid.size()){
            if(grid[j][i] == '#'){
                okay.push_back(i);
                break;
            }
        }
    }
    rep(i, grid.size()){
        rep(j, okay.size()){
            cout << grid[i][okay[j]];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long  a[4];
    for(int i=0;i<3;i++)
        cin>>a[i];
    sort(a,a+3);
    if(a[0]==a[2])
        cout<<"No"<<endl;
    else if(a[0]==a[1] && a[0]!=a[2])
        cout<<"Yes"<<endl;
    else if(a[1]==a[2] && a[0]!=a[2])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 256
<?php
  declare(strict_types=1);

  fscanf(STDIN, "%i %i", $n, $m);
  $g = (int)0;
  for ($i = 0; $i < $m; $i++)
  {
      fscanf(STDIN, "%i %i", $a, $b);
      $g |= (int)1 << (($a - 1) * $n + $b - 1);
      $g |= (int)1 << (($b - 1) * $n + $a - 1);
  }

  $limit = 1 << $n;
  for ($passing = (int)1; $passing < $limit; $passing++)
  {
      for ($i = 0; $i < $n; $i++)
      {
          $dp[$passing][$i] = 0;
      }
  }  
  for ($i = 0; $i < $n; $i++)
  {
      $dp[1 << $i][$i] = 1; // trivial paths
  }
  for ($passing = (int)1; $passing < $limit; $passing += 2)
  {
      for ($i = 0; $i < $n; $i++)
      {
          if ($dp[$passing][$i] <= 0 || ($passing & (1 << $i)) === 0)
          {
              continue;
          }

          $unexplored = ~$passing & ($g >> ($i * $n));
          for ($j = 0; $j < $n; $j++)
          {
              if (($unexplored & (1 << $j)) !== 0)
              {
                  $dp[$passing | (1 << $j)][$j] += $dp[$passing][$i];
              }
          }
      }
  }
  
  echo array_sum($dp[$limit - 1]).PHP_EOL;


Measured memory_bytes: 2936
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC123().SolveB(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

    public static class AtCoderLib
    {
        // ユークリッドの互除法 
        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
  class ABC123
    {
        public void SolveB(ConsoleInput cin)
        {
            var cookList = new int[5];
            for (int i = 0; i < 5; i++)
            {
                cookList[i] = cin.ReadInt;
            }
            var modList = new int[5];
            for (int i = 0; i < 5; i++)
            {
                modList[i] = cookList[i] % 10;
            }
            var list = new List<int>();
            int sumTime = 0;
            for (int i = 0; i < 5; i++)
            {
                if (modList[i] == 0) sumTime += cookList[i];
                else
                {
                    sumTime += (cookList[i] / 10) * 10;
                    list.Add(modList[i]);
                }
            }
            if (list.Count() != 0) sumTime += list.Min() + (list.Count() - 1) * 10;
            WriteLine(sumTime);
            ReadLine();

        }
    }
}


Measured memory_bytes: 13396
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
 
int main() {
    int n;
    int tmp;
    int a[100004];
    cin >> n;
    fill(a, a + 100004, 0);
    imfor(i, n) {
        cin >> tmp;
        tmp++;
        a[tmp - 1] += 1;
        a[tmp + 2] -= 1;
    }
    for (int i = 1; i < 100003; i++) {
        a[i] += a[i - 1];
    }
    int ans = 0;
    imfor (i, 100003) {
        if (a[i] > ans) {
            ans = a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
/*
 * a.cc:
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<iomanip>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */
int main(){
  string n;
  cin>>n;

  for(int i=0;i<3;i++){

    if(n.at(i)=='1') n.at(i)='9';
    
    else n.at(i)='1';
    
  }

  cout<<n<<endl;
  


  






  
}

Measured memory_bytes: 3600
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;

const double PI  = 3.141592653589793238463;

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


Measured memory_bytes: 640
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces1148C
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }
ll mod = 1000000007;

int main(){
	char s[222222];
	int n;
	scanf("%s%n", s, &n);
	ll ans = 0;
	ll flag = 0;
	for ( int k = 0; k < n - 1; k++ ){
		if (s[k] == 'A') { flag++; }
		else if (s[k] == 'B' && s[k+1] == 'C') {
			ans += flag;
			k++;
		}else { flag = 0; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
  int n, a[200];
  
  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i];
  
  int count = 0;
  
  while(1){
    for(int i=0; i<n; i++){
      if(a[i] % 2 == 0){
        a[i] /= 2;
      }else{
        cout << count << endl;
        return 0;
      }
    }
    count++;
  }
}
      
      

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int main() {
	int n;
	while (cin >> n, n) {
		map<string, vector<string>> mp;
		string st;
		rep(i, n) {
			string x; cin >> x;
			string ori;
			string nex;
			int len = x.length();
			bool f = false;
			rep(j, len) {
				if (x[j] == ':') {
					f = true;
				}
				else if (x[j] == ','||x[j]=='.') {
					mp[ori].push_back(nex);
					nex.clear();
				}
				else {
					if (!f) {
						ori += x[j];
					}
					else {
						nex += x[j];
					}
				}
			}
			if (i == 0) {
				st = ori;
			}
		}
		vector<string> z; z.push_back(st);
		set<string> out;
		map<string, int> used;
		while (z.size()) {
			string now = z[0]; z.erase(z.begin());
			int len = mp[now].size();
			rep(i, len) {
				if (mp[mp[now][i]].size()) {
					if (used[mp[now][i]]!=1) {
						z.push_back(mp[now][i]);
						used[mp[now][i]] = 1;
					}
				}
				else {
					out.insert(mp[now][i]);
				}
			}
		}
		int l = out.size();
		cout << l << endl;
	}
	return 0;
}


Measured memory_bytes: 3344
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    vi a(n*2);
    vi check(n*2);
    rep(i,n) cin >>a[i];
    int ans = 0;
    for(int i = 1; ; i = a[i-1]) {
        check[i-1]++;
        if(check[i-1] == 2) {
            ans = -1;
            break;
        }
        else if (i == 2) {
            break;
        }
        ans++;
    }
    cout <<  ans << endl;
}

Measured memory_bytes: 4788
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    long long N,M;cin>>N>>M;
    if(N>=2&&M>=2)cout<<(N-2)*(M-2)<<endl;
    else if(N==1&&M==1)cout<<1<<endl;
    else if(N==1)cout<<M-2<<endl;
    else if(M==1)cout<<N-2<<endl;
}

Measured memory_bytes: 256
n,m,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))

sa=[0]*(n+1)
sb=[0]*(m+1)
s=0
for i in range(n):
  s+=a[i]
  sa[i+1]=s
s=0
for i in range(m):
  s+=b[i]
  sb[i+1]=s

if sa[n]+sb[m]<=k:
  print(n+m)
  exit()

ans=0
j=0
for i in reversed(range(n+1)):
  if sa[i]+sb[j]>k:
    continue
  while j<m and sa[i]+sb[j+1] <= k:
    j+=1
  if sa[i]+sb[j] <= k and ans<i+j:
    ans=i+j

print(ans)

Measured memory_bytes: 111044
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,min;
	cin>>n>>k;
	int a[n],b[k];
	for(int i=0;i<n;i++)
	cin>>a[i];
	b[0]=0;
	b[1]=abs(a[1]-a[0]);
	for(int i=2;i<=k;i++)
	{
		min=b[0]+abs(a[i]-a[0]);
		for(int j=1;j<i;j++)
		{
			if((b[j]+abs(a[j]-a[i]))<min)
			{
				min=b[j]+abs(a[j]-a[i]);
			}
		}
		b[i]=min;
	}
	for(int i=k+1;i<n;i++)
	{
		min=b[i-k]+abs(a[i-k]-a[i]);
		
		for(int j=i-k+1;j<i;j++)
		{
			if((b[j]+abs(a[j]-a[i]))<min)
			{min=b[j]+abs(a[j]-a[i]);}
		}
		b[i]=min;
	}
	cout<<b[n-1];
}

Measured memory_bytes: 640
N,x=gets.chomp.split(" ").map(&:to_i)
as=gets.chomp.split(" ").map(&:to_i).sort
cnt = 0
as.each do |a|
    x -= a
    if x < 0
        break
    end
    cnt += 1
end
cnt -= 1 if x > 0
p cnt

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

int main() {
	int n,x,t;
	cin >> n >> x >> t;

	if(n%x==0){
		cout << t * (n/x) << endl;
	}else{
		cout << t * (n/x + 1) << endl;
	}
	return 0;
  
}


Measured memory_bytes: 3616
#include <stdio.h>
#define MAX 100001

int A[MAX],n;

int partition(int A[], int p, int r){
  int i,j,x,temp;
  x = A[r];
  i = p-1;
  for (j = p;j<=r-1;j++){
    if (A[j] <= x){
      i = i+1;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;
  return i+1;
}

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

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	pair<long long, int> b[m];
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	for (int i = 0; i < m; i++) cin >> b[i].second >> b[i].first;
	sort(b, b+m);
	reverse(b, b+m);

	int i_idx = 0;
	long long res = 0;
	for (int i = 0; i < m; i++){
		auto iter = lower_bound(a.begin()+i_idx, a.end(), b[i].first);
		int dis = distance(a.begin()+i_idx, iter);
		if (dis == 0) continue;
		int d_idx = min(dis, b[i].second);
		res += d_idx * b[i].first;
		i_idx += d_idx;
	}

	for (int i = i_idx; i < n; i++){
		res += a[i];
	}

	cout << res << endl;

}


Measured memory_bytes: 2176