akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
using namespace std;
int h,w,k;
char mz[1005][1005];
int sx,sy;
int vis[1005][1005];
struct point{
  int x,y;
  point(int a,int b){
    x=a;y=b;
  }
  point(){}
}q[1005*1005];
int head,tail;
int d[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
bool legal(int x,int y){
  return 1<=x&&x<=h&&1<=y&&y<=w;
}
int dis[1005][1005];
void bfs0(int sx,int sy){
  head=tail=0;
  q[tail++]=point(sx,sy);
  while(head!=tail){
    point tmp=q[head++];
    if(dis[tmp.x][tmp.y]==k)continue;
    vis[tmp.x][tmp.y]=1;
    for(int k=0;k<4;++k){
      int xx=tmp.x+d[k][0],yy=tmp.y+d[k][1];
      if(vis[xx][yy]||!legal(xx,yy)||mz[xx][yy]=='#')continue;
      vis[xx][yy]=1;dis[xx][yy]=dis[tmp.x][tmp.y]+1;
      q[tail++]=point(xx,yy);
    }
  }
}
void bfs(){
  while(head!=tail){
    point tmp=q[head++];
    for(int k=0;k<4;++k){
      int xx=tmp.x+d[k][0],yy=tmp.y+d[k][1];
      if(vis[xx][yy]||!legal(xx,yy))continue;
      vis[xx][yy]=1;dis[xx][yy]=dis[tmp.x][tmp.y]+1;
      q[tail++]=point(xx,yy);
    }
  }
}
int main(){
  scanf("%d%d%d",&h,&w,&k);
  for(int i=1;i<=h;++i){
    scanf("%s",mz[i]+1);
  }
  for(int i=1;i<=h;++i){
    for(int j=1;j<=w;++j){
      if(mz[i][j]=='S')sx=i,sy=j;
    }
  }
  bfs0(sx,sy);
  for(int i=1;i<=h;++i){
    for(int j=1;j<=w;++j){
      if(vis[i][j])q[tail++]=point(i,j),dis[i][j]=0;
    }
  }
  bfs();
  int ans=0x3f3f3f3f;
  for(int i=1;i<=h;++i){
    ans=min(ans,1+(dis[i][1]+k-1)/k);
    ans=min(ans,1+(dis[i][w]+k-1)/k);
  }
  for(int i=1;i<=w;++i){
    ans=min(ans,1+(dis[1][i]+k-1)/k);
    ans=min(ans,1+(dis[h][i]+k-1)/k);
  }
  printf("%d\n",ans);
  return 0;
}


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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

int main(int argc, char *argv[])
{
    int x;
    int cnt=0;
    rep(i, 5) {
        cnt++;
        cin >> x;
        if (x == 0) {
            cout << cnt << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3624
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long a, b;

long ext_gcd(long a, long b, long &x, long &y){
    if(b == 0){
        x = 1;
        y = 0;
        return a;
    }
    long d = ext_gcd(b, a % b, y, x);
    y -= a/b * x;
    return d;
}

int main(){
    scanf("%ld%ld", &a, &b);
    long x, y;
    ext_gcd(a, b, x, y);
    printf("%ld %ld\n", x, y);
}



Measured memory_bytes: 3232
N = int(input())
C = []
for i in range(N):
    C.append(list(map(int, input().split())))
c_pre = [0, 0, 0]
for c_now in C:
    tr = abs(c_now[0]-c_pre[0])
    length = abs(c_now[1]-c_pre[1])+abs(c_now[2]-c_pre[2])
    if length<=tr and tr%2==length%2:
        c_pre = c_now
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 27380
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#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>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int s;
    cin >> s;
    vector<int> set;
    set.push_back(s);
    while(1){
        if(s % 2 == 0){
            s = s/2;
        }else{
            s = 3*s+1;
        }
        set.push_back(s);
        rep(i, set.size()){
            rep(j, set.size()){
                if(i != j){
                    if(set[i] == set[j]){
                        cout << max(i, j)+1;
                        return 0;
                    }
                }
            }        }
    }
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N; cin >> N;
  map<int,int> num;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (num.count(a)) num.erase(a);
    else num[a] = 1;
  }
  
  cout << num.size() << endl;
}

Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int a,b,c;
    cin >> a >> b >>c;

    if(a == b){
        cout << c << endl;
    }
    else if(a == c){
        cout << b << endl;
    }
    else if(b == c){
        cout << a << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
inpl = lambda: list(map(int,input().split()))

class SegAccumCalc:
    def __init__(self, value, N=0, calc=lambda x,y: x+y):
        M = max(len(value),N)
        N = 2**(len(bin(M))-3)
        if N < M: N *= 2
        self.N = N
        self.node = [None] * (2*N-1)
        for i, v in enumerate(value):
            self.node[i+N-1] = v
        self.calc = lambda x, y: x if y is None else y if x is None else calc(x,y)
        for i in range(N-2,-1,-1):
            left, right = self.node[2*i+1], self.node[2*i+2]
            self.node[i] = self.calc(left, right)

    def set_value(self, n, v):
        i = (self.N-1) + n
        self.node[i] = v
        while i > 0:
            i = (i-1)//2
            left, right = self.node[2*i+1], self.node[2*i+2]
            new = self.calc(left,right)
            if self.node[i] == new:
                break
            else:
                self.node[i] = new

    def get(self,
            a=0, b=-1,
            k=0, l=0, r=-1):
        if b < 0:
            b = self.N
        if r < 0:
            r = self.N
        if a <= l and r <= b:
            return self.node[k]
        elif r <= a or b <= l:
            return None
        else:
            left = self.get(a,b,2*k+1,l,(l+r)//2)
            right = self.get(a,b,2*k+2,(l+r)//2,r)
            return self.calc(left,right)

N = int(input())
A = inpl()
sac = SegAccumCalc(A,calc=gcd)
ans = 0
for i in range(N):
    if i == 0:
        c = sac.get(1,N)
    elif i == N-1:
        c = sac.get(0,N-1)
    else:
        c = gcd(sac.get(0,i),sac.get(i+1,N))
    if c > ans:
        ans = c
print(ans)

Measured memory_bytes: 97640
import copy
n,k=map(int,input().split())
a=list(map(int,input().split()))
fact=[]
for i in range(1,int(sum(a)**0.5)+1):
  if sum(a)%i==0:
    fact.append(i)
    fact.append(sum(a)//i)
fact=list(set(fact))
fact.sort()
fact.reverse()
a.sort()
a.reverse()
for i in range(len(fact)):
  a2=copy.copy(a)
  for j in range(n):
    a2[j]%=fact[i]
  a2.sort()
  a2.reverse()
  ct=0
  for m in range(sum(a2)//fact[i]):
    ct+=a2[m]
  if (sum(a2)-ct)<=k:
    print(fact[i])
    break

Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, k;
    cin >> n >> k;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vvl dp(n+1, vl(k+1));  // dp[i+1][j] : i人目の子供(iは0-index)まででj個の飴を分け合う方法の数
    dp[0][0] = 1;
    rep(i, n) {
        exrep(j, 0, k) {
            /* exrep(x, 0, min(j, a[i])) {  // i人目の子供にx個の飴をあげるとする
                dp[i+1][j] += dp[i][j-x];
            }
            ↑ このままではTLEなので漸化式の階差を取って高速化する
            dp[i+1][j] = sum_{0 <= x <= a[i]} dp[i][j-x] で
            dp[i+1][j-1] = sum_{0 <= x <= a[i]} dp[i][j-x-1] なので
            dp[i+1][j] - dp[i+1][j-1] = dp[i][j] - dp[i][j - a[i] - 1] となる(最初と最後の項だけ残る)
            よって、 dp[i+1][j] = dp[i][j] + dp[i+1][j-1] - dp[i][j - a[i] - 1] と更新すればよい */
            if(j == 0) {
                dp[i+1][j] = dp[i][j];
            }
            else if(j <= a[i]) {
                dp[i+1][j] = dp[i][j] + dp[i+1][j-1];
            }
            else {
                 dp[i+1][j] = dp[i][j] + dp[i+1][j-1] - dp[i][j - a[i] - 1] + mod;
            }
            dp[i+1][j] %= mod;
        }
    }

    out(dp[n][k]);
    re0;
}

Measured memory_bytes: 80256
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
n=N()
l=LN(n)
ans=l[0]-1
lo=2
for i in l[1:]:
    if i==lo:
        lo+=1
    else:
        ans+=(i-1)//lo
print(ans)

Measured memory_bytes: 7876
# -*- coding: utf-8 -*-
n = int(input())
counter = 0
for i in range(n):
  if (i + 1) % 2 == 0:
    continue
  _c = 0
  for j in range(n):
    if (i + 1) % (j + 1) == 0:
      _c += 1
  if _c == 8:
    counter += 1
    #print(i + 1)
print(counter)

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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = INF + 7;

/////////////////////////////////////////////////////////////////////

const int N = 1e3 + 5;

bool c[N][N];

int32_t main() {

    sync;

	int n, m, a, b; cin >> n >> m >> a >> b;
	for(int i = 0; i < b; i++) for(int j = 0; j < a; j++) c[i][j] = true;
	for(int i = b; i < n; i++) for(int j = a; j < m; j++) c[i][j] = true;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) cout << c[i][j];
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	int taro = 0, hanako = 0;
	rep(i, 0, n) {
		string s, t;
		cin >> s >> t;
		if (s < t) hanako += 3;
		else if (s > t)taro += 3;
		else { taro++;hanako++; }
	}
	cout << taro << " " << hanako << '\n';
	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
bool comp(pair<ll, ll> &a, pair<ll, ll> &b) { return a.second < b.second; }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, k, s;
  cin >> n >> k >> s;

  ll maxVal = 1e9;
  if (s == maxVal) {
    for (ll i = 1; i <= k; i++)
      cout << maxVal << " ";
    for (ll i = k + 1; i <= n; i++)
      cout << 1 << " ";
    cout << en;
  } else {
    for (ll i = 1; i <= k; i++)
      cout << s << " ";
    for (ll i = k + 1; i <= n; i++)
      cout << maxVal << " ";
    cout << en;
  }

  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define int long long
const int N=110;
int n,a[N],c[N],ans,g,de[N];
inline void dfs(int x,int sum,int g){
	if (g+sum<=ans) return;
	if (x==n+1) {ans=sum;return;}
	if (de[x]) {dfs(x+1,sum,g);return;}
//	if (x+x>n) {dfs(x+1,sum+c[x],g-c[x]);return;}
	dfs(x+1,sum+a[x],g-c[x]);
	for (int i=x;i<=n;i+=x) if (!de[i]++) g-=c[i]; 
	dfs(x+1,sum,g);	
	for (int i=x;i<=n;i+=x) --de[i];	
}
main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i]),g+=c[i]=max(a[i],0ll);
	dfs(1,0,g);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPictureFrame solver = new BPictureFrame();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPictureFrame {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int h = in.nextInt(), w = in.nextInt();
            IntStream.range(0, w + 2).forEach(x -> out.print('#'));
            out.println();
            for (int i = 0; i < h; i++) {
                out.print('#');
                out.print(in.next());
                out.println('#');
            }
            IntStream.range(0, w + 2).forEach(x -> out.print('#'));
            out.println();
        }

    }
}



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

using namespace std;

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

	if(a > b){
		for(int i=0; i<a; i++)
			cout << b ;
	}else{
		for(int i=0; i<b; i++)
			cout << a;
	}	
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
def readinput():
    s=input()
    return s

def main(s):
    if s=='ABC':
        return 'ARC'
    elif s=='ARC':
        return 'ABC'
    ans=''
    return ans

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)


Measured memory_bytes: 8980
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	// エラトステネスのふるい(n以下の素数を求める)
	public static boolean[] sieve (int n) {
		boolean[] isPrime = new boolean[n + 1];
		Arrays.fill(isPrime, true);
		for (int i = 4; i < isPrime.length; i += 2)
			isPrime[i] = false;
		for (int i = 3; i * i <= n; i += 2) {
			for (int j = 3; i * j <= n; j += 2)
				isPrime[i * j] = false;
		}
		return isPrime;
	}

	public static int solve (int n) {
		int ret = 0;
		boolean[] primes = sieve(n);
		for (int i = 2; i <= n / 2; i++) {
			if (!primes[i]) continue;
			ret = primes[n - i] ? ret + 1 : ret;
		}
		return ret;
	}

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			int n = Integer.parseInt(br.readLine());
			if (n == 0) break;
			System.out.println(solve(n));
		}

	}

}

