akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;



int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  vector<vector<int> > cnt(h, vector<int>(w, 0));

  rep(i, h){
    vector<bool> done(w, false);
    rep(j, w){
      int len = 0;
      if(done[j] == true) continue;
      if(s[i][j] == '#')  continue;

      while(len + j < w){
        if(s[i][j + len] == '#') break;
        ++len;
      }
      
      rep(k, len){
        cnt[i][j + k] += len;
        done[j + k] = true;
      }
    }
  }

    rep(j, w){
    vector<bool> done(h, false);
      rep(i, h){
        int len = 0;
        if(done[i] == true) continue;
        if(s[i][j] == '#')  continue;

        while(len + i < h){
          if(s[i + len][j] == '#') break;
          ++len;
        }
        
        rep(k, len){
          cnt[i + k][j] += len;
          done[i + k] = true;
        }
    }
  }

  int ans = 0;
  rep(i, h){
    rep(j, w){
      ans = max(ans, cnt[i][j] - 1);
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 20096
#include <stdio.h>
#include <stdint.h>

int main(void) {
  int64_t X;
  scanf("%ld", &X);

  int64_t DIST = 0;
  int64_t TIME = 1;
  for(TIME = 1; TIME < X; TIME++) {
    DIST += TIME;
    if(DIST >= X)
      break;
  }

  printf("%ld\n", TIME);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 int main(void){
   int N,A,B,C,D;
     cin >> N;
   A=N%1000;
   B=N-N%10;
   C=A%111;
   D=B%111;
   if (C==0 || D==0) {
     cout << "Yes" << endl;
   }
   else {
     cout << "No" << endl;
   }
 }

Measured memory_bytes: 256
temp=input().split()
N=int(temp[0])
M=int(temp[1])
Lmax=int(0)
Rmin=int(N-1)

for i in range(M):
  temp=list(map(int, input().split()))
  if Lmax<temp[0]-1:
    Lmax=temp[0]-1
    
  if Rmin>temp[1]-1:
    Rmin=temp[1]-1
    
if Rmin>=Lmax:
  print(Rmin-Lmax+1)
else:
  print(0)

Measured memory_bytes: 44136
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> l(m),r(m);
    vector<int> memo(n,0);
    for(int i=0; i<m; i++){
        cin >> l[i] >> r[i];
    }
    int lmax=0; int rmin=1e9;
    for(int i=0; i<m; i++){
        lmax=max(l[i],lmax);
        rmin=min(r[i],rmin);
    }
    if(rmin-lmax+1>=0){
        cout<<rmin-lmax+1;
    }else{
        cout << 0;
    }
}
/*
int main(){
    int n,m;
    cin >> n >> m;
    vector<ll>a(n,0),b(m,0),c(m,0);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<m; i++){
        cin >> b[i] >> c[i];
    }    
    vector<ll> wa(m,0);
}
*/


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PI;
int dfs(VVI& g, vector<PI>& res, int v, int& count, int from, VI& low, VI& pre);
vector<PI> bridges(VVI& g, int V);
int main(){
	int N, M;
	cin >> N >> M;
	vector<vector<int>> graph;
	vector<int> init;
	rep(i,N) graph.emplace_back(init);
	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);

	vector<pair<int,int>> ans = bridges(graph, N);
// for(auto x:ans)
// 	cout << "(" << x.first << "," << x.second << ")" << endl;
	cout << ans.size() << endl;
}

// res: bridges
// v: current node
// from: parent node
int dfs(VVI& g, vector<PI>& res, int v, int& count, int from, VI& low, VI& pre) {
	 pre[v] = count++;
	 low[v] = pre[v];
	 for (VI::iterator it = g[v].begin(); it != g[v].end(); it++) {
		 int to = *it;
		 if (pre[to] == -1) {
			 // destination has not been visited
			 // visit destination and update low[v]
			 low[v] = min(low[v], dfs(g, res, to, count, v, low, pre));
			 if (low[to] == pre[to]) {
				 // edge is not contained in a closed path -> bridge
				 res.push_back(make_pair(v, to));
			 }
		 } else {
			 if (from == to) {
				 // ignore a path to parent
				 continue;
			 }
			 low[v] = min(low[v], low[to]);
		 }
	 }
	 return low[v];
 }
 
 // Calculate bridges in a undirected graph.
 // Assume graph is connected and has no parallel edges or self-loops.
 // g: adjacency list
 // V: number of nodes
 vector<PI> bridges(VVI& g, int V) {
	 vector<PI> res;
	 if (V > 0) {
		 // assume at least the first vertex exists
		 VI low(V, -1);  // lowest reacheable index
		 VI pre(V, -1);  // pre-order index
		 int count = 0;  // pre-order index counter
		 dfs(g, res, 0, count, -1, low, pre);  // start dfs from vertex 0
	 }
	 return res;
 }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long int inf = 1e18;

int main() {

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

  long long int ans = inf;
  long long int tmp = 0;
  long long int cnt = 0;
  for(int i=0; i<n; i++){
    tmp += a[i];
    if( i % 2 == 0 && tmp <= 0 ){
      cnt += (1 - tmp);
      tmp = 1;
    }else if( i % 2 == 1 && tmp >= 0 ){
      cnt += (1 + tmp);
      tmp = -1;
    }
  }
  ans = min(ans, cnt);
  tmp = 0;
  cnt = 0;
  for(int i=0; i<n; i++){
    tmp += a[i];
    if( i % 2 == 1 && tmp <= 0 ){
      cnt += (1 - tmp);
      tmp = 1;
    }else if( i % 2 == 0 && tmp >= 0 ){
      cnt += (1 + tmp);
      tmp = -1;
    }
  }
  ans = min(ans, cnt);

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


Measured memory_bytes: 640
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a, b, c) min(a, min(b, c))
#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>str;
	n=str.length();
	for(int i=0;i<n/2;i++)
	{
	    if(str[i]!=str[n-1-i])
	    a++;
	}
	cout<<a;
}

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  for (int i = 0; i < abs(tx - sx); i++) {
    cout << "R";
  }
  for (int i = 0; i < abs(ty - sy); i++) {
    cout << "U";
  }
  for (int i = 0; i < abs(tx - sx); i++) {
    cout << "L";
  }
  for (int i = 0; i < abs(ty - sy); i++) {
    cout << "D";
  }
  cout << "D";

  for (int i = 0; i < abs(tx - sx) + 1; i++) {
    cout << "R";
  }
  for (int i = 0; i < abs(ty - sy) + 1; i++) {
    cout << "U";
  }
  cout << "L";
  cout << "U";
  for (int i = 0; i < abs(tx - sx) + 1; i++) {
    cout << "L";
  }
  for (int i = 0; i < abs(ty - sy) + 1; i++) {
    cout << "D";
  }
  cout << "R";
  cout << "\n";
}


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

 

