akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll N;
    cin>>N;
    v A(N);
    v lis(1000001, 0);
    rep(i,0,N){
        cin>>A[i];
        lis[A[i]]++;
    }
    ll ans = 0;
    rep(i,0,N){
        bool ok = true;
        if(A[i] == 1){
            if(lis[1] >= 2)ok = false;
        }
        else if(lis[1] >= 1)ok = false;
        if(lis[A[i]] >= 2)ok = false;
        for(ll j = 2; j * j <= A[i]; j++){
            if(A[i] % j == 0){
                if(lis[A[i]/j] || lis[j]){
                    ok = false;
                    break;
                }
            }
        }
        if(ok) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 12756
#include<iostream>
#include<vector>
#include<map>
#include<numeric>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 11;
const int inf = (1<<20);

template <class T> int getindex(T &a,map<T,int> & M){
  int index = M.size();
  if (M.find(a) == M.end())M[a]=index;
  return M[a];
}

int g[N][N];
int dp[(1<<N)][N];
void tsp(int n){
  rep(i,(1<<n))rep(j,n)dp[i][j]=inf;
  dp[1<<0][0]=0;
  rep(i,(1<<n)){
    rep(j,n){//visited
      if (((1<<j)&i) == 0)continue;
      rep(k,n){//unvisited
	if ((1<<k)&i)continue;
	int next=(1<<k)|i;
	dp[next][k]=min(dp[next][k],dp[i][j]+g[j][k]);
      }
    }
  }
}

void solve(int n,map<int,int> *c,vector<int> &req){
  int ac=inf,aw=inf;
  rep(i,(1<<n)){
    if ((1&i) == 0)continue;
    int tc=inf,tw=inf;
    vector<int> mini(req.size(),inf);
    rep(j,n){
      if (((1<<j)&i) == 0)continue;
      tw=min(tw,dp[i][j]+g[j][0]);
      rep(k,(int)req.size()){
	if (c[j].find(req[k]) != c[j].end())mini[k]=min(mini[k],c[j][req[k]]);
      }
      tc = accumulate(mini.begin(),mini.end(),0);
    }
    if (tc < ac || (tc == ac && tw < aw))ac=tc,aw=tw;
  }
  if (ac == inf)cout <<"impossible"<<endl;
  else cout << ac <<" " << aw << endl;
}

main(){
  int n;
  while(cin>>n && n){
    rep(i,n+1){rep(j,n+1)g[i][j]=inf;g[i][i]=0;}
    map<string,int> M;
    map<int,int> c[n+1];
    rep(i,n){
      int num;cin>>num;
      rep(j,num){
	string name;int cost,ind;
	cin>>name>>cost;
	ind=getindex(name,M);
	c[i+1][ind]=cost;
      }
    }

    int req;
    cin>>req;
    vector<int> in(req);
    rep(i,req){
      string tmp;
      cin>>tmp;
      in[i]=getindex(tmp,M);
    }
    
    int m;
    cin>>m;
    rep(i,m){
      int f,t,c;cin>>f>>t>>c;
      g[f][t]=g[t][f]=c;
    }
    rep(k,n+1)rep(i,n+1)rep(j,n+1)g[i][j]=min(g[i][j],g[i][k]+g[k][j]);

    tsp(n+1);

    solve(n+1,c,in);
  }
}

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

int main(){
    long long a,b,c,d; 
    cin >> a >> b >> c >> d;

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

        long long quo1 = b / c; //b以下のcの倍数
        long long quo2 = b / d; //b以下のdの倍数

        //重複を数を求める
        //c、dの最小公倍数を求める
        //１、ユークリッドの互助法からc、dの最大公約数を求める
        long long r,e,f; //rが余り、eが割られる数、fが割る数
        if(c>d){
            e = c;
            f = d;
        }else{
            e = d;
            f = c;
        }

        while (true){
            r = e % f;
            if(r == 0){
                break;
            }
            e = f;
            f = r;
            //※最大公約数はfとなる
        }

        long long g = c * d / f; //最小公倍数
        long long quo3 = b / g; //b以下のcとdの重複の数

        //bの条件は
        b = b - quo1 - quo2 + quo3;
   
        //a−1の条件を同様にして求める
        quo1 = (a-1) / c; //a-1以下のcの倍数
        quo2 = (a-1) / d; //a-1以下のdの倍数
        quo3 = (a-1) / g; //a-1以下のcとdの重複の数

        //a-1の条件は
        a = a-1 - quo1 - quo2 + quo3;
        
        //answer
        long long ans = b - a;
        
        //display
        cout << ans << endl;
        
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  string s[7]={ "SUN","MON","TUE","WED","THU","FRI","SAT"};
  string input;cin>>input;
  for(int i=0;i<7;i++){
    if(input.compare(s[i])==0){
      cout<<7-i<<endl;
    }
  }
}

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

using namespace std;

const int maxn=100005;

int n,m;

vector<int>adj[maxn];

vector<bool>visited;

vector<int>ans;

void dfs(int v)
{
    visited[v]=true;
    for(auto u:adj[v])
    {
        if(!visited[u])
            dfs(u);
    }
    ans.push_back(v);
}

void topological_sort()
{
    visited.assign(maxn,false);
    ans.clear();
    for(int v=1;v<=n;v++)
    {
        if(!visited[v])
            dfs(v);
    }
reverse(ans.begin(),ans.end());
}

vector<int>DAG(maxn);

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

    topological_sort();

    int first=ans[0];
    DAG[first]=0;

    for(int i=0;i<ans.size();i++)
    {
        int v=ans[i];
        for(auto u:adj[v])
        {
            DAG[u]=max(DAG[u],DAG[v]+1);
        }
    }
    cout<<*max_element(DAG.begin(),DAG.end())<<endl;
return 0;
}


