akhauriyash/Code-Regression huggingface dataset:
fun main(arr:Array<String>) {
    val (x,a,b) = readLine()!!.split(" ").map { it.toLong() }
    val tmp = -1 * a + b
    var ans = "delicious"
    if(tmp > 0) {
        if(tmp <= x) {
            ans = "safe"
        } else {
            ans = "dangerous"
        }
    }
    println(ans)
}

Measured memory_bytes: 37992
#include<stdio.h>
#include<string.h>
main()
{
    char a[1000],b[1000],c[1000],d[10000];
    int len,i,j=0,k=0,len2,p=0,s,flag=0;
    scanf("%s%s",a,c);
    len=strlen(a);
    strcpy(d,a);
    strcat(a,d);
    while(1)
    {
        while(j<len)
        {
            if(a[p]==c[j])
            {
                p++;j++;
            }
            else break;
        }

        if(j==(len)){flag=1;goto s;}
        k++;p=k;j=0;
        if(k==len)break;


    }s:;
    if(flag==1)printf("Yes\n");
    else printf("No\n");
    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <limits>
#include <utility>
#include <algorithm>

int main(int argc, char *argv[])
{
    int n;
    std::vector<std::string> s;
    std::vector<std::pair<int,std::string>> scnt;

    std::cin >> n;

    s.resize(n);

    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
    }

    std::sort(s.begin(), s.end());

    std::string scur = "";

    for (int i = 0; i < n; i++) {
        if (s[i] != scur) {
            scur = s[i];
            scnt.push_back(std::pair<int,std::string>(0,scur));
        }
        scnt.back().first++;
    }

    std::sort(scnt.begin(), scnt.end());

    const int maxcnt = scnt.back().first;

    std::vector<std::string> smax;
    //smax.reserve(n);

    for (int i = 0; i < scnt.size(); i++) {
        if (scnt[i].first == maxcnt) {
            smax.push_back(scnt[i].second);
        }
    }

    std::sort(smax.begin(), smax.end());

    for (int i = 0; i < smax.size(); i++) {
        std::cout << smax[i] << std::endl;
    }

    return 0;
}


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

N, K = map(int, input().split())
A = [int(i) for i in input().split()]

last = dict()
v = [-1] * N

for i, a in enumerate(A + A) :
    if a in last and last[a] < N :
        v[last[a]] = i + 1
    
    last[a] = i

dist = [-1] * N
cur = 0
cycle = 0
while dist[cur] < 0 :
    dist[cur] = cycle 
    cycle += v[cur] - cur
    cur = v[cur] % N

NK = N * K

m = NK % cycle
cur = v[cur] % N
s = 0
while m > dist[cur] > 0 :
    s = dist[cur]
    cur = v[cur] % N
m -= s

ret = []
seen = set()
for a in A[N-m:] :
    if a in seen :
        p = ret.pop()
        seen.remove(a)
        while p != a :
            seen.remove(p)
            p = ret.pop()
    else :
        ret.append(a)
        seen.add(a)
        
print(' '.join([str(i) for i in ret]))

Measured memory_bytes: 117960
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Q; cin>> N >> Q;
    VL S(N), T(N), X(N);
    vector<tuple<LL,LL,LL>> ran(N);

    REP(i,N){
        LL s,t,x; cin >> s >> t >> x;
        s -= x; t -= x;
        S[i] = s;
        T[i] = t;
        X[i] = x;
        ran[i] = tie(x,s,t);
    }

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

    set<PLL> seg;

    REP(i,Q){
        int D;
        cin >> D;
        seg.insert(PLL(D,i));
    }

    VL ans(Q,-1);

    REP(i,N){
        int x,l,r;
        tie(x,l,r) = ran[i];

        auto it = seg.lower_bound(PLL(l,-1));
        while(it != seg.end()){
            if(it->first >= r) break;
            ans[it->second]  = x;
            seg.erase(it++);
        }
    }
    REP(i,Q){
        cout << ans[i] << endl;
    }



}

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

ll f(ll b,ll n){
	if(n<b) return n;
	return f(b,n/b)+n%b;
}

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll n,s;
	cin>>n>>s;
	if(s>n){
		cout<<-1;
		return 0;
	}
	ll res=1e16;
	if(s==n) res=n+1;
	for(ll b=2;b*b<=n;++b) if(f(b,n)==s) res=min(res,b);
	for(ll i=1;i<=1000000;++i){
		ll b=(n-s)/i+1;
		if(b<2) continue;
		if(f(b,n)!=s) continue;
		res=min(res,b);
	}
	if(res==1e16) res=-1;
	cout<<res;
}

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


