akhauriyash/Code-Regression huggingface dataset:
import qualified Data.Vector.Unboxed as V
import Data.Array.IArray (listArray, accumArray, (!))
import Data.Array.MArray
import Data.Array.ST (STUArray, runSTUArray)
import Data.Array.Unboxed (UArray)
import Data.List (sortOn, sortBy, unfoldr, partition)
import Data.Char (isSpace)
import Control.Monad.ST (ST)
import Control.Monad.Trans.State (StateT(..))
import qualified Data.ByteString.Char8 as B

-- utility functions

--   Input functions
readInt = B.readInt . B.dropWhile isSpace

readInts :: Int -> B.ByteString -> [Int]
readInts n = take n . unfoldr readInt

readIntsV :: Int -> B.ByteString -> V.Vector Int
readIntsV n = V.unfoldrN n readInt

readIntsA :: Int -> B.ByteString -> UArray Int Int
readIntsA n bs = runSTUArray $ do
  arr <- newArray_ (0,n-1)
  go arr 0 bs
  return arr
  where
    go :: STUArray s Int Int -> Int -> B.ByteString -> ST s ()
    go arr i bs
      | i==n = return ()
      | otherwise = do
        let Just (x,bs') = readInt bs
        writeArray arr i x
        go arr (i+1) bs'

readTsV :: Int -> B.ByteString -> V.Vector (Int,Int)
readTsV n = V.unfoldrN n $ runStateT ((,) <$> StateT readInt <*> StateT readInt)

readTs :: Int -> B.ByteString -> [(Int,Int)]
readTs n = take n . unfoldr readT where
  readT = runStateT ((,) <$> StateT readInt <*> StateT readInt)

-- main

acgt 'A' = True
acgt 'C' = True
acgt 'G' = True
acgt 'T' = True
acgt _ = False

solv s = maximum [length s' | f<-[0..10], e<-[f..10], let s'=drop f (take e s), all acgt s']

main = do
  s <- getLine
  print $ solv s


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a,b; cin>>x>>a>>b;
    if (abs(x-a)<abs(x-b)){
        cout<<"A\n";
    }else{
        cout<<"B\n";
    }
    return 0;
}


Measured memory_bytes: 256
EPS = 1e-9
def dfs(bits, pos, s)
  return true if bits == (1<<$n) - 1
  $n.times do |i|
    unless bits & (1<<i) == 1<<i
      return false if $dist[i][$n+1] < s + $dist[pos][i] + EPS
    end
  end
  $n.times do |i|
    unless bits & (1<<i) == 1<<i
      return true if dfs(bits | (1<<i), i, s + $dist[pos][i])
    end
  end
  false
end
 
while l = gets
  $n, x0, y0, x1, y1 = l.split.map(&:to_i)
  break if $n == 0
  ps = $n.times.map { gets.split.map(&:to_i) }
  $ps = [*ps, [x0, y0], [x1, y1]]
  $dist = $ps.map { |x0, y0| $ps.map { |x1, y1| Math.sqrt((x1 - x0) ** 2 + (y1 - y0) ** 2) } }
  $used = [false] * $n
  puts dfs(0, $n, 0) ? 'YES' : 'NO'
end

Measured memory_bytes: 8876
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
      ll n,t,i,j;
      cin>>n>>t;
      ll w[n+1],v[n+1],x[n+1][t+2];
      for(i=1;i<=n;i++){
            cin>>w[i]>>v[i];
      }
      for(i=0;i<=n;i++)
      {
           for(j=0;j<=t;j++)
           {
                  if(i==0 || j==0)
                  {
                        x[i][j]=0;
                  }
                  else if(j>=w[i])
                  {
                        x[i][j]=max(x[i-1][j],x[i-1][j-w[i]]+v[i]);
                  }
                  else{
                        x[i][j]=x[i-1][j];
                  }
                //  cout<<x[i][j]<<" ";
           }
           //cout<<"\n";
      }
      cout<<x[n][t]<<"\n";
}