Measured memory_bytes: 89832
#include<iostream>
#include <string>

using namespace std;
int main()
{
  int N;
  cin >> N;
  int P[N];
  for(int i = 0; i < N; i++) cin >> P[i];
  
  int minN = 200000;
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if (P[i] <= minN) {
      ans++;
      minN = P[i];
    }
  }

  cout << ans << endl;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
// #define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define RFOR(i, a, b) for(int i = (int)(b - 1); i >= (int)(a); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

int main() {
  int N, T;
  cin >> N >> T;
  T /= 2;

  vll apples(N);
  REP(i, N) {
    cin >> apples[i];
  }

  vll maxd(N, -1);
  ll maxv = 0;
  ll gain = 0;
  RREP(i, N) {
    maxv = max(maxv, apples[i]);
    maxd[i] = maxv - apples[i];
    gain = max(gain, maxd[i]);
  }

  int cnt = 0;
  REP(i, N) {
    if (gain == maxd[i]) {
      cnt++;
    }
  }

  // REP(i, N - 1) FOR(j, i + 1, N) {
  //   int d = apples[j] - apples[i];
  //   if (gain == d) {
  //     cnt++;
  //   } else if(gain < d) {
  //     gain = d;
  //     cnt = 1;
  //   }
  // }


  cout << cnt << endl;
  // LOG("gain %d, n %d\n", gain, cnt);
}


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