int main()
{
   int a, b;     
   cin >> a >> b;
   
   if (a == b)
      cout << "a == b" << endl;
   else if(a > b)
      cout << "a > b" << endl;
   else if(a < b)
      cout << "a < b" << endl;
   
   return 0;
}


Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MP make_pair
#define ull unsigned long long int
#define F first
#define S second
#define put insert
#define pb push_back
#define rsort(arr) sort(arr.begin(),arr.end(),greater<int>())
#define srt(arr) sort(arr.begin(),arr.end())
ll MOD = 1e9+7;
int main() {
    int t = 1;
    // cin>>t;
    while(t--) {
        int x;
        cin>>x;
        if(x >= 1800)
            cout<<"1";
        else if(x >= 1600)
            cout<<"2";
        else if(x >= 1400)
            cout<<"3";
        else if(x >= 1200)
            cout<<"4";
        else if(x >= 1000)
            cout<<"5";
        else if(x >= 800)
            cout<<"6";
        else if(x >= 600)
            cout<<"7";
        else if(x >= 400)
            cout<<"8";
    }
    return 0;
}

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

using namespace std;

int gcd(int a, int b) {
    int c;

    while (b) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int main() {
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    int x, cmmdc;
    cin >> x;

    bool bigger_than_all = true;

    if (x > k) {
        bigger_than_all = false;
    }
    else if (x == k) {
        cout << "POSSIBLE";
        return 0;
    }

    cmmdc = x;

    for (int i = 2; i <= n; ++i) {
        cin >> x;

        if (x > k) {
            bigger_than_all = false;
        }
        else if (x == k) {
            cout << "POSSIBLE";
            return 0;
        }

        cmmdc = gcd(cmmdc, x);
    }


    if (bigger_than_all) {
        cout << "IMPOSSIBLE";
        return 0;
    }

    if (cmmdc == 1 || cmmdc == gcd(cmmdc, k)) {
        cout << "POSSIBLE";
        return 0;
    }

    cout << "IMPOSSIBLE";

    return 0;
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 100 + 5 , MAXS = 10000 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);


int n , m;

struct node {
    int v;
    int A;
    ll  B;

    node(){};
    node(int _v , int _A , ll _B) {
        v = _v;
        A = _A;
        B = _B;
    }
};

vector < node > adj[N];
int C[N];
int S;
ll D[N];

ll dis[N][MAXS];
int all = 0;

void djk() {

    for(int i = 0 ; i < N ; i ++) {
            for(int j = 0 ; j < MAXS ; j ++) {
                    dis[i][j] = INF;
            }
    }

    dis[1][S] = 0;
    priority_queue < lii , vlii , greater < lii > > pq;
    pq.push({0 , {S , 1} });

    while( !pq.empty() ) {
            ll  d = pq.top().first;
            int currS = pq.top().second.first;
            int u = pq.top().second.second;
            pq.pop();

            //cout << "u = " << u << " , d = " << d << " , currS = " << currS << endl;
            //system("pause");

            if(d != dis[u][currS]) continue;

            for(node nd : adj[u]) {
                    int v = nd.v;
                    ll  A = nd.A;
                    ll  B = nd.B;

                    for(int j = 0 ; j <= 10000 ; j ++) {
                            ll newS = currS + 1ll*j*C[u];
                            ll newD = d     + 1ll*j*D[u];

                            if(newS >= A) {
                                    ll costS = newS - A;
                                    if(newD + B < dis[v][costS]) {
                                            dis[v][costS] = newD + B;
                                            pq.push({newD + B , {costS , v} });
                                    }
                            }
                            if(newS > all) break;
                    }
            }
    }
}

void solve(int testCase){

    scanf("%d %d %d" , &n , &m , &S);

    S = min(S , 10000);

    for(int i = 0 ; i < m ; i ++) {
            int u , v;
            int A;
            ll  B;
            scanf("%d %d %d %lld" , &u , &v , &A , &B);
            all += A;

            adj[u].push_back(node(v , A , B));
            adj[v].push_back(node(u , A , B));
    }

    for(int i = 1 ; i <= n ; i ++) {
            scanf("%d %lld" , &C[i] , &D[i]);
            C[i] = min(C[i] , 5000);
    }

    djk();

    for(int i = 2 ; i <= n ; i ++) {
            ll ans = INF;
            for(int j = 0 ; j < MAXS ; j ++) {
                    ans = min(ans , dis[i][j]);
            }

            printf("%lld\n" , ans);
    }
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 44472
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
r=any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))
print('Yes' if r else 'No')

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N;
	cin>>N;
    map<ll,ll> mp;
    vector<ll> A(N);
    rep(i,N){
        cin>>A[i];
        mp[A[i]]++;
    }

    ll ans = 0;
    for(auto v:mp){
        ans += v.second*(v.second-1)/2;
    }
    ll tmp_ans;
    rep(i,N){
        tmp_ans = ans;
        if(mp[A[i]]!=1){
            tmp_ans -= mp[A[i]]-1;
        }
        cout<<tmp_ans<<"\n";
    }

	return 0;
}

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