Measured memory_bytes: 79104
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
    long long n = 0;
    cin >> n;
    long long ans = 0;
    long long i = 1;
    while (i*i <= n) {
        ans = i*i;
        i++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  int n;
  cin>>n;
  
  double xa,ya,ra,xb,yb,rb;
  double D,R1,R2;
  rep(i,n){
    cin>>xa>>ya>>ra>>xb>>yb>>rb;
    
    D=(xa-xb)*(xa-xb)+(ya-yb)*(ya-yb);
    R1=(ra+rb)*(ra+rb);
    R2=(ra-rb)*(ra-rb);
    
    if(D>R1) cout<<0<<endl;
    else if(D>=R2 && D<=R1) cout<<1<<endl;
    else{
      if(ra>rb) cout<<2<<endl;
      else cout<<-2<<endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
		int in;
	cin>>n;
	vector<tuple<string,int,int>> v(n);
	rep(i,n){
		string s;
		cin>>s>>in;
		tuple<string,int,int> t;
		get<0>(t)=s;
		get<1>(t)=in;
		get<2>(t)=i+1;
		v[i]=t;
	}
	sort(all(v),[](auto &a,auto &b){
		if(get<0>(a)!=get<0>(b))return get<0>(a) < get<0>(b);
		else return get<1>(a) > get<1>(b);
	});
	rep(i,n){
		cout<<get<2>(v[i])<<endl;
	}
}


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

using namespace std;

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

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

    ans += b[N-1];
    sum = ans;

    for(int i=N-1;0<i;i--){
        sum -= a[i];
        sum += b[i-1];
        ans = max(ans,sum);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
// DP

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

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

ll dp[100010][3];
ll A[100010][3];

int main() {
  int n; cin >> n;
  rep(i,n){ rep(j,3) cin >> A[i][j]; }
  
  rep(i,n) {
    rep(j,3) {
      rep(k,3) {
        if(j == k) continue;
        chmax( dp[i+1][k], dp[i][j] + A[i][k] );
      }
    }
  }
  ll ans = 0;
  rep(j,3) chmax(ans, dp[n][j]);
  cout << ans << endl;
}

Measured memory_bytes: 8268
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

T binarySearch(alias pred, T)(T ok, T ng)
{ 
	while (abs(ok-ng) > 1)
	{
		auto mid = (ok+ng)/2;
		if (unaryFun!pred(mid)) ok = mid;
		else ng = mid;
	}
	return ok;
}

void main()
{
	auto N = RD;
	auto A = RDA;
	
	auto B = new long[](N);
	long[][long] list;
	foreach (i; 0..N)
	{
		B[i] = A[i] - i;
		list[B[i]] ~= i;
	}
	debug writeln(A);

	long ans;
	foreach (i; 0..N)
	{
		auto x = -(A[i] + i);
		auto l = list.get(x, []);
		
		bool f(long x)
		{
			return l[x] <= i;
		}
		auto pos = binarySearch!(f)(-1, cast(long)l.length);
		ans += l.length - (pos+1);
		debug writeln(ans);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

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

public class Main {
	public static void main(String[] args) {
		atcode();
	}

	public static void atcode() {
		String[] info = new Scanner(System.in).nextLine().split(" ");
		int max = Integer.parseInt(info[0]);
		int sMin = Integer.parseInt(info[1]);
		int sMax = Integer.parseInt(info[2]);
		Long sum=0l;
		for (Integer i = 1; i <= max; i++) {
			Integer s = Arrays.asList(i.toString().split(""))
					.stream()
					.mapToInt(Integer::parseInt)
					.sum();
			if (s >= sMin && s <= sMax)
				sum+=i.longValue();
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 43864
#include <iostream>
#include <iomanip>

using namespace std;

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

    int d = a / b;
    int r = a % b;
    double f = static_cast<double>(a) / b;

    cout << d << ' ' << r << ' ' << fixed << setprecision(5) << f << endl;

    return 0;
}

Measured memory_bytes: 3280
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int toi = Integer.parseInt(scanner.nextLine());
		String bin = "";

		while( toi != 0) {
			if(toi % -2 == 0) {
				bin = "0" + bin;
			}else if(toi % -2 != 0) {
				bin = "1" + bin;
				toi--;
			}

			toi /= -2;
		}

		if(bin.equals("")) {
			bin = "0";
		}

		System.out.println(bin);


	}
}


Measured memory_bytes: 21972
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if A<=9 and B<=9:
        print(A*B)
    else:
        print(-1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))

N = ii()
S = input()
cnt = [0] * N

for i in range(N):
    if S[i] == 'W':
        cnt[i] = 1

cnt = list(accumulate(cnt))
ans = N

for i in range(N):
    if S[i] == 'E':
        ans = min(ans, cnt[i] + (N-1-i)-(cnt[-1]-cnt[i]))
    else:
        ans = min(ans, i+1-cnt[i] + (N-1-i)-(cnt[-1]-cnt[i]))

print(ans)

Measured memory_bytes: 23760
#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() {
    int n,m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    ll time=0;
    rep(i,m) time += b[i];
    int j=m;
    int ans=0;

    rep(i,n+1) {
        while(j > 0 && time > k){
            --j;
            time -= b[j];
        }
        if(time>k) break;
        ans = max(ans, i+j);
        if(i==n) break;
        time += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    for(int r = K; r < N; r++)
    {
        int l = r - K;
        if(a[l] < a[r]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4020
#include <stdio.h>

int main(){
	int N,a[100001];

	scanf("%d",&N);

	int i;
	for(i=1;i<=N;i++){
		scanf("%d",&a[i]);
	}

	int num=0,next=1,flag=0;
	for(i=1;i<=N;i++){

		next=a[next];
		if(next==2){
			num++;
			printf("%d",num);
			flag=1;
			break;
		}
		num++;
	}

	if(flag==0)printf("-1");

}

Measured memory_bytes: 512
#include <iostream>

int main () {
    int n, max = 0;
    std::cin >> n;
    int h[n];
    std::cin >> h[0];
    max = h[0];
    for (int i = 1; i < n; ++i) {
        std::cin >> h[i];
        if(max <= h[i]) {
            max = h[i];
        }
        else if (max - h[i] > 1){
            std::cout << "No" << std::endl;
            max = -1;
            break;
        }
        else {
            continue;
        }
    }
    if(max != -1) {
        std::cout << "Yes" << std::endl;
    }
}
    


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,m,k;
int a[200005],b[200005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
	{
        cin>>a[i];
    }
    long long tot=0;
    for(int i=1;i<=m;i++)
	{
        cin>>b[i];
        tot+=b[i];
    }
    int ans=0;
    for(int ia=0,ib=m;ia<=n;ia++)
	{
        tot+=a[ia];
        while(tot>k&&ib>0)tot-=b[ib--];
        if(tot>k)break;
        ans=max(ans,ia+ib);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  
  
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <complex>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
// ------ Defines ------ //
#define Point complex<long double>
#define px real()
#define py imag()
// ------ Classes ------ //
class Segment {
public:
	Point p1, p2;
	Segment(Point p1_, Point p2_) : p1(p1_), p2(p2_) {};
	Segment(long double p1x, long double p1y, long double p2x, long double p2y) : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)) {};
	friend bool operator==(const Segment& s1, const Segment& s2) { return (s1.p1 == s2.p1 && s1.p2 == s2.p2) || (s1.p1 == s2.p2 && s1.p2 == s2.p1); }
	friend bool operator!=(const Segment& s1, const Segment& s2) { return !(s1 == s2); }
};
class Line {
public:
	Point p1, p2;
	Line(Point p1_, Point p2_) : p1(p1_), p2(p2_) {};
	Line(long double p1x, long double p1y, long double p2x, long double p2y) : p1(Point(p1x, p1y)), p2(Point(p2x, p2y)) {};
	friend bool operator==(const Line& s1, const Line& s2) { return (s1.p1 == s2.p1 && s1.p2 == s2.p2) || (s1.p1 == s2.p2 && s1.p2 == s2.p1); }
	friend bool operator!=(const Line& s1, const Line& s2) { return !(s1 == s2); }
};
// ------ Functions ------ //
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0, b = p2 - p0;
	if (crs(a, b) > 1e-8) return 1;
	if (crs(a, b) < -1e-8) return -1;
	if (dot(a, b) < -1e-8) return 2;
	if (norm(a) < norm(b)) return -2;
	return 0;
}
bool its(Point p1, Point p2, Point p3, Point p4) {
	return ((ccw(p1, p2, p3) * ccw(p1, p2, p4)) <= 0 && (ccw(p3, p4, p1) * ccw(p3, p4, p2)) <= 0);
}
bool its(Segment s1, Segment s2) {
	return its(s1.p1, s1.p2, s2.p1, s2.p2);
}
// ------ Main ------ //
int q, xp1, yp1, xp2, yp2, xq1, yq1, xq2, yq2;
int main() {
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d%d%d%d%d%d", &xp1, &yp1, &xp2, &yp2, &xq1, &yq1, &xq2, &yq2);
		printf("%d\n", (its(Segment(xp1, yp1, xp2, yp2), Segment(xq1, yq1, xq2, yq2)) ? 1 : 0));
	}
	return 0;
}

Measured memory_bytes: 2804
i = input().split()
all = int(i[0])
x = int(i[1])
y = int(i[2])
t = 0
max = 0
if x > y:
    max = x - abs(x - y)
    t = x
elif y > x:
    max = y - abs(x - y)
    t = y 
else:
    t = x
    max = x

min = 0
nx = all - x
ny = all - y

if nx > ny:
    nt = nx
elif ny > nx:
    nt = ny
else:
    nt = nx
if t >= nt: 
    min = t - nt
else:
    min = 0
print("{0} {1}".format(max,min))

Measured memory_bytes: 3064
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	int a, b,ans=0;
	cin >> a >> b;
	int n = gcd(a, b);
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0 && prime(i))ans++;
		if (n % i == 0 && prime(n / i))ans++;
	}
	cout << ans+1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int i,j;

        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();

            for(i = 0;i < x;i++){
                for(j = 0;j < y;j++){
                    if(i == 0 || j == 0 || i == x-1 || j == y-1){
                        System.out.printf("#");
                    }
                    else{
                        System.out.printf(".");
                    }
                }

                System.out.printf("\n");

            }

            if(x == 0 && y == 0)break;

            System.out.printf("\n");

        }
    }
}