int main(){
    int H, W;
    for(;;){
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }
   for(int i = 1; i <= H; i++){
       for(int j = 1; j <= W; j++){
            if((i + j) % 2 == 0){
               cout << "#";
            }
            if((i + j) % 2 != 0){
                cout << ".";
            }
           }
           cout << endl;
       }
       cout << endl;
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
 
    using namespace std;
 
    typedef long long ll;
    typedef long double ld;
 
    typedef pair<int, int> pi;
    typedef pair<ll,ll> pl;

    typedef vector<int> vi;
    typedef vector<ll> vl;
    typedef vector<pi> vpi;
    typedef vector<pl> vpl;
    typedef vector<vi> vvi;

    #define FOR(i, a, b) for (int i=a; i<(b); i++)
    
    #define sz(x) (int)(x).size()
    #define mp make_pair
    #define pb push_back
    #define f first
    #define s second
    #define lb lower_bound
    #define ub upper_bound
    #define all(x) x.begin(), x.end()
 
    template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
    template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
    
    #define trav(container, it) for(typeof(container.begin()) it=container.begin(); it!=container.end(); it++)
 
    const int MOD = 1000000007;
    #define PI 3.14159265358979323846264338327950L
    const char nl = '\n';
 
    int main() 
    {
        ios_base::sync_with_stdio(0); cin.tie(0);
        ld a,b,h,m;cin>>a>>b>>h>>m;

        ld H = 360.0 - (((360.0/12.0)*h) + ((360.0/720.0)*m));
        ld M;
        (m!=0) ? (M = 360.0 - ((360.0/60.0)*m)) : (M=0);
        
        ld ang = abs(H-M);

       cout<<setprecision(20)<<fixed<<sqrt((a*a) + (b*b) - (2*a*b*cosl(ang*PI/180.0)));
    }


Measured memory_bytes: 4184
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5,maxm=2e2,mod=1e9+7;
int n,lim,cnt[maxn];
long long Ans=1;
char s[maxn];

int main(){
	scanf("%d",&n);
	scanf(" %s",s+1);
	for(int i=1;i<=n;i++){cnt[s[i]-'a']++;}
	for(int i=0;i<26;i++){
		Ans=(Ans*(cnt[i]+1))%mod;
	}
	Ans=(Ans+mod-1)%mod;
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long inf = 100000000000000;
typedef pair<int, int> P;
int main() {
	int n,m;
	cin >> n >> m;
	int i;
	ll a[110000];
	priority_queue<ll> que;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		que.push(a[i]);
	}
	for (i = 0; i < m; i++) {
		int n = que.top();
		que.pop();
		n /= 2;
		que.push(n);
	}
	ll ans = 0;
	while (!que.empty()) {
		ans += que.top();
		que.pop();
	}
	cout << ans;
	return(0);
}

Measured memory_bytes: 2036
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
    Mbak Seulgi Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    ll a,b,c,d;
    ll chaeng = -1e18;
    cin >> a >> b >> c >> d;
    chaeng = max(chaeng, a * c);
    chaeng = max(chaeng, a * d);
    chaeng = max(chaeng, b * c);
    chaeng = max(chaeng, b * d);
    cout << chaeng << endl;
    return 0;
}