using namespace std;
long long  dp[51][51][2501]={1,};

int main(){
  int n,a;
  int x[60];
  cin >> n >> a;
  for(int i=0;i<n;i++){
    cin >> x[i];
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<50;j++){
      for(int k=0;k<2501;k++){
        if(dp[i][j][k]){
          dp[i+1][j][k]+=dp[i][j][k];
          dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
        }
      }
    }
  }
  long long ans=0;
  for(int i=1;i<n+1;i++){
    ans+=dp[n][i][i*a];
  }
  cout << ans<<endl;
}


Measured memory_bytes: 9728
def f1(n):
    divs = []
    for i in range(1, int(n ** 0.5) + 1):  # range(n, int(n ** 0.5) - 1, -1)とすると非常に遅い！！
        if n % i == 0:
            divs.append(i)
            j = n // i
            if i != j:
                divs.append(j)
    return divs


MOD = 10 ** 9 + 7

N, K = map(int, input().split())
ans = 0

X = [0] * (K + 1)

for i in range(K, 0, -1):
    num1 = K // i
    var = pow(num1, N, MOD)
    var -= X[i]
    ans += var * i
    ans %= MOD

    divs = f1(i)
    for d in divs:
        X[d] += var
        X[d] %= MOD
    

print(ans)


Measured memory_bytes: 70176
N, M = map(int, input().split())
lisH = list(map(int, input().split()))

