akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

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; }
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll result = 0;
  ll start_Ci = (A + (C - 1)) / C;
  ll end_Ci = B / C;
  result += end_Ci - start_Ci + 1;
  ll start_Di = (A + (D - 1)) / D;
  ll end_Di = B / D;
  result += end_Di - start_Di + 1;
  ll CD = lcm(C, D);
  ll start_CDi = (A + (CD - 1)) / CD;
  ll end_CDi = B / CD;
  result -= end_CDi - start_CDi + 1;
  result = B - A + 1 - result;
  cout << result << endl;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    vector<vector<bool>> visited(H, vector<bool>(W, false));
    queue<tuple<int, int, int>> q;
    REP(i, H) {
        cin >> s[i];
    }
    int black = 0;
    REP(i, H) {
        REP(j, W) {
            if(s[i][j] == '#') {
                black++;
            }
        }
    }
    q.push(make_tuple(0, 0, 0));

    auto judge = [H, W](auto i, auto j){return 0 <= i && i < H && 0 <= j && j < W;};
    for(;!q.empty();) {
        auto f = q.front();
        q.pop();
        int i = get<0>(f);
        int j = get<1>(f);
        int dis = get<2>(f);
        if(i == H - 1 && j == W - 1) {
            cout << H*W - black - (dis + 1) << endl;
            return 0;
        }
        FOR(k, i - 1, i + 2) {
            FOR(l, j - 1, j + 2) {
                if((i == k || j == l) && judge(k, l) && !visited[k][l] && s[k][l] == '.') {
                    visited[k][l] = true;
                    q.push(make_tuple(k, l, dis + 1));
                }
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

S = sum(A)

snk = 0
arigm = S

ans = 1e20

for i in range(N-1):
  snk += A[i]
  arigm -= A[i]
  #print(snk,arigm)
  ans = min(abs(snk-arigm),ans)
print(ans)

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

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<long long> num(k, 0);
    for (int i = 1; i <= n; ++i){
        num[i%k]++; // num[x] = kで割ってxあまる数が1以上N以下に何個あるか
    }

    long long res = 0;
    for (int a = 0; a < k; a++){
        int b = (k-a) % k;
        int c = (k-a) % k;
        if((b+c) % k != 0){
            continue;
        }else{
            res += num[a] * num[b] * num[c];
        }
    }

    cout << res << endl;


    return 0;
}

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

int main() {
  int N,K,Q,t;
  cin >> N >> K >> Q;
  vector<int> pnt(N,K - Q);
  for (int i=0; i < Q; i++) {
    cin >> t; t--;
    pnt.at(t)++;
  }
  for (int i=0;i < N; i++) {
    cout << (pnt.at(i) < 1 ? "No" : "Yes") << endl;
  } 
}

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

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

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

    // cumulative sum
    vector<long long int> sa(n+1);
    for(int i=0; i<n; i++){
        sa[i+1] = sa[i] + a[i];
    }

    map<long long int, long long int> count;
    for(int i=0; i<n+1; i++){
        //cout << sa[i] << " ";
        if(count.find(sa[i]) == count.end()) count[sa[i]] = 1;
        else count[sa[i]] += 1;
    }

    long long int ans = 0;
    for(auto c : count){
        ans += c.second * (c.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    vector<int> t(n+1), x(n+1), y(n+1);
    t.at(0) = x.at(0) = y.at(0) = 0;
    for (int i = 1; i <= n; i++) {
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }

    bool can_travel;
    for (int i = 0; i < n; i++) {
        int t_diff, x_diff, y_diff;
        t_diff = t.at(i+1) - t.at(i);
        x_diff = x.at(i+1) - x.at(i);
        y_diff = y.at(i+1) - y.at(i);
        while (t_diff > 0) {
            if (x_diff != 0) {
                if (x_diff < 0) {
                    x_diff++;
                } else {
                    x_diff--;
                }
            } else {
                if (y_diff < 0) {
                    y_diff++;
                } else {
                    y_diff--;
                }
            }
            t_diff--;
        }
        if ((x_diff == 0) && (y_diff == 0)) {
            can_travel = true;
        } else {
            can_travel = false;
            break;
        }
    }

    if (can_travel) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 3e3+1;
string s, t;
int DP[N][N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s >> t;
  int ss = sz(s);
  int tt = sz(t);
  FOR(i, 0, ss)FOR(j, 0, tt){
    if(s[i] == t[j]){
      DP[i+1][j+1] = DP[i][j] + 1;
    }else{
      maxs(DP[i+1][j+1], DP[i][j+1]);
      maxs(DP[i+1][j+1], DP[i+1][j]);
    }
  }
  string ans;
  int c = DP[ss][tt];
  while(c > 0){
    if(DP[ss-1][tt] == c){
      ss--;
    }else if(DP[ss][tt-1] == c){
      tt--;
    }else{
      c--;
      ans.pb(s[ss-1]);
      ss--;
      tt--;
    }
  }
  reverse(all(ans));
  cout << ans << endl;
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

template<typename T> inline constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

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

	int kuchi = 1, ans = 0;

	while (1) {
		if (kuchi >= B) break;
		kuchi += (A - 1);
		ans++;
	}

	COL(ans);

	return 0;
}

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

using namespace std;

long long knapsackRecursive(vector<vector<long long>> &dp, vector<int> &profits,
                        vector<int> &weights, int capacity, int currentIndex) {
    // base checks
    if (capacity <= 0 || currentIndex >= profits.size()) {
      return 0;
    }

    // if we have already solved a similar problem, return the result from memory
    if (dp[currentIndex][capacity] != -1) {
      return dp[currentIndex][capacity];
    }

    // recursive call after choosing the element at the currentIndex
    // if the weight of the element at currentIndex exceeds the capacity, we shouldn't process this
    long long  profit1 = 0;
    if (weights[currentIndex] <= capacity) {
      profit1 = profits[currentIndex] + knapsackRecursive(dp, profits, weights,
                                                          capacity - weights[currentIndex],
                                                          currentIndex + 1);
    }

    // recursive call after excluding the element at the currentIndex
    long long  profit2 = knapsackRecursive(dp, profits, weights, capacity, currentIndex + 1);

    dp[currentIndex][capacity] = max(profit1, profit2);
    return dp[currentIndex][capacity];
  }

int main(){
	
  int N, W;
  cin >> N >> W;
  
  vector<int> v(N);
  vector<int> w(N);
  
  for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
  
 vector<vector<long long>> memo(N, vector<long long>(W+1, -1));
  long long res = knapsackRecursive(memo, v, w, W, 0);
  cout << res << endl; 
  
}
  


Measured memory_bytes: 79360
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;

int main()
{
	int n;
	string s,t;
	char ans[255] = {};
	cin >> n;
	cin >> s >> t;

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		ans[cnt] += s[i];
		cnt++;
		ans[cnt] += t[i];
		cnt++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;

namespace abc153_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str1 = Console.ReadLine().Split(' ');
            monster mst = new monster();
            raccoon arai = new raccoon();
            mst.hp = long.Parse(str1[0]);
            arai.skill = int.Parse(str1[1]);
            arai.skillNo = new int[arai.skill];
            string[] str2 = Console.ReadLine().Split(' ');
            for (int i = 0; i < arai.skill; ++i)
            {
                arai.skillNo[i] = int.Parse(str2[i]);
            }
            int damage = 0;
            for (int i = 0; i < arai.skill; ++i)
            {
                damage = damage + arai.skillNo[i];
            }
            if (damage >= mst.hp)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
    /// <summary>
    /// モンスタークラス
    /// </summary>
    class monster
    {
        public long hp;
    }
    /// <summary>
    /// アライグマクラス
    /// </summary>
    class raccoon
    {
        public int skill;
        public int[] skillNo;
    }
}

Measured memory_bytes: 16480
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

int main() {
  int n,k;
  cin >> n>> k;
  int h[n];
  fr(i,n){
    cin >> h[i];
  }
  sort(h,h+n);
  ll sum=0;
  fr(i,n-k){
    sum+=h[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
use List::Util 'sum';
use List::Util 'min';
use Math::BigInt;

while(<>){
	chomp;
	$n = $_ if($. == 1);
	@s = split(/ /, $_) if($. == 2);
}

($f, $t) = (0, 0);
$f = Math::BigInt->new($f);
$t = Math::BigInt->new($t);

$t = int(sum(@s) / 2);
if($t >= sum(@s[0 .. int($#s / 2)])){
	$f = sum(@s[0 .. int($#s / 2)]);
	for $i (int($#s / 2) + 1 .. $#s){
		$f += $s[$i];
		if($f > $t){
			$index = $i;
			last;
		}
	}
}else{
	if($t >= sum(@s[0 .. int($#s / 4)])){
		$f = sum(@s[0 .. int($#s / 4)]);
		for $i (int($#s / 4) + 1 .. int($#s / 2)){
			$f += $s[$i];
			if($f > $t){
				$index = $i;
				last;
			}
		}
	}else{
		for $i (0 .. int($#s / 4)){
			$f += $s[$i];
			if($f > $t){
				$index = $i;
				last;
			}
		}
	}
}

print min(
		abs(sum(@s[0 .. $index]) - sum(@s[$index + 1 .. $#s])),
		abs (sum(@s[0 .. $index - 1]) - sum(@s[$index .. $#s]))
	  ) . "\n";


Measured memory_bytes: 46088
<?php

list($n, $m) = array_map("intval", explode(" ", fgets(STDIN)));
$dp[0] = 0;

$c = explode(",", "999,2,5,5,4,5,6,3,7,6");

$aArray = array_map("intval", explode(" ", fgets(STDIN)));
rsort($aArray);

for($i = 1; $i <= $n; $i++){
    foreach($aArray as $a){
        if(isset($dp[$i - $c[$a]])){
            if(@$dp[$i] < $dp[$i - $c[$a]] + 1){
                $dp[$i] = $dp[$i - $c[$a]] + 1;
            }
        }
    }
}
while($n > 0){
    foreach($aArray as $a){
        if(isset($dp[$n - $c[$a]])){
            if($dp[$n - $c[$a]] == $dp[$n] - 1){
                $n-=$c[$a];
                echo $a;
                break;
            }
        }
    }
}


Measured memory_bytes: 4984
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  return *(long *)a - *(long *)b;
}

int main(){
   int n,i,j,k;
   long a[100000],m;
    
   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%ld",&a[i]);
   while (n>1) {
      qsort(a,n, sizeof(long),asc);
      m=a[0];
      for (i=1;i<n;i++) {
        a[i]=a[i]%m;
        if (a[i]==0) {
          a[i]=a[n-1];
          n--;
          if (n==1) break;
          i--;
        }
      }
   }
   printf("%ld\n",m);
   return 0;
}


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include <queue>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;



int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N,M;
    cin>>N>>M;
    vector<int> A(M),B(M);
    vector<vector<int> > G(N);
    vector<int> flag(N,-1);
    flag[0] = 0;
    REP(i,M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    vector<int> dp(N);
    queue<P> que; que.push(P(0,0)); //first = 場所, second = なんこめか
    while(!que.empty()){
        P now = que.front(); que.pop();

        REP(i,G[now.first].size()){
            int next = G[now.first][i];
            int itr = now.second + 1;
            if(flag[next] == -1){
                flag[next] = now.second + 1;
                que.push(P(next,itr));
                dp[next] = now.first;
            }
        }
    }

    cout << "Yes" << endl;

    FOR(i,1,N){
        cout << dp[i] + 1 << endl;
    }



}

Measured memory_bytes: 12436
<?php

	fscanf(STDIN, "%s", $S);
	
	for ($i = 0; $i < strlen($S); $i++) {
      if (($i+1) % 2 === 0) {
        if ($S[$i] === 'R') {
          echo ('No');
          return ;
        }
      } else {
        if ($S[$i] === 'L') {
          echo ('No');
          return ;
        }
      }
    }
	echo ('Yes');
?>

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define ll long long
#define mod (ll)1000000007
using namespace std;

int main()
{
   int n;
   cin>>n;
   unordered_map<int,int> f;
   for(int i = 0; i < n; i++){
    int num;
    cin>>num;
    f[num]++;
   }

   bool ok = true;

   for(auto i:f){
    if(i.second > 1)
        ok = false;
   }

   if(ok)
    cout<<"YES\n";
else
    cout<<"NO\n";
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int data[n];
    for(int i = 0; i < n; i++){
        cin >> data[i];
    }
    
    int flag = 1;
    int count = 0;
    while(flag){
        flag = 0;
        for(int i = n-1; i > 0; i--){
            if(data[i] < data[i-1]){
                swap(data[i], data[i-1]);
                flag = 1;
                count += 1;
            }
        }
    }
    for(int i = 0; i < n; i++){
        if(i == 0){
            cout << data[i];
        }
        else{
            cout << ' ' << data[i];
        }
    }
    cout << endl << count << endl;
    return 0;
}


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
int n=sc.nextInt();
int p[]=new int[n];
int dif,ans=0,ans_dif,che;
ans_dif=x;
for(int i=0;i<n;i++)
{

p[i]=sc.nextInt();
}

for(int i=1;i<=101;i++)
{
	dif=i-x;
	if(dif<0)
	{dif=-dif;}
	if(ans_dif>dif)
	{che=0;
		for(int j=0;j<n;j++)
		{
			if(i==p[j])
			{
				che=1;
			}
		}
		if(che==0)
		{
			ans=i;
			ans_dif=dif;
		}
	}
}
System.out.println(ans);
	}

}


Measured memory_bytes: 35980
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int x = int.Parse(input[0]);
		int a = int.Parse(input[1]);
		if(x < a) Console.WriteLine(0);
    else Console.WriteLine(10);
	}
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, a, b;

int main() {
    cin >> n >> a >> b;
    if (a > b) cout << 0 << endl;
    else if (n == 1 && a != b) cout << 0 << endl;
    else cout << a+b*(n-1)-(a*(n-1)+b)+1 << endl;
}
































Measured memory_bytes: 256
from math import factorial

n = int(input())
A = list(map(int,input().split()))
dict = {}

for i,a in enumerate(A):
  if a in dict:
    dict[a].append(i)
  else:
    dict[a]=[i]

ans = 0    
    
for k,v in dict.items():
  if len(v) >= 2:
    ans += len(v) * (len(v)-1) //2
#print(ans)

  
for i in range(n):
  wnum = A[i]
  l=dict[wnum]
#  print('l',l)
  if 2 < len(dict[wnum]):
#    print(ans)
#    print('x',(len(v)-1) * (len(v)-2) // 2 )
#    print('y',len(v) * (len(v)-1) // 2 )
    print(int(ans -(len(l) * (len(l)-1) //2) + (len(l)-1) * (len(l)-2) //2))
  elif 2 == len(dict[wnum]):
    print(int(ans - 1))
  else:
    print(int(ans))

Measured memory_bytes: 102604
A[20000];z(int*a,int*b){return*b-*a;}
main(n,i,j){for(;scanf("%d",&n),n;puts(i>n?"No":"Yes")){
for(i=0;i<n*2;i++)scanf("%d",A+i);
for(i=qsort(A,n,4,z);i<n;A[i++]?i=n+1:1)for(j=n;j<n*2;j++)if(A[j])A[i]--,A[j]--;
}exit(0);}

Measured memory_bytes: 736
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int a,b; cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}


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

#define ll                 long long
#define mod                1000000007
#define pb                 push_back
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define T(t)               cout << "Case " << t <<": ";
#define scan(v)            for(int i = 0; i<n; i++){ll x;cin>>x;v.pb(x);}
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL);




int main() {



     ll x , k , d;
     cin >> x >> k >> d;
     x = abs( x );
     if( x/d >= k ){
         cout << x - (d * k ) << endl;
         return 0 ;
     }
     ll t = x / d;
     x -= t * d;
     k -= t;
     if( k % 2 == 0 ){
         cout << abs(x) << endl;
     }
     else{
         cout << min(abs(x-d),abs(x+d)) << endl;
     }









    return 0;

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector <int> height(no_of_stones + 1, 0);
    for(int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    vector <int> minimum_cost(no_of_stones + 1);
    minimum_cost[2] = abs(height[2] - height[1]);
    for(int i = 3; i <= no_of_stones; i++)
        minimum_cost[i] = min(minimum_cost[i - 1] + abs(height[i] - height[i - 1]),
                              minimum_cost[i - 2] + abs(height[i] - height[i - 2]));

    cout << minimum_cost[no_of_stones];
    return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

string isSquare(int n) {
  for(int k=2; k*k <=n; k++) {
    if(k*k == n) {
      return "Yes";
    }
  }
  return "No";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b;
  cin >> a >> b;
  int concat = stoi(to_string(a).append(to_string(b)));
  cout << isSquare(concat) << '\n';
  return 0;
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e5+5;

ll n , a[N] , val[N];


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

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

    for(int i=n; i>0; i--)
    {
        ll sum = 0;
        for(int j=i; j<=n; j+=i) //contains ball
            sum += val[j];

        if (sum%2 == a[i]) continue;
        val[i] = 1;
    }


    for(int i=1; i<=n; i++)
    {
        ll sum=0;
        for(int j=i; j<=n; j+=i)
        {
            sum += val[j];
        }
        if (a[i] != sum%2) return cout << "-1\n" , 0;
    }
    vector<ll> ans;

    for(int i=1; i<=n; i++)
        if (val[i]) ans.push_back(i);

    cout << ans.size() << '\n';
    for(auto i : ans)
        cout << i << ' ';

    return 0;
}

Measured memory_bytes: 7336
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<iostream>
#include<algorithm>
#include<set>
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef long long LL;
int read()
{
	int s=0;int c=getchar(),f=1;
	while(c<48||c>57)
	{
		if(c==45) f=-1;
		c=getchar();
	}
	while(c>=48&&c<=57) s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return s*f;
}
void write(int x)
{
	if(x>=10) write(x/10);
	putchar(x%10+48);
}
void W(int x)
{
	if(x<0) x=-x,putchar(45);
	write(x);
}
const int INF=1000000009;
multiset<int> A,B;
int tmp[1111111];
bool check(int n)
{
	B.insert(*A.rbegin());A.erase(*A.rbegin());A.insert(INF);
	for(int i=1;i<=n;++i)
	{
		int tot=0;
		for(multiset<int> ::reverse_iterator ii=B.rbegin();ii!=B.rend();++ii) tmp[++tot]=*ii;
		for(int j=1;j<=tot;++j)
		{
			multiset<int> ::iterator op=A.lower_bound(tmp[j]);
			if(op==A.begin()) return false;
			--op;
			B.insert(*op),A.erase(op);
		}
	}
	return true;
}
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	int N=read();
	for(int i=1;i<=(1<<N);++i) A.insert(read());
	if(check(N)) puts("Yes");
	else puts("No");
//	for(multiset<int> ::reverse_iterator ii=B.rbegin();ii!=B.rend();++ii) printf("%d ",*ii);
	return 0;
}

Measured memory_bytes: 13056
# 変更後2 後ろから数える　デバッグ用

H,W,N = map(int,input().split())
init_r,init_c = map(int,input().split())
S = input()
T = input()

r = W+1
l = 0
u = 0
d = H+1

ans = "YES"

for i in range(N):
    t = N-1-i
    #savor's turn
    direction = T[t]
    if direction == "R" and l != 0:
        l -= 1
    elif direction == "L" and r != W+1:
        r += 1
    elif direction == "U" and d != H+1:
        d += 1
    elif direction == "D" and u != 0:
        u -= 1
        
#     killer's turn
    t = N-1-i
    direction = S[t]
    if direction == "R":
        r -=1
        if r == 1:
            ans = "NO"
            break
    elif direction == "L":
        l +=1
        if l == W:
            ans = "NO"
            break
    elif direction == "U":
        u +=1
        if u == H:
            ans = "NO"
            break
    elif direction == "D":
        d -=1
        if d == 1:
            ans = "NO"
            break
    if r <= l:
        ans = "NO"
        break    
    if d <= u:
        ans = "NO"
        break

if init_c <= l or init_c >= r:
    ans = "NO"
if init_r <= u or init_r >= d:
    ans = "NO"
print(ans)

Measured memory_bytes: 3888
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

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

int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
vector<int> a(101);

int dist[1010][1010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    fill(dist[0], dist[h + 1], INF);
    queue<pii> que;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> s[i][j];
            if (s[i][j] == '#') {
                dist[i][j] = 0;
                que.emplace(i, j);
            }
        }
    }
    while (que.size()) {
        int x, y;
        tie(x, y) = que.front();
        que.pop();
        for (int k = 0; k < 4; ++k) {
            int nx = x + dx[k];
            int ny = y + dy[k];
            if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
            if (dist[nx][ny] > dist[x][y] + 1) {
                dist[nx][ny] = dist[x][y] + 1;
                que.emplace(nx, ny);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(vector<T> v){
    cout << "#vdebug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n;
    cin >> n;

    string res = "";
    while(n != 0){
        ll r = n%2;
        n = (n - abs(r)) / (-2);
        res = char('0'+abs(r)) + res;
    }

    if(res.length() == 0) res = '0';

    cout << res << endl;

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

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

  vector<ll>results;
  rep(i, n){
    auto it = lower_bound(results.begin(), results.end(), a[i]);

    if(it!=results.begin()) *prev(it)=a[i];
    else results.insert(it, a[i]);

//cout<<results.size()<<':';rep(i, results.size())cout<<results[i]<<' ';cout<<endl;

  }
  cout<<results.size()<<endl;

  return 0;
}

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

int gcd(int a, int b){
  if(b > a) swap(a, b);
  if(a % b == 0) return b;
  return gcd(b, a % b);
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> d;
  for(int i=1; i*i<=M; i++){
    if(M % i == 0){
      d.push_back(i);
      if(i != M / i) d.push_back(M / i);
    }
  }
  int ans = 1;
  for(int i=0; i<d.size(); i++){
    if(M / d[i] >= N) ans = max(d[i], ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));

    int sum=0;
    for(int i=n-k; i<n; i++){
        sum += v[i];
    }
    out(sum);

}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    int n, m;
    int[][] es;

    void run() {

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        es = new int[m][2];
        for (int i = 0; i < m; i++) {
            es[i][0] = sc.nextInt() - 1;
            es[i][1] = sc.nextInt() - 1;
        }

        long[] ans = new long[m];
        UnionFind uf = new UnionFind(n);
        ans[m - 1] = 1L * n * (n - 1) / 2;
        for (int i = m - 1; i >= 1; i--) {
            if (uf.same(es[i][0], es[i][1])) {
                ans[i - 1] = ans[i];
            } else {
                int sx = uf.size(es[i][0]);
                int sy = uf.size(es[i][1]);
                uf.union(es[i][0], es[i][1]);
                ans[i - 1] = ans[i] - sx * sy;
            }
        }

        for (int i = 0; i < m; i++) {
            System.out.println(ans[i]);
        }

    }

    class UnionFind {
        private int n, t;
        private int[] parent, rank, size;

        public UnionFind(int n) {
            this.n = n;
            this.parent = new int[n];
            this.rank = new int[n];
            this.size = new int[n];
            Arrays.fill(rank, 1);
            Arrays.fill(size, 1);
            for (int i = 0; i < n; i++) parent[i] = i;
        }

        public void union(int x, int y) {
            t++;
            int xr = find(x);
            int yr = find(y);

            if (xr > yr) {
                parent[yr] = xr;
                size[yr] += size[xr];
                size[xr] = size[yr];
            } else if (xr < yr) {
                parent[xr] = yr;
                size[xr] += size[yr];
                size[yr] = size[xr];
            } else {
                parent[yr] = xr;
                rank[yr]++;
                size[xr] += size[yr];
                size[yr] = size[xr];
            }

        }

        public int find(int x) {
            if (x != parent[x]) {
                parent[x] = find(parent[x]);
            }
            return parent[x];
        }

        public int size(int x) {
            return size[find(x)];
        }

        public boolean same(int x, int y) {
            return find(x) == find(y);
        }

    }



    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

int main(){
    string s,t;
    int l;
    cin >> s >> t;
    l=s.size();
    vector <vector <int>> al(26);

    rep(i,26){
        al[i].push_back(-1);
    }
    rep(i,l){
        al[s[i]-97].push_back(i);
    }


    ll ans=0;
    int k=0;
    int l2;
    int rt,lt,m;
    int l3;
    l3=t.size();

    rep(i,l3){
        l2=al[t[i]-97].size();
        //cout << l2 << endl;
        if(l2==1){
            ans=-1;
            break;
        }
        if(k>al[t[i]-97][l2-1]){
            ans+=l;
            k=0;
        }
        rt=l2-1;
        lt=0;
        while(rt-lt>1){
            m=(rt+lt)/2;
            if(al[t[i]-97][m]<k){
                lt=m;
            }
            else{
                rt=m;
            }
        }
        k=al[t[i]-97][rt];
        ++k;
        //cout << k << endl;
        if(i==(l3-1)){
            ans+=k;
        }


    }

    
    cout << ans << endl;
    

    return 0;
}

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

int main(){
	char b;
	char ans;

	cin >> b;
	if(b == 'A'){
		ans = 'T';
	}else if(b == 'T'){
		ans = 'A';
	}else if(b == 'G'){
		ans = 'C';
	}else{
		ans = 'G';
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
 
	var line1 = input[0].split(" ");
	var a = Number(line1[0])
	var b = Number(line1[1]);
	if((a+b)%3 && a%3 && b%3){
	    console.log("Impossible");
	} else {
	    console.log("Possible")
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false); 
    int k;
    string s;
    cin>>k>>s;
    if(k>=s.length()){
        cout<<s;
    }
    else{
    for(int i=0;i<k;i++){
        cout<<s[i];
    }
    cout<<"...";
    }


}

Measured memory_bytes: 3612
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();

    for(int i =0;i<1000;i++){
      for(int j =0;j<1000;j++){
        long ii = (long)Math.pow(i,5);
        long jj = (long)Math.pow(j,5);
        if(ii-jj==N){
          System.out.println(i +" "+j); 
          return; 
        }else if(ii+jj==N){
          System.out.println(i +" "+-j);
          return;   
        }
      }
    }


    // System.out.println(-1);  
  }
}





Measured memory_bytes: 38796
<?php
$input_lines = trim(fgets(STDIN));
$s = explode(" ", $input_lines);
if($s[0] > $s[1]){
    echo "a > b";
}else if($s[0] == $s[1]){
    echo 'a == b';
}else{
    echo 'a < b';
}
echo "\n";

Measured memory_bytes: 15416
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

int main(){
	int n;
	cin>>n;
	
	vi a(n);
	REP(i,n){
		cin>>a[i];
		a[i]-=i+1;
	}
	sort(ALL(a));
	//line(a);
	
	int b=a[n/2];
	//debug(b);
	llong ans=0;
	REP(i,n) ans+=abs((llong)a[i]-b);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 4044
#include<stdio.h>

int main(void) {
	int n;
	char s[100000];
	scanf("%d %s", &n, s);
	if (n % 2 == 1) {
		printf("No");
		//printf("%s", s);
	}
	else {
		for (int i = 0; i < n / 2; i++) {
			if (s[i] != s[i + n / 2]) {
				printf("No");
				return 0;
			}
		}
		printf("Yes");
	}
	return 0;
}

Measured memory_bytes: 128
n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
flag=False
for i in g[1]:
  for j in g[i]:
    if j==n:
      flag=True
if flag==True:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 38320
/**
 *Code Author: codeknight13
 *Institution: IIT(ISM)
**/
 
#include <bits/stdc++.h>
using namespace std;

//remember-> largest 2d memory that can be allocated is dp[5100][5100];
#define ll long long int
#define v vector
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define str string
#define pq priority_queue
#define vi vector< ll >
#define vii vector< vi >
#define viii vector< vii >
#define pii pair< ll, ll >
#define vpii vector< pii >
#define len length()
#define pb push_back
#define mp make_pair3
#define ff first
#define ss second
#define nl cout <<  endl
#define all(ar) ar.begin(), ar.end()
#define ini(X,Y) ll X; X=Y
#define inx(X) ll X; cin >> X
#define inxy(X, Y) ll X, Y; cin >> X >> Y
#define iter(arr) for (ll i=0; i<arr.size(); i++)
#define ret return
#define cont continue
ll inf=1000000007;

ll min1(ll a, ll b, ll c)
{
	ret (max(a,max(b,c)));
}

long long int *val,*wet;
long long int n,w;
long long int dp[103][100003];

ll solve(long long int i, long long int j)
{
	if (i==0)
	{
		ret 0;
	}
	if (dp[i][j]!=-1)
	{
		ret dp[i][j];
	}
	if (j>=wet[i])
	{
		dp[i][j]=val[i]+solve(i-1,j-wet[i]);
	}
	dp[i][j]=max(dp[i][j],solve(i-1,j));
	ret dp[i][j];
}

int main()
{
	fast;
	cin >> n >> w;
	val=new long long int[n+1];
	wet=new long long int[n+1];
	for (long long int i=1; i<=n; i++)
	{
		cin >> wet[i] >> val[i];
	}
	for (long long int i=0; i<103; i++)
	{
		for (long long int j=0; j<100003; j++)
		{
			dp[i][j]=-1;
		}
	}
	cout << solve(n,w);
	ret 0;
}

Measured memory_bytes: 80768
#include<stdio.h>

int main(){
	unsigned long int a,b;
	unsigned long int digit;
	int count = 1;
	
	while(scanf("%ld %ld",&a,&b) != EOF){
		count = 1;
		digit = a+b;
		
		while(1){
			digit /= 10;
			if(digit<1)break;
			++count;
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 600
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		int n=sc.nextInt();
		int c=sc.nextInt();
		int max=(int)1e5+5;
		int [] cnt=new int [max];
		ArrayList<pair> [] arr=new ArrayList [c];
		for(int i=0;i<c;i++)
			arr[i]=new ArrayList<pair>();
		while(n-->0){
			int s=sc.nextInt();
			int e=sc.nextInt();
			int cc=sc.nextInt()-1;
			arr[cc].add(new pair(s, e));
		}		
		for(ArrayList<pair> a : arr){
			Collections.sort(a);
			for(int i=0;i<a.size();i++){
				int s=a.get(i).x;
				int j=i;
				while(j<a.size()-1 && a.get(j+1).x==a.get(j).y)
					j++;
				int e=a.get(j).y+1;
				cnt[s]++;
				cnt[e]--;
				i=j;
			}
		}
		
		int ans=0;
		for(int i=0;i<max;i++){
			if(i>0)
				cnt[i]+=cnt[i-1];
			ans=Math.max(ans, cnt[i]);
		}
		pw.println(ans);
		pw.flush();
		pw.close();
	}
	
	static class pair implements Comparable<pair>{
		int x,y;
		pair(int a,int b){
			x=a;
			y=b;
		}
		public int compareTo(pair o){
			return x-o.x;
		}
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

Measured memory_bytes: 48076
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iomanip>
#include"math.h"


using namespace std;

int main(){
    int l;
    cin >> l;
    printf("%lf", pow((double)l/3, 3));
    return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

template<typename T>
class Heap {
private:
    vector<T> heap;
    int lastIndex = 0;
    function<bool(T, T)> compare;

    int up(int x) {
        if(x == 1) {
            return x;
        }
        if(compare(heap[x/2], heap[x])) {
            return x;
        }
        swap(heap[x/2], heap[x]);
        return up(x/2);
    }

    int down(int x) {
        if(x == lastIndex) {
            return x;
        }
        if(x*2 > lastIndex) {
            return x;
        }
        if(x*2 == lastIndex) {
            if(compare(heap[x], heap[x*2])) {
                return x;
            }
            swap(heap[x], heap[x*2]);
            return x*2;
        }

        int i = x*2 + !compare(heap[x*2], heap[x*2 + 1]);

        if(compare(heap[x], heap[i])) {
            return x;
        }
        swap(heap[x], heap[i]);
        return down(i);
    }
public:
    Heap(int size, function<bool(T, T)> compare) {
        lastIndex = 0;
        heap.resize(size + 1);
        this->compare = compare;
    }
    Heap(int size) {
        Heap(size, less<T>());
    }

    void add(T t) {
        lastIndex++;
        heap[lastIndex] = t;
        up(lastIndex);
    }

    void del() {
        swap(heap[1], heap[lastIndex]);
        lastIndex--;
        down(1);
    }

    T get() {
        return heap[1];
    }

    bool empty() {
        return heap.empty();
    }
};

int main() {
    LL N;
    cin >> N;
    vector<LL> a;
    a.resize(3*N);
    REP(i, 3*N) {
        cin >> a[i];
    }

    vector<LL> first;
    vector<LL> second;

    first.resize(N + 1);
    second.resize(N + 1);

    fill(ALL(first), 0);
    fill(ALL(second), 0);

    REP(i, N) {
        first[0] += a[i];
        second[0] += a[3*N - 1 - i];
    }

    Heap<LL> firstHeap(N + 1, less<LL>());
    Heap<LL> secondHeap(N + 1, greater<LL>());

    REP(i, N) {
        firstHeap.add(a[i]);
        secondHeap.add(a[3*N - 1 - i]);
    }

    FOR(i, 1, N + 1) {
        firstHeap.add(a[N + i - 1]);
        first[i] = first[i - 1] + a[N + i - 1] - firstHeap.get();
        firstHeap.del();

        secondHeap.add(a[2*N - i]);
        second[i] = second[i - 1] + a[2*N - i] - secondHeap.get();
        secondHeap.del();
    }

    LL res = -LINF;
    REP(i, N + 1) {
        res = max(first[i] - second[N - i], res);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
bool prime[100001];
vector<int> pr;
void makeprime(){
	rep(i,100001) prime[i]=true;
	prime[0]=prime[1]=0;
	rep(j,1000){
		if(!prime[j]) continue;
		for(int i=2;i*j<=100000;i++) prime[i*j]=false;
	}
	rep(i,100001) if(prime[i]) pr.pb(i);
}
int main(){
	makeprime();
	while(true){
		int m,a,b,ans=-1,ansp,ansq;
		cin>>m>>a>>b;
		if(m==0) break;
		for(int q:pr){
			int d=min(q,m/q);
			int id=upper_bound(all(pr),d)-pr.begin()-1;
			if(id!=-1){
				if(pr[id]*b>=q*a) if(ans<pr[id]*q) ans=pr[id]*q,ansp=pr[id],ansq=q;
			}
		}
		cout<<ansp<<" "<<ansq<<endl;
	}
}

Measured memory_bytes: 1424
// ABC073A - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

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

	bool ans = false;

	while (N > 0) {
		if (N % 10 == 9) {
			cout << "Yes" << endl;
			return 0;
		}
		N /= 10;
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256