Measured memory_bytes: 3672
n = int(input())

dp = [10**6]*(n+1)
dp[0] = 0

l = [1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049]


for i in range(1, n+1):
    for j in l:
        if i >= j:
            dp[i] = min(dp[i-j]+1, dp[i])

print(dp[-1])

Measured memory_bytes: 3828
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<set>
using namespace std;
int main (){
	int n,m,T[100],P[100],w;//n = par,m = time
	cin >> n >> m;

	for(int i=0; i<m; i++){//clean
		int t;
		cin >> t;
		T[i] = t-1;//target
	}
	for(int i=0; i<n; i++){
		P[i] = 0;//point
	}

	for(int i=0; i<m; i++){
		w = 0;//wrong
		for(int j=0; j<n; j++){//gamestart
			int g;
			cin >> g;
			g--;
			if( g == T[i]){//correct
				P[j]++;
			}
			else{//wrong
				w++;
			}
		}//end
		P[T[i]] += w;
	}
	

	for(int i=0; i<n; i++){
	cout << P[i] << endl;
	}


	return 0;

}


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define inf 1000000100

int main()
{
    ll n, t;
    cin >> n >> t;
    ll ans = 0, tprev = 0, tcurr = 0;
    for(int i = 0; i < n; i++)
    {
        ll tt;
        cin >> tt;
        if(i == 0)
        {
            tcurr = tt;
        }
        else
        {
            tprev = tcurr;
            tcurr = tt;
        }

        ans += min(tcurr - tprev, t);

    }
    ans += t;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int head[N * 2], to[N * 4], cap[N * 4], nxt[N * 4], eid;
void init_edge() {
	memset(head, -1, sizeof(head));
	eid = 0;
}
void _add_edge(int u, int v, int w) {
	to[eid] = v;
	cap[eid] = w;
	nxt[eid] = head[u];
	head[u] = eid++;
}
void add_edge(int u, int v, int w) {
	_add_edge(u, v, w);
	_add_edge(v, u, 0);
}
int que[N * 2], ql, qr, lvl[N * 2];
bool bfs(int s, int t) {
	ql = 1, qr = 0;
	memset(lvl, -1, sizeof(lvl));
	que[++qr] = s;
	lvl[s] = 0;
	while (ql <= qr) {
		int u = que[ql++];
		for (int i = head[u]; ~i; i = nxt[i]) {
			int v = to[i];
			if (cap[i] > 0 && lvl[v] == -1) {
				lvl[v] = lvl[u] + 1;
				que[++qr] = v;
			}
		}
	}
	return lvl[t] != -1;
}
int vis[N * 2];
int dfs(int u, int t, int fl) {
	if (u == t) return fl;
	int res = 0;
	for (int &i = vis[u]; ~i; i = nxt[i]) {
		int v = to[i];
		if (lvl[v] == lvl[u] + 1 && cap[i] > 0) {
			int tmp = dfs(v, t, min(fl, cap[i]));
			cap[i] -= tmp;
			cap[i ^ 1] += tmp;
			fl -= tmp;
			res += tmp;
			if (!fl) break;
		}
	}
	if (!res) lvl[u] = -1;
	return res;
}
int Dinic(int s, int t) {
	int res = 0;
	while (bfs(s, t)) {
		memcpy(vis, head, sizeof(head));
		res += dfs(s, t, 0x3f3f3f3f);
	}
	return res;
}
int n, a[N], b[N], x[N], y[N];
int tot;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 0; i < n; i++) scanf("%d", &b[i]);
	memset(x, -1, sizeof(x));
	memset(y, -1, sizeof(y));
	for (int i = 0; i < n; i++) if (x[i] == -1) {
		int p = i;
		while (x[p] == -1) {
			x[p] = tot;
			p = a[p];
		}
		tot++;
	}
	for (int i = 0; i < n; i++) if (y[i] == -1) {
		int p = i;
		while (y[p] == -1) {
			y[p] = tot;
			p = b[p];
		}
		tot++;
	}
	int s = tot, t = tot + 1;
	int ans = 0;
	for (int i = 0; i < n; i++) if (a[i] != b[i]) ans++;
	init_edge();
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i]) {
			if (a[i] == i) continue;
			ans++;
			add_edge(x[i], y[i], 1);
			add_edge(y[i], x[i], 1);
		} else {
			if (a[i] == i) add_edge(s, y[i], 1);
			else if (b[i] == i) add_edge(x[i], t, 1);
			else add_edge(x[i], y[i], 1);
		}
	}
	printf("%d\n", ans - Dinic(s, t));
	return 0;
}

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

