akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
	Scanner sc;
	int n, a, b;
	static final int MOD = 1_000_000_007;
	
	void calc() {
		sc = new Scanner(System.in);
		n = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		
		long s = (pow2(n)-1+MOD)%MOD;
		long na = nCr(a);
		long nb = nCr(b);
		System.out.println( ((s-na+MOD)%MOD-nb+MOD)%MOD );
	}
	
	long pow2(int n) {
		long ans = 1;
		for (int i = 0; i < 31; i++) {
			ans = ans * ans % MOD;
			if ((n&0x40000000) > 0) ans = ans * 2 % MOD;
			n = n << 1;
		}
		return ans;
	}
	
	long nCr(int a) {
		if (a > n/2) a = n - a;
		long c = 1;
		for (int i = 0; i < a; i++) {
			c = c * (n - i) % MOD;
			c = c * inv(a - i) % MOD;
		}
		return c;
	}
	
	static final long inv(long a) {
		long b = MOD;
		long aa = a, bb = b;
		long x0 = 1, x1 = 0;
		long y0 = 0, y1 = 1;
	
		while (b != 0) {
			long q = a / b;
			long r = a % b;
			long x2 = x0 - q * x1;
			long y2 = y0 - q * y1;
	
			a = b; b = r;
			x0 = x1; x1 = x2;
			y0 = y1; y1 = y2;
		}
		if (bb > 0 && x0 < 0) {
			long n = -x0/bb;
			if (-x0%bb != 0) n++;
			x0 += n*bb; y0 -= n*aa;
		}
	    return x0;
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}
	


Measured memory_bytes: 25300
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int r;
    cin >> r;
    if(r < 1200) cout << "ABC" << endl;
    else if(r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile

INF = float("inf")


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in readi(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[0]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    N = readi()
    x = readi(N, 3)
    dp = arr(N + 1, 3)
    for i in range(N):
        dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + x[i][0], dp[i][2] + x[i][0])
        dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + x[i][1], dp[i][2] + x[i][1])
        dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + x[i][2], dp[i][1] + x[i][2])
    print(max(dp[N]))


if __name__ == "__main__":
    main()


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

using namespace std;

