akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e5 + 17;

struct edge
{
	int u, v, cap, flow, i;
	edge() { }
	edge(int u, int v, int c, int f) : u(u), v(v), cap(c), flow(f) { }
};

struct maxflow
{
	int n, s, t, z;
	vector<int> pt, Q, D;
	vector<edge> E;
	vector< vector<int> > g;
	maxflow() { }

	maxflow(int n, int s, int t) : n(n), s(s), t(t)
	{
		g.resize(n + 2);
		pt.resize(n + 2);
		Q.resize(n + 2);
		D.resize(n + 2);
	}

	void add_edge(int u, int v, int cap)
	{
		edge e1 = edge(u, v, cap, 0);
		edge e2 = edge(v, u, 0, 0);
		g[u].push_back(size(E));
		g[v].push_back(size(E) + 1);
		E.push_back(e1);
		E.push_back(e2);
	}

	bool bfs()
	{
		int qh = 0, qt = 0, cnt = 1;
		Q[qt++] = s;
		fill(D.begin(), D.end(), -1);
		D[s] = 0;

		for (; qh < qt && D[t] == -1; )
		{
			int v = Q[qh++];
			
			for (auto to : g[v])
				if (D[E[to].v] == -1 && E[to].flow < E[to].cap)
					D[E[to].v] = D[v] + 1, Q[qt++] = E[to].v, ++cnt;
		}

		return D[t] != -1;
	}

	llong dfs(int v, int mrg)
	{
		if (mrg == 0) return 0;
		if (v == t) return mrg;

		for (int& j = pt[v]; j < size(g[v]); ++j)
		{
			int i = g[v][j];

			if (D[E[i].u] + 1 == D[E[i].v])
			{
				llong pushed = dfs(E[i].v, min(mrg, E[i].cap - E[i].flow));
				E[i].flow += pushed;
				E[i ^ 1].flow -= pushed;
				if (pushed) return pushed;
			}
		}

		return 0;
	}

	llong dinic()
	{
		llong flow = 0, pushed = 0;

		for (;;)
		{
			if (!bfs())
				break;

			fill(pt.begin(), pt.end(), 0);
			
			while (pushed = dfs(s, inf))
				flow += pushed, ++z;
		}

		return flow;
	}
};

int n, m;
string s[maxn];

bool read()
{
	if (scanf("%d %d", &n, &m) != 2)
		return false;

	forn (i, n)
	{
		scanf("%s", buff);
		s[i] = buff;
	}

	return true;
}

void solve()
{
	maxflow g(2 + n + m, 0, n + m + 1);

	forn (i, n)
		forn (j, m)
		{
			if (s[i][j] == 'S')
			{
				g.add_edge(0, i + 1, inf);
				g.add_edge(0, n + j + 1, inf);
			}

			if (s[i][j] == 'o')
			{
				g.add_edge(i + 1, j + n + 1, 1);
				g.add_edge(j + n + 1, i + 1, 1);
			}

			if (s[i][j] == 'T')
			{
				g.add_edge(i + 1, n + m + 1, inf);
				g.add_edge(j + n + 1, n + m + 1, inf);
			}
		}

	llong ans = g.dinic();
	if (ans >= inf) ans = -1;
	printf("%lld\n", ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 5776
#include<iostream>

using namespace std;

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


Measured memory_bytes: 256
k=int(input())
lunlun=[None for _ in range(100)]
lunlun[0]=(1,2,3,4,5,6,7,8,9)
for i in range(0,10):
  tmp=[]
  for j in lunlun[i]:
    s=j%10
    if s==0:
      tmp+=j*10+0,
      tmp+=j*10+1,
    elif s==9:
      tmp+=j*10+8,
      tmp+=j*10+9,
    else:
      tmp+=j*10+s-1,
      tmp+=j*10+s,
      tmp+=j*10+s+1,
  lunlun[i+1]=tuple(tmp)
L=[]
for i in range(0,10):
  for j in lunlun[i]:
    L+=j,
print(L[k-1])

Measured memory_bytes: 35328
#include<bits/stdc++.h>
#define dd(x) cout<<#x<<" = "<<x<<" "
#define de(x) cout<<#x<<" = "<<x<<"\n"
#define sz(x) int(x.size())
#define All(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef priority_queue<int> BQ;
typedef priority_queue<int,vector<int>,greater<int> > SQ;
const int maxn=3e5+10,mod=1e9+7,INF=0x3f3f3f3f;
int add(int a,int b){
	a+=b;
	if (a<0)
		return a+mod;
	return a>=mod?a-mod:a;
}
int mul(ll a,ll b){
	return a*b%mod;
}
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
P hs(ll x,ll y){
	if (x==0&&y==0)
		return mp(0,0);
	ll g=gcd(abs(x),abs(y));
	x/=g;
	y/=g;
	if (x==0)
		y=abs(y);
	if (y==0)
		x=abs(x);
	if (x<0)
		x=-x,y=-y;
	return mp(x,y);
}
ll a[maxn],b[maxn];
map<P,int> cnt,cnt2;
set<P> vis;
int kpow(int a,int b){
	int res=1;
	while (b){
		if (b&1)	res=mul(res,a);
		a=mul(a,a);
		b>>=1;
	}
	return res;
}
int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;++i){
		scanf("%lld%lld",&a[i],&b[i]);
		cnt[hs(b[i],-a[i])]++;
		cnt2[hs(a[i],b[i])]++; 
	}
	int ans=1;
	for (auto it:cnt2){
		if (it.fi.fi==0&&it.fi.se==0)
			continue;
		if (vis.count(it.fi))
			continue;
		vis.insert(it.fi);
		P t=hs(it.fi.se,-it.fi.fi);
		vis.insert(t);
		int A=cnt[it.fi],B=it.se;
		ans=mul(ans,add(add(kpow(2,A),kpow(2,B)),-1));//de(ans);
		//dd(it.fi);dd(it.se);dd(t.fi);dd(t.se);dd(A);de(B);
	}
	cout<<add(add(ans,-1),cnt[mp(0,0)]);
	return 0;
}