Measured memory_bytes: 8828
#include <bits/stdc++.h>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
signed main(){
    string s;
    int a=0,b=0;
    cin>>s;
    rep(i,s.size()){
        if(s[i]=='1')a++;
        else b++;
    }
    cout<<min(a,b)*2<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long x[100005];
int main(){
	long long n,a,b,tot=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	scanf("%d",&x[i]);
	for(int i=1;i<n;i++)
	{
		long long l=x[i+1]-x[i];
		tot+=(l*a)>b?b:(l*a);
	}
	cout<<tot;
}

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

long long n;

long long solve();

int main() {
  cin >> n;

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(long long i = 1; i <= n; ++i) {
    long long x = i, cnt = 0;
    while(x > 0) {
      ++cnt;
      x /= 10;
    }
    ans += cnt % 2;
  }
  return ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define pii pair<int,int>
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int m=1000000007;
bool cmp2(int n,pii p)
 {return n<p.f;}
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%m;n=(n*n)%m;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
string s1,s2;
cin>>s1>>s2;
cout<<s2+s1;
}

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    L=[]
    s=input()
    for i in range(len(s)):
        if s[i]=="0":
            L.append(0)
        elif s[i]=="1":
            L.append("1")
        else:
            if len(L)>=1:
                L.pop()
                
    print(''.join(map(str,L)))
                

main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  vector<ll> h(n+1, 1000000001);
  for (ll i = 0; i < n; i++) {
    cin >> h[i];
  }
  
  ll ans = 0, cnt = 0;
  for (ll i = 0; i < n+1; i++) {
    if (h[i] >= h[i+1]) {
      cnt++;
    }
    else {
      ans = max(ans, cnt);
      cnt = 0;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
/* ****AWARE**** */
#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp13       make_pair
using namespace std; 
#define MAX  3000000000
#define MODULO 2
using namespace std;   
#define hell 1000000007 
#define hell1 30000000000000000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define mysizeof(i) (char*)(&i+1)-(char *)(&i);
ll T;

void solve()
{ long long int a=-1,b=-1,c=-1,n,l,r,m,k,i,j,ans=0,ans1,ans2;
  cin>>n>>k;
  vector<ll>v;
  for(i=0;i<n;i++)
    cin>>a,v.pb(a);

  ll dp[n];
  for(i=n-1;i>=0;i--)
  { 
    if(i==n-1)
    {dp[i]=0;
      continue;}
      dp[i]=dp[i+1]+abs(v[i+1]-v[i]);
    for(j=i+1;j<n && j<=i+k;j++)
    {
        dp[i]=min(dp[i],dp[j]+abs(v[j]-v[i]));
    }
  }

  cout<<dp[0];
}
             
int main(){ 
cut; 
ll t; 
//cin>>t;
//T=t;
 t=1;
while(t--)
solve();
return 0;
}
       


Measured memory_bytes: 5040
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
using ll = long long;


#define rep(i,n) for(int i=0;i<(n);i++)


int dat[200007];

int main() {

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

    //rep(i, N)cin >>dat[i];

    cin >> S;

    if (S[S.length() - 1] == 's')S += "es";
    else S += "s";

    cout << S;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
	long long n, s;
	scanf("%lld", &n);
	scanf("%lld", &s);
	if (n == s) {
		printf("%lld\n", n + 1);
		fflush(stdout);
		return 0;
	}
	
	long long b, m, d;
	for (b = 2; b * b <= n; b++) {
		for (m = n, d = 0; m > 0; m /= b) d += m % b;
		if (d == s) {
			printf("%lld\n", b);
			fflush(stdout);
			return 0;
		}
	}
	
	for (d = (b - 1 < s)? b - 1: s; d >= 1; d--) {
		b = (n - (s - d)) / d;
		if (d * b + s - d == n && d < b && s - d < b) {
			printf("%lld\n", b);
			fflush(stdout);
			return 0;
		}
	}
	
	printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1696
#include<stdio.h>

int main(void)
{
    int a,b;
    scanf("%d%d",&a,&b);
    while(((1>a)||(a>100))||((1>b)||(b>100)))
    {
        scanf("%d%d",&a,&b);
    }
    if(a%3==0||b%3==0||(a+b)%3==0)
    {
        printf("Possible\n");
    }
    else
    {
        printf("Impossible\n");
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  vector<int> ans(n);
  for(int i=0;i<n;i++){
    ans[a[i]-1]=i+1;
  }
  for(int i=0;i<n;i++){
    cout << ans[i] << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int N, M;
vector<string> tail;
int mx[]={1, 0, -1, 0}, my[]={0, 1, 0, -1};

int main(){
    while(cin>>N>>M&&N){
        tail.assign(M, "");
        foreach(i, tail)cin>>i;
        int fx, fy;
        REP(i, M){
            REP(j, N){
                if(tail[i][j]=='@'){
                    fy=i;
                    fx=j;
                    tail[i][j]='#';
                    break;
                }
            }
        }
        int ans = 1;
        queue<PII> que;
        que.push(PII(fy, fx));
        while(!que.empty()){
            PII d = que.front();
            que.pop();
            REP(i, 4){
                int ny = d.first + my[i];
                int nx = d.second + mx[i];
                if(nx==-1||ny==-1||nx==N||ny==M||tail[ny][nx]=='#')continue;
                ++ans;
                tail[ny][nx]='#';
                que.push(PII(ny, nx));
            }
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3076
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int a;
string s;

main(){
	cin>>a>>s;
	if(a<3200)dump("red");
	else dump(s);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define vl vector
using namespace std;

int main()
{
    ll t,i,n;
    ll a,b,c;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++) cout<<"x";
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

//#define rep(i, n)     for(auto i = 0; i != n; ++i)
#define REP(i, k, n)  for(auto i = k; i != n; ++i)
//#define rrep(i, n)    for(auto i = n; i != 0; --i)
#define RREP(i, n, k) for(auto i = n; i != k; --i)

#define debug(x) cerr << #x << " " << x << endl
#define spc << " " <<

#define mp make_pair
#define mt make_tuple

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<typename T>using V = vector<T>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

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

    Vi seq_len;
    int N; cin >> N;

    int last; cin >> last;
    int streak = 1;
    REP(i, 2, N+1) {
        int light; cin >> light;
        if (light != last) ++streak;
        else {
            seq_len.push_back(streak);
            streak = 1;
        }
        last = light;
    }

    seq_len.push_back(streak);
    seq_len.insert(seq_len.begin(), 0);
//    REP(i,0,seq_len.size()) cout << seq_len[i] << " "; cout << endl;

    REP(i, 1, seq_len.size()) {
        seq_len[i] += seq_len[i-1];
    }

    int ans = 0;
    if (seq_len.size() > 3) {
        REP(i, 3, seq_len.size()) {
            ans = max(ans, seq_len[i] - seq_len[i-3]);
        }
    } else {
        ans = seq_len[seq_len.size()-1];
    }

    cout << ans << endl;
//    REP(i,0,seq_len.size()) cout << seq_len[i] << " "; cout << endl;

    return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;
const ll INF = 1e18L + 1;

double dp[310][310][310];
int nums[4];
int N;

double rec(int a, int b, int c)
{
  if (a + b + c == 0)
    return 0.0;
  if (dp[a][b][c] >= 0)
    return dp[a][b][c];
  double res = 0.0;
  if (a > 0)
    res += rec(a - 1, b, c) * a;
  if (b > 0)
    res += rec(a + 1, b - 1, c) * b;
  if (c > 0)
    res += rec(a, b + 1, c - 1) * c;
  res += N;
  res /= (a + b + c);
  return dp[a][b][c] = res;
}

int main()
{
  scanf("%d", &N);
  rep(i, N)
  {
    int a;
    scanf("%d", &a);
    nums[a]++;
  }
  memset(dp, -1, sizeof(dp));

  double ans = rec(nums[1], nums[2], nums[3]);
  printf("%.13f\n", ans);
  return 0;
}


Measured memory_bytes: 233088
import java.util.Scanner;

public class Main {
    static final long INF = (long)Math.pow(10, 18);
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long res = 1;
        for (int i = 0; i < N; i++) {
            long A = sc.nextLong();
            if (A == 0) {
                res = 0;
                break;
            }
            if (res == -1) {
                continue;
            }
            if (A > INF / res) {
                res = -1;
            } else {
                res *= A;
            }
        }
        System.out.println(res);
        sc.close();
    }
}

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

int main()
{
	string S;
	cin >> S;
	if ((S[0] == S[1] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3]))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = []
i = 0
while i != n:
    cnt = 1
    for j in range(i+1,n):
        if s[i] == s[j]:
            cnt+=1
        else:
            break
    ans.append(s[i])
    if cnt>=2:
        i+=cnt
    else:
        i+=1

print(len(ans))

        

Measured memory_bytes: 3956
import sys

def I(): 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 main():
    n, k = MI()
    p = sorted(LI())[0:k]
    print(sum(p))

if __name__ == '__main__':
    main()

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

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

  if((A + B) % 2 != 0 || (B + A) % 2 != 0){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  
  if(A > B){
    cout << (A + B) / 2 << endl;
  }else{
    cout << (B + A) / 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;


namespace DP {

llong solve(int N, const string& S, int P) {
   if (P == 2) {
      long long res = 0;
      for (int i = 0; i < N; ++i) {
         int d = S[i]-'0';
         if ((d % 2) == 0) {
            res += i+1;
         }
      }
      return res;
   }
   
   if (P == 5) {
      long long res = 0;
      for (int i = 0; i < N; ++i) {
         int d = S[i]-'0';
         if (d == 0 || d == 5) {
            res += i+1;
         }
      }
      return res;
   }


   vector<long long> freq(P);
   freq[0] = 1;

   long long res = 0;
   long long P10 = 1;

   long long rem = 0;
   for (int i = N-1; i >= 0; --i) {
      int d = S[i]-'0';

      rem = (rem + d*P10) % P;

      long long add = freq[rem];

   // cerr << "i:" << i << "  add:" << add <<  "  rem:" << rem << endl;
      
      res += add;

      freq[rem]++;

      P10 = (P10*10) % P;
   }
   
   return res;
}

}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, P;
   cin >> N >> P;

   string S;
   cin >> S;

   llong res = DP::solve(N, S, P);
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;

LL mod = 1000000007;

int main()
{
	LL n, h, w;
	cin >> h >> w >> n;

	cout << n/max(h, w) + (n%max(h, w) ? 1 : 0)<< "\n";

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=7000;
int h,w;
vvi a;

int main(){
	cin>>h>>w;
	vector<vvi> dp(h,vvi(w,vi(2*M)));
	a=vvi(h,vi(w));
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		cin>>a[i][j];
	}
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		int x;
		cin>>x;
		a[i][j]-=x;
	}
	dp[0][0][M-a[0][0]]=1;
	dp[0][0][M+a[0][0]]=1;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) for(int k=0;k<2*M;k++) if(dp[i][j][k]){
		if(i<h-1){
			if(0<=k+a[i+1][j]&&k+a[i+1][j]<2*M) dp[i+1][j][k+a[i+1][j]]=1;
			if(0<=k-a[i+1][j]&&k-a[i+1][j]<2*M) dp[i+1][j][k-a[i+1][j]]=1;
		}
		if(j<w-1){
			if(0<=k+a[i][j+1]&&k+a[i][j+1]<2*M) dp[i][j+1][k+a[i][j+1]]=1;
			if(0<=k-a[i][j+1]&&k-a[i][j+1]<2*M) dp[i][j+1][k-a[i][j+1]]=1;
		}
	}
	int res=inf;
	for(int i=0;i<2*M;i++) if(dp[h-1][w-1][i]) res=min(res,abs(i-M));
	cout<<res<<endl;
}

Measured memory_bytes: 354944
#define mm(a) memset(a,0,sizeof(a));
#define max(x, y) (x)>(y)?(x):(y)
#define min(x, y) (x)<(y)?(x):(y)
#define Fopen freopen("1.in","r",stdin); freopen("m.out","w",stdout);
#define rep(i, a, b) for(int i=(a);i<=(b);i++)
#define per(i, b, a) for(int i=(b);i>=(a);i--)
#define PII pair<ll,ll>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 2e5+5;
const ll mod=1e9+7;
int n;
ll dp[MAXN][13];
char s[MAXN];
int main() {
    while(~scanf("%s",s+1)) {
        n=strlen(s+1);
        mm(dp);
        dp[0][0]=1;
        for(int i=1; i<=n; i++) {
            int temp=-1;
            if(s[i]=='?') {
                for(int j=0; j<13; j++) {
                    for(int k=0; k<10; k++) {
                        dp[i][(j*10+k)%13]+=dp[i-1][j];
                        dp[i][(j*10+k)%13]%=mod;
                    }
                }
            } else {
                for(int j=0; j<13; j++) {
                    dp[i][(j*10+s[i]-'0')%13]+=dp[i-1][j];
                    dp[i][(j*10+s[i]-'0')%13]%=mod;
                }
            }
        }
        printf("%lld\n",dp[n][5]);
    }
    return 0;
}


Measured memory_bytes: 20608
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self, n):
        fact, invfact = [1] * (n + 1), [1] * (n + 1)
        for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
        invfact[n] = pow(fact[n], MOD - 2, MOD)
        for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD
        self._fact, self._invfact = fact, invfact

    def fact(self, n):
        return self._fact[n]

    def invfact(self, n):
        return self._invfact[n]

    def comb(self, n, k):
        return self._fact[n] * self._invfact[k] % MOD * self._invfact[n - k] % MOD if 0 <= k <= n else 0

    def perm(self, n, k):
        return self._fact[n] * self._invfact[n - k] % MOD if 0 <= k <= n else 0

def resolve():
    k = int(input())
    n = len(input())
    mf = modfact(n + k)
    ans = 0
    for i in range(n, n + k + 1):
        ans += mf.comb(n + k, i) * pow(25, n + k - i, MOD)
        ans %= MOD
    print(ans)
resolve()

Measured memory_bytes: 103556
#include<bits/stdc++.h>
using namespace std;
int n,h[100009];
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",h+i);
	int mx=1,len=1;
	for(int i=1;i<n;i++) {
		if(h[i]<=h[i-1]) len++;
		else len=1;
		mx=max(len,mx);
	}
	printf("%d\n",mx-1);
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<bitset>
#define ll long long
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define fd(i,a,b) for(register int i=a;i>=b;--i)
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Abs(a) ((a<0)?-(a):(a))
using namespace std;
namespace io{
	char buf[1<<17],*p1=buf,*p2=buf;
	inline int getc(){
	     return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<17,stdin),p1==p2)?EOF:*p1++;
    }
    template<class T>
    inline void Read(T &x){
        x=0;T f=1;char c;
        for(c=getc();c<'0'||c>'9';f=((c=='-')?-1:f),c=getc());
        for(;c>='0'&&c<='9';x=x*10+(c^48),c=getc());
        x*=f;
    }
    template<class T>
    inline void write(T a){
        if(a==0){putchar('0');return;}
        if(a<0)putchar('-'),a=-a;
        char c1[120];
        int h=0;
        while(a)c1[++h]=a%10+'0',a/=10;
        for(int i=h;i>=1;i--)putchar(c1[i]);
        return;
    }
    template<class T>
    inline void write_(T a){write(a);putchar(' ');}
    template<class T>
    inline void writeln(T a){write(a);putchar('\n');}
}
using namespace io;
template<class T>
inline T gcd(T a,T b){return a==0?b:gcd(b%a,a);}
template<class T>
inline T lcm(T a,T b){return 1ll*a/gcd(a,b)*b;}
/*----------------------------------------------------------------------*/


int main(){
    int n;
    Read(n);
    writeln(180 * (n - 2));
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int N = Integer.parseInt(str[0]);
        int K = Integer.parseInt(str[1]);
        List<List<Integer>> A = new ArrayList<>(K);
        for(int i=0; i<K; ++i){
            A.add(new ArrayList<>());
            int d = Integer.parseInt(br.readLine());
            str = br.readLine().split(" ");
            for(int j=0; j<d; ++j)
                A.get(i).add(Integer.parseInt(str[j]));
        }
        int res = 0;
        for(int i=1; i<=N; ++i){
            boolean have = false;
            for(List<Integer> snack : A){
                for(int j=0; j<snack.size(); ++j){
                    if(snack.get(j) == i){
                        have = true;
                        break;
                    }
                }
                if(have) break;
            }
            if(!have) res++;
        }
        System.out.println(res);
    }
}


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

 int main() {
 int n;
 cin >> n;
 vector<int> p(n);
 for(int i = 0; i < n; i++) cin >> p[i];
 int ans = 0;
 for(int i = 1; i < n - 1; i++) {
 if((p[i - 1] < p[i]) && (p[i] < p[i + 1])) ans++;
 else if((p[i - 1] > p[i]) && (p[i] > p[i + 1])) ans++;
 }
 cout << ans << endl;
 return 0;
 }


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <vector>
using namespace std;
struct edge { int to, cost; };
bool operator<(const edge& e1, const edge& e2) { return e1.cost < e2.cost; }
int N, M, C, b1, b2, e1, e2, e3, e4;
int main() {
	while (scanf("%d%d%d%d%d", &N, &M, &C, &b1, &b2), b1--, b2--, N) {
		vector<vector<vector<edge> > > G1(C, vector<vector<edge> >(N));
		for (int i = 0; i < M; i++) {
			scanf("%d%d%d%d", &e1, &e2, &e3, &e4); e1--, e2--, e4--;
			G1[e4][e1].push_back(edge{ e2, e3 });
			G1[e4][e2].push_back(edge{ e1, e3 });
		}
		vector<vector<vector<int> > > dist(C, vector<vector<int> >(N, vector<int>(N, 999999999)));
		for (int i = 0; i < C; i++) {
			for (int j = 0; j < N; j++) {
				dist[i][j][j] = 0;
				priority_queue<edge> que1; que1.push(edge{ j, 0 });
				while (!que1.empty()) {
					edge u = que1.top(); que1.pop();
					for (edge e : G1[i][u.to]) {
						if (dist[i][j][e.to] > -u.cost + e.cost) {
							dist[i][j][e.to] = -u.cost + e.cost;
							que1.push(edge{ e.to, -dist[i][j][e.to] });
						}
					}
				}
			}
		}
		vector<int> P(C);
		for (int i = 0; i < C; i++) scanf("%d", &P[i]);
		vector<vector<int> > costs(C, vector<int>(20000));
		for (int i = 0; i < C; i++) {
			vector<int> Q(P[i] + 1), R(P[i]); Q[0] = 0, Q[P[i]] = 19999;
			for (int j = 1; j < P[i]; j++) scanf("%d", &Q[j]);
			for (int j = 0; j < P[i]; j++) scanf("%d", &R[j]);
			for (int j = 0; j < P[i]; j++) {
				for (int k = Q[j] + 1; k <= Q[j + 1]; k++) {
					costs[i][k] = costs[i][k - 1] + R[j];
				}
			}
		}
		vector<vector<int> > G2(N, vector<int>(N, 999999999));
		for (int i = 0; i < C; i++) {
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N; k++) {
					if (j == k) continue;
					if (dist[i][j][k] == 999999999) continue;
					G2[j][k] = min(G2[j][k], costs[i][dist[i][j][k]]);
				}
			}
		}
		vector<vector<edge> > G3(N);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (G2[i][j] != 999999999) G3[i].push_back(edge{ j, G2[i][j] });
			}
		}
		vector<int> dist2(N, 999999999); dist2[b1] = 0;
		priority_queue<edge> que2; que2.push(edge{ b1, 0 });
		while (!que2.empty()) {
			edge u = que2.top(); que2.pop();
			for (edge e : G3[u.to]) {
				if (dist2[e.to] > -u.cost + e.cost) {
					dist2[e.to] = -u.cost + e.cost;
					que2.push(edge{ e.to, -dist2[e.to] });
				}
			}
		}
		printf("%d\n", dist2[b2] != 999999999 ? dist2[b2] : -1);
	}
	return 0;
}

Measured memory_bytes: 5272
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    repr(i, 1, n + 1) if (i % 3 != 0 && i % 5 != 0) sum += i;
    cout << sum << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,answer;
  cin >> n;
  answer = 0;
  for(int i = 0;i < n;i++){
    int l,r;
    cin >> l >> r;
    answer += (r-l)+1;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))

ans = 0
for i in range(1, n - 1):
    if (p[i - 1] > p[i] > p[i + 1]):
        ans +=1
    if (p[i - 1] < p[i] < p[i + 1]):
        ans +=1

print(ans)

Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int main(){
    double r;
    cin >> r;
    double result = r;
    cout.setf(std::ios_base::fixed,std::ios_base::floatfield);
    cout << r * r * 3.141592653589 << " ";
    cout << 2 * r * 3.141592653589 << endl;
}


Measured memory_bytes: 3288
#include<stdio.h>
void print(int);
int rec(int ,int);
#define Max 100000
#define NIL -1
int A[Max];
struct Node{
  int p;
  int l;
  int r;
    };
 
struct Node T[Max];
int n;
int main()
{ 
  int child,h,i,v,e,depth,l,r;
 
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
 
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&v,&depth);
       
      for(h=0;h<depth;h++)
    {
      scanf("%d",&child);
      if(h==0)T[v].l=child;
      else T[l].r=child;
      l=child;
      T[child].p=v;
    }
    }
  for(i=0;i<n;i++)
    {
      if(T[i].p==NIL) r=i;
    }
 
  rec(r,0);
 
  for(i=0;i<n;i++) print(i);
 
  return 0;
}
 