int main(){

  string ramen;

  while(cin >> ramen){
    int topp=0,payment=700;

    for(int i=0;i<3;i++){
      if(ramen.at(i) == 'o')payment+=100;
    }
    cout << payment << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
 
int main(void)
{
    int n, t[100001], x[100001], y[100001];
    int i, dt, dist;
    bool flag = false;
    scanf("%d", &n);
    t[0] = x[0] = y[0] = 0;
    for (i=1; i<=n; i++)
    {
        scanf("%d %d %d", &t[i], &x[i], &y[i]);
    }
 
    for (i=0; i<=n-1; i++)
    {
        dt =  t[i+1] - t[i];
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) {
            flag = true;
            break;
        }
        if (dt%2 != dist%2) {
            flag = true;
            break;
        }
    }
 
    if (flag == true) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<stack>

#define int long long
#define all(x) x.begin(), x.end()
#define forn(i, x) for(int i = i; i < x; ++i)

using namespace std;

int INF = 1e16 + 7;

struct dsu {
private:
    vector<int> sz;
    vector<int> a;
public:
    int get_root(int v) {
        return a[v] == v ? v : a[v] = get_root(a[v]);
    }
    
    int get_sz(int v) {
        return sz[v];
    }

    dsu(int size) {
        a.resize(size);
        sz.resize(size);
        for (int i = 0; i < size; ++i) {
            a[i] = i; sz[i] = 1;
        }
    }

    void unite(int v, int u) {
        v = get_root(v), u = get_root(u);
        if (rand() % 2) {
            a[v] = u;
            sz[u] += sz[v];
        }
        else {
            a[u] = v;
            sz[v] += sz[u];
        }
    }

    bool is_united(int v, int u) {
        v = get_root(v), u = get_root(u);
        return v == u;
    }
};

void solve() {
    int n, m;
    cin >> n >> m;
    dsu ds(n);
    while(m--) {
        int v, u;
        cin >> v >> u;
        if(!ds.is_united(v - 1, u - 1)) ds.unite(v - 1, u - 1);
    }
    int mx = 0;
    for (int i = 0; i < n; ++i) {
        mx = max(ds.get_sz(i), mx);
    }
    cout << mx;
}

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

    cout << setprecision(10) << fixed;

    solve();

    return 0;
}

Measured memory_bytes: 6048
NUM = 10**9 + 7


def sum1(n):
    return n*(n+1)//2


def sum_arithmetic_seq(a, d, n):
    ans = n*(2*a+(n-1)*d)//2
    return ans


n, k = map(int, input().split())
ans = 0
for i in range(k, n+2):
    tmp = sum_arithmetic_seq(n-i+1,1,i) - sum_arithmetic_seq(0,1,i) + 1
    ans += tmp % NUM
print(ans % NUM)


Measured memory_bytes: 9144
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main() {
	double a,b,c,d,e,f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		// ???????????????(???????????????????????????????????????)
		// ?¬¬?????????x????????°???1?????????
		b /= a;
		c /= a;
		a = 1;
		// ????????¶?????§???????¨???? (e-bd)y = f-cd ?????????????????????
		double y = (f - c*d) / (e - b*d);
		double x = c - b * y;
		printf ("%1.3f %1.3f",x,y);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int N;
    cin>>N;
    int ans=0;

    vector<int>p(N);
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    for(int i=1;i<N-1;i++){
        int A=max(p[i-1],max(p[i],p[i+1]));
        int B=min(p[i-1],min(p[i],p[i+1]));
        int C=p[i-1]+p[i]+p[i+1]-A-B;
        if(C==p[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

int main(void){
    string d;
    cin >> d;
    int len = d.size();
    for(int i = 0; i < len; ++i){
	if(d[i] == '?'){
	    d[i] = 'D';
	}
    }
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 3696
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            //日付を入力する
            string input = Console.ReadLine();
            int n = input[0];

            n++;
            

            //月が同じなら月末、それ以外は別
            
            Console.WriteLine((char)(n));
            
        }
    }

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

int main(){
  int N; cin>>N;
  long long S=0;
  vector<long long>part_S(N-1);
  for(int i=0;i<N;i++){
    int a; cin>>a;
    S+=a;
    if(i==0)
      part_S.at(i)=a;
    else if(i!=N-1)
      part_S.at(i)=part_S.at(i-1)+a;
  }
  
  long long res=1000000000000;
  
  for(int i=0;i<N-1;i++){
    res=min(res,abs(S-2*part_S.at(i)));
  }
  
  cout<<res<<endl;
}
  

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int a,b,x;
  cin>>a>>b>>x;
  if(a<=x && x<=a+b) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int a, b, c, d;
  
  scanf("%d %d %d", &a, &b, &c);
  
  if(a == b && b == c){
    d = 1;
  } else if(a == b || b == c || a == c){
    d = 2;
  } else {
    d = 3;
  }
  
  printf("%d\n", d);
  
  return 0;
}


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

int main(){
  int n,n1,n2,n3,n4;
  cin >> n;
  n1 = n/1000;
  n2 = n/100-n1*10;
  n3 = n/10-n1*100-n2*10;
  n4 = n%10;
  if((n1 == n2 && n2==n3)||(n2 == n3 && n3==n4)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


inf = float("inf")


def main():
    total = inputInt()

    dp = [0 for _ in range(total + 1)]

    for i in range(100, total + 1):
        for j in range(100, 106):
            if dp[i] < i:
                dp[i] = dp[i - j] + j
    return 1 if dp[total] == total else 0


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 7064
import java.util.*;

public class Main {

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

        long result = execute(sc.nextInt());
        System.out.println(result);
    }

    public static long execute(int count) {
        Queue<Long> queue = new ArrayDeque<>();

        for(int i = 1; i <= 9 ; i++){
            queue.add(Long.valueOf(i));
        }

        long polled = 0;
        for(int i = 1 ; i <= count ; i++){
            polled = queue.poll();
            long nextAddBase = polled * 10 + polled % 10;
            if(polled % 10 != 0){
                queue.add(nextAddBase - 1);
            }
            queue.add(nextAddBase);
            if(polled % 10 != 9){
                queue.add(nextAddBase + 1);
            }
        }
        return polled;
    }
}


Measured memory_bytes: 30804
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
int INF=(1<<30)-1;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<int> a;
    a.resize(n+2);
    a[0]=INF;
    REP(i,n) a[i+1]=i%2?-INF:INF;
    a[n+1]=n%2?INF:-INF;
    vector<bool> broken;
    broken.assign(n+2,false);
    REP(i,n){
      string str;
      cin >> str;
      if(str=="x") broken[i+1]=true;
      else {
	a[i+1]=stoi(str);
      }
    }
    int ansl=-INF,ansr=INF;
    //[l,r)
    FOR(i,1,n+1){
      if(broken[i]){
	if(i%2){
	  ansr=min(ansr,min(a[i-1],a[i+1]));
	  a[i]=ansl;
	}
	else{
	  ansl=max(ansl,max(a[i-1]+1,a[i+1]+1));
	  a[i]=ansr;
	}
      }
      else{
	if(i%2 && a[i]>=a[i-1]) ansl=ansr;
	if(!(i%2) && a[i]<=a[i-1]) ansl=ansr;
      }
    }
    
    if(ansr-ansl==1) cout << ansl << endl;
    else if(ansr>ansl) cout << "ambiguous" << endl;
    else cout << "none" << endl;
  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;

int main(){
	IOS;
set<char> s;
string v;
cin>>v;
for(int i=0;i<3;i++)
s.insert(v[i]);
if(s.size()==2)
cout<<"Yes";
else 
cout<<"No";    
    
}

Measured memory_bytes: 3620
N, M, X, Y = [int(x) for x in input().split()]
xN = [int(x) for x in input().split()] + [X]
yM = [int(x) for x in input().split()] + [Y]

if max(xN) < min(yM):
  print('No War')
else:
  print('War')

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

int main() {
  int N, M, k, a1, a2, b1, b2, c1, c2, d1, d2, e1, e2;
  cin >> N;
  cin >> M;
  cin >> k;
  cin >> a1;
  cin >> a2;
  if ( N == 0){
    cout << 1 << endl;
  }
  else if ( M == 0){
    cout << 2 << endl;
  }
  else if ( k == 0){
    cout << 3 << endl;
  }
  else if ( a1 == 0){
    cout << 4 << endl;
  }
  else if ( a2 == 0){
    cout << 5 << endl;
  }
}



Measured memory_bytes: 3588
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(){
  mint ans=1;
  long long int n,m,i;
  vector<long long int> a;
  scanf("%lld %lld\n",&n,&m);
  for(i=2;i<=m;i++){
    long long int res=0;
    while(m%i==0){
      res++;
      m=m/i;
    }
    a.push_back(res);
  }
  if(m!=1){
    a.push_back(1);
  }
  long long int j,n1,k1;
  for(i=0;i<a.size();i++){
    n1=n+a[i]-1,k1=a[i];
    long long int ans1=1;
    for(j=1;j<=k1;j++){
      ans=ans*(n1-j+1)/j;
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 525012
#include<stdio.h>
int main(){
  int a=0,b=0,d=0,r=0;
  double f=0;

  scanf("%d %d",&a,&b);
 
  d=a/b;
  r=a%b;
  f=(double)a/b;

  printf("%d %d %f\n",d,r,f);

  return 0;
}

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

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define ll long long int 
#define PI 3.1415926535897932384626

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<string> v;
	for(int i=0;i<n;i++)
	{
	     string temp;
	     cin>>temp;
	     v.push_back(temp);
	}
	cout<<"AC x "<<count(v.begin(),v.end(),"AC")<<"\n";
	cout<<"WA x "<<count(v.begin(),v.end(),"WA")<<"\n";
	cout<<"TLE x "<<count(v.begin(),v.end(),"TLE")<<"\n";
	cout<<"RE x "<<count(v.begin(),v.end(),"RE")<<"\n";
	return 0;
}

Measured memory_bytes: 7428
#include<bits/stdc++.h>
#define Pair pair<int,int>
#define mo(x) if(x>=p) x-=p
#define fill(x) if(x<0) x+=p
using namespace std;
const int p=1e9+7;
const int maxn=2e5+10;
int n,m,b[maxn],l[maxn],f[maxn],pre[maxn],s[maxn][2];
struct node{
    int x,v;
    void Read(){scanf("%d%d",&x,&v);}
    bool operator < (const node& B)const{return v<B.v;}
}a[maxn];
int main()
{
    cin>>n;int i,t;
    for(i=1;i<=n;i++)
        a[i].Read(),b[++m]=a[i].x;
    sort(a+1,a+1+n);
    sort(b+1,b+1+m);
    m=unique(b+1,b+1+m)-b-1;
    for(i=1,t=0;i<=n;i++)
        s[i][1]=(t=max(t,a[i].x));
    for(i=n,t=2e9;i;i--)
        s[i][0]=(t=min(t,a[i].x));
    for(i=1;i<=n;i++){
        s[i][0]=lower_bound(b+1,b+1+m,s[i][0])-b;
        s[i][1]=lower_bound(b+1,b+1+m,s[i][1])-b;
        l[s[i][1]]=max(l[s[i][1]],s[i][0]);
    }
    for(i=f[0]=pre[0]=1;i<=m;i++){
        if(l[i]){
            f[i]=pre[i-1];
            if(l[i]!=1) f[i]-=pre[l[i]-2];
            fill(f[i]);
        }
        else{
            f[i]=f[i-1]<<1;
            mo(f[i]);
        }
        pre[i]=pre[i-1]+f[i];
        mo(pre[i]);
    }
    cout<<f[m];
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;
 
// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)
 
// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
 
// グラフ表現
using Graph = vector<vector<int>>;
 
// グラフの辺表現
using Edge = map<pair<int,int>,int>;
 
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}
 
// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}
 
int main()
{
    cout << fixed << setprecision(15);
    ll H, W, K;
    cin >> H >> W >> K;
    
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
 
    vector<vector<char>> c;
    vector<vector<ll>> v;
    c.assign(H, vector<char>(W, '.'));
    v.assign(H, vector<ll>(W, INF));
 
    REP(i, H){
        string S;
        cin >> S;
        
        REP(j, W){
            c[i][j] = S[j];
        }
    }
 
    // indexが0からなので1減らす
    x1--; y1--; x2--; y2--;
 
    vector<vector<ll>> dx(4, vector<ll>(K));
    vector<vector<ll>> dy(4, vector<ll>(K));
 
    for(ll i=0; i<K; i++){
        dx[0][i] = i+1;
        dy[0][i] = 0;
    }
    for(ll i=0; i<K; i++){
        dx[1][i] = (i+1)*(-1);
        dy[1][i] = 0;
    }
    for(ll i=0; i<K; i++){
        dx[2][i] = 0;
        dy[2][i] = i+1;
    }
    for(ll i=0; i<K; i++){
        dx[3][i] = 0;
        dy[3][i] = (i+1)*(-1);
    }
 
    // REP(i, 4){
    //     // 4方向へ繰り返す
    //     REP(j, K) {
    //         cout << dx[i][j] << " " << dy[i][j] << endl;
    //     }
    // }
 
    // キューを準備
    queue<P> que;
    // 探索の初期値を入れる
    que.push(P(x1, y1));
    v[x1][y1] = 0;
 
    while(true) {
        //　もしも探索地点がゴールならば現在の歩数を探索終了
        if(que.empty()) {
            break;
        }
        // キューの中身を取り出す
        P p = que.front(); que.pop();
        int x = p.first;
        int y = p.second;
        int s = v[x][y];
 
        // cout << "x:" << x << " y:" << y << endl;
        // cout << c[0][1] << endl;
 
        REP(i, 4){
            // 4方向へ繰り返す
            REP(j, K) {
                int nx = x+dx[i][j];
                int ny = y+dy[i][j];
        
                // 移動すると範囲外になったり、#だったり、探索済みだったら終了する
                if(nx < 0 || nx >= H || ny < 0 || ny >= W){
                    // i = (i/K + 1)*K-1;
                    break;
                }
                // if(v[nx][ny] != -1 || c[nx][ny] == '@'){
                //     break;
                // }
                if(c[nx][ny] == '@'){
                    break;
                }
                if(v[nx][ny] <= v[x][y]){
                    break;
                }
                // if(v[nx][ny] != -1){
                //     continue;
                // }
                // 未探索だったら、キューに入れて現在の距離を記録
                if(v[nx][ny] == INF){
                    que.push(P(nx, ny));
                    v[nx][ny] = s+1;
                }
            }
        }
        
    }
 
    if(v[x2][y2] == INF){
        v[x2][y2] = -1;
    }
    cout << v[x2][y2] << endl;
    return 0;
}

Measured memory_bytes: 19960
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n = in();
  vector<ll> a(n+1);
  vector<ll> b(n);
  rep(i,n+1) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll init_b = 0;
  rep(i,n) init_b += b[i];
  for(int i=n-1; i>=0; --i){
    if(a[i+1]>b[i]){
      a[i+1] -= b[i]; b[i] = 0;
    } else {
      b[i] -= a[i+1]; a[i+1] = 0; 
    }
    if(a[i]>b[i]){
      a[i] -= b[i]; b[i] = 0;
    } else {
      b[i] -= a[i]; a[i] = 0; 
    }
  }
  ll last_b = 0;
  rep(i,n) last_b += b[i];
  cout << init_b - last_b << endl;
  return 0;
}


Measured memory_bytes: 1792
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	var a []int
	for i := 0; i < n; i++ {
		var cin int
		fmt.Scan(&cin)
		a = append(a, cin)
	}
	var b []string
	for i := range make([]int, n) {
		b = append(b, strconv.Itoa(a[n-i-1]))
	}
	fmt.Println(strings.Join(b, " "))
}



Measured memory_bytes: 1148
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn=200;
int n,m;
int a[maxn];

int main(){
#ifdef LZT
//	freopen("in","r",stdin);
#endif
	int num=0;
	n=read();m=read();
	rep(i,1,m){
		a[i]=read();
		if(a[i]&1) num++;
	}
	if(num>2){
		puts("Impossible");
		return 0;
	}
	for(int i=1;i<=m;i++)
		if(a[i]&1){
			if(a[1]&1) swap(a[i],a[m]);
			else swap(a[i],a[1]);
		}
	rep(i,1,m) cout<<a[i]<<' ';
	cout<<endl;
	a[1]++;a[m]--;
	if(a[m]==0) m--;
	if(m>=2){
		cout<<m<<endl;
		rep(i,1,m) cout<<a[i]<<' ';
		cout<<endl;
	}
	else{
		if(n<=2){
			cout<<1<<endl;
			cout<<n<<endl;
		}
		else{
			cout<<2<<endl;
			cout<<n-1<<' '<<1<<endl;
		}
	}
	return 0;
}


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

int maxtime(int x){
  return (x + 9) / 10 * 10;
}
int remtime(int x){
  return maxtime(x) - x;
}
int main(){
  int a, b, c, d, e;
  cin >> a >> b >> c >>d >>e;
  int sum = maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e) ;
  sum -= max({ remtime(a), remtime(b), remtime(c), remtime(d), remtime(e)});
  cout << sum << endl;
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sum,g;
int main()
{
	int n,i,s,minn=5000;
	cin>>n>>s;
	int a[n+1];
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
		minn=min(minn,a[i]);
	}
	s-=sum;
	g=n+s/minn;
	cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define rep(i,N) for(int i=0;i<(N);++i)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr ll mod = 1000000007;

int ex[8] = { 1,0,-1,0,1,1,-1,-1 };
int ey[8] = { 0,1,0,-1,1,-1,1,-1 };
int main() {
	int H, W; cin >> H >> W;
	vector<vector<char>>t(H, vector<char>(W));
	vector<vector<int>>dist(H, vector<int>(W, 0));
	rep(i, H)rep(j, W)cin >> t[i][j];
	int nx, ny;
	rep(i, H) {
		rep(j, W) {
			if (t[i][j] == '#') {
				rep(k, 8) {
					nx = j + ex[k], ny = i + ey[k];
					if (nx < 0 || ny < 0 || ny >= H || nx >= W)continue;
					else dist[ny][nx]++;
				}
			}
		}
	}
	rep(i, H) {
		rep(j, W) {
			if (j != W - 1) {
				if (t[i][j] == '#')cout << t[i][j];
				else cout << dist[i][j];
			}
			else {
				if (t[i][j] == '#')cout << t[i][j] << "\n";
				else cout << dist[i][j] << "\n";
			}
		}
	}
	return 0;
}

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

const int N = 1001, mod = 1e9 + 7;

int n, m, a[N][N], dp[N][N];

signed main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			char c;
			cin >> c;
			a[i][j] = c == '.';
		}
	}
	if (a[1][1]) {
		dp[1][1] = 1;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (a[i - 1][j]) {
				dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
			}
			if (a[i][j - 1]) {
				dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
			}
		}
	}
	cout << dp[n][m];
}