Measured memory_bytes: 69268
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,M;
    int A[57],B[57];
    int u[24],v[24];
    int d[24]={};
    cin >> N;
    REP(i,N-1){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
    }
    cin >> M;
    REP(i,M){
        cin >> u[i] >> v[i];
        u[i]--;v[i]--;
    }
    vector<int> G[57];
    REP(i,N-1){
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    map<pair<int,int>,int> mp;
    REP(i,N-1){
        mp[{A[i],B[i]}]=i;
        mp[{B[i],A[i]}]=i;
    }
    
    REP(i,M){
        int parent[57]={};
        REP(j,57){parent[j]=INF;}
        parent[u[i]]=-1;
        queue<int> Q;
        Q.push(u[i]);
        while(!Q.empty()){
            int q=Q.front();
            Q.pop();
            REP(j,G[q].size()){
                if(parent[G[q][j]]==INF){
                    parent[G[q][j]]=q;
                    Q.push(G[q][j]);
                }
            }
        }
        int now=v[i];
        while(parent[now]!=-1){
            //cout << now+1 MM parent[now]+1 << endl;
            int s = mp[{parent[now],now}];
            //cout << s << endl;
            d[i]+=(1ll<<s);
            now=parent[now];
        }
        //cout << d[i] << endl;
    }
    
    int Ans=0;
    for(int j=0;j<(1ll<<M);j++){
        int e=0;
        int mode=1;
        REP(i,M){
            if((j>>i)%2==1){
                e |= d[i];
                mode*=-1;
            }
        }
        int k=0;
        while(e>0){
            if(e%2==1)k++;
            e>>=1ll;
        }
        Ans+=mode*(1ll<<(N-1-k));
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> data;
  REP(i, n) {
    ll a;
    cin >> a;
    data.push_back(a);
  }
  ll ans = 0;
  FOR(i, 1, n) {
    if (data[i] < data[i - 1]) {
      ans += data[i - 1] - data[i];
      data[i] = data[i - 1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5272
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	for(int i = 0;i < 4;i++)
	    {
	    	cout << s[i];
		}
	cout << " ";
	for(int i = 4;i < 12;i++)
	    {
	    	cout << s[i];
		}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, N) for (int i = 0; i < (N); i++)
#define REP(i, a, N) for (int i = a; i < (N); i++)
#define rrep(i, N, k) for (int i = (N); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N), dp(K + 1, -1);
    cin >> A;
    dp[0] = 0;
    for (int i = 1; i <= K; i++) {
        bool check = false;
        for (auto now : A) {
            if (i - now < 0) continue;
            if (dp[i - now] == 0) check = true;
        }
        dp[i] = check;
    }
    cout << (dp[K] == 0 ? "Second" : "First") << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef uint32_t u32;
typedef uint64_t u64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

const u64 mod = 1000000007;

u64 *tmp = NULL;
void matmul (u32 *c, u32 *a, u32 *b, u32 n) {
  for (u32 i = 0; i < n; ++i) {
    for (u32 j = 0; j < n; ++j) {
      tmp[i * n + j] = 0;
      for (u32 k = 0; k < n;) {
        u32 last = k + 17 < n ? k + 17 : n;
        for (; k < last; ++k) {
          tmp[i * n + j] += (u64) a[i * n + k] * b[k * n + j];
        }
        tmp[i * n + j] %= mod;
      }
    }
  }
  for (u32 i = 0; i < n * n; ++i) {
    c[i] = tmp[i];
  }
}

void run (void) {
  u32 n;
  u64 m;
  scanf ("%" SCNu32 "%" SCNu64, &n, &m);
  u32 *s = ALLOC (n * n, u32);
  for (u32 i = 0; i < n * n; ++i) {
    scanf ("%" SCNu32, s + i);
  }
  tmp = ALLOC (n * n, u64);
  u32 *t = ALLOC (n * n, u32);
  for (u32 i = 0; i < n; ++i) {
    t[i * n + i] = 1;
  }
  while (m > 0) {
    if (m & 1) matmul (t, s, t, n);
    matmul (s, s, s, n);
    m >>= 1;
  }
  u64 ans = 0;
  for (u32 i = 0; i < n * n; ++i) {
    ans += t[i];
  }
  ans %= mod;
  printf ("%" PRIu64 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
   int a[3][3];
   int x[3][3];

   FOR(i,0,3)FOR(j,0,3) cin >> a[i][j];

   int n;
   cin >> n;
   
   FOR(i,0,n){
       int yu;
       cin >> yu;
       FOR(j,0,3){
           FOR(k,0,3){
               if(a[j][k] == yu){
                   x[j][k] = 1;
               }
           }
       }
   }
       bool ans = false;
       int co=0;
        FOR(i,0,3){
            FOR(j,0,3){
                co += x[i][j];
                if( co == 3) ans = true;
            }
            co = 0;
        }
        FOR(i,0,3){
            co = 0;
            FOR(j,0,3){
                co += x[j][i];
                if( co == 3) ans = true;
            }
            
        }
        co = 0;
        FOR(i,0,3){
            co += x[i][i];
            if(co == 3) ans = true;

        }
        co = 0;
        FOR(i,0,3){
            co += x[i][2 - i];
            if(co == 3) ans = true;

        }
        if(ans == true){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        return 0;


       
   
}



Measured memory_bytes: 256
# 入力
S = input('')

# 比較して出力
if S == str('SUN'):
    print(7)
elif S == str('MON'):
    print(6)
elif S == str('TUE'):
    print(5)
elif S == str('WED'):
    print(4)
elif S == str('THU'):
    print(3)
elif S == str('FRI'):
    print(2)
else:
    print(1)


Measured memory_bytes: 9108
#include <bits/stdc++.h>
    #include <numeric>
    #include <cmath>
    #include <stdio.h>
    #define ll long long
    #define pb push_back
    #define all(a) (a).begin(),(a).end()
    #define sz(a) int((a).size())
    #define mp(a,b) make_pair(a,b)
    #define ff first
    #define ss second
    #define fr(i,p,n) for(int i=p;i<n;i++)
    #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    using namespace std;

    typedef pair<int, int> pairs;
    //ll M=1000000007;
    //const int N=200000;
    int T=0;
    vector< vector<int> >  v;
    vector<int> vis,d; //p,tin,tout;
    int dfs(int k){
        
        fr(i,0,sz(v[k])){
        if(vis[v[k][i]]==0){
            //p[v[k][i]]=k;
            vis[v[k][i]]=1;
            d[k]=max(d[k],1+dfs(v[k][i])); }
        else d[k]=max(d[v[k][i]]+1,d[k]);
        }
        
        return d[k];
    }

    int main()
    {
        fastio;
        int t=1;
        //cin>>t;
        while(t--){
            int n,m;
            cin>>n>>m;
            //tin=tout=
            d=vis=vector<int> (n,1);
            vector<int> r;
            v=vector<vector<int> > (n);
            int x,y;
            fr(i,0,m){
                cin>>x>>y;
                vis[y-1]=0;
                v[x-1].pb(y-1); //v[y-1].pb(x-1);
            }
            fr(i,0,n){
            d[i]=0;
            if(vis[i]==1) r.pb(i);
            }
            fr(i,0,sz(r)) dfs(r[i]);
            //fr(i,0,n) cout<<d[i]<<" ";
            T=*max_element(all(d));
            cout<<T<<endl;

        }
        return 0;
    }


Measured memory_bytes: 17144
import bisect
def main():

    N = int(input())
    L = list(map(int, input().split()))
    L.sort()

    # print(L)
    ans = 0
    for i in range(N-2):
        for j in range(i+2, N):
            a = L[i]
            c = L[j]
            k = bisect.bisect_left(L, c-a+1)
            if k <= i:
                ans += j-i-1
            else:
                ans += j-k
    return ans

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

Measured memory_bytes: 3188
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
ans = 0
for i in range(1, N + 1):
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        ans += i

print(ans)

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

int gcd(int x, int y){
    if(y == 0) return x;
    return gcd(y, x%y);
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    int g = a.at(0);
    for(int i = 1; i < n; i++){
        g = gcd(g, a.at(i));
    }
    if(g == 1) cout << 1 << endl;
    else cout << g << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    string ans;
    if(a==1)a+=20;
    if(b==1)b+=20;
    if(a>b)ans="Alice";
    else if(a<b)ans="Bob";
    else ans="Draw";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
int main()
{
	int maxv = -1000000000;
	int minv;
	int n;
	int r,r0;

	std::cin >> n;
	std::cin >> r0;
	minv = r0;

	for(int i=1;i<n;i++){
		std::cin >> r;
		maxv = std::max(maxv,r-minv);
		minv = std::min(minv,r);
	}

	std::cout << maxv << "\n";

	return (0);
}

Measured memory_bytes: 3096
#include <iostream>
using i64 = long long;

int main() {
    i64 x;
    std::cin >> x;
    for (i64 i = -1000; i <= 1000; i++) for (i64 j = -1000; j <= 1000; j++) {
        if (i * i * i * i * i - j * j * j * j * j == x) {
            std::cout << i  << ' ' << j << std::endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3640
class UnionFind():
    def __init__(self, n):
        self.__parent = [i for i in range(n)]
        self.size = [1 for _ in range(n)]
 
    def union(self, x, y):
        pX, pY = self.find(x), self.find(y)
        if pX != pY:
            if pX < pY:
                self.__parent[pY] = pX
                self.size[pX] += self.size[pY]
            else:
                self.__parent[pX] = pY
                self.size[pY] += self.size[pX]                                                                 
 
    def find(self, x):
        if self.__parent[x] != x:
            self.__parent[x] = self.find(self.__parent[x])
        return self.__parent[x]
 
N, M = map(int, input().split())
bridge = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(M)]
uf = UnionFind(N)
num_disconnect = int(N*(N-1)/2)
ans = []
for a, b in reversed(bridge):
    ans.append(num_disconnect)
    pA, pB = uf.find(a), uf.find(b)
    if pA != pB:
        num_disconnect -= uf.size[pA] * uf.size[pB]
        uf.union(a, b)
 
for i in reversed(ans): print(i) 

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

int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	char s[n];
	cin >> s;
	int i;
	int flag = 0, flag2 = 1;
	for (i = 0; i < n; i++) {
		if ((a <= i || b <= i) && (c - 1 >= i || d - 1 >= i)) {
			if (s[i] == '#' && s[i + 1] == '#')
				flag = 1;
		}
	}
	if (c > d) {
		for (i = 0; i < n; i++) {
			if ((d - 2) >= i && (b - 2) <= i) {
				if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
					flag2 = 0;
			}
		}
	}
	else if (flag == 0) {
		flag2 = 0;
	}
	if (flag == 0 && flag2 == 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 384
a, b, c, d, e, k = [int(input()) for _ in range(6)]

s = [b-a, c-a,d-a,e-a,b-c,b-d,b-e,d-c,d-e,e-d]
ans = "Yay!"
for ss in s:
  if ss > k:
    ans = ":("
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7,base=2000;
int n,x[200005],y[200005];
int f[4005][4005],ans;
void add(int &x,int val)
{
	x+=val;
	if(x>=mod) x-=mod;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		f[base-x[i]][base-y[i]]++;
	}
	for(int i=0;i<=base+base;i++)
	{
		for(int j=0;j<=base+base;j++)
		{
			if(i>0) add(f[i][j],f[i-1][j]);
			if(j>0) add(f[i][j],f[i][j-1]);
		}
	}
	for(int i=1;i<=n;i++) add(ans,f[base+x[i]][base+y[i]]);
	memset(f,0,sizeof(f));
	f[0][0]=1;
	for(int i=0;i<=base+base;i++)
	{
		for(int j=0;j<=base+base;j++)
		{
			if(i>0) add(f[i][j],f[i-1][j]);
			if(j>0) add(f[i][j],f[i][j-1]);
		}
	}
	for(int i=1;i<=n;i++) add(ans,mod-f[x[i]+x[i]][y[i]+y[i]]);
	if(ans&1) ans+=mod;
	ans/=2;
	printf("%d\n",ans);
}

Measured memory_bytes: 64512
let rec fold_n n f v = if n <= 0 then v else fold_n (n-1) f (f v)
let inf = 10101010101010

let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let a = Array.init m (fun _ -> Scanf.scanf " %d %d %d" (fun a b c -> a-1,b-1,c)) in

  let reach = begin
    let g = Array.init n (fun _ -> []) in
    a |> Array.iter (fun (u,v,_) -> g.(v) <- u :: g.(v));
    let vis = Array.make n false in
    let rec f u =
      vis.(u) <- true;
      List.iter (fun v -> if not vis.(v) then f v) g.(u)
    in f (n-1);
    vis
  end in

  let sc = Array.make n (-inf) in sc.(0) <- 0;
  let mem = Array.make n false in
  let has_loop = true |> fold_n n (fun upd ->
    if not upd then false else begin
      Array.fill mem 0 n false;
      Array.fold_left (fun b (u,v,c) ->
        let b' = sc.(u) + c > sc.(v) in
        if b' then (mem.(v) <- true; sc.(v) <- sc.(u) + c);
        b || b'
        ) false a
    end)
  in
  let inf_loop = has_loop && begin
    Array.init n (fun i -> reach.(i) && mem.(i)) |> Array.fold_left (||) false
  end in

  if inf_loop then
    print_endline "inf"
  else
    Printf.printf "%d\n" sc.(n-1)


Measured memory_bytes: 3328
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
x = 0
for i in range(1,n+1):
    #ddprint(f"{i=} {n//i} {i*(n//i)}")
    m = n//i
    x += i*(m*(m+1)//2)
print(x)


Measured memory_bytes: 63240
import sys
sys.setrecursionlimit(10**9)

N = int(input())
T = [[] for _ in range(N+1)]

for _ in range(N-1) :
    a,b,c = map(int,input().split())
    T[a].append([b,c])
    T[b].append([a,c])

Q,K = map(int,input().split())

dist = [None]*(N+1)

def dfs(now,d) :
    dist[now] = d
    for to,c in T[now] :
        if dist[to] is not None :
            continue
        dfs(to,d+c)

dfs(K,0)

for _ in range(Q) :
    u,v = map(int,input().split())
    print(dist[u] + dist[v])
    

Measured memory_bytes: 137932
n, length = list(map(int, input().split()))
nums = list(map(int, input().split()))

idx = -1
for i in range(n-1):
    if nums[i] + nums[i+1] >= length:
        idx = i
        break
if idx < 0:
    print('Impossible')
    exit()

print('Possible')
for i in range(idx):
    print(i+1)
for i in reversed(range(idx, n-1)):
    print(i+1)



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

static const int MAX = 200010;

vector<int> G[MAX];

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

    vector<int> d(N+1,-1);
    vector<int> c(N+1,-1);

    int s, t;
    for (int i=0; i<M; ++i) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    queue<int> q;
    q.push(1);
    d[1]=0;

    int u;
    while(!q.empty()) {
        u=q.front(); q.pop();
        for(int i=0; i<G[u].size(); i++) {
            int v = G[u][i];
            if (d[v] != -1) continue;
            c[v] = u;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }

    for (int i=1; i<=N; ++i) {
        if (d[i]==-1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i=2; i<=N; ++i) {
        cout << c[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 12980
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int64_t dp[51][51][2501];

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

    int x[50];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    // 最初のi枚のうちj枚を使ってkを作る通り数
    int s = 0;
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k <= s; k++) {
                dp[i + 1][j][k] += dp[i][j][k];
                dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
            }
        }
        s += x[i];
    }

    int64_t r = 0;
    for (int j = 1; j <= n; j++) {
        r += dp[n][j][j * a];
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 49024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int s = (1 + (n - 1)) * n / 2;
    vector<pair<int, int>> ans;
    rep(i, n) {
        reps(ii, i + 1, n) {
            if (ii == (n - i - 2 + (n + 1) % 2)) continue;
            ans.emplace_back(i + 1, ii + 1);
        }
    }
    printf("%d\n", sz(ans));
    for (auto x : ans) {
        printf("%d %d\n", x.first, x.second);
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;
char arr[101][101];
int main()
{
    FAST
    int n;
    cin>>n;
    int c=0;
    set<int>s;
    for(int i=0; i<n; i++)
    {
        int a;
        cin>>a;
        if(a>=1 && a<=399)
            s.insert(0);
        else if(a>=400 && a<=799)
            s.insert(1);
        else if(a>=800 && a<=1199)
            s.insert(2);
        else if(a>=1200 && a<=1599)
            s.insert(3);
        else if(a>=1600 && a<=1999)
            s.insert(4);
        else if(a>=2000 && a<=2399)
            s.insert(5);
        else if(a>=2400 && a<=2799)
            s.insert(6);
        else if(a>=2800 && a<=3199)
            s.insert(7);
        else
            c++;
    }
    int mx=s.size()+c;
    int mn;
    if(s.size()==0)
        mn=1;
    else
        mn=s.size();
    cout<<mn<<" "<<mx<<endl;



    return 0;
}


Measured memory_bytes: 256
/*My CSP has exploded*/
/*ABC146*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<map>
using namespace std;

#define LL long long
#define DB double
#define MAXN 200000
#define Pr pair<int,int>
#define X first
#define Y second
#define mem(x,p) memset(x,p,sizeof(x))

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<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}

int n,a[MAXN+5];
int sum[MAXN+5],k;
map<int,int> D;LL ans;
int main()
{
    n=read(),k=read();
    for(int i=1;i<=n;i++)
    a[i]=read()-1;
    D[0]++;
    for(int i=1;i<=n;i++){
        sum[i]=(sum[i-1]+a[i])%k;
        if(i>=k)D[sum[i-k]]--;
        ans+=D[sum[i]];
        D[sum[i]]++;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 11136
# 素因数分解してくれる関数
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

A, B = map(int, input().split())
A_soinsu = set(factorize(A))
B_soinsu = set(factorize(B))

ans = A_soinsu & B_soinsu

print(len(ans) + 1)


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

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i,N) cin >> h.at(i);
    h.push_back(0);
    int ans = 0;
    int left;
    rep(i,N+1) {
        if (h.at(i) > 0) {
            int minimum = h.at(i);
            left = i;
            ++i;
            for (; i < N + 1; ++i) {
                if (h.at(i) == 0) {
                    ans += minimum;
                    for (int j = left; j < i; ++j) {
                        h.at(j) -= minimum;
                    }
                    i = left - 1;
                    break;
                }
                minimum = min(minimum, h.at(i));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<std::vector<int>> happiness(n, std::vector<int>(3));

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

    std::vector<std::vector<int>> dp(n + 1, std::vector<int>(3));

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 1; k <= 2; k++) {
                dp[i][j] = std::max(dp[i][j], dp[i - 1][(j + k) % 3] + happiness[i - 1][(j + k) % 3]);
            }
        }
    }

    std::cout << std::max({ dp[n][0], dp[n][1], dp[n][2] }) << std::endl;
}


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

const int MAXN = 200000;
const int INF = 1e9;


int main(){
    set<int> event_set;
    int d[MAXN];
    vector<pair<int,int>> stoppers;
    int N, Q; cin >> N >> Q;
    
    for (int i = 0; i < N; i++) {
        int S, T, X; cin >> S >> T >> X;
        stoppers.push_back(make_pair(S - X, X));
        stoppers.push_back(make_pair(T - X, -X));
    }
    
    for (int i = 0; i < Q; i++) {
		int D; cin >> D;
		d[i] = D;
    }
    
    sort(d, d + Q);
    sort(stoppers.begin(), stoppers.end());
    stoppers.push_back(make_pair(INF, INF));
    
    int ite = 0;
    
    for (int i = 0; i < Q; i++) {
        int T = d[i];
        while (T >= stoppers[ite].first) {
            if (stoppers[ite].second > 0) event_set.insert(stoppers[ite].second);
            else event_set.erase(-stoppers[ite].second);
            ite++;
        }
        if (event_set.size()==0) cout << -1 << endl;
        else cout << *event_set.begin() << endl;
    }
    
    return 0;
}

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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } init_;

template<class C> using iodef_rng_t = typename enable_if<decltype(declval<C>().begin(), true_type{})::value && !is_same<C, string>::value>::type;
template<class C, class = iodef_rng_t<C>> istream& operator>>(istream& in, C& c) { for (auto& v : c) { in >> v; } return in; }
template<class C, class = iodef_rng_t<C>> ostream& operator<<(ostream& out, const C& c) { int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double t = abs(H / 12 + M / 12 / 60 - M / 60);
    if (t > 0.5) t = 1 - t;
    double s = t * 2 * M_PI;
    TRACE(s);
    double C = sqrt(A * A + B * B - 2 * A * B * cos(s));
    cout << C << '\n';
}


Measured memory_bytes: 4112
N, M, X = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(N)]
cand = []
for i in range(2**N):
    ps = [0] * (M + 1)
    for j in range(N):
        if (i >> j) & 1:
            for idx, x in enumerate(data[j]):
                ps[idx] += x
    if all([x >= X for x in ps[1:]]):
        cand.append(ps[0])
if len(cand) == 0:
    print(-1)
else:
    print(min(cand))


Measured memory_bytes: 9292
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
const bool DEBUG = 1;
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <stdio.h>
#include <sys/time.h>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef pair<int, PP> IPP;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define LREP(i,n) LFOR(i,0,n)
#define LRFOR(i,a,b) for(ll i=(b)-1;i>=(a);--i)
#define LRREP(i,b,a) LRFOR(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define REACH(i,c) RREP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define BR cout << "\n"

#define dump(x) if(DEBUG)cerr<<"[" << __LINE__ << "] "<<#x<<"="<<(x)<<"\n"
#define dump2(x,y) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
			<<" , "<<#y<<"="<<(y)<<"\n"
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
			<<" , "<<#y<<"="<<(y)<<"\n"\
			<<" , "<<#z<<"="<<(z)<<"\n"

#define SAY(x) if(DEBUG) cerr << "[" << __LINE__ << "] " << (x) << "\n"

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

ll ans;

int main() {
	omajinai;
	ll n,a,b;
	cin >>n;
	a=n;
	int c[10];
	int i=0;
	int s=0;
	while(a){
		s+=a%10;
		a/=10;
	}


//	cout << min(n*a,b);BR;
	if(n%s==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
	int a,i;
  	double b,ans;	
	cin >> a;
 for(i=0;i<a;i++){
   cin >>b;
   ans=ans+1/b;
 }
  ans=1/ans;
  cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100010;
LL a[MAXN];

int n; LL l;

int main() {
    GI(n); GLL(l);

    FOR1(i, n) {
        GLL(a[i]);
    }

    for (int i = 1; i <= n-1; i++) {
        if (a[i] + a[i+1] >= l) {
            printf("Possible\n");
            for (int j = 1; j < i; j++) {
                printf("%d\n", j);
            }
            for (int j = n-1; j > i; j--) {
                printf("%d\n", j);
            }
            printf("%d\n", i);
            return 0;
        }
    }

    printf("Impossible\n");
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;

int main() {
    int N;
    cin >> N;
    long int A[N];

    rep(i, N) {
        cin >> A[i];
    }

    int answer = 0;
    while(true) {
        bool check = false;
        rep(i, N) {
            if(A[i] % 2 == 1) check = true;
        }

        if (check) break;

        rep(i, N) A[i] /= 2;
        ++answer;
    }

    output(answer);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a, b;
  char op;
  while(1){
    scanf("%d %c %d", &a, &op, &b);
    if(op == '?') break;
    else if(op == '+') printf("%d\n", a + b);
    else if(op == '-') printf("%d\n", a - b);
    else if(op == '*') printf("%d\n", a * b);
    else printf("%d\n", a / b);
  }
}



Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

int main() {
    int n;
    cin >> n;
    Graph g (n);
    queue<int> q;
    rep (i, n) {
        int a, k;
        cin >> a >> k;
        rep (j, k) {
            int b;
            cin >> b;
            g[a - 1].push_back (b - 1);
        }
    }
    int dist[n] = {};
    rep (i, n) dist[i] = -1;
    dist[0] = 0;
    q.push (0);
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (auto p : g[now]) {
            if (dist[p] != -1) continue;
            dist[p] = dist[now] + 1;
            q.push (p);
        }
    }
    rep (i, n) {
        cout << i + 1 << " " << dist[i] << "\n";
    }
}


Measured memory_bytes: 3152
#include <iostream>

using namespace std;

int n;
int a[1010];

void show_array() {
  for (int i = 0; i < n - 1; i++) {
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
}
int main() {

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  show_array();
  for (int i = 1; i < n; i++) {
    int tmp = a[i];
    int j = i - 1;
    while(j >= 0 && a[j] > tmp) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = tmp;
    show_array();
  }
}



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

#include <stdio.h>
#include <string.h>

/******
*	????????°
******/
/******??¢?????´?????????
*	????????????S???2?????????????????§???2?????°????????????????????????S?????????????????????P??????????????????
*	????????????????????????S??¨P????????????????????§?????¨????????????????????¨??????0???????????¨????????????????????????
*	??¢?????????P????????°??????0?????£?¶?????????°Yes??¨??????
******/

int main(void)
{
	char string_S[200]={0};			//?????????????????????S?????????????????????
	char string_P[ 99]={0};			//?????????????????????P?????????????????????
	int i,  k;
	int result[200]={0};
	int sum, answer ;
	int s, p; 						//???????????????
	int count;

	scanf("%s\n", string_S);
	scanf("%s\n", string_P);
	s = strlen(string_S);		//?????????S?????????s
	p = strlen(string_P);		//?????????P?????????p
		
	for(i = 0 ; i < s ; i++){
		string_S[(i+s)] = string_S[i]  ;  //??????S????????\
	}
	
	for(i = 0 ; i < s ; i++){			//??????S???i???????????????????????????P????????????????????¨????????¨????????¢???
			result[i] = string_S[i] - string_P[0];
				
			if(	result[i] == 0){	//???????????????????????£?????´?????????????????????????????????
				count = 0;
				sum   = 0;
				for (k =0; k < p; k++ ){
					if(string_S[i+k] > string_P[k]){
						result[i+k] = string_S[i+k]-string_P[k];
						sum += result[i+k];
						count++;
					}else {
						result[i+k] = string_P[k] - string_S[i+k];
						sum += result[i+k];
						count++;
					}
				}
				if(sum == 0 && p == (count)){
					answer=1;
						break;
				}else {
					answer=0;
				}
			}else {
			//??????????????????????¬????????????????
			}
	}
	if( answer >= 1 ){
		printf("Yes\n");		//p??????????????´???
	}
	else {
		printf("No\n");		//p?????????????????´???
	}
		
	return 0;

}

Measured memory_bytes: 1116
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  
  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }
  
  vector <int> X(M);
  for (int i = 0; i < M; i++) {
    cin >> X[i];
  }
  
  sort(X.begin(), X.end());
  
  vector<int> dist(M - 1);
  for (int i = 0; i < M - 1; i++) {
    dist[i] = X[i + 1] - X[i];
  }
  
  sort(dist.begin(), dist.end());
  
  int travel = X[M - 1] - X[0];
  for (int i = M - 2; i >= M - N; i--) {
    travel -= dist[i];
  }
  
  cout << travel << endl;
       
  return 0;
}

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

int main() {
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);
  if (m > 4) {
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cmath>
#include<complex>
using namespace std;

bool isin(double a, double b, double c){
	if(a>b) swap(a,b);
	if(b-a<M_PI){
		return (a<c && c<b);
	}
	else{
		return (b<c || c<a);
	}
}

int main(void){

	double a, b, c, d, e, f, g, h;

	while(cin>>a>>b>>c>>d>>e>>f>>g>>h){

	complex<double> p[4];
	p[0] = complex<double>(a,b);
	p[1] = complex<double>(c,d);
	p[2] = complex<double>(e,f);
	p[3] = complex<double>(g,h);

	double arg1, arg2, arg3;
	arg1 = arg(p[1]-p[0]);
	arg2 = arg(p[2]-p[0]);
	arg3 = arg(p[3]-p[0]);

	if(arg1<0) arg1+=2*M_PI;
	if(arg2<0) arg2+=2*M_PI;
	if(arg3<0) arg3+=2*M_PI;

	bool b0;
	b0 = isin(arg1, arg2, arg3);

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

	arg1 = arg(p[0]-p[1]);
	arg2 = arg(p[2]-p[1]);
	arg3 = arg(p[3]-p[1]);

	if(arg1<0) arg1+=2*M_PI;
	if(arg2<0) arg2+=2*M_PI;
	if(arg3<0) arg3+=2*M_PI;

	bool b1;
	b1 = isin(arg1, arg2, arg3);

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

	arg1 = arg(p[0]-p[2]);
	arg2 = arg(p[1]-p[2]);
	arg3 = arg(p[3]-p[2]);

	if(arg1<0) arg1+=2*M_PI;
	if(arg2<0) arg2+=2*M_PI;
	if(arg3<0) arg3+=2*M_PI;

	bool b2;
	b2 = isin(arg1, arg2, arg3);

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

	if( b0 && b1 && b2 ) cout << "YES" << endl;
	else cout << "NO" << endl;

	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll INF = 1ll<<60;
static const int MOD = 1e9+7;

int main(){
    int K;
    cin>>K;
    int cur = 7;
    int ans = 0;

    if(K%2 == 0){
        cout<<"-1"<<endl;
        return 0;
    }

    while(1){
        ans++;
        if(ans > 1e8) break;
        if(cur < K){
            cur *= 10;
            cur += 7;
            continue;
        }else{
            cur = cur%K;
            if(cur == 0) break;
            cur *= 10;
            cur += 7;
        }
    }

    if(ans > 1e8) cout<<"-1"<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    int prev = 0;
    string ans = "Yes";
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if (h < prev) ans = "No";
        if (h > prev) prev = h - 1;
    }

    cout << ans << '\n';
    return 0;
}

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

using namespace std;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    string s;
    cin >> s;

    vector<int> s_array;
    s_array.push_back(0);
    char num = '1';
    for(int i=0; i < n; i++) { 
        if ((char)s[i] != num) {
            s_array.push_back(1);
            num = ( num == '0' ? '1' : '0' );
        } else {
            s_array.back()++;
        }
    }
    if (num == '0') s_array.push_back(0);
    int result = 0, sum = 0;
    for(int i=0; i < s_array.size(); i+=2) {
        if (i == 0) {
            sum += s_array[i];
        } else if (i <= k*2){
            sum += (s_array[i-1]+s_array[i]);
        } else {
            sum -= (s_array[i-k*2-2]+s_array[i-k*2-1]);
            sum += (s_array[i-1]+s_array[i]);
        }
        result = max(result, sum);
    }
    cout << result << endl;
}


Measured memory_bytes: 1020
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x[] = new int[4];
		int y[] = new int[4];
		for(int i = 0; i < 2; i ++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		for(int i = 2; i < 4; i ++) {
			x[i] = x[i - 1] + y[i - 2] - y[i - 1];
			System.out.print(x[i]+" ");
			y[i] = y[i - 1] - x[i - 2] + x[i - 1];
			if(i == 2) {
				System.out.print(y[i]+" ");
			}else {
				System.out.println(y[i]);
			}
		}
	}
}

Measured memory_bytes: 22996
N = int(input())
w = list(map(int,input().split()))
lists = []
s1 = 0
s2 = 0
for i in range(1,max(w)):
    T = i
    s1 = 0
    s2 = 0
    for j in range(N):
        if T >= j:
            s1 += w[j]
        if T < j:
            s2 += w[j]
    lists.append(abs(s1-s2))
print(min(lists))

Measured memory_bytes: 3064
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define LL long long
#define ll long long
#define LD double

#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int main()
{
    HabdModeActive
    int n;
    cin>>n;
    cout<<double(2*PI*n);
    return 0;
}


Measured memory_bytes: 3808