int main(){
	int A,B;cin>>A>>B;
	int total = 0;
	for(int i=A;i<=B;i++){
		string s = to_string(i);
		string r = s;
		reverse(r.begin(),r.end());
		if(r == s) total += 1;
	}
	cout<<total<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT cin.tie(0); ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

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

    ll res = 0;
    rep(i, SZ(s)) { res += s[i] - '0'; }

    if (res % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3780
w = input()
strlist = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
def search():
    for i in strlist:
        if w.count(i) % 2 == 1:
            return "No"
    return "Yes"
print(search())

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

using namespace std;

int main() 
{
    int n, m, i;
    scanf("%d", &n);
    
    set<int> s;
    
    for(i = 0; i < n; i++)
    {
        scanf("%d", &m);
        s.insert(m);
    }
    
    scanf("%d", &m);
    
    for(i = 0; i < m; i++)
    {
        scanf("%d", &n);
        s.insert(n);
    }
    
    for(auto x : s)
        printf("%d\n", x);
    
    return 0;
}


Measured memory_bytes: 21912
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    string A,B;
    cin>>A>>B;
    if(A.size()>B.size()){
        cout<<"GREATER"<<endl;
        return 0;
    }
    if(B.size()>A.size()){
        cout<<"LESS"<<endl;
        return 0;
    }
    if(A.size()==B.size()){
        REP(i,A.size()){
            if(A[i]-'0'>B[i]-'0'){
                cout<<"GREATER"<<endl;
                return 0;
            }
            if(B[i]-'0'>A[i]-'0'){
                cout<<"LESS"<<endl;
                return 0;
            }
        }
    }
    cout<<"EQUAL"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int s=0,max=0;
	int fool;
	string sa;
	cin>>fool;
	cin>>sa;
	for(int i=0;i<fool;i++){
		s=0;
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
			for(int j=0;j<i;j++){
				if(sa[j]==c){
					left=true;
				}
			}
			for(int j=i;j<fool;j++){
				if(sa[j]==c){
					right=true;
				}
			}
			if(left==true&&right==true){
				s++;
			}
		}
		if(s>max){
			max=s;
		}
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;

void main() {
	auto input = map!(to!int)(readln.split);
	int N = input[0], T = input[1], H = input[2], L = input[3];
	Tuple!(int, int)[] data;
	foreach (i; 0..N) {
		input = map!(to!int)(readln.split);
		auto t = input[0], h = input[1];
		data ~= tuple(t, h);
	}
	int i = 0;
	int remain = 0;
	while (true) {
		if (data[i][0] > 0) {
			T++;
			data[i][0]--;
			remain += 10;
			if (T > L){
				break;
			 }
		} else if(data[i][1] > 0) {
			H++;
			data[i][1]--;
			remain += 100;
		} else {
			break;
		}
		if (remain >= 90) {
			remain -= 90;
			if (remain <= 10 * T) {
				data[i][0] += remain / 10;
				T -= remain / 10;
			} else if ((remain % 100) <= 10 * T && remain / 100 <= H) {
				data[i][1] += remain / 100;
				H -= remain / 100;
				remain %= 100;
				data[i][0] += remain / 10;
				T -= remain / 10;
			} else {
				break;
			}
			remain = 0;
		}
		i++;
		if (i == N) i = 0;
	}
	writeln(i+1);
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N;
    cin >> N;
    ll max = 0;
    for (ll i = 1; i * i <= N; ++i)
    {
        max = std::max(max, i * i);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>

using namespace std;

const int MAXN = 100000 + 1000;

typedef pair<int, int> pii;
typedef set<pii> set_pii;

int n, a, b, d;
int px[MAXN], py[MAXN];
map<pii, int> id;
map<int, set_pii> X, Y;
bool ok[MAXN];

int get_one(set_pii &s, int l, int r)
{
	set_pii::iterator it = s.lower_bound(make_pair(l, 0));
	return it == s.end() || it->first > r ? 0 : it->second;
}

void remove(int p)
{
	X[px[p]].erase(make_pair(py[p], p));
	Y[py[p]].erase(make_pair(px[p], p));
}

void bfs()
{
	queue<int> que;
	remove(a), ok[a] = true, que.push(a);
	remove(b), ok[b] = true, que.push(b);
	while(!que.empty())
	{
		int x = que.front();
		que.pop();
		int y = 0;
		while(y = get_one(X[px[x] - d], py[x] - d, py[x] + d))
			remove(y), ok[y] = true, que.push(y);
		while(y = get_one(X[px[x] + d], py[x] - d, py[x] + d))
			remove(y), ok[y] = true, que.push(y);
		while(y = get_one(Y[py[x] - d], px[x] - d, px[x] + d))
			remove(y), ok[y] = true, que.push(y);
		while(y = get_one(Y[py[x] + d], px[x] - d, px[x] + d))
			remove(y), ok[y] = true, que.push(y);
	}
}

map<int, vector<int> > vx, vy;

int get_num(const vector<int> &v, int l, int r)
{
	int st = lower_bound(v.begin(), v.end(), l) - v.begin();
	int ed = upper_bound(v.begin(), v.end(), r) - v.begin();
	return ed - st;
}

void solve()
{
	vector<pii> arr;
	for(int i = 1; i <= n; i++)
		if(ok[i])
			arr.push_back(make_pair(px[i], py[i]));
	sort(arr.begin(), arr.end());
	for(int i = 0; i < arr.size(); i++)
	{
		vx[arr[i].first].push_back(arr[i].second);
		vy[arr[i].second].push_back(arr[i].first);
	}

	long long ans = 0;
	for(int i = 1; i <= n; i++)
		if(ok[i])
		{
			ans += get_num(vx[px[i] - d], py[i] - d, py[i] + d - 1);
			ans += get_num(vx[px[i] + d], py[i] - d + 1, py[i] + d);
			ans += get_num(vy[py[i] - d], px[i] - d + 1, px[i] + d);
			ans += get_num(vy[py[i] + d], px[i] - d, px[i] + d - 1);
		}
	ans /= 2;
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> a >> b;
	for(int i = 1; i <= n; i++)
	{
		cin >> px[i] >> py[i];
		int xx = px[i] + py[i], yy = px[i] - py[i];
		px[i] = xx, py[i] = yy;
	}
	d = max(abs(px[a] - px[b]), abs(py[a] - py[b]));

	for(int i = 1; i <= n; i++)
		id[make_pair(px[i], py[i])] = i;
	for(int i = 1; i <= n; i++)
		X[px[i]].insert(make_pair(py[i], i));
	for(int i = 1; i <= n; i++)
		Y[py[i]].insert(make_pair(px[i], i));

	bfs();
	solve();

	return 0;
}


Measured memory_bytes: 80248
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

vector<int> vlist;
vector<int> vresult;

long long merge(int s, int mid, int e)
{
	long long cnt = 0;
	int t = mid + 1;
	int f = s;

	int resultidx = s;
	while (f <= mid && t <= e)
	{
		if (vlist[t] < vlist[f])
		{
			vresult[resultidx++] = vlist[t++];
			cnt += (mid - f + 1);
		}
		else
		{
			vresult[resultidx++] = vlist[f++];
		}
	}

	while (f <= mid) vresult[resultidx++] = vlist[f++];
	while (t <= e) vresult[resultidx++] = vlist[t++];

	for (resultidx = s; resultidx <= e; resultidx++)
	{
		vlist[resultidx] = vresult[resultidx];
	}

	return cnt;
}

long long msort(int s, int e)
{
	if (s == e) return 0;

	int mid = (s + e) / 2;
	long long cnt = 0;

	cnt += msort(s, mid);
	cnt += msort(mid + 1, e);
	cnt += merge(s, mid, e);

	return cnt;
}

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

	string S;
	cin >> S;

	vlist.assign(S.size(), 0);
	vresult.assign(S.size(), 0);

	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == 'B') vlist[i] = 1;
	}

	cout << msort(0, S.size() - 1);

	return 0;
}


Measured memory_bytes: 2196
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <array>

using namespace std;

const double eps = 1e-10;

class Vector
{
public:
  double x;
  double y;

  Vector(){}
  Vector( double x, double y ) : x(x), y(y) {}

  Vector operator + ( const Vector v ) { return Vector( x + v.x, y + v.y ); }
  Vector operator - ( const Vector v ) { return Vector( x - v.x, y - v.y ); }
  Vector operator * ( const double k ) { return Vector( x * k, y * k ); }
  Vector operator / ( const double k ) { return Vector( x / k, y / k ); }
  bool operator < ( const Vector &v ) const { return x * x + y * y < v.x * v.x + v.y * v.y; }

  double abs() { return sqrt( norm() ); }
  double norm() { return x * x + y * y; }

  static double dot( Vector v1, Vector v2 ) { return v1.x * v2.x + v1.y * v2.y; }
  static double cross( Vector v1, Vector v2 ) { return v1.x * v2.y - v1.y * v2.x; }
  
  void print() { cout << fixed << setprecision(10) << x << " " << y << endl; }
};

class CrossPoint
{
public:
  Vector p0, p1, p2, p3;
  CrossPoint(){}
  CrossPoint( Vector p0, Vector p1, Vector p2, Vector p3 ) : p0(p0), p1(p1), p2(p2), p3(p3) {}
  int solve();
};

int CrossPoint::solve()
{
  Vector a = p1 - p0;
  Vector b = p3 - p2;
  Vector p = p2 - p0;

  Vector cp = p0 + a * Vector::cross( b, p ) / Vector::cross( b, a );
  cp.print();
  
  return 0;
}

int main()
{
  int q;
  cin >> q;
  
  for ( auto i = 0; i < q; ++i )
    {
      double xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3;
      cin >> xp0 >> yp0 >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3;

      CrossPoint cp(Vector(xp0, yp0), Vector(xp1, yp1), Vector(xp2, yp2), Vector(xp3, yp3));
      cp.solve();
    }

  return 0;
}

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

int main() {
  int k , x;
  cin >> k >> x;
  int max = x + k - 1;
  int min = x - k + 1;

  if (max <= 1000000 && min >= -1000000) {
    for (int i = min; i <= max; i++) cout << i << " ";
  }

  else if (max >= 1000000 && min >= -1000000) {
    for (int i = min; i <=1000000; i++) cout << i << " ";
  }

  else if (max <= 1000000 && min <= -1000000) {
    for (int i = -1000000; i <= max; i++) cout << i << " ";
  }

  else if (max >= 1000000 && min <= -1000000) {
    for (int i = -1000000; i <= 1000000; i++) cout << i << " ";
  }
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
L = []
for i in range(N):
	L.append(0)
for i in range(M):
	a, b = list(map(int, input().split()))
	L[a - 1] += 1
	L[b - 1] += 1
for i in range(N):
	print(L[i])

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int n, m, k_size, s;
	cin >> n >> m;
	vector< vector<int> > k(m, vector<int>());
	vector<int> p(m);
	for(int i = 0; i < m; ++i)
	{
		cin >> k_size;
		for(int j = 0; j < k_size; ++j)
		{
			cin >> s;
			s--;
			k[i].emplace_back(s);
		}
	}
	for(int i = 0; i < m; ++i)
	{
		cin >> p[i];
	}

	int ans = 0;
	int mask = 1 << n;
	while(mask--, mask >= 0)
	{
		vector<int> sw(m, 0);
		for(int i = 0; i < m; ++i)
		{
			for(const auto& j : k[i])
			{
				sw[i] ^= ((mask & (1 << j)) > 0);
			}
		}
		if (sw == p) ans++;
	}
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

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

    if(A+B>=A-B){
        if(A+B>=A*B){
            cout << A+B << endl;
        } else {
            cout << A*B << endl;
        }
    } else{
        if(A-B>=A*B){
            cout << A-B << endl;
        } else{
            cout << A*B << endl;
        }
    }




}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc132/tasks/abc132_a
# A - Fifty-Fifty

s = input().split()[0]
count_dict = {}

for char in list(s):
    if char in count_dict.keys():
        count_dict[char] += 1
    else:
        count_dict[char] = 1

ans = True

if len(count_dict.keys()) == 2:
    is_match = True
    for k, v in count_dict.items():
        if v != 2:
            is_match = False
else:
    is_match = False

ans = 'Yes' if is_match else 'No'

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx=1e5+10;
struct point
{
    double x,y;
};
bool cmp1(point a,point b)
{
    if(atan2(a.y,a.x)!=atan2(b.y,b.x))
        return atan2(a.y,a.x)<atan2(b.y,b.x);
    else return a.x<b.x;
}
point a[maxx];
int main(){
    int n; cin>>n;
    for(int i=1;i<=n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        a[i]=point{x,y};
    }
    sort(a+1,a+1+n,cmp1);
    for(int i=n+1;i<=n*2;i++){
        a[i]=a[i-n];
    }
    double ans=0;
    for(int i=1;i<=n;i++){
        double rex=0,rey=0;
        for(int j=i;j<i+n;j++){
            rex+=a[j].x;
            rey+=a[j].y;
            ans=max(ans,sqrt(rex*rex+rey*rey));
        }
        
    }
    printf("%.15f\n",ans);
}


Measured memory_bytes: 892
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())

    def string():
        return sys.stdin.readline().rstrip()

    def map_int():
        return [int(x) for x in Scanner.string().split()]

    def string_list(n):
        return [input() for i in range(n)]

    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    def roundUp(a, b):
        return -(-a // b)

    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    def toLowerMultiple(a, x):
        return (a // x) * x

    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    A, B, C = Scanner.map_int()
    ans = 0
    if not A % 2 == B % 2 == C % 2:
        ans += 1
        if A % 2 == B % 2:
            A += 1
            B += 1
        elif B % 2 == C % 2:
            B += 1
            C += 1
        else:
            A += 1
            C += 1
    D = max(A, B, C)
    ans += (D-A)//2
    ans += (D-B)//2
    ans += (D-C)//2
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40488
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void){
    int N;
    cin>>N;
    string S;
    cin>>S;
    stack<char> st;

    for (int i=0;i<N;i++) {
        char t = S[i];
        if (st.size()==0) {
            st.push(t);
        }
        else {
            if (t == '(') {
                st.push(t);
            }
            if (t == ')') {
                if (st.top() == '(') {
                    st.pop();
                }
                else {
                    st.push(t);
                }
            }
        }

    }    
    int left = 0, right = 0;
    while (st.size()) {
        char t = st.top();
        st.pop();
        if (t == '(') right++;
        else left++;
    }
    for (int i=0;i<left;i++) cout<<'(';
    cout<<S;
    for (int i=0;i<right;i++) cout<<')';
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
N, T = [int(i) for i in input().split()]
ts =  [int(i) for i in input().split()]

max_shower = N * T

doubled = 0
for i in range(N-1):
    difference = T - abs(ts[i]-ts[i+1])
    if difference <= 0:
        doubled += 0
    else :
        doubled += difference
    
print(max_shower-doubled)

Measured memory_bytes: 25196
<?php
fscanf(STDIN, "%s", $s);
$s_1 = substr($s, 0, 1);
$s_2 = substr($s, 1, 1);
$s_3 = substr($s, 2, 1);
$s_4 = substr($s, 3, 1);
if ($s_1 === $s_2) {
    echo 'Bad';
} elseif ($s_2 === $s_3) {
    echo 'Bad';
} elseif ($s_3 === $s_4) {
    echo 'Bad';
} else {
    echo 'Good';
}


Measured memory_bytes: 16148
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (int)a; i <= (int)b; i++) 

int n, arr[100050], a[100050], b[100050], ans = 0;

int main() {
	cin >> n;
	FOR(i, 1, n) {
		cin >> arr[i];
		if (i == 1) {a[i] = arr[i]; continue;}
		a[i] = __gcd(a[i-1], arr[i]);
	}
	b[n] = arr[n];
	for(int i = n-1; i >= 1; i--) b[i] = __gcd(b[i+1], arr[i]);
	ans = max(a[n-1], b[2]);
	ans = max(ans, a[n]);
	FOR(i, 2, n-1) {
		ans = max(ans, __gcd(a[i-1], b[i+1]));
	}
	cout << ans;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] array = new int[n];
        HashMap<Integer, Integer> map = new HashMap<>();

        for (int i = 1; i <= n; i++) {
            array[i - 1] = sc.nextInt();
            int v = i - array[i - 1];
            Integer t = map.get(v);
            if (t == null) {
                map.put(v, 1);
            } else {
                map.put(v, ++t);
            }
        }

        long ans = 0;

        for (int i = 1; i <= n; i++) {
            Integer v = map.get(i + array[i - 1]);
            if (v != null) {
                ans += v;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 68420
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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 RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A[3][3];
    REP(i,3){
        REP(j,3){
            cin>>A[i][j];
        }
    }
    int N=in();
    bool b[101]={};
    REP(i,101){
        b[i]=false;
    }
    int temp;
    REP(i,N){
        cin>>temp;
        b[temp]=true;
    }
    REP(i,3){
        if(b[A[i][0]]&&b[A[i][1]]&&b[A[i][2]]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    REP(i,3){
        if(b[A[0][i]]&&b[A[1][i]]&&b[A[2][i]]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    
        if(b[A[0][0]]&&b[A[1][1]]&&b[A[2][2]]){
            cout<<"Yes"<<endl;
            return 0;
        }
    
        if(b[A[0][2]]&&b[A[1][1]]&&b[A[2][0]]){
            cout<<"Yes"<<endl;
            return 0;
        }
        cout<<"No"<<endl;
        return 0;

}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline().rstrip('\n')

def calc(N, M, G):
    d = {i: [] for i in range(1, N + 1)}
    for a, b in G:
        m = min(a, b)
        n = max(a, b)
        d[m] += [n]
        d[n] += [m]
    s = d[1]
    ans = {i: 1 for i in s}
    ans[1] = 0
    while s:
        new_s = set()
        for t in s:
            for k in d[t]:
                if not k in ans:
                    ans[k] = t
                    new_s.add(k)
        s = new_s
    return 'Yes\n' + '\n'.join([str(ans[i]) for i in range(2, N + 1)])

    

(N, M) = tuple([int(s) for s in input().split()])
G = [tuple([int(s) for s in input().split()]) for _ in range(M)]
print(calc(N, M, G))


Measured memory_bytes: 130608
number,money=input().rstrip().split()
number=int(number)
money=int(money)
bill=[0,0,0]

for i in range(number+1):
    bill=[0,0,0]
    mass=money-10000*i
    bill[0]=i
    if mass==0 and sum(bill)==number:
        break
    elif mass<0:
        break
    else:
        for j in range(number+1-i):
            if j!=0:
                mass=mass-5000
            bill[1]=j
            if mass==0 and sum(bill)==number:
                break
            elif mass<0:
                break
            else:
                k=int(mass/1000)
                bill[2]=k
                if sum(bill)==number:
                    break
    if sum(bill)==number:
        mass=0
        break
                
if mass==0:
    print(str(bill[0])+' '+str(bill[1])+' '+str(bill[2]))
else:
    print(str(-1)+' '+str(-1)+' '+str(-1))


Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    cout << setprecision(16);

    int N;
    cin >> N;
    vector<double> heads(N + 1, 0);
    heads[0] = 1;

    for (int i = 0; i < N; i++) {
        double p;
        cin >> p;

        for (int h = i; h >= 0; h--) {
            heads[h + 1] += heads[h] * p;
            heads[h] *= 1 - p;
        }
    }

    double total = 0;

    for (int i = N; i > N / 2; i--)
        total += heads[i];

    cout << total << '\n';
}


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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    
    if (k * 2 > b - a)
    {
        for (int i = a; i <= b; i++)
        {
            cout << i << endl;
        }
        return 0;
    }
    else
    {
        for (int i = a; i < a + k; i++)
        {
            cout << i << endl;
        }
        for (int i = b + 1 - k; i < b + 1; i++)
        {
            cout << i << endl;
        }
        return 0;
    }
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


a, b, h, m = inpl()
h_rad = (h * 60 + m) / 720 * 2 * math.pi
m_rad = 2 * math.pi * m / 60
print(math.sqrt(a * a + b * b - 2 * a * b * math.cos(abs(h_rad - m_rad))))


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

int64_t getVal(int64_t d){
  int64_t ans = 1;
  for(int i=1;i<d;i++){
    ans *= 10;
  }
  return ans;
}



signed main() {
  int a,b;
  cin >> a >> b;
  if(a>9 || b>9){
    cout << "-1" << endl;
    return 0;
  }
  
  cout << a*b << endl;
  return 0;
  
}




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

#define ll long long
using namespace std;
#define maxn 100000+100


int main() {
    int n;
    string s;
    cin >> n >> s;
    if (n < 3200) {
        cout << "red" << endl;
    } else {
        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

char a[101][101];
int h, w;

void fill(char c, int i, int j) {
    a[i][j] = 'x';
    if (i + 1 < h  && a[i + 1][j] == c) fill(c, i + 1, j);
    if (0 <= i - 1 && a[i - 1][j] == c) fill(c, i - 1, j);
    if (j + 1 < w  && a[i][j + 1] == c) fill(c, i, j + 1);
    if (0 <= j - 1 && a[i][j - 1] == c) fill(c, i, j - 1);
}

int main(void) {
    while (true) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++) {
            scanf("%s", a[i]);
        }
        int n = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (a[i][j] != 'x') {
                    fill(a[i][j], i, j);
                    n++;
                }
            }
        }
        printf("%d\n", n);
    }
    return 0;
}

Measured memory_bytes: 1504
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();
		if(b%a == 0) {
			System.out.println(a+b);
		}else {
			System.out.println(b-a);
		}
	}
}


Measured memory_bytes: 23764
#include <cmath>
#include <cstdio>
typedef long long lld;
lld A, B;

template <typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

int main() {
  scanf(" %lld%lld", &A, &B);
  lld G = gcd(A, B);
  lld S = sqrt(G);
  int ret = 1;
  for (int i = 2; i <= S; ++i) {
    if (G % i) continue;
    while ((G % i) == 0) {
      G /= i;
    }
    ++ret;
  }
  if (G > 1) ++ret;
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int flex = 0;
    int normal = 0;
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N)cin >> A[i];
    REP(i,N){
        if(A[i] >= 3200){
            flex++;
        }else{
            normal |= 1 << (A[i]/400);
        }
    }
    cout << max(1,__builtin_popcount(normal)) << "\n";
    cout << flex + __builtin_popcount(normal) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=100005,M=8*N;
int n,A,B,d,g[N];long long ans;
struct arr{int x,y,id;}a[N];
bool cmp(arr a,arr b){
	return a.x==b.x?a.y<b.y:a.x<b.x;
}
int et;int Head[N],Next[M],Adj[M],tot=0;
void addedge(int u,int v){
	Next[++tot]=Head[u],Head[u]=tot,Adj[tot]=v;
	Next[++tot]=Head[v],Head[v]=tot,Adj[tot]=u;
}
void work(int k){
	int i,j,l,r;sort(a+1,a+n+1,cmp);
	for (i=j=l=r=1;i<=n;i++){
		for (;a[l].x<a[i].x-d||a[l].x==a[i].x-d&&a[l].y<a[i].y-k;l++);
		for (;a[r].x<a[i].x-d||a[r].x==a[i].x-d&&a[r].y<=a[i].y+k;r++);
		g[a[i].id]+=r-l;j=max(j,l);if (j>=r) continue;
		for (addedge(a[i].id,a[j].id);j+1<r;j++)
			addedge(a[j].id,a[j+1].id);
	}
}
bool vis[N];
void dfs(int x){
	vis[x]=1;ans+=g[x];
	for (int e=Head[x];e;e=Next[e])
		if (!vis[Adj[e]]) dfs(Adj[e]);
}
int main(){
	scanf ("%d%d%d",&n,&A,&B);
	for (int i=1,x,y;i<=n;i++){
		scanf ("%d%d",&x,&y);
		a[i]=(arr){x+y,x-y,i};
	}
	d=max(abs(a[A].x-a[B].x),abs(a[A].y-a[B].y));
	work(d);
	for (int i=1;i<=n;i++) swap(a[i].x,a[i].y);
	work(d-1);dfs(A);printf("%lld",ans);
	return 0;
}

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

typedef long long ll;
const int N = 2000006;
const ll MOD = 1e9+7;

int n;
int nxt[N],prv[N];
int a[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	a[0] = a[n+1] = -1;
	stack<int> st;
	
	for(int i=0;i<=n+1;i++){
		while(!st.empty() && a[i] < a[st.top()]){
			nxt[st.top()] = i;
			st.pop();
		}
		st.push(i);
	}
	
	while(!st.empty())st.pop();
	for(int i=n+1;i>=0;i--){
		while(!st.empty() && a[i] < a[st.top()]){
			prv[st.top()] = i;
			st.pop();
		}
		st.push(i);
	}
	
	ll ans = 0;
	for(int i=1;i<=n;i++){
		ll x = i - prv[i];
		ll y = nxt[i] - i;
		ans += x * y * a[i];
	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 6768
#include<stdio.h>

int main()
{
	int a;
	int b;
	int c;

	scanf("%d %d %d",&a,&b,&c);
	
	int d=b-a;
	int e=c-b;
	
	
	if(d==e)
	{
		printf("YES");
	}
	else if(d!=e)
	{
		printf("NO");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll knap(ll w[],ll v[],ll W,ll n,vector<vector<ll>>&dp)
{
	if (n==0||W==0)
	{
		return 0;
	}
	if(dp[n-1][W]==-1)
	{
    	if(w[n-1]<=W)
    	{
    		return dp[n-1][W]=max(v[n-1]+knap(w,v,W-w[n-1],n-1,dp),knap(w,v,W,n-1,dp));
    	}
    	else
    	{
    		return dp[n-1][W]=knap(w,v,W,n-1,dp);
    	}
	}
	else
	{
		return dp[n-1][W];
	}

}
int main()
{
	ll n,W;
	cin>>n>>W;
	ll w[n],v[n];
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
	//vector<ll>dp(W+1,-1);
	//dp[0]=0;
	//ll dp[n][W+1];
	vector<vector<ll>>dp(n,vector<ll>(W+1,-1));
	//cout<<dp[W]<<endl;
	cout<<knap(w,v,W,n,dp)<<endl;

	return 0;
}

Measured memory_bytes: 82172
A, B, C = map(int, input().split())

if A == B == C:
    ans = -1 if A % 2 == 0 else 0
else:
    ans = 0
    while A % 2 + B % 2 + C % 2 == 0:
        A, B, C = (B + C) // 2, (C + A) // 2, (A + B) // 2
        ans += 1
print(ans)


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

ll dp[100005][105];
ll prefix[100005][105];

ll mod=1000000007;

ll modulo(ll x){
	return (x%mod+mod)%mod;
}

ll calc(ll arr[],ll n,ll k){
	
	for(ll i=0;i<=n;i++){
		dp[0][i]=1;
		prefix[0][i]=1;
	}
	
	for(ll i=1;i<=k;i++){
		prefix[i][0]=1;
	}
	
	for(ll i=1;i<=k;i++){
		for(ll j=1;j<=n;j++){
			ll v=0;
			if(i-arr[j-1]-1>=0) 
				v=prefix[i-arr[j-1]-1][j-1];
			dp[i][j]=modulo(prefix[i][j-1]-v);
			prefix[i][j]=modulo(prefix[i-1][j]+dp[i][j]);	      	
		}
	}
	return dp[k][n];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,0,sizeof(dp));
    memset(prefix,0,sizeof(prefix));
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(ll i=0;i<n;++i){
        cin>>arr[i];
    }
    cout<<modulo(calc(arr,n,k))<<endl;
}

Measured memory_bytes: 167672
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int X;
    cin >> X;
    vector<bool> prime(200000);
    prime[1] = false;
    FOR(i, 2, 200000) prime[i] = true;
    FOR(i, 2, 200000) {
        if(prime[i]) {
            for(int j=i*2; j<200000; j+=i) {
                prime[j] = false;
            }
        }
    }
    FOR(i, X, 200000) {
        if(prime[i]) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    s = input()
    ss = False

    while ss is False:
        s = s[:-1]
        boundary = int(len(s) / 2)
        forward = s[:boundary]
        backward = s[boundary:]

        if forward == backward:
            print(len(forward * 2))
            ss = True


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

public class Main {

    long MOD = 998244353;

    void run() {
        Scanner sc = new Scanner(System.in);
        String l = sc.next();
        int n = l.length();
        int[] rs = new int[n];
        int[] bs = new int[n];
        for (int i = 0; i < n; i++) {
            switch (l.charAt(i)) {
                case '0':
                    rs[i] = 2;
                    bs[i] = 0;
                    break;
                case '1':
                    rs[i] = 1;
                    bs[i] = 1;
                    break;
                case '2':
                    rs[i] = 0;
                    bs[i] = 2;
                    break;
            }
        }
        for (int i = 1; i < n; i++) {
            rs[i] += rs[i - 1];
            bs[i] += bs[i - 1];
        }

//        debug("rbs", rs, bs);


        long[][] dp = new long[2 * n + 1][rs[n - 1] + 1];

        dp[0][0] = 1;
        for (int i = 1; i <= 2 * n; i++) {
            int reach = Math.min(i - 1, n - 1);
            if (bs[reach] >= i) {
                dp[i][0] = dp[i - 1][0];
            }
            for (int j = 1;j <= Math.min(i, rs[reach]); j++) if (i - j <= bs[reach]) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
            }
            for (int j = 1;j <= Math.min(i, rs[reach]); j++) {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
            }
//            debug(dp[i]);
        }
        System.out.println(dp[2 * n][rs[n - 1]]);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 165716
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int a[3][3];
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
            scanf(" %d",&a[i][j]);
    }
    int n;
    scanf("%d",&n);
    int b[n];
    for(int i=0;i<n;i++)
        scanf("%d",&b[i]);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int l=0;l<3;l++)
            {
                if(b[i]==a[j][l])
                    a[j][l]=0;
            }
        }
    }
    int d1=0,d2=0,c[3],r[3];
    for(int i=0;i<3;i++)
    {
        r[i]=0;
        c[i]=0;
        if(a[i][i]==0)
            d1++;
        if(a[i][2-i]==0)
            d2++;
        for(int j=0;j<3;j++)
        {
            if(a[i][j]==0)
                r[i]++;
            if(a[j][i]==0)
                c[i]++;
        }
    }
    if(d1==3 || d2==3 || r[0]==3 || r[1]==3 || r[2]==3 || c[0]==3 || c[1]==3 || c[2]==3)
        printf("Yes");
    else
        printf("No");
    return 0;
}


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


def solve(N: int, X: "List[int]"):
    x = sorted(X)
    l = x[N // 2 - 1]
    r = x[N // 2]
    for a in X:
        if a <= l:
            print(r)
        else:
            print(l)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32308
n = int(input())
k = [[[0 for x in range(10)] for x in range(3)] for x in range(4)]
for i in range(n):
    b,f,r,v = map(int,raw_input().split())
    k[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, k[b][f])))
    if b != 3:
        print("#"*20)

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

namespace myApp
{
    class Program
    {
        static void Main()
        {
            var TX = Console.ReadLine().Split(' ').Select(s=>double.Parse(s)).ToArray();
            var T = TX[0];
            var X = TX[1];
            Console.WriteLine(T/X);
        }
    }
}

Measured memory_bytes: 11220
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

using namespace std;

typedef pair<int,int> pii;

int main(){
	int n,c[200],m,k,tmp[200];
	scanf("%d%d",&n,&m);
	n*=2;
	rep(i,n)c[i]=i+1;
	rep(i,m){
		scanf("%d",&k);
		if(k==0){
			rep(j,n){
				tmp[j] = c[(j%2)*(n/2)+j/2];
			}
			memcpy(c,tmp,sizeof(tmp));
		}else rotate(c,c+k,c+n);
	}
	rep(i,n)printf("%d\n",c[i]);
	return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main(void) {
    string S;
    cin >> S;

    set<char> d;
    for (char c: S) {
        d.insert(c);
    }
    if (d.count('S')^d.count('N')) {
        cout << "No\n";
        return 0;
    }
    if (d.count('W')^d.count('E')) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<double, int> P;

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

    ll lb=0, rb=0;
    
    rep(i, N) {
        int n, t;
        char c;
        cin >> n >> c >> t;
        if (c == '(') lb += t;
        else if (c == ')') rb += t;

        cout << (lb==rb?"Yes":"No") << endl;
    }
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    bool is_same = true;
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        if (1 <= i && a.at(i - 1) != a.at(i)) is_same = false;
    }
    if (is_same) {
        cout << 1 << endl;
        return 0;
    }
    
    int cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        if (a.at(i) == a.at(i + 1)) continue;

        if (a.at(i) < a.at(i + 1)) while (i < n - 1 && a.at(i) <= a.at(i + 1)) i++;
        else while (i < n - 1 && a.at(i) >= a.at(i + 1)) i++;

        cnt++;
        if (i == n - 2) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640