Measured memory_bytes: 61768
N,M = list(map(int, input().split()))
cakes = []
for i in range(N):
    cakes.append(list(map(int, input().split())))

ans = 0

values = []
for x,y,z in cakes:
    values.append(x+y+z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))

values = []
for x,y,z in cakes:
    values.append(x+y-z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


values = []
for x,y,z in cakes:
    values.append(x-y+z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


values = []
for x,y,z in cakes:
    values.append(x-y-z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


values = []
for x,y,z in cakes:
    values.append(-x+y+z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


values = []
for x,y,z in cakes:
    values.append(-x+y-z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))



values = []
for x,y,z in cakes:
    values.append(-x-y+z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


values = []
for x,y,z in cakes:
    values.append(-x-y-z)
values.sort()
values = values[::-1]
ans = max(ans, sum(values[:M]))


print(ans)


Measured memory_bytes: 3316
#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 a;cin>>a;
  string b;cin>>b;

  ll tb=0;
  for(auto c:b){
    if(c=='.')continue;
    tb*=10;
    tb+=(c-'0');
  }
  cout<<tb*a/100<<endl;

//cout<<a<<' '<<tb<<endl;

  return 0;
}

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

int main(){
	int x, y;
	cin  >> x;
	
	if      (x < 600) y = 8;
	else if (x < 800) y = 7;
	else if (x < 1000) y = 6;
	else if (x < 1200) y = 5;
	else if (x < 1400) y = 4;
	else if (x < 1600) y = 3;
	else if (x < 1800) y = 2;
	else               y = 1;
	
	cout << y << endl;
return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n, k;
  cin >> n >> k;
  long long int tmp;
  if(n > k){
    tmp = n / k;
    n = min(abs(n - k * tmp),abs(n - k * (tmp + 1)));
  }
  else {
    n = min(n, abs(n-k));
  }
  cout << n << endl;
}



Measured memory_bytes: 256
from math import ceil
N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

def calc(A):
    if N%A==0:
        return N//A
    else:
        return N//A+1
a=calc(A)
b=1+max(a, calc(B))
c=2+max(b-1,calc(C))
d=3+max(c-2, calc(D))
e=4+max(d-3, calc(E))
print(e)

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

int main() {
    int x,y;
    for(int i = 0; i < 3000; i++){
        cin >> x >> y;
        if(x == 0 && y == 0)break;
        cout << min(x,y) << " " << max(x,y) << endl;
    }
}


Measured memory_bytes: 2992
N,M = map(int,input().split())
S = input()
T = input()
flag = True
def lcm(a, b): # 最小公倍数
    def gcd(a, b): # 最大公約数
        while b:
            a, b = b, a % b
        return a
    return a * b // gcd(a, b)
L = lcm(N,M)
def gcd(a, b): # 最大公約数
    while b:
        a, b = b, a % b
    return a

flag = True
for i in range(gcd(N,M)):
    if S[i*N//gcd(N,M)] == T[i*M//gcd(N,M)] and flag:
        pass
    else:
        flag = False
if flag:
    print(L)
else:
    print(-1)


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N_MAX = 100;
typedef pair<int,int> P;
int main()
{
  int n,i,j=0,res=0;
  P r[N_MAX],b[N_MAX];
  vector<int> v={};
  vector<int>::iterator it;
  cin >> n;
  for(i=0;i<n;i++)
    cin >> r[i].first >> r[i].second;
  for(i=0;i<n;i++)
    cin >> b[i].first >> b[i].second;
  sort(r,r+n,greater<P>());
  sort(b,b+n,greater<P>());
  for(i=0;i<n;i++){
    for(;j<n&&b[j]>r[i];j++)
      v.push_back(b[j].second);
    if(v.empty()) continue;
    sort(v.begin(),v.end());
    it=upper_bound(v.begin(),v.end(),r[i].second);
    if(it!=v.end()){
      res++;
      v.erase(it);
    }
  }
  cout << res << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> q.at(i);
  }
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    a.at(i) = i + 1;
  }
  
  int A, B;
  int count = 0;
  do {
    count++;
    if (a == p) A = count;
    if (a == q) B = count;
  }while(next_permutation(a.begin(), a.end()));
  
  cout << abs (A - B) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,c,d1[100000],d2[100000],ans;
vector<ll> v[100000];
void dfs1(ll a,ll b,ll c){
    for(ll x:v[a]){
        if(x==c)continue;
        dfs1(x,b+1,a);
    }
    d1[a]=b;
    return ;
}
void dfs2(ll a,ll b,ll c){
    for(ll x:v[a]){
        if(x==c)continue;
        dfs2(x,b+1,a);
    }
    d2[a]=b;
    return ;
}
int main(void){
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs1(0,0,-1);
    dfs2(n-1,0,-1);
    for(int i=0;i<n;i++){
        if(d1[i]<=d2[i])ans++;
    }
    if(ans>n-ans)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}


Measured memory_bytes: 13568
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list>
#include <unordered_set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define _GLIBCXX_DEBUG
using namespace std;
struct __INIT { __INIT() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } __init;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool PSecComp(const pair_t& a, const pair_t& b) {
	if (a.second == b.second)return  a.first > b.first;
	else {
		return a.second > b.second;
	}
}

int main(){
	
	string s;
	cin >> s;
	ll n = s.length();
	vector<ll>ans(n,0);
	for (ll i = 0; i < n; i++) {
		if ((s[i] == 'R' && s[i + 1] == 'L') && (i+1 < s.length())) {
			ans[i] += 1;
			ans[i + 1] += 1;
			i++;
		}
	}
	s += 'R';
	ll Rcnt = 0, Lcnt = 0, Rindex = -1, Lindex = -1;
	for (ll i = 0; i < n; i++) {
		if (s[i] == 'R' && s[i + 1] == 'L') {
			Rindex = i;
			Lindex = i + 1;
		}
		else {
			if (s[i] == 'L' && s[i + 1] == 'R') {
				if(i != Lindex)Lcnt++;
				ll tmpR = ceil((Rcnt) / 2.0);
				ll tmpL = ceil((Lcnt) / 2.0);
				ans[Rindex] += Rcnt - tmpR + tmpL;
				ans[Lindex] += Lcnt - tmpL + tmpR;
				Rcnt = 0;
				Lcnt = 0;
			}
			else if (s[i] == 'R' && i != Rindex)Rcnt++;
			else if (s[i] == 'L' && i != Lindex)Lcnt++;
		}
	}
	rep(i, n) { cout << ans[i] << " "; }
	cout << endl;
}



Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  map<int, long long> M;
  for (int i = 0; i < N; i++){
    M[A[i]]++;
  }
  long long total = 0;
  for (auto j : M){
    int a = j.first;
    long long b = j.second;
    total += b * (b - 1) / 2;
  }
  for (int i = 0; i < N; i++){
    cout << total - (M[A[i]] - 1) << endl;
  }
}


Measured memory_bytes: 10240
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MOD = 1000000007;

int add(int x, int y) {
	return (x + y >= MOD ? x + y - MOD : x + y);
}

int mult(int x, int y) {
	return (x * 1LL * y) % MOD;
}

void solve() {
	int n = fetch<int>();
	auto a = fetch_vec<int>(n);
	int answ = 1, uniq = 0;
	vector<int> cnt(n, 0);

	for(auto& x: a) {
		if(x == 0) {
			++uniq;
			++cnt[x];

		} else {
			answ = mult(answ, cnt[x - 1]);

			++cnt[x];
			--cnt[x - 1];
		}
	}

	for(int i = 0; i < uniq; ++i) {
		answ = mult(answ, 3 - i);
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ll n,m;cin>>n>>m;
    vector<pll> v[n+1];
    rep(i,0,m){
        ll s,t;cin>>s>>t;
        v[s].push_back({t,i});
    }
    double ans=1000000000;
    double dpp[n+1];
    fill(dpp,dpp+n+1,0);
    dpp[n]=0;
    rrep(i,n-1,1){
        double cnt=v[i].size();
        
        rep(k,0,v[i].size()){
            
            dpp[i]+=dpp[v[i][k].first]/cnt;
        }
        
        dpp[i]=dpp[i]+1;
    }
    ans=dpp[1];
    rep(i,1,n){
        double dp[n+1];
        fill(dp,dp+n+1,0);
        dp[n]=0;
        ll che=0;
        rrep(j,n-1,1){
           if(j==i){
              if(v[j].size()==1){
                dp[j]=1000000000;
              }
              else{
                double summ=0;
                double maa=0;
                rep(k,0,v[j].size()){
                   ll ne=v[j][k].first;
                  summ+=dp[ne];
                  maa=max(maa,dp[ne]);
                }
                summ-=maa;
                summ/=(double)(v[j].size()-1);
                dp[j]=summ+1;
              }
           }
           else{
             rep(k,0,v[j].size()){
               ll ne=v[j][k].first;
               dp[j]+=dp[ne];
             }
             dp[j]/=(double)(v[j].size());
             dp[j]++;
           }
        }

       
        ans=min(ans,dp[1]);
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
long long extgcd(long long a, long long b, long long &x, long long &y) {
	if (!b) {
		x = 1, y = 0;
		return a;
	}
	long long g = extgcd(b, a % b, y, x);
	y -= (a / b) * x;
	return g;
}
inline long long calcinv(long long a, long long m) {
	long long x, y;
	extgcd(a, m, x, y);
	return (x % m + m) % m;
}
vector<pair<long long, long long> > FF(long long n) {
	vector<pair<long long, long long> > vec;
	for (long long i = 2; i * i <= n; i++) if (n % i == 0) {
		int cc = 0;
		long long pp = 1;
		while (n % i == 0) {
			cc++;
			n /= i;
			pp *= (long long)i;
		}
		vec.push_back(make_pair(i, pp));
	}
	if (n > 1) vec.push_back(make_pair(n, n));
	return vec;
}
long long m1[100], m2[100];
int main() {
	long long n;
	cin >> n;
	if (n % 2 == 0) {
		n *= 2;
	}
	vector<pair<long long, long long> > vec = FF(n);
	for (int i = 0; i < (int)vec.size(); i++) {
		m1[i] = n / vec[i].second;
		m2[i] = calcinv(m1[i] % vec[i].second, vec[i].second);
	}
	long long ans = 0;
	for (int mask = 1; mask < (1 << vec.size()); mask++) {
		long long cur = 0;
		for (int i = 0; i < (int)vec.size(); i++) if (mask >> i & 1) {
			cur += m1[i] * m2[i];
		}
		cur %= n;
		ans = max(ans, cur);
	}
	cout << n - ans << endl;
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int w;
		int n;
		
		//データ入力の準備
		Scanner sc = new Scanner(System.in);
		
		//あみだくじのサイズを入力
		w = sc.nextInt();
		n = sc.nextInt();
		
		//データ格納用配列の追加
		int[] data = new int[w];
		for (int i = 0; i < w; i++){
			data[i] = i + 1;
		}
		
		//あみだくじのswap
		for (int i = 0; i < n; i++){
			String str = sc.next();
			String ab[] = str.split(",");
			
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			
			swap(data,a,b);
		}
		
		//結果の出力
		for (int i = 0; i < w; i++){
			System.out.println(data[i]);
		}
	}
	
	private static void swap(int[] data, int a, int b){
		int temp = data[a];
		data[a] = data[b];
		data[b] = temp;
	}
}


Measured memory_bytes: 26096
#include<stdio.h>

int main() {
    int X, A, B;
    scanf("%d %d %d", &X, &A, &B);
    if ((B - A) <= 0) {
        printf("delicious\n");
    } else if ((B - A) > 0 && (B - A) <= X) {
        printf("safe\n");
    } else {
        printf("dangerous\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h ,w;
  cin >> h >> w;
  vector<vector<char>> maze(h+2,vector<char>(w+2,'.'));
  vector<int> dx = {1,-1,0,0};
  vector<int> dy = {0,0,1,-1};
  bool ok = true;
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      cin >> maze.at(i).at(j);
    }
  }
  for(int i=1;i<h+1;i++){
    for(int j=1;j<w+1;j++){
      if( maze.at(i).at(j) =='#'){
        int count = 0;
        for(int k=0;k<4;k++){
          if(maze.at(i+dx.at(k)).at(j+dy.at(k))=='#'){
            count ++;
          }
        }
        if(count ==0){
          ok = false;
        }
      }
    }
  }
  if(ok) cout << "Yes" <<endl;
  else cout << "No" << endl;
}
          
  
      

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

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int x; cin >> x;
    cout << !x << endl;
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
int K,T;
int a[100];
int main(){
  int max=0,count=0;
  cin >> K >> T;
  for(int i=0;i<T;i++){
    cin >> a[i];
    if(a[max]<a[i])max=i;
  }
  int i,x=101;
  while(K>0){
    max=0;
    for(i=0;i<T;i++){
      if(a[max]<a[i])max=i;
    }
    a[max]--;K--;
    if(x==max)count++;
    x=max;
    if(K==0)break;
    for(i=0;i<T;i++){
      if(i!=max && a[i]!=0) break;
    }
    if(i==max || i==T){
      a[max]--;
      K--;
      if(x==max)count++;
      x=max;
    }
    else{
      a[i]--;
      K--;
      if(x==i)count++;
      x=i;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define nln printf("\n")
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll t, n, x;
    string s;
    cin >> s;
    ll sum = 0;
    for (int i = 0; i < s.size(); i++)
    {
        x = s[i] - '0';
        sum += x;
    }

    if (sum % 9 == 0)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define REP(i,n) for(ll i = 0;i < n; i++)
int main(){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> A(q); //問題
    vector<int> Point(n,0);
    REP(i,q) cin >> A[i];
    REP(i,q){
        Point[A[i]-1]++;
    }
    int max= *max_element(Point.begin(),Point.end());
    cerr << max << endl;
    REP(i,n){
        if(q-k<Point[i] && Point[i]<=max) cout << "Yes" << endl;
        else cout << "No" << endl;
    } 
    return 0;
}

Measured memory_bytes: 1408
#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 Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

ll f(int d){
    ll res=1;
    while(d>0){
        res *= 100;
        d--;
    }
    return res;
}

int main(){
    int d,n;
    cin >> d >> n;
    if(n==100 && d==0){
        cout << 101 << endl;
    }else if(n==100 && d==1){
        cout << 10100 << endl;
    }else if(n==100 && d==2){
        cout << 1010000 << endl;
    }
    else cout << f(d) * (ll)n << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,M,m;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++) cin>>A[i];
  M=A[0];
  m=A[0];
  for(int i=0;i<N;i++){
  	M=max(M,A[i]);
    m=min(m,A[i]);
  }
  cout<<M-m<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
    	Scanner s = new Scanner(System.in);
    	long a = s.nextLong(), b = s.nextLong(), c = s.nextLong(), d = s.nextLong();
    	long r = b * d;
    	r = Math.max(r, a * c);
    	r = Math.max(r, a * d);
    	r = Math.max(r, b * c);
    	System.out.println(r);
    }
}


Measured memory_bytes: 35700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


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

   if(s=="SUN") out(7);
   else if(s=="MON") out(6);
   else if(s=="TUE") out(5);
   else if(s=="WED") out(4);
   else if(s=="THU") out(3);
   else if(s=="FRI") out(2);
   else if(s=="SAT") out(1);
}

Measured memory_bytes: 256
n=io.read("*n","*l")
a={}
l={}
r={}
for i=1,n do
    a[i]=io.read("*n")
    if not l[i+a[i]] then
        l[i+a[i]]=1
    else
        l[i+a[i]]=l[i+a[i]]+1
    end
    if not r[i-a[i]] then
        r[i-a[i]]=1
    else
        r[i-a[i]]=r[i-a[i]]+1
    end
end

combination=0
for i,_ in pairs(l) do
    if r[i] then
        combination=combination+l[i]*r[i]
    end
end
print(combination)

Measured memory_bytes: 27208
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

int n,s;
int saiki(int n1,int u,int m){
    if(n1 > s) return 0;
    else if(m==1){
	int d = s-n1;
	if(d <= 9 && (u & (1<<d))==0) return 1;
	else return 0;
    }else if(m==2){
	if(s-n1>26) return 0;
    }else if(m==3){
	if(s-n1>50) return 0;
    }else if(m==4){
	if(s-n1>80) return 0;
    }else if(m==5){
	if(s-n1>115) return 0;
    }

    int ans;
    for(int i=9;i>=0;i--){
	if((u & (1<<i))==0){
	    ans += saiki(n1+m*i,u|(1<<i),m-1);
	}
    }
    return ans;
}

void main(){
    while(true){
	auto ss = readln();
	if(stdin.eof()) break;
	int[] s1 = ss.split().to!(int[]);
	n = s1[0];
	s = s1[1];
	if(n <= 330)
	    writeln(saiki(0,0,n));
	else writeln(0);
    }
}

Measured memory_bytes: 2312
#include<cstdio>
#include<iostream>
using namespace std;
int h,w,fir[10],las[10];
bool ans=1;
char a[10][10];
int main() {
    cin>>h>>w;
    for(int i=1;i<=h;i++) {
        scanf("%s",a[i]+1);
        int num=0;
        for(int j=1;j<=w;j++) {
            if(a[i][j]=='#'&&a[i][j+1]!='#')
                num++,las[i]=j;
            if(!fir[i]&&a[i][j]=='#')
                fir[i]=j;
        }
        if(num!=1) ans=0;
        if(fir[i]!=las[i-1]&&i>1) ans=0;
    }
    if(a[h][w]!='#') ans=0;
    ans ? cout<<"Possible":cout<<"Impossible";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <random>
#include <tuple>
#include <iomanip>
#include <cstring>

using namespace std;

typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n-1); i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}


double solve(double s, double g, double mv, double t){
  double rs = mv - s;
  double rg = t - (mv - g);
  double res = 0;
  if(rs <= rg){
    res = mv * t;
    res -= rs * rs / 2;
    res -= (t - rg) * (t - rg) / 2;
  }else{
    double x, y;
    x = (-s + g + t) / 2;
    y = (s + g + t) / 2;
    res = y * t;
    res -= x * x / 2;
    res -= (t - x) * (t - x) / 2;
  }
  return res;
}


int main(){
  ll N; cin >> N;
  vector<double> T(N), maxV(N+1, 0);
  rep(i, N) cin >> T[i];
  vector<double> tmpMaxV(N);
  rep(i, N) cin >> tmpMaxV[i];
  rep(i, N-1) maxV[i+1] = min(tmpMaxV[i], tmpMaxV[i+1]);
  maxV[0] = 0, maxV[N] = 0;

  bool update = 1;
  while(update){
    update = 0;
    rep(i, N){
      if(maxV[i+1] > maxV[i] + T[i]){
        maxV[i+1] = maxV[i] + T[i];
        update = 1;
      }
    }
    revrep(i, N){
      if(maxV[i] > maxV[i+1] + T[i]){
        maxV[i] = maxV[i+1] + T[i];
        update = 1;
      }
    }
  }
  double ans = 0;
  rep(i, N){
    ans += solve(maxV[i], maxV[i+1], tmpMaxV[i], T[i]);
  }
  cout << fixed << setprecision(12) << ans << endl;

}


Measured memory_bytes: 384