int rec(int u, int p)
{
  A[u]=p;
  if(T[u].r!=NIL) rec(T[u].r,p);
  if(T[u].l!=NIL) rec(T[u].l,p+1);
}
 
void print(int u)
{
  int i,child;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u]);
  printf("depth = %d, ",A[u]);
 
  if(T[u].p==NIL) printf("root, ");
  else if(T[u].l==NIL)  printf("leaf, ");
  else printf("internal node, ");
 
  printf("[");
 
  child=T[u].l;
  for(i=0;child!=NIL;i++){
    if(i) printf(", ");
    printf("%d",child);
    child=T[child].r;
  }
  printf("]\n");
}

Measured memory_bytes: 5296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(a,j,n) for(ll i=a;i<j;i=i+n )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;

int main(){
    string s;
    cin>>s;
    set<char> c;
    rep(0,3,1){
        c.insert(s.at(i));
    }
    if(c.size()==1)cout<<"No";
    else cout<<"Yes";
    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int a[100010];
  int b[10]={0};
  for(int i=1;i<=N;i++){
    cin >> a[i];
    if(a[i]%4==0){
      b[4]++;
    }else if(a[i]%2==0){
      b[2]++;
    }else{
      b[1]++;
    }
  }
  int t=b[1]-b[4];
  bool flag=false;
  if(t>1){
    cout << "No" << endl;
    return 0;
  }else if(t==1){
    if(b[2]>0){
      cout << "No" << endl;
      return 0;
    }else{
      flag=true;
    }
  }else{
    flag =true;
  }

  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 640
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int s; cin >> s;
    bool flag1 = false, flag2 = false;
    int low = s%100, high = s/100;
    if(low>=1 && low<=12) flag2 = true;
    if(high>=1 && high<=12) flag1 = true;
    if(flag1 && flag2){
        cout << "AMBIGUOUS" << '\n';
        
    } else if(flag1){
        cout << "MMYY" << '\n';
        
    } else if(flag2){
        cout << "YYMM" << '\n';
        
    } else {
        cout << "NA" << '\n';
        
    }
}


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