lisN = [[] for i in range(N)]
lisIdx = []
for i in range(M):
    inlis = list(map(int, input().split()))
    lisN[max(inlis)-1].append(lisH[min(inlis)-1])
    lisN[min(inlis)-1].append(lisH[max(inlis)-1])
    lisIdx += inlis

ans = 0
for i in range(N):
    if len(lisN[i])>0:
        if lisH[i] > max(lisN[i]):
            ans += 1
ans += N - len(set(lisIdx))
print(ans)

Measured memory_bytes: 37604
#include <cstdio>
#include <algorithm>

const int64_t INF=1e15;

void setmax(int64_t& x,int64_t y){
  x=std::max(x,y);
}

struct Block{
  int w,s,v;
  bool operator<(struct Block b)const{
    return s+w<b.s+b.w;
  }   
}blocks[1005];

int64_t dp[20001];

int main(){
  int N;
  scanf("%d",&N);
  for(int i=0;i<N;i++){
    scanf("%d %d %d",&blocks[i].w,&blocks[i].s,&blocks[i].v);
  }
  std::sort(blocks,blocks+N);
  std::fill(dp+1,dp+20001,-INF);
  for(int i=0;i<N;i++){
    for(int w=blocks[i].s;w>=0;w--){
      setmax(dp[w+blocks[i].w],dp[w]+blocks[i].v);
    }
  }
  printf("%ld\n",*std::max_element(dp,dp+20001));
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{
    char str[110],str1[110];
    scanf("%s %s",str,str1);
    int len=strlen(str);
    int len1=strlen(str1);

    int m=len+len1;
    char ans[m];

    for(int i=0,j=0;i<m && j<len1;i++,j++){
       ans[i]=str1[j];
    }

    for(int i=len1,j=0;i<m && j<len;j++,i++){
        ans[i]=str[j];
    }

    ans[m]='\0';
    printf("%s\n",ans);

}


Measured memory_bytes: 128
def f(x1, x2):
  W=[[i,1000] for i in range(n)]
  W[x1]=[x1,0]
  W[x2]=[x2,2000]
  G = range(n); G=G[x2:]+G[:x2]
  while 1:
    A = sorted([W[e] for e in G], key=lambda x: x[1])
    p1, w1 = A[0]
    G.remove(p1)
    if p1==x2: break
    for p2, w2 in A[1:]:
      way=(p1, p2)
      if way in cost:
        W[p2] = [p2, min([w2, w1 + cost[(p1,p2)]])]
  return w1

def g(): return map(int, raw_input().split(","))

n=int(raw_input())
m=int(raw_input())
cost={}
for _ in [0]*m:
  a,b,c,d=g()
  a-=1
  b-=1
  cost[(a,b)]=c
  cost[(b,a)]=d
x1,x2,y1,y2=g()
x1-=1
x2-=1
print y1-y2-f(x1,x2)-f(x2,x1)

Measured memory_bytes: 4292
s = input()
n = len(s)

ans = 0


for i in range(2**(n - 1)):
    a = ""
    for j in range(n-1):
        if (i >> j)& 1 == 1:
            a += s[j] + '+'
        else:
            a += s[j]
    a += s[-1]
    ans += eval(a)

print(ans)

Measured memory_bytes: 39152
#include <stdio.h>

int times[4];
int ans[2];

int main(void) {
	scanf("%d%d%d%d", &times[0], &times[1], &times[2], &times[3]);
	
	ans[0] = (times[0] + times[1] + times[2] + times[3]) / 60;
	ans[1] = (times[0] + times[1] + times[2] + times[3]) - (ans[0] * 60);
	
	printf("%d\n%d\n", ans[0], ans[1]);
	return 0;
}

Measured memory_bytes: 2704
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]

xyh.sort(key = lambda x:x[2])

H0 = xyh[-1][2]