int main() {
  unsigned long L, R;
  cin >> L >> R;
  
  unsigned long minimum = 2018;
  unsigned long tempL = 0, tempR = 0;
  
  if( L <= 2019 && R >= 2019 ) {
    cout << 0 << endl;
  }
  else if( (L/2019) < (R/2019) ) {
    cout << 0 << endl;
  }
  else {
    for( unsigned long i = L; i < R; i++ ) {
      for( unsigned long j = i + 1; j <= R; j++ ) {
        if( minimum > ((i * j) % 2019) ) {
          minimum = (i * j) % 2019;
          
          tempL = i;
          tempR = j;
        }
      }
    }
    cout << minimum << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9+7;
const double EPS = 1e-11;
const double PI = 2 * acos(0.0);
using ll = long long;
using ull =  unsigned long long;

#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define pf printf
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sll(x,y) scanf("%lld %lld",&x,&y)

#define pii pair<int,int>
#define nl '\n'
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define uniq(a) a.erase(unique(a.begin(), a.end()), a.end())
#define out(x) cout <<"#x = "<<x<<endl
#define outt(x,y) cout <<"# "<<x<<" "<<y<<endl
#define mem(array,value) memset(array,value,sizeof(array))

const int MX = 305;
int dig[4];
double dp[MX][MX][MX];
int n;

double solve(int a,int b,int c)
{
	if(a+b+c<=0)return 0.0;
	if(dp[a][b][c]>=0.0)return dp[a][b][c];
	double k = (double)n/(a+b+c);
	double p1 = (double)a/(a+b+c);
	double p2 = (double)b/(a+b+c);
	double p3 = (double)c/(a+b+c);
	double ans=0.0;
	if(a)ans+=p1*(solve(a-1,b,c)+k);
	if(b)ans+=p2*(solve(a+1,b-1,c)+k);
	if(c)ans+=p3*(solve(a,b+1,c-1)+k);
	return dp[a][b][c]=ans;
}
int main()
{
	mem(dp,-1);
	fast_io
	cin >>n;
	for(int i=0;i<n;i++){
		int x;
		cin >>x;
		dig[x]++;
	}
	double ans = solve(dig[1],dig[2],dig[3]);
	pf("%.11lf\n",ans);
	return 0;	
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  rep(i, n) cin >> a.at(i);
  rep(i, n) cin >> b.at(i);
  rep(i, n - 1) cin >> c.at(i);
  int sb = 0;
  rep(i, n) sb += b.at(i);
  int sc = 0;
  rep(i, n - 1) {
    if(a.at(i + 1) - a.at(i) == 1) sc += c.at(a.at(i) - 1);
  }
  cout << sb + sc << endl;
}

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

int main(int argc, char const* argv[])
{
	string s;
	int count[26] = {};
	
	while(getline(cin, s) && s[s.size()]!=istream::traits_type::eof()) {
		for (int i=0; i<s.size(); i++) {
			if ('A' <= s[i] && s[i] <= 'Z') {
				count[s[i]-'A']++;
			} else if ('a' <= s[i] && s[i] <= 'z') {
				count[s[i]-'a']++;
			}
		}
	}
	for (int i=0; i<sizeof(count)/sizeof(count[0]); i++) {
		cout << (char)(i+'a') << " : " << count[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 1176
#include<stdio.h>

char str[32],s[32]="CODEFESTIVAL2016";
int ans;

int main(){
	scanf("%s",str);
	for(int i=0;i<16;i++)
		if(str[i]!=s[i])
			ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
// ref: https://qiita.com/tubo28/items/e6076e9040da57368845
use std::io::{stdin, Read};
use std::str::FromStr;

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

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let h: i32 = read();

    let area = (a + b) * h / 2;
    println!("{}", area);
}

Measured memory_bytes: 4352
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <cassert>
#include <atcoder/all>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	vector <long long int> a, b;
	long long int t;

	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> t;
		a.push_back(t);
	}
	for (int i = 0; i < m; i++)
	{
		cin >> t;
		b.push_back(t);
	}
	vector <long long int> c = convolution<998244353>(a, b);
	for (int i = 0; i < c.size(); i++)
	{
		cout << c[i] << ' ';
	}
	cout << '\n';

	return 0;
}

Measured memory_bytes: 27412
def fibonacci(n):
	if n==0:
		return 0
	a,b=1,1
	for i in range(0,int((n-1)/2)):
		a+=b
		b+=a
	if n%2!=0:
		return a
	return b

n=[int(i) for i in input().split()]
f=1
a=-1
for i in range(0,n[1]):
	b=int(input())
	f*=fibonacci(b-a-1)
	a=b
f*=fibonacci(n[0]-a)
print(f%1000000007)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n;
  vector<i64> d;
  cin >> n;
  read_n(d, n);
  i64 ans = 0;
  for (i64 i = 0; i < n; ++i) {
    for (i64 j = 0; j < n; ++j) {
      if (i != j) ans += d[i] * d[j];
    }
  }
  cout << ans / 2 << endl;
  return 0;
}


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

int main() 
{
    int n, x;

    while( cin >> n >> x )
    {
        if( n == 0 && x == 0 )
            break;

        int count = 0;                                      //組み合わせ
        int data[n];

        for( int i = 0; i < n; i++ )                        //1~nの数を格納する配列
            data[i] = i + 1;
        

        for( int i = 0; i <= n - 3; i++ )                    //iがn-3の時、jはn-2、kはn-1の要素を指す
            for( int j = i + 1; j <= n - 2; j++ )
                for( int k = j + 1; k <= n - 1; k++ )
                    if( data[i] + data[j] + data[k] == x )
                        count++;
                        
        cout << count << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
/*input
4 30
6 18
2 5
3 10
7 9
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const int maxn=1e5+5;
pii arr[maxn];
int main(){
	int n,m;
	cin>>n>>m;
	REP(i,n) cin>>arr[i].f>>arr[i].s;
	sort(arr,arr+n);
	ll ans=0;
	int cur=0;
	while(m){
		if(arr[cur].s){
			ans+=arr[cur].f;
			--m;
			--arr[cur].s;
		}
		else{
			++cur;
		}
	}
	cout<<ans;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

const int hs[] ={0,3,5,7};

int f(string s){
	int ans = 0;
	int dp[8][2] ={};
	dp[0][0] =1;
	rep(i, sz(s)){
		int np[8][2] = {};
		rep(j, 8) for(int d=0, nj=999; d<4; d++){
			if(d>0) nj = j | (1<<(d-1));
			else if(d==0 && j==0) nj = j;
			if(nj >7) continue;
			
			if(hs[d] < s[i] -'0') np[nj][1] += dp[j][0];
			else if(hs[d] == s[i] -'0') np[nj][0] += dp[j][0];
			np[nj][1] += dp[j][1];
		}
		swap(dp, np);
	}
	//for(auto x :dp) printf("%d:%d, ",x[0],x[1]); puts("");
	return dp[7][0] + dp[7][1];
}

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	
	
	cout << f(s) <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

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

int32_t main() {
  ios::sync_with_stdio(0); cin.tie(0);
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  int ans = 1;
  for(int i = 2; i < 1000000; ++i) {
    if(g % i == 0) {
      ans += 1;
      while(g % i == 0) g /= i;
    }
  }
  ans += g > 1;
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#define MOD 1e9+7
typedef long long llong;
using namespace std;

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

	llong ans = 1;
	for(int i = 1; i <= n; ++i){
		ans = ans * i;
		ans %= (llong)MOD;
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string s,t; cin >> s >> t;
  int a,b; cin >> a >> b;
  string u; cin >> u;
  if(s == u)
    a--;
  else if(t == u)
    b--;
  cout << a << " " << b << endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define Q 1000000
int main() {
  int s;
  cin >> s;
  bool check=false;
  vector<int> A(Q);
  A.at(0) = s;
  for(int i=0;i<Q;i++){
    if(A.at(i)%2==0){
      A.at(i+1)=A.at(i)/2;
    }else{
      A.at(i+1)=3*A.at(i)+1;
    }
    for(int j=0;j<i;j++){
      if(A.at(j)==A.at(i)){
        s=i;
        check = true;
      }
    }
    if(check){
      break;
    }
  }
  cout << s+1 << endl;
}



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

using namespace std;

#define int long long

signed main()
{
	string t;
	cin >> t;
	int fl = 0;
	for (int i = 0; i < t.size(); i++)
	{
		if (t[i] == '7')
			fl = 1;
	}
	if (fl)
	{
		cout << "Yes" << endl;
	}
	else 
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
int main(){
    int n; 
    cin >> n;
    long long int v[100000];
    for(int i=0; i<(n); ++i){
      cin >> v[i];
    }
    v[n] = 1000000000;
    int flg=0;
    for(int i=0; i<(n); ++i){
      if(v[i]>v[i+1]+1){
        cout << "No"; break;
      }else if(v[i]>v[i+1] && flg==0){
        flg=1;
      }else if(v[i]>v[i+1] && flg==1){
        cout << "No"; break;
      }else if(v[i]<v[i+1]){
        flg=0;
      }
      if(i==n-1) cout << "Yes";
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
	int keys[100];
	int n,i;
	char s[101];

	while(scanf("%d",&n),n){
		for(i=0;i<n;i++){
			scanf("%d",&keys[i]);
		}
		scanf("%s",s);
		for(i=0;s[i];i++){
			if('a'<=s[i]&&s[i]<='z'){
				s[i]=s[i]-'a';
			}else if('A'<=s[i]&&s[i]<='Z'){
				s[i]=26+s[i]-'A';
			}
			s[i]=(52+s[i]-keys[i%n])%52;
			if(0<=s[i]&&s[i]<26){
				s[i]+='a';
			}else if(26<=s[i]&&s[i]<52){
				s[i]-=26;
				s[i]+='A';
			}
		}
		printf("%s\n",s);
	}
	return 0;
}

Measured memory_bytes: 592
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll n;

	return OUT((int)(n / 3));
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;



int main() {
    int ans = 0;
    rep(i, 5) {
        int c; cin >> c;
        if (c == 0) ans = i + 1; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#include "bits/stdc++.h"
#define ll long long
using namespace std;
void calc(int n,int r, vector<int>& ans) {
	int digit = 1;
	for (int i = 0; i <= r; i++) {
		int temp = digit / n;
		temp %= 10;
		ans[i] += temp;
		digit %= n;
		digit *= 10;
	}
}

int main() {
	int n, k, m, r;
	while (true) {
		cin >> n >> k >> m >> r;
		if (n == 0 && k == 0 && m == 0 && r == 0) break;
		vector<int> ans(10055, 0);
		calc(n,10050,ans);
		if (m == 1) {
			for (int i = 1; i < n;i++) {
				calc(i*n, 10050, ans);
			}
		}

		for (int i = 10050; i > 0;i--) {
			ans[i - 1] += (ans[i] / 10);
			ans[i] %= 10;
		}

		cout << ans[0] << ".";
		for (int i = 1; i <= r;i++) cout << ans[i];
		cout << endl;
	}
}

Measured memory_bytes: 3108
def resolve():
    X, Y, A, B, C = map(int,input().split())
    P = sorted(tuple(map(int, input().split())), reverse=True)
    Q = sorted(tuple(map(int, input().split())), reverse=True)
    R = sorted(tuple(map(int, input().split())), reverse=True)

    NP = P[0:X]
    NQ = Q[0:Y]

    NP.extend(NQ)
    NP.extend(R)

    print(sum(sorted(NP, reverse=True)[0:X+Y]))

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 24368
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	stack<int> ans;
	string s;
	getline(cin, s);
	string num = "";
	for (int i = 0; i < s.length(); ++i)
	{
		if (s[i] == '+') {
			int m, n;
			m = ans.top();
			ans.pop();
			n = ans.top();
			ans.pop();
			ans.push(m + n);
		}
		else if (s[i] == '-') {
			int m, n;
			m = ans.top();
			ans.pop();
			n = ans.top();
			ans.pop();
			ans.push(n - m);
		}
		else if (s[i] == '*') {
			int m, n;
			m = ans.top();
			ans.pop();
			n = ans.top();
			ans.pop();
			ans.push(m * n);
		}
		else {
			if (s[i] == ' ' && num != "") {
				ans.push(stoi(num));
				num = "";
			}
			else if(s[i] != ' '){
				num += s[i];
			}
		}
	}
	cout << ans.top() << endl;
	return 0;
}


Measured memory_bytes: 3216
import java.io.*;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int a = fs.nextInt();
        int b = fs.nextInt();
        System.out.println( 6 - a - b );
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) {
                return buffer[ptr++];
            } else {
                return -1;
            }
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
                throw new NumberFormatException();
            }
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 21204
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int r,D;
    LL x;
    R(r,D,x);
    FOR(i,1,10){
        x=r*x-D;
        W(x);
    }
    return 0;
}


Measured memory_bytes: 256