int main() {
	long a,b,d,r;
	double f;
	cin >> a >> b;
	d = a/b;
	r = a%b;
	f = 1.000000000*a / b;
	cout  << d << ' ' << r << ' '<< fixed << setprecision(8) << f << endl;
}

Measured memory_bytes: 1240
#include <cstdio>

using namespace std;

int v,k;

main(){
  scanf("%d", &v);

  if(v==0) return 0;

  for(int i=0;i<9;i++){
    scanf("%d", &k);
    v -= k;
  }
  printf("%d\n", v);

  main();
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
using namespace std;
int lcm(int a,int b){return a/__gcd(a,b)*b;}
int a1,a2,a3,m1,m2,m3,a,b,c,x,y,z;
main(){
  while(cin>>a1>>m1>>a2>>m2>>a3>>m3,a1){
    a=b=c=0;
    x=y=z=1;
    while(!(a&&x==1))x=(a1*x)%m1,a++;
    while(!(b&&y==1))y=(a2*y)%m2,b++;
    while(!(c&&z==1))z=(a3*z)%m3,c++;
    cout<<lcm(a,lcm(b,c))<<endl;
  }
}

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

int main() {
    
    int A,B;
    string S,T,U;
    
    cin >> S >> T >> A >> B >> U;
    
    if (S == U) {
    cout << A-1 << " " << B << endl;
    }
    
    if (T == U) {
    cout << A << " " << B-1 << endl;
    }
   
}


Measured memory_bytes: 256
import numpy
import math

a, b, h, m = map(int, input().split())


mkaku = m*6
hkaku = h*30 + 0.5*m

if hkaku == mkaku:
    if a > b:
        print(a-b)
    else:
        print(b-a)
elif hkaku > mkaku:
    kaku = hkaku - mkaku
    if kaku > 180:
        kaku =  360 - kaku



    c = a ** 2 + b ** 2 - 2*a*b*(math.cos(math.radians(kaku)))
    print('{:21}'.format(numpy.sqrt(c)))

else:
    kaku = mkaku - hkaku
    if kaku > 180:
        kaku = 360 - kaku 
    


    c = a ** 2 + b ** 2 - 2*a*b*(math.cos(math.radians(kaku)))
    print('{:21}'.format(numpy.sqrt(c)))

Measured memory_bytes: 27136
N,K = map(int,input().split())
P = [0 for i in range(N)]
for i in range(K):
    a = int(input())
    b = list(map(int,input().split()))
    for j in range(a):
        P[b[j]-1] = 1
m = 0   
for i in range(N):
    if P[i] == 0:
        m += 1
print(m)

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

int main() {
    int n, ans = 200;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        int a, cnt = 0;
        cin >> a;
        while(a%2==0){
            a/=2;
            cnt++;
        }
        ans = min(cnt, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
#define F first
#define S second
using namespace std;

int n, ans, mn, mx, w, s1[N], s2[N];
pair<int, int> a[N];
int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%d %d", &a[i].F, &a[i].S);
		w = max(w, a[i].S - a[i].F + 1);
	}
	sort(a, a + n);
	mn = 2e9;
	for (i = 0; i < n; i++) {
		mx = a[i].F;
		mn = min(mn, a[i].S);
		s1[i] = max(mn - mx + 1, 0);
	}
	mx = 2e9;
	for (i = n - 1; i >= 0; i--) {
		mn = a[n - 1].F;
		mx = min(mx, a[i].S);
		s2[i] = max(mx - mn + 1, 0);
	}
	for (i = 0; i + 1 < n; i++) {
		ans = max(ans, s1[i] + s2[i + 1]);
	}
	ans = max(ans, s1[n - 1] + w);
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first1
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define set             set<string>  //insert()
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
        int v;
        cin>>v;
        int n;
        cin>>n;
        mk(a,n,int);
        int sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        if(sum<=v)cout<<v-sum;
        else cout<<"-1";



    return 0;
}


Measured memory_bytes: 3716
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  scanf("%d",&n);
  int a;
  double ans=0;
  REP(i, n){
    scanf("%d",&a);
    ans += 1.0/(double)a;
  }
  printf("%.10f\n",1.0/ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n; cin >> n;
    int a = 0, un = 0;
    rep(i, n) {
        string s; cin >> s;
        if (s == "A") a++;
        else un++;
        if (un > a) {
            out("NO");
            return 0;
        }
        
    }
    if (un != a) out("NO");
    else out("YES");
    
}



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

using namespace std;

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

    int n;
    cin >> n;

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

    sort(a.begin() , a.end());

    double res = a[0];
    for (int i = 1 ;i < a.size() ;i++)
        res = (res + a[i]) / 2.0;


    cout << fixed << setprecision(10) << res;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int sy, sx, gy, gx;
    cin >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    vector<string> g(h);
    rep(i, h) cin >> g[i];

    mat dist(h, vec(w, INF));
    dist[sy][sx] = 0;

    queue<P> que;
    que.push({sy, sx});

    while (!que.empty()) {
        auto fr = que.front();
        que.pop();

        rep(i, 4) {
            for (int j = 1; j <= k; j++) {
                int ty = fr.first + dy[i] * j;
                int tx = fr.second + dx[i] * j;
                if (ty >= 0 && ty < h && tx >= 0 && tx < w) {
                    if (g[ty][tx] == '@') break;
                    if (dist[ty][tx] <= dist[fr.first][fr.second]) break;
                    if (dist[ty][tx] == INF) {
                        dist[ty][tx] = dist[fr.first][fr.second] + 1;
                        que.push({ty, tx});
                    }
                }
            }
        }
    }

    if (dist[gy][gx] != INF) cout << dist[gy][gx] << endl;
    else cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 12052
import java.io.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line = br.readLine();
            do{
            	String[] in = line.split(" ", 0);
            	String data = "" + (Integer.parseInt(in[0]) + Integer.parseInt(in[1]));
            	System.out.println(data.length());
            	line = br.readLine();
            }while(line != null);
           	


        }catch (Exception e) {
			// TODO: handle exception
        	System.exit(0);
		}
		
	}

}

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

using namespace std;

void solve(void)
{
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 1; i < 11; i++)
	{
		x = r*x - d;
		cout << x << endl;
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int N=10234;
char k[N];
int main(){
    scanf("%s",k);
    int d;
    cin>>d;
    ll len=strlen(k);
    vector<vector<int>>dp(d,vector<int>(2));
    dp[0][0]=1;
    for(int where=0;where<len;where++){
        vector<vector<int>>new_dp(d,vector<int>(2));
        for(int sum=0;sum<d;sum++){
            for(bool smaller:{true,false}){
                for(int digit=0;digit<10;digit++){
                    if(digit>(k[where]-'0')&&!smaller)
                        break;
                    new_dp[(sum+digit)%d][smaller||digit<(k[where]-'0')]=
                            (new_dp[(sum+digit)%d][smaller||digit<(k[where]-'0')]+dp[sum][smaller])%mod;


                }
            }
        }
        dp=new_dp;
    }
    cout<<(dp[0][0]+dp[0][1]-1+mod)%mod<<endl;
}


Measured memory_bytes: 256