for H in range(H0,H0+200):
    for CX in range(101):
        for CY in range(101):
            for n in range(N):
                if max(0, H-abs(xyh[n][0]-CX)-abs(xyh[n][1]-CY)) != xyh[n][2]:
                    break
            else:
                print(CX, CY, H)
                break
        else:
            continue
        break
    else:
        continue
    break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////

int main(){
    ll sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
    ll a=tx-sx;
    ll b=ty-sy;
    rep(i,0,b-1){
        cout<<'U';
    }
    rep(i,0,a-1){
        cout<<'R';
    }
    rep(i,0,b-1){
        cout<<'D';
    }
    rep(i,0,a-1){
        cout<<'L';
    }
    cout<<'L';
    rep(i,0,b){
        cout<<'U';
    }
    rep(i,0,a){
        cout<<'R';
    }
    cout<<'D';
    cout<<'R';
    rep(i,0,b){
        cout<<'D';
    }
    rep(i,0,a){
        cout<<'L';
    }
    cout<<'U'<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <iomanip>
using namespace std;
int main(){
	int A, B, H, M;
	cin >> A >> B >> H >> M;
	double x = 6.0 * M - (30.0 * H + 0.5 * M);
  	cout << setprecision(10) << sqrt(-2.0 * A * B * cos(x * (M_PI / 180)) + A * A + B * B) << endl;
}


Measured memory_bytes: 4180
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  ll n; cin >> n;
  ll ans = 10 - n / 200;
  cout << ans << '\n';
  return 0;
}


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

N, M = map(int, input().split())
# a = []
# b = []
count = [True] * N
for m in range(M):
    a_, b_ = map(int, input().split())
    a_ -= 1
    b_ -= 1
    # a.append(a_)
    # b.append(b_)
    count[a_] = count[a_] ^ True
    count[b_] = count[b_] ^ True

# count = [0] * N
# for m in range(M):
#     count[a[m]]
for m in range(M):
    if not count[m]:
        print("NO")
        sys.exit(0)
print("YES")


Measured memory_bytes: 45400
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }.sorted()
    val b = readLine()!!.split(" ").map { it.toLong() }.sorted()
    val c = readLine()!!.split(" ").map { it.toLong() }.sorted()

    b.map {
        a.lowerBound(it).toLong() * (n-c.lowerBound(it+1)).toLong()
    }.sum().let { println(it) }

}

//ソート済みのListに対して、log(size)回の比較でelementより(真に)小さい要素の個数(element以上の要素が初めて現れるindex)を返す。
fun <T : Comparable<T>> List<T>.lowerBound(element: T, fromIndex: Int = 0, toIndex: Int = size): Int {
    var low = fromIndex
    var high = toIndex

    while (low < high) {
        val mid = (low + high).ushr(1)
        val cmp = get(mid).compareTo(element)

        if (cmp < 0)
            low = mid + 1
        else //(cmp >= 0)
            high = mid
    }
    return low
}

Measured memory_bytes: 112220
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n%10 == 9 || n/10==9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>
 
#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;
 
int main()
{
	int a,b,c,d;
	
	cin >> a >> b >> c >> d;
	
	
	int ret = min(b,d) - max(a,c);
	
	if(ret > 0)
		cout << ret << endl;
	else
		cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1080], b[1080];
int n, m;