Measured memory_bytes: 15872
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<math.h>

int main(){
	char str[19];
	int l,i;
	gets(str);
	l = strlen(str);
	for ( i = l-1; i >= 0; i--)
	{
		printf("%c",str[i]);
	}
	printf("\n");
	getchar();
	return 0;
}

Measured memory_bytes: 524
use std::io::prelude::*;
use std::io;
use std::str::FromStr;
#[cfg(local)]
use std::fs::File;
#[cfg(local)]
use std::io::BufReader;

#[cfg(local)]
fn buf_read() -> io::Result<(Vec<String>)> {
    let f = try!(File::open("input.txt"));
    let input_lines: Vec<_> = BufReader::new(f).lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

#[cfg(not(local))]
fn buf_read() -> io::Result<(Vec<String>)> {
    let stdin = io::stdin();
    let input_lines: Vec<_> = stdin.lock().lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

fn main() {
    type Element = i64;
    let input = buf_read().unwrap();
    let mut input_vectors: Vec<Vec<Element>> = vec![];
    for input_line in input {
        let input_str: Vec<String> = input_line.split(' ').map(String::from).collect();
        let mut input_vector: Vec<Element> = vec![];
        for input_elem_str in input_str {
            let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();
            input_vector.push(elem);
        }
        input_vectors.push(input_vector);
    }
    let a = if input_vectors[0][0] == 0 {
        0
    } else {
        input_vectors[0][0] - 1
    };
    let b = input_vectors[0][1];
    let x = input_vectors[0][2];
    let b_quotient = b / x;
    // let a_quotient = (a - 1) / x;
    let a_quotient = a / x;
    let ans = if input_vectors[0][0] != 0 {
        b_quotient - a_quotient
    } else {
        b_quotient - a_quotient + 1
    };
    println!("{}", ans);
    // println!("{}", b_quotient - a_quotient);
    // println!("{}", 0 / 1);
}


Measured memory_bytes: 380
#9:54〜10:29
N=int(input())
A=sorted(map(int,input().split()))
while len(A) != 1:
	B_nonzeros=[A[0]]
	for n in range(len(A)):
		i = A[n]%A[0]
		if i != 0:
			B_nonzeros.append(i)
	B_nonzeros.sort()
	A=B_nonzeros
print(A[0])

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

using namespace std;

int main(){
  int W,H,x,y;
  cin >> W >> H >> x >> y;
  double a;
  a = double(W) * double(H) / 2;
  if(x * 2 == W && y * 2 == H){
    cout << fixed << setprecision(6) << a << ' ' << 1 << endl;
  }else{
    cout << fixed << setprecision(6) << a << ' ' << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define debug(x) cout << #x << " = " << x << endl
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");};
const int maxn = 1e5+233;
struct Edge{
	int to,nxt;
	Edge(){}
	Edge(int to,int nxt):to(to),nxt(nxt){}
}edge[maxn *2];
int first[maxn],nume;
int n,m,k[maxn],a[maxn],s[maxn],dep[maxn],fa[maxn];
void Addedge(int a,int b){
	edge[nume] = Edge(b,first[a]);
	first[a] = nume++;
}
int x,y;
void dfs(int u,int last){
	s[u] = (dep[u]&1) ? 1 : -1;
	for(int e=first[u];~e;e=edge[e].nxt){
		if(e==(last^1)) continue;
		int v = edge[e].to;
		if(dep[v]){x = v,y = u;}
		else{
			dep[v] = dep[u] + 1;
			fa[v] = u;
			dfs(v,e);
			s[u] += s[v];
//			printf("s[%d] += s[%d]\n",u,v);
		}
	}
}
ll ans;
int main(){
	n = rd(),m = rd(); 
	mem(first,-1);nume = 0;
	Rep(i,1,m){
		int a = rd(),b = rd();
		Addedge(a,b);
		Addedge(b,a);
	}
	dep[1] = 1;
	dfs(1,0);
	if(m==n-1){
		if(s[1]) ans = -1; else{
			Rep(i,2,n) ans += abs(s[i]);
		}
	} else{
		if((dep[x]-dep[y])&1){
//			Rep(i,1,n) debug(s[i]);
			if(s[1]) ans = -1; else{
				for(;x;x=fa[x]) k[x]++;
				for(;y;y=fa[y]) k[y]--;
//				kx + b的最小值 
				int tot = 0;
				a[++tot] = 0;//1号点 
				Rep(i,2,n)
					if(k[i]) a[++tot] = k[i] * s[i]; else ans += abs(s[i]);
				sort(a+1,a+1+tot);
				int z = a[(tot+1) / 2];
				Rep(i,1,tot) ans += abs(a[i] - z);
			}
		} else{
			if(abs(s[1])&1) ans = -1; else{
				int z;
				ans = abs(z = s[1] / 2);
				for(;x;x=fa[x]) s[x]-=z;
				for(;y;y=fa[y]) s[y]-=z;
				Rep(i,2,n) ans += abs(s[i]);	
			}//偶数
		}
	}writeln(ans);
	return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 1e6+5;
int main()
{
	sync;
	string s;
	cin >> s;
	ll ans = 0, cnt = 0;
	for(ll i = 0 ; i < 3; i++)
	{
		if(s[i] == 'R')
			cnt++;
		else
			cnt = 0;
		ans = max(ans, cnt);
	}
	cout<< ans;
}

Measured memory_bytes: 3608
import java.util.*;
        import java.io.*;
         
        public class Main {
            public static void main(String[] args) throws IOException{
                Scanner scan = new Scanner(System.in);
                String str = scan.nextLine();
                if(str.contains("7")){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
                scan.close();
            }
        }

Measured memory_bytes: 35788
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#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(x) (x).begin(),(x).end()
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a*b,c)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

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

int main() {
  int N;
  ll X;
  while (cin >> N >> X) {
    ll D = 0;
    for (int i = 0; i < N; i++) {
      ll y;
      cin >> y;
      y -= X;
      D = gcd(D, abs(y));
    }
    cout << D << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
using lint = long long;

vector < lint > v;
lint s = 0;

int main(){
    v.push_back(s);
    int n;scanf("%d",&n);
    for(int i=0;i<n;i++){
        lint x;scanf("%lld",&x);
        s += x;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    lint t = 1;
    lint ans = 0;
    for(int i=1;i<=n+1;i++){
        if(i==n+1){
            ans += t*(t-1)/2;
        }
        else{
            if(v[i-1]!=v[i]){
                ans += t*(t-1)/2;
                t = 1;
            }
            else{
                ++t;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,k;
  cin>>n>>k;
  if (n%k==0) {cout<<0<<endl;}
  else if (n%k<=k-n%k){cout<<n%k<<endl;}
  else cout<<k-n%k<<endl;
}

Measured memory_bytes: 256
def main():
    x, y = list(map(int, input().split()))
    if abs(x) == abs(y):
        ans = 1
    elif x < y:
        if x >= 0 and y >= 0:
            ans = y - x
        elif x < 0 and y < 0:
            ans = y - x
        else:
            ans = min(abs(x + y) + 1, y - x)
    else:
        if x >= 0 and y >= 0:
            ans = min(x - y + 2, x + y + 1)
        elif x < 0 and y < 0:
            # 二回反転
            ans1 = abs(y) - abs(x) + 2
            # １回転
            ans2 = abs(y) - x + 1
            ans = min(ans1, ans2)
        else:
            # BからA、もしくはAからB
            ans = abs(x + y) + 1

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    double r; cin >> r;
    double pi = 3.141592653589793238;
    cout << setprecision(30)<< pi * r * 2 << endl;
    return 0;
}

Measured memory_bytes: 3764
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();
		int C = sc.nextInt();
		
		int answer = 0;

		int count = B / A;

		if (count > C){
			answer = C;
		}else{
			answer = count;
		}
		
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
#include <cstdio>
using namespace std;

class Dice{
    public:
    int face[6];
    Dice(){}
    int roll(int a, int b, int c, int d){
        int temp = face[a]; face[a] = face[b]; face[b] = face[c]; face[c] = face[d]; face[d] = temp;
        return 0;
    }
    int move(char c){
        if (c == 'W') roll(0, 2, 5, 3);
        if (c == 'E') roll(0, 3, 5, 2);
        if (c == 'S') roll(0, 4, 5, 1);
        if (c == 'N') roll(0, 1, 5, 4);
        return 0;
    }
};

int main(void){
    char direction;
    
    Dice dice;
    scanf("%d%d%d%d%d%d", &dice.face[0], &dice.face[1], &dice.face[2], &dice.face[3], &dice.face[4], &dice.face[5]);
    while(scanf("%c", &direction) != EOF){
        dice.move(direction);
    }
    printf("%d\n", dice.face[0]);
    return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
*/

ll a,b,c,ans;

void init(){
	cin>>a>>b>>c;
}

int main(void){
	init();
	ans=0;
	if(b+c>=a)ans=c-(a-b);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // 入力受取
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line1 = input.readLine();

        int r = Integer.parseInt(line1);

        System.out.println(3*(r*r));
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int M;
  cin>>M;
  cout<<48-M<<"\n";

  return 0;
}


Measured memory_bytes: 256
using System;

class B
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static void Main()
	{
		var z = Read();
		int h = z[0], w = z[1], n = z[2];
		var p = Read();
		var s = Console.ReadLine();
		var t = Console.ReadLine();

		var (mx, Mx) = (1, w);
		var (my, My) = (1, h);

		for (int i = n - 1; i >= 0; i--)
		{
			switch (t[i])
			{
				case 'L': if (Mx < w) Mx++; break;
				case 'R': if (mx > 1) mx--; break;
				case 'U': if (My < h) My++; break;
				case 'D': if (my > 1) my--; break;
				default: break;
			}
			switch (s[i])
			{
				case 'L': mx++; break;
				case 'R': Mx--; break;
				case 'U': my++; break;
				case 'D': My--; break;
				default: break;
			}

			if (mx > Mx || my > My) { Console.WriteLine("NO"); return; }
		}
		Console.WriteLine(mx <= p[1] && p[1] <= Mx && my <= p[0] && p[0] <= My ? "YES" : "NO");
	}
}


Measured memory_bytes: 29060
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
def main():
    n = int(input())
    rc = tuple(input())
    rc2 = [c == 'W' for c in rc]
    r1 = sum(rc2) # 白をすべて赤にした場合
    r2 = n - r1  # 赤をすべて白にした場合。
    r3 = sum(rc2[:r2]) # 赤を左につめるのに邪魔になる白の数
    print(min(r1, r2, r3))

if __name__ == '__main__':
    main()


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

using namespace std;

int main(void)
{
    int w,h,n;
    vector<vector<bool>> v;
    cin>>w>>h>>n;

    //2次元配列の確保
    v = vector<vector<bool>>(w,vector<bool>(h,true));

    for(int k = 0;k < n;k++) {
	int x,y,a;
	cin>>x>>y>>a;

	if(a == 1)
	{
	    for(int i = 0;i < x;i++) {
		for(int j = 0;j < h;j++) {
		    v[i][j] = false;
		}
	    }
	} else if(a == 2) {
	    for(int i = x;i < w;i++) {
		for(int j = 0;j < h;j++) {
		    v[i][j] = false;
		}
	    }
	} else if(a == 3) {
	    for(int j = 0;j < y;j++) {
		for(int i = 0;i < w;i++) {
		    v[i][j] = false;
		}
	    }
	} else if(a == 4) {
	    for(int j = y;j < h;j++) {
		for(int i = 0;i < w;i++) {
		    v[i][j] = false;
		}
	    }
	}
    }

    int counter = 0;

    for(int i = 0;i < w;i++)
	for(int j = 0;j < h;j++)
	    if(v[i][j])
		counter++;

    cout<<counter<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        ans+=a[i]*a[j]
print(ans)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
const int INFINT = INT_MAX/2;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

struct Edge{
    int dst;
    int weight;
    Edge(int dst, int weight): dst(dst), weight(weight) {}
};

struct TmpDist{
    int vertex;
    int dist;
    TmpDist(int vertex, int dist): vertex(vertex), dist(dist) {}
    bool operator< (const TmpDist& right)const{
        return dist > right.dist;
    }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

vector<int> dijkstra(Graph &G, int r){
    int V = G.size();
    vector<int> dist(V, INFINT);
    priority_queue<TmpDist> pq;
    vector<bool> check(V, false);
    TmpDist init(r, 0);
    pq.push(init);
    while(!pq.empty()){
        TmpDist td = pq.top();pq.pop();
        int now = td.vertex;
        if(!check[now]){
            check[now] = true;
            dist[now] = td.dist;
            for (int i=0;i<G[now].size();i++){
                if(dist[G[now][i].dst] > td.dist + G[now][i].weight){
                    TmpDist tdCandidate(G[now][i].dst, td.dist + G[now][i].weight);
                    pq.push(tdCandidate);
                }
            }
        }
    }
    return dist;
}

int main(){
	ll H, W;
	cin >> H >> W;
	Graph G(10);
	REP(i, 10)REP(j, 10){
		ll w;
		cin >> w;
		Edge e(j, w);
		G[i].push_back(e);
	}

	ll A[H][W];
	REP(i, H)REP(j, W) cin >> A[i][j];

	vector<ll> shortest(10);
	REP(i, 10){
		vector<int> res = dijkstra(G, i);
		shortest[i] = res[1];
	}

	ll res = 0;
	REP(i, H)REP(j, W){
		if(A[i][j]>=0) res += shortest[A[i][j]];
	}
	cout << res  << endl;


    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define it vector<ll>:: iterator
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    string t;
    cin>>t;
    ll n = s.length();
    ll m = t.length();
    ll dp[n+1][m+1];
    for(int i=0;i<=n;i++){
        dp[i][0]=0;
    }
    for(int i=0;i<=m;i++){
        dp[0][i]=0;
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string ans;
 //   ll len = dp[n][m];
    ll i=n,j=m;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            ans=ans+s[i-1];
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
    }

Measured memory_bytes: 73976
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 105;
const int MAX_K = 100005;
int K;
int N;
int A[MAX_N];

int dp[MAX_K][2];

int solve(int size, int turn) 
{
  if(dp[size][turn] != -1) {
    return dp[size][turn];
  }

  int nextTurn = (turn+1)%2;

  REP(n,N) {
    if(size >= A[n]) {
      if(solve(size-A[n], nextTurn) == turn) {
        return dp[size][turn] = turn;
      }
    } else {
      break;
    }
  }

  return dp[size][turn] = nextTurn;
}

signed main()
{
  cin >> N >> K;
  REP(n,N) {
    cin >> A[n];
  }

  memset(dp, -1, sizeof(dp));
  if(solve(K, 0) == 0) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }

  return 0;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;

namespace C___Typical_Stairs
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int n = input[0];
            int m = input[1];

            int[] broken = new int[m];
            int[] dp = new int[n + 1];

            for (int j = 0; j < m; j++)
            {
                broken[j] = int.Parse(Console.ReadLine());
                dp[broken[j]] = -1;
            }

            dp[0] = 1;
            dp[1] = 1;

            if(broken.Contains(1))
            {
                dp[1] = 0;
            }

            for (int i = 2; i < n + 1; i++)
            {
                if (dp[i] == -1) continue;
                if (dp[i - 2] != -1) dp[i] += dp[i - 2];
                if (dp[i - 1] != -1) dp[i] += dp[i - 1];
                dp[i] = dp[i] % 1000000007;
            }

            Console.WriteLine(dp[n]);

        }
    }
}


Measured memory_bytes: 13792