string button[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
string str;

char _str[10800];
void output(int val, int cnt){
	if(val == 0)return;
	cout << button[val][(cnt-1) % button[val].size()];
}


int main(){
	int q;
	cin >> q;
	while(q--){
		cin >> str;
		int val = 0;
		int cnt = 0;
		for(int i = 0;i < str.size();i++){
			if(str[i] == '0'){
				output(val, cnt);
				val = cnt = 0;
			}
			else{
				val = str[i] - '0';
				cnt++;
			}
		}
		output(val, cnt);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		// aとbの最小公倍数を求める
		long lcm = calcLcm(a, b);
		System.out.println(lcm);

		sc.close();
	}

	static long calcLcm(int a, int b) {
		int max = Math.max(a, b);
		int min = Math.min(a, b);
		long product = 1l * max * min;

		if (min == 0)
			return max;

		int temp;
		while ((temp = max % min) != 0) {
			max = min;
			min = temp;
		}

		return product / min;
	}

}


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

int main() {
    ll r, d, x;
    cin >> r >> d >> x;
    rep(i, 10) {
        x = r*x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int x;
    cin>>x;
    REP(i,x){
        int k=i*4;
        if(k<=x&&(x-k)%7==0){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll c[m];
  mem(c);
  REP(i,1,n+1) c[i%m]++;
  ll ans=c[0]*c[0]*c[0];
  if(m%2==0) ans+=c[m/2]*c[m/2]*c[m/2];
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1792
#include<iostream>
#include<sstream>
#include<stdio.h>
#include<stack>
#include<string>
#include<string.h>
#include<math.h>
#include <algorithm>
#include<cctype>			
#include<iomanip>
#include <time.h>
#include <map>
#include <stdlib.h>
#include <vector>
#include <set>
#include <iterator>
#include<fstream>
#include <queue>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i, a, b) for(int i=a; i<b; i++)
#define per(i, a, b) for(int i=b-1; i>=a; i--)
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
	char s[10004];
int main(){
	int n;
	cin>>n;
    scanf("%s",&s);
    int x=strlen(s);
    ifor(x){
    	s[i]=s[i]+n;
    	if(s[i]>'Z')s[i]-=26;
	}
	printf("%s\n",&s);
}

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

int main() {
	ll n,d=0,f=0;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(ll i=0;i<2*n;i++)
	{
		if(i%2==0)
		{
		cout<<s[d];
		++d;
		}
		else
		{
		cout<<t[f];
		++f;
		}
	}
	return 0;
}

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

using namespace std;

void solve() {
    int A, B;
    string S;
    cin >> A >> B >> S;
    for(int i = 0; i < A; i++) if(!('0' <= S[i] && S[i] <= '9')){
        cout << "No" << endl;
        return;
    }
    if(S[A] != '-'){
        cout << "No" << endl;
        return;
    }
    for(int i = A + 1; i <= A + B; i++) if(!('0' <= S[i] && S[i] <= '9')){
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
}

int main() {
    solve();
    return 0;
}


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

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)


# print(Base_10_to_n(n,k))
print(len(Base_10_to_n(n,k)))

Measured memory_bytes: 2940
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
A=get_i
lcm=A.inject(1){|res,x| res.lcm(x)}
ans=0
A.each do|a|
    ans+=lcm/a
end
puts ans% (10**9+7)

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

using namespace std;

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

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

    int n;
    cin >> n;
    double v[n];
    rep(i, 0, n){
        cin >> v[i];
    }
    sort(v, v+n);
    double result=v[0];
    rep(i, 1, n){
        result = (result+v[i])/2;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    char c;
    cin >> c;
    cout << ++c << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

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

black = sum(a[:k])
white = 0

for i in range(k,n):
    if a[i]>0:
        white += a[i]
black += white

b = [black]
w = [white]

for i in range(n-k):
    if a[i]>0:
        white += a[i]
    else:
        black -= a[i]
    if a[i+k] > 0:
        white -= a[i+k]
    else:
        black += a[i+k]
    b.append(black)
    w.append(white)

print(max(max(b),max(w)))



Measured memory_bytes: 77216
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		long mod = 998244353;
		long[] B = new long[N+1];
 		long[] A = new long[N+1];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			int a2 = int.Parse(str[i]);
			B[i] = a2;
			A[a2]++;
		}
		long ans = 0;
		long a1 = 0;
      	bool flag = true;
		if(B[0]==0 && A[0]==1){
			ans = 1;
			a1 = 1;
			for(var i=1;i<=N;i++){
				if(A[i] > 0){
                  	if(flag == false){
                      	ans = 0;
                    }
					ans = ans * Mpow(a1,A[i],mod) % mod;
					a1 = A[i];
                } else {
                  	flag = false;
                }
				//Console.WriteLine(A[i]+" "+a1+" "+ans);
            }
		}
		Console.WriteLine(ans);
	}
	
	public static long Mpow(long x,long n,long m)
	{
		long ans = 1;
		while(n > 0){
			if(n % 2 == 1){
				ans = ans * x % m;
				n -= 1;
			}
			x = x * x % m;
			n /= 2;
		}
		return ans;
	}
}


Measured memory_bytes: 20064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <utility>

#include <cassert>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define FOR(i,a,b) for(ll i=(a); i < (b); i++)
#define RFOR(i,a,b) for(ll i=(b)-1; i >= (a); i--)
#define rep(i,n) FOR(i,0,(n))
#define rrep(i,n) RFOR(i,0,(n))

int main() {
	int N;
	cin >> N;
	string s[3];
	rep(i,3)
		cin >> s[i];
	int res = 0;
	rep(i,N) {
		char a = s[0][i], b = s[1][i], c = s[2][i];
		if(a != b && b != c && c != a) {
			res += 2;
		}
		else if(a == b && b == c) {
			res += 0;
		}
		else {
			res += 1;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000

int main(){
   IOS;
ll t;t=1;//cin>>t;

while(t--){
ll a,b,c;cin>>a>>b>>c;
if(a%b==0)cout<<(a/b)*c;
else cout<<(a/b+1)*c;
  
}
    
return 0;    
}

Measured memory_bytes: 3612
#include<set>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    set<int> s;
    int q;
    cin>>q;
    while(q--)
    {
        int c,t;
        cin>>c>>t;
        if(c==0) 
        {
            s.insert(t);
            cout<<s.size()<<endl;
        }
        else if(c==1) 
        {
            cout<<s.count(t)<<endl;
        }
        else if(c==2)
        {
            s.erase(t);
        }
        else
        {
            int R;
            cin>>R;
            auto its=s.lower_bound(t);
            auto ite=s.upper_bound(R);
            for(auto it=its;it!=ite;it++)
            {
                cout<<*it<<endl;
            }
        }
    }
}



Measured memory_bytes: 12372
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int a , b;
    cin>>a>>b;
    int out = 1;
    int ans = 0;
    while(out < b){
        out += a - 1;
        ans ++;
    }
    cout<<ans<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		String S = s.next();
		String T = s.next();
		char[] t = T.toCharArray();
		
		String question = "";
		for(int i = 0; i < T.length(); i++) {
			question += "?";
		}
		if(S.lastIndexOf(question) > -1) {
			String rest = S.substring(0, S.lastIndexOf(question));
			System.out.println(rest.replaceAll("\\?", "a") + T);
			return;
		}
		
		String cur;
		for(int i = S.length() - T.length(); i > -1; i--) {
			cur = S.substring(i, i + T.length());
			for(int j = T.length() - 1; j > -1; j--) {
				if(cur.charAt(j) == t[j] || cur.charAt(j) == '?') {
					if(j == 0) {
						String front = S.substring(0, i).replaceAll("\\?", "a");
						String back = S.substring(i + T.length()).replaceAll("\\?", "a");
						System.out.println(front + T + back);
						return;
					}
				}else {
					break;
				}
			}
		}
		System.out.println("UNRESTORABLE");
    }
}

Measured memory_bytes: 23124
#!/usr/bin/env python
"""AtCoder Beginner Contest 167: B - 
https://atcoder.jp/contests/abc167/tasks/abc167_b
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def main():
    [A, B, C, K] = list(map(int, input().split()))

    a = min(A, K)
    b = min(B, K - a)
    c = min(C, K - a - b)

    print((a * 1) + (b * 0) + (c * -1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<bool>> g(N, vector<bool>(N, false));
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        g[x - 1][y - 1] = true;
        g[y - 1][x - 1] = true;
    }

    vector<int> order(N);
    for (int i = 0; i < N; i++) {
        order[i] = i;
    }
    int count = 0;
    do {
        bool ok = true;
        for (int i = 1; i < N; i++) {
          if (!g[order[i - 1]][order[i]]) {
              ok = false;
              break;
          }
        }
        if (ok) {
            count++;
        }
    } while (next_permutation(order.begin() + 1, order.end()));
    cout << count << endl;
    return 0;
}



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

int main(){
	string a;
	string b;
	int n=0;
	int i=0;
	int s=0;
	int h=0;
	b="JOI";
	while(cin>>a){
		s=0,h=0;
		n=a.size();
		for(i=0;i<n-2;i++){
			if(a[i]==b[0] && a[i+1]==b[1] && a[i+2]==b[2]){
				s++;
			}
			if(a[i]==b[2] && a[i+1]==b[1] && a[i+2]==b[2]){
				h++;
			}
		}
		cout<<s<<endl<<h<<endl;
	}
}

Measured memory_bytes: 3180
#include<stdio.h>
int solve(int,int);
int n,A[50];
int main(){
  
  int q,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  int M;
   for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M)){
       printf("yes\n");
     }else{
       printf("no\n");
     }
   }
   return 0;
}
int solve(int i,int m){
  if(m==0)return 1;
  if(i>=n)return 0;
  int res = solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}



Measured memory_bytes: 2108
n = int(input())
flist = []
for _ in range(n):
    flist.append([int(f) for f in input().split()])

plist = []
for _ in range(n):
    plist.append([int(p) for p in input().split()])

def commonSum(a_l, b_l):
    """共通要素を返す"""
    cnt = 0
    for a, b in zip(a_l, b_l):
        if a == b and a == 1:
            cnt += 1
    return cnt

# 初期値
profit = -10**15
for open in range(1, 2**10):
    openlist = [int(i) for i in format(open, 'b').zfill(10)]

    # 各店との利益を求める
    prof = 0
    for i in range(n):
        common = commonSum(flist[i], openlist)
        prof += plist[i][common]
    if profit < prof:
      profit = prof
print(profit)


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

int main() {
    LL N, K, prefix[200003];

    cin >> N >> K;

    prefix[0] = 0;
    for (int i = 1; i <= N; i++)
        prefix[i] = prefix[i - 1] + i;

    LL answer = 0;
    for (int k = K; k <= N + 1; k++) {
        LL mini = prefix[k - 1];
        LL maxi = prefix[N] - (N - k < 0 ? 0 : prefix[N - k]);

        LL temp = (maxi - mini + 1)%MOD;

        answer = (answer + temp)%MOD;
    }

    cout << answer << endl;
}


Measured memory_bytes: 5196
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    h = input().split()
    h = [int(n) for n in h]
    max = 0
    now = 0
    i = 0
    for i in range(n-1):
        if h[i] >= h[i+1]:
            now += 1
        else:
            if now >= max:
                max = now
            now=0
        if now >= max:
            max = now
    print(max)

if __name__ == "__main__":
    main()



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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) PRINT("Yes");
    else PRINT("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

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

  if (b <= a) {
    cout << k + 1 << endl;
    return 0;
  }

  if (k <= a) {
    cout << k + 1 << endl;
    return 0;
  }

  if (b - a == 1) {
    cout << k + 1 << endl;
    return 0;
  }

  // k > a & a > b
  ll remain = k - a + 1;
  ll kaisuu = remain / 2;
  ll sub = b - a;
  ll ans = 0;
  if (remain % 2 == 0) {
    ans = sub * kaisuu + a;
  } else {
    ans = sub * kaisuu + a + 1;
  }

  cout << ans << endl;
}


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

#define MAXN 400

using namespace std;

typedef long long ll;

ll sz[MAXN+1];
ll acc[MAXN+1];
ll d[MAXN+1][MAXN+1]; 

ll merge(int a, int b)
{
    if(d[a][b]) return d[a][b];
    if(a==b) return 0;
    
    ll r = merge(a, a) + merge(a+1, b);
    for(int i=a+2 ; i<=b ; i++)
        r = min(r, merge(a, i-1) + merge(i, b));
    d[a][b] = r + acc[b] - acc[a-1];
    
    return d[a][b];
}

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

    int n;
    cin >> n;
    for(int i=1 ; i<=n ; i++) cin >> sz[i];
    for(int i=1 ; i<=n ; i++) acc[i] = sz[i] + acc[i-1];

    cout << merge(1, n) << '\n';

    return 0;
}

Measured memory_bytes: 1536
N = int(input())

for i in range(N):
    t_i, x_i, y_i = map(int, input().split()) 

    if (x_i+y_i)> t_i:
        print("No")
        exit()
    elif (x_i+y_i) %2 != t_i%2 :
        print("No")
        exit()

print("Yes")
    

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include <numeric>
#include<vector>

#define LL long long
#define MOD 1000000007

using namespace std;

LL gcd(LL C, LL D) {
	if (C < D) gcd(D, C);

	if (C%D == 0)return D;
	else gcd(D, C%D);
}
int main() {

	LL A, B, C, D;
	cin >> A >> B >> C >> D;

	LL LCM = C * D / gcd(C, D);

	LL dif = B - A + 1;
	LL Adiv = (A - 1) / C + (A - 1) / D - (A - 1) / LCM;
	LL Bdiv = B / C + B / D - B / LCM;
	LL ans = dif - (Bdiv - Adiv);
		cout << ans << endl;
		cin >> A;

}





Measured memory_bytes: 256