akhauriyash/Code-Regression huggingface dataset:
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=1000*1007;
using pdd=pair<double,double>;

int n;
ll k;

pdd pun[nax];

void odj(pdd &a, pdd b)
{
	a.first-=b.first;
	a.second-=b.second;
}

double pole(pdd s, pdd a, pdd b)
{
	odj(a, s);
	odj(b, s);
	return abs(a.first*b.second-a.second*b.first)/2;
}

ll licz(double v)
{
	//~ int ile=0;
	//~ for (int i=0; i<n; i++)
		//~ for (int j=0; j<i; j++)
			//~ for (int l=0; l<j; l++)
				//~ if (pole(pun[i], pun[j], pun[l])<=v)
					//~ ile++;
	//~ return ile;
	ll ret=0;
	
	int w=0;
	for (int i=2; i<n; i++)
	{
		if (pole(pun[0], pun[i], pun[i/2])<=v)
		{
			ret+=i-1;
			continue;
		}
		if (pole(pun[0], pun[i], pun[1])>v)
		{
			continue;
		}
		while(pole(pun[0], pun[i], pun[w+1])<=v)
			w++;
		while(pole(pun[0], pun[i], pun[w])>v)
			w--;
		ret+=2*w;
	}
	
	ret*=n;
	ret/=3;
	return ret;
}

int main()
{
	scanf("%d%lld", &n, &k);
	for (int i=0; i<n; i++)
		pun[i]={sin(2*M_PI*i/n), cos(2*M_PI*i/n)};
	double bsa=0.0;
	double bsb=15;
	double bss;
	for (int h=0; h<100; h++)
	{
		bss=(bsa+bsb)/2;
		if (licz(bss)>=k)
			bsb=bss;
		else
			bsa=bss;
	}
	bsa=(bsa+bsb)/2;
	printf("%.11lf\n", bsa);
	return 0;
}


Measured memory_bytes: 1152
from collections import deque
inf=10**9


def BFS(s,num):
    color=["white" for _ in range(n+1)]
    D=[inf for _ in range(n+1)]
    M=[[] for _ in range(n+1)]

    for i in range(m):
        if i==num:continue
        a,b=AB[i]
        M[a].append(b)
        M[b].append(a)

    D[s]=0
    color[s]="gray"

    queue=deque([s])
    while len(queue)>0:
        u=queue.popleft()
        for i in M[u]:
            if color[i]=="white":
                D[i]=D[u]+1
                color[i]="gray"
                queue.append(i)
        color[u]="black"

    return True if inf in D[1:] else False


n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(m)]

cnt=0
for i in range(m):
    cnt +=BFS(1,i)
print(cnt)

Measured memory_bytes: 40560
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[5];
int main()
{
    int sum=0;
    for(int i=1; i<=3; i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
     int maxx=0;
    for(int i=1; i<=3; i++)
    {

        if(maxx<=a[i])
        {
            int t;
            t=maxx;
            maxx=a[i];
            a[i]=maxx;
        }
    }
    printf("%d\n",sum-maxx);
    return 0;
}


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

int main() {
  int N,a,b,c,d;
  cin >> N;
  a=N/1000;
  b=(N-a*1000)/100;
  c=(N-a*1000-b*100)/10;
  d=N-a*1000-b*100-c*10;
 if(a==b&&b==c){
   cout << "Yes" << endl;
 }
  else if(b==c&&c==d){
    cout<< "Yes" << endl;
  }
  else
    cout << "No" << endl;
}

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

string day[] = { "Thursday" , "Friday" , "Saturday" , "Sunday" , "Monday" , "Tuesday" , "Wednesday" } ;
int month[] = { 31,29,31,30,31,30,31,31,30,31,30,31 } ;
string calendar[13][32] = {} ;

int main(){
	
	int x , y , n=0 ;
	
	for( int i=0 ; i<12 ; i++ ){
		for( int j=0 ; j<=month[i] ; j++ ){
			calendar[i][j] = day[n%7] ;
			n++ ;
		}
		n-- ;
	}
	
	while(1){
		cin >> y >> x ;
		if( y==0 && x==0 ) break ;
		
		cout << calendar[y-1][x-1] << endl ;
	}
	
return 0 ;
}

Measured memory_bytes: 1200
import sys
sys.setrecursionlimit(1000000)
from operator import *

ops = {'+':lambda x1, x2: x1 | x2, '*': lambda x1, x2: x1 & x2, '^': lambda x1, x2: x1 ^ x2}

def f(op, s1, s2):
    return ops[op](s1, s2)

def toN(s, numbers):
    for abc, number in zip(letters, list(numbers)):
        s = s.replace(abc, number)
    return s

letters = list("abcd")
def solve(S, P):
    origin = S
    S = S.replace('[', 'f(')
    S = S.replace(']', '),')
    for k in ops.keys():
        S = S.replace(k, "'" + k + "',")
    for l in letters:
        S = S.replace(l, l + ",")
    transed = S

    # print(S)
    res = eval(toN(S, P))[0]
    print(res, end=' ')
    count = 0
    for i in range(10000):
        if res == eval(toN(S, "{:04d}".format(i)))[0]:
            count += 1
    
    print(count)

while True:
    S = input()
    if S == '.':
        break
    P = input()
    solve(S, P)


Measured memory_bytes: 5704
function Main(input) {

  var input = input.split("\n")

  var arya = input[0].split(" ").map(val => parseInt(val, 10)).slice(0, 2);
  var a = arya[0];
  var p = arya[1];
  var result = ((a * 3) + p) / 2

  console.log(Math.floor(result));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int n, k, d, x, ans;
bool own[105];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= k; ++i) {
        scanf("%d", &d);
        for (int j = 1; j <= d; ++j) {
            scanf("%d", &x);
            own[x] = true;
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (own[i] == false) {
            ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3832
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x < 0 || y < 0 || x > W || y > H || x - r < 0 || y - r < 0
		|| x+r>W||y+r>H){
		cout << "No" << endl;
	}
	if (x > 0 && y > 0 && x < W && y < H && x - r >= 0 && y - r >= 0
		&& x + r<=W && y + r<=H){
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 3112
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int x1 = sc.nextInt();
int y1 = sc.nextInt();
int x2 = sc.nextInt();
int y2 = sc.nextInt();
int dx=x2-x1;
int dy=y2-y1;
    out.println((x2-dy)+" "+(y2+dx)+" "+(x1-dy)+" "+(y1+dx));
}}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
  int N, K;
  cin >> N;
  cin >> K;
  int count=0;
  for(int i = 0; i<N; i++){
    int h;
    cin >> h;
    if(h>=K){
      count++;
    }
  }
  	
  cout << count;
    
  return 0;
}

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

int main(void){
    string S;
    map<char, int> cnt;
    char alpha[26] = {'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'};
    //int cnt[26];
    for (int i = 0; i < 26; i++)
    {
    cnt[alpha[i]] = 0;
    
    }
    
    cin >> S;
    
    for(int i = 0; i<S.size(); i++)
    {
        for(char moji='a'; moji<='z'; moji++)
        {
            if (S[i] == moji)
            {
                cnt[moji]++;
            }
        }
    }
    for(char moji='a'; moji <= 'z'; moji++)
    {
        if (cnt[moji] == 0)
        {
            cout << moji << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    
    return 0;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}


int n,k;



int main()
{
    cin>>n>>k;
    // vec<int> d(k);
    int d;
    set<int> sunuke;
    int tmp;
    rep(i,k){
        cin>>d;
        rep(j,d){
            cin>>tmp;
            tmp--;
            sunuke.insert(tmp);
        }
    }
    int ans=0;
    rep(i,n){
        decltype(sunuke)::iterator it = sunuke.find(i);
        if(it==sunuke.end()){
            ans++;
        }
        
    }

    cout<<ans<<endl;


    return 0;

}




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

int main() {
  int x1, y1, x2, y2;
  cin>>x1>>y1>>x2>>y2;
  int x3 = x2 - y2 + y1;
  int y3 = y2 + x2 - x1;
  int x4 = x3 - y3 + y2;
  int y4 = y3 + x3 - x2;
  printf("%d %d %d %d\n", x3, y3, x4, y4);
}

Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int A = 0;
        int B = 0;
        long answer = 0;

        Map<Integer, Integer> energyMap = new TreeMap<Integer, Integer>();

        for (int i = 0; i < N; i++) {

            A = sc.nextInt();
            B = sc.nextInt();

            if (energyMap.containsKey(A)) {
                energyMap.put(A, energyMap.get(A) + B);
            } else {
                energyMap.put(A, B);
            }
        }

        int counter = 0;
        for (Map.Entry<Integer, Integer> energy : energyMap.entrySet()) {
            int energyPrice = energy.getKey();
            for (int i = 0; i < energy.getValue(); i++) {
                answer = answer + energyPrice;
                counter++;
                if (counter == M) {
                    break;
                }
            }
            if (counter == M) {
                break;
            }
        }

        System.out.println(answer);
        sc.close();
    }
}

Measured memory_bytes: 66140
#include<bits/stdc++.h>
using namespace std;
const long long int INF=1000000000;
typedef long long int l;

int main(){
	l n;
	cin>>n;
	int k;
	cin>>k;
	vector<l> h(n);
	for(auto& it:h)cin>>it;
	
/*
	int ans[n][k];	
	for(l i=0;i<n;i++){
		for(int j=0;j<k;j++){
			if(i==n-1)ans[i][j]=0;
			else if(n-1-i==j)ans[i][j]=abs(h[n-1]-h[i]);
		}
	}
	int min_arr[n];
	min_arr[n-1]=0;
	for(l i =0;i<n-1;i++)min_arr[i]=INF;
	for(l i=n-2;i>=0;i--){
		for(l j=k-1;j>=0;j--){
			if(i+j+1<n){
				//cout<<i<<endl;
				ans[i][j]=abs(h[i]-h[i+j+1])+min_arr[i+j+1];
				min_arr[i]=min(min_arr[i],ans[i][j]);
				//cout<<min_arr[i]<<endl;
			}
		}
	}
	cout<<min_arr[0]<<'\n';
*/	
	l min_arr[n];
	min_arr[n-1]=0;
	for(l i =0;i<n-1;i++)min_arr[i]=INF;
	for(l i=n-2;i>=0;i--){
		for(l j=0;j<k;j++){
			if(i+j+1<n)
			min_arr[i]=min(min_arr[i], abs(h[i]-h[i+j+1])+min_arr[i+j+1]);
		}
	}cout<<min_arr[0]<<'\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vst;
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};


int main(){
    char x,y;
    cin >> x >> y;

    if(x>y)cout << ">" << endl;
    else if(x==y)cout << "=" << endl;
    else if(x<y)cout << "<" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int h, m, s;
    scanf("%d", &s);
    h = s / 3600;
    m = (s % 3600) / 60;
    s = s % 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}


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

const int MN = 2e5+5;
pair<char,char> arr[MN];
int n, q, i, l, r, lo, hi;
string s;

int main(){
    cin >> n >> q >> s;
    s.insert(s.begin(),' ');
    for(i=1;i<=q;i++)
        scanf(" %c %c",&arr[i].first,&arr[i].second);
    lo=1, hi=n+1;
    while(lo<hi){
        int m = lo+hi>>1;
        int p = m;
        for(i=1;i<=q;i++){
            if(s[p]==arr[i].first){
                if(arr[i].second=='L') p--;
                else p++;
            }
            if(p<1||p>n) break;
        }
        if(p==0) lo=m+1;
        else hi=m;
    }
    l = lo-1;
    lo=1, hi=n+1;
    while(lo<hi){
        int m = lo+hi>>1;
        int p = m;
        for(i=1;i<=q;i++){
            if(s[p]==arr[i].first){
                if(arr[i].second=='L') p--;
                else p++;
            }
            if(p<1||p>n) break;
        }
        if(p==n+1) hi=m;
        else lo=m+1;
    }
    r = lo;
    printf("%d\n",n-(n+1-r)-(l));
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int h, w, x, y;
	cin >> w >> h >> x >> y;
	cout << fixed << setprecision(10) << h * 0.5 * w << ' ' << (x + x == w && y + y == h) << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int a, b;
  cin >> a >> b;

  string ans1 = "";
  string ans2 = "";

  for (int i = 0; i < b; i++) {
    ans1 += to_string(a);
  }

  for (int i = 0; i < a; i++) {
    ans2 += to_string(b);
  }

  string ans = ans1;
  if (ans1 > ans2) {
    ans = ans2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

void solve(){
    int n,k;
    cin>>n>>k;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>sum(n+1),pos(n+1);
    rep(i,n)sum[i+1]=sum[i]+a[i];
    rep(i,n){
        if(a[i]>=0)pos[i+1]=pos[i]+a[i];
        else pos[i+1]=pos[i];
    }
    ll ans=0;
    rep(i,n-k+1){
        ll cul=max(0LL,sum[i+k]-sum[i]);
        cul+=pos[n]-pos[i+k];
        cul+=pos[i];
        chmax(ans,cul);
    }
    cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define next nxt

int n,a[N],x[N],y[N],next[N],p[N],h[N];

bool solve(int x){
	h[x]=1;bool ans=0;
	for (int t=p[x];t;t=next[t])
		if (!h[y[t]])
		ans|=a[x]>a[y[t]]&&!solve(y[t]);
	h[x]=0;return ans;
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=n-1;i++){
		x[2*i-1]=y[2*i]=read();
		y[2*i-1]=x[2*i]=read();
		next[2*i-1]=p[x[2*i-1]];p[x[2*i-1]]=2*i-1;
		next[2*i]=p[x[2*i]];p[x[2*i]]=2*i;
	}
	for (int i=1;i<=n;i++)
		if (solve(i)) printf("%d ",i);
	printf("\n");return 0;
}

Measured memory_bytes: 10496
#include<bits/stdc++.h> 
using namespace std;
int vis[10]; 
int a[4]={0,3,5,7};
int main()
{
	vector<int>v;
	int t;
	scanf("%d",&t);
	for(int i=0;i<4;i++)
	{
		for(int j=0;j<4;j++)
		{
			for(int k=0;k<4;k++)
			{
				for(int k1=0;k1<4;k1++)
				{
					for(int k2=0;k2<4;k2++)
					{
						for(int k3=0;k3<4;k3++)
						{
							for(int k4=0;k4<4;k4++)
							{
								for(int k5=0;k5<4;k5++)
								{
									for(int k6=0;k6<4;k6++)
									{
										vis[a[i]]=1;
										vis[a[j]]=1;
										vis[a[k]]=1;
										vis[a[k1]]=1;
										vis[a[k2]]=1;
										vis[a[k3]]=1;
										vis[a[k4]]=1;
										vis[a[k5]]=1;
										vis[a[k6]]=1;
										int ans=a[i]*100000000+a[j]*10000000+a[k]*1000000+a[k1]*100000+a[k2]*10000+a[k3]*1000+a[k4]*100+a[k5]*10+a[k6];
										int temp=ans;
										int flag=0;
										while(temp)
										{
											if(!(temp%10==3 || temp%10==5 || temp%10==7))
												flag=1;
											temp=temp/10;
										}
										if(!flag && ans<=t && vis[3] && vis[5] && vis[7])
											v.push_back(ans);
										memset(vis,0,sizeof(vis));
									}
								} 
							} 
						} 
					} 
				} 
			}
		}
	} 
	printf("%d\n",v.size());
	return 0; 
};

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

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

    ll lb = 0, ub = a[0] * 2 + 1;
    for(int j=0; j<1000; j++){
        if(ub % 2 == 0) ub--;
        ll mid = (lb + ub) / 2;

        ll rain = mid;
        vector<ll> ans(n);
        for(int i=0; i<n; i++){
            ans[i] = rain;
            ll num = a[i] - rain / 2;
            rain = num * 2;
        }

        if(rain > mid){
            lb = mid;
        }
        else if(rain < mid){
            ub = mid;
        }
        else{
            for(int i=0; i<n; i++){
                cout << ans[i] << " \n"[i==n-1];
            }
            return 0;
        }
    }
}

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

int main(){
    string str; cin >> str;
    if(str == "Sunny") cout << "Cloudy" << endl;
    if(str == "Cloudy") cout << "Rainy" << endl;
    if(str == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<s.size();i++){
		cout<<char(((s[i]-'A')+n)%26+'A');
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	int a, b;
	cin >> a >> b;
	if (a > 0) {
		cout << "Positive" << endl;
	}
	else if (b < 0) {
		if ((b - a) % 2 == 0) {
			cout << "Negative" << endl;
		}
		else {
			cout << "Positive" << endl;
		}
	}
	else {
		cout << "Zero" << endl;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ps push_back
#define mod 1000000007
#define fi first
#define so second
#define pii pair<int,int>
#define TT int tt;cin>>tt;while(tt--)

signed main()
{
    int n;
    cin>>n;
    int sum=(n*(n+1))/2;
    int a=n/3;
    int b=n/5;
    int c=n/15;
    sum-=((a*(a+1))*3)/2;
    sum-=((b*(b+1))*5)/2;
    sum+=((c*(c+1))*15)/2;
    cout<<sum;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
#define int long long
#define double long double
int gcd(int x,int y){
    if(y==0)return x;
    x=x%y;
    gcd(y,x);
}
main()
{
    int n;
    cin>>n;
    vector<int>a(n);
    cin>>a[0];
    for(int i=1;i<n;i++){
        int b;
        cin>>b;
        a[0]=gcd(a[0],b);
    }
    cout<<a[0]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int> gate(n+2,0);
	rep(i,m){
		int l,r;
		cin>>l>>r;
		r++;
		gate[l]++;
		gate[r]--;
	}
	FOR(i,1,n+2){
		gate[i]+=gate[i-1];
	}
	int ans=0;
	rep(i,n+2){
		if(gate[i]==m) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
// ABC152_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    ll mx = max(N, M), mn = min(N, M);
    rep(i, mx) cout << mn;
    cout << "\n";
    
    return 0;
}

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

int N;
string S;

int main(){
	cin >> S;
	int size = (int)(S.length());
	int count_a = 0;
//	if(size % 2 == 0){
		for(int i = 0; i < size; ++i){
			if(i % 2 == 0){
				if(S[i] != '0') count_a++;
			}else{
				if(S[i] != '1') count_a++;
			}
		}
		cout << min(count_a, size - count_a) << endl;
//	}

}

Measured memory_bytes: 512
// https://atcoder.jp/contests/abc172/tasks/abc172_b
#include <bits/stdc++.h>
using namespace std ;
int main() 
{
    string s , t ;
    cin >> s >> t ;
    int counter = 0 ;
    int n = s.size() ;
    for (int i = 0 ;  i < n ; i++) {
        if (s[i] != t[i]) counter++ ;
    }
    cout << counter << endl ;
}
/*  CODED BY:-
 ___________________________________
|                       ___         |
|  /\   /\  \ /  |  |  |___   |__|  |        
| /~~\ /~~\  |   |__|   ___|  |  |  |
|___________________________________|
 
*/

Measured memory_bytes: 3876
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = root(x), y = root(y);
    if(x == y) return false;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  int root(int k)
  {
    if(data[k] < 0) return(k);
    return (data[k] = root(data[k]));
  }

  int size(int k)
  {
    return -data[root(k)];
  }
};


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

    int N, K, L;
    cin >> N >> K >> L;

    
    UnionFind road(N);
    UnionFind rail(N);

    REP(i, K){
        int p, q;
        cin >> p >> q;
        p--; q--;
        road.unite(p, q);
    }
    REP(i, L){
        int p, q;
        cin >> p >> q;
        p--; q--;
        rail.unite(p, q);
    }
    map<P, int> m;
    REP(i, N){
        m[mp(road.root(i), rail.root(i))]++;
    }
    REP(i, N){
        cout << m[mp(road.root(i), rail.root(i))] << (i == N-1 ? "\n":" ");
    }

    return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int k;
  cin >> k;
  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int bmodk = 7;
  REP(i, 2000000) {
    // cout << "i = " << i << ", " << bmodk << endl;
    if (bmodk % k == 0) {
      cout << i + 1 << endl;
      return 0;
    }
    bmodk = bmodk * 10 + 7;
    bmodk %= k;
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define mod 1000000007

int h,w;
int dp[1005][1005];
char grid[1005][1005];

int paths_recursive(int i,int j){
    if(i>=h || j>=w){
        return 0;
    }
    if(grid[i][j]=='#') return 0;
    if(i==h-1 && j==w-1)    return 1;
    return (paths_recursive(i+1,j)%mod+paths_recursive(i,j+1)%mod)%mod;
}

int paths_dp(int i,int j){
    if(i>=h || j>=w)    return 0;
    if(grid[i][j]=='#') return 0;
    if(i==h-1 && j==w-1)    return 1;
    if(dp[i][j]==-1){
        dp[i][j]= (paths_dp(i+1,j)%mod + paths_dp(i,j+1)%mod)%mod;
    }
    return dp[i][j];
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)    cin>>grid[i][j];
    }
    // cout<<paths_recursive(0,0)<<endl;
    memset(dp,-1,sizeof dp);
    cout<<paths_dp(0,0)<<endl;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
long long a[200001],sum[200001];
int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
		if(i==0)
		sum[i]=a[i];
		else
		sum[i]=sum[i-1]+a[i];
	}
	long long ans=1e17;
	rep(i,n){
		ans=min(ans,abs(sum[i]-(sum[n-1]-sum[i])));
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
int A,B,C;
cin>>A>>B>>C;
if(A<C&&C<B){
cout<<"Yes"<<endl;
}
else if(A>C&&C>B){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
return(0);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b)
        swap(a, b);
    if (b > c)
        swap(b, c);
    if (a > b)
        swap(a, b);

    cout << 10 * c + b + a << endl;
    return 0;
}

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

int main() {
	string s = "";
	cin >> s;
	int ans = 0;
	for (int i=0, j=(int)s.size() - 1; i<(int) s.size()/2; i++, j--)
		if (s[i] != s[j]) ans++;
		
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define smlas(a,b) if(a>b){a=b;}
int main(void){
    int i=0,j,x,y,N;
    vector<pair<int,int> >question;//????????\???????????????????????¢??????????????????,?????????????????????
    static int mon[1005];//mon[0]???0????????????
    for(i=1;i<1005;i++){
        mon[i]=(1<<25);
    }
    scanf("%d",&N);
    for(i=0;i<N;i++){
         scanf("%d %d",&x,&y);
         question.push_back(make_pair(y,x));
    }
    sort(question.begin(),question.end());
    for(i=0;i<N;i++){
        x=question[i].first;
        y=question[i].second;//y??????????????????
        for(j=i+1;j>0;j--){//mon[j]?????´??°
            smlas(mon[j],mon[j-1]+y)
            if(mon[j]>x){mon[j]=(1<<25);}
        }
    }
    for(i=0;i<N+5;i++){
        if(mon[i]>(1<<24)){
            printf("%d\n",i-1);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 2760
A = [int(input()) for _ in range(5)]
K = int(input())

lenge = 0

for i in range(5):
  for j in range(5):
    if A[i] - A[j] > K:
      lenge += 1
      
if lenge > 0:
  print(":(")
else :
  print("Yay!")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long A, long long B)
{
    for (int i = A; i <= B; i++)
    {
    }
}

int main()
{
    string A, B;
    cin >> A >> B;
    int ans = 0;
    for (int i = stoi(A); i <= stoi(B); i++)
    {
        string num = to_string(i);

        if (num[0] == num[4] && num[1] == num[3])
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //string[] str = Console.ReadLine().Split(' ');
            //int n = int.Parse(Console.ReadLine());

            string s = Console.ReadLine();

            if (s[2] == s[3] && s[4] == s[5])
            {
                Console.WriteLine("Yes");
            }
            else { Console.WriteLine("No"); }


            //ここまで
        }



    }

}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+4;
int dp[maxn], h[maxn];

int main() {
	int n, k;
	cin>>n>>k;
	for(int i=0; i<n; i++) {
	    cin>>h[i];
	    dp[i] = 1e9;
	}
	
	dp[0] = 0;
	for(int i=0; i<n-1; i++) {
	    for(int j=1; j<=k; j++){
	        if(i+j<n)
	            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i])); 
	    }
	}
	
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int N, K;
    cin >> N >> K;
    long long result = 0;
    if (K == 0) {
        result = (long long)N * N;
    } else {
        for (int b = K+1; b <= N; b++) {
            result += N / b * (b - K) + max(0, N % b - K + 1);
        }
    }
    cout << result << endl;
    return 0;
}

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

int main(){
  int N,T;
  cin >> N >> T;
  int c[N];
  int t[N];
  int ans = 1111;
  for (int i = 0; i < N; i++) {
    cin >> c[i] >> t[i];
    if(T>=t[i]){
      ans = min(ans,c[i]);
    }
  }
  if(ans==1111){
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
if X < Y:
    cn = range(Y+1)
    p = X
else:
    cn = range(X+1)
    p = Y
min_price = A*X + B*Y
for i in cn:
    if i <= p:
        price = (A*(X-i)+C*i)+(B*(Y-i)+C*i)
        if min_price > price:
            min_price = price
    else:
        if p == X:
            price = C*i+(B*(Y-i)+C*i)
            if min_price > price:
                min_price = price
        else:
            price = (A*(X-i)+C*i) + C*i
            if min_price > price:
                min_price = price
print(min_price)

Measured memory_bytes: 3064
n,k=map(int,input().split())
if k>(n-1)*(n-2)//2:
  print(-1)
else:
  Chk=[[False]*n for _ in range(n)]
  E=[]
  for i in range(2,n+1):
    E.append([1,i])
    Chk[0][i-1]=True
  res=(n-1)*(n-2)//2-k
  
  while res>0:
    for i in range(2,n+1):
      for j in range(i+1,n+1):
        if Chk[i-1][j-1]==False:
          s,g=i,j
          Chk[i-1][j-1]=True
          break
      else:
        continue
      break
    E.append([s,g])
    res-=1
  print(len(E))
  for s,g in E:
    print(s,g)


Measured memory_bytes: 45788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int s,n,b,i,min,max;
    cin>>s>>n;
    long long int a[n+5];
    for(i=0;i<n;i++)
        cin>>a[i];
    max=(a[n-1]-a[0]);
       for(i=n-1;i>0;i--)
       {
           b=((s-a[i])+a[i-1]);
           if(max>b)
              max=b;
       }
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 1792
number=list(map(int,input().split()))
likes=[]
result=0
for i in range(number[0]):
    rawdata=list(map(int,input().split()))
    for k in range(rawdata[0]):
        likes.append(rawdata[k+1])
for i in range(number[1]):
    if likes.count(i+1)==number[0]:
        result+=1
print(result)


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define ZERO(a) memset(a,0,sizeof(a))

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[(1<<21)+1];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  ll a[n][n];
  REP(i,n)REP(j,n)cin>>a[i][j];

  REP(i,(1<<n)+1)dp[i]=0;

  dp[0]=1;
  REP(i,(1<<n)){
    ll cnt=0;
    REP(j,n){
      if((i>>j)&1)
        cnt++;
    }

    if(cnt==0)
      continue;

    REP(j,n){
//      if(a[cnt][j]==1 && ~(i>>j)&1)
//        dp[i^(1<<j)] = (dp[i^(1<<j)]+dp[i])%MOD;

      if(a[cnt-1][j]==1 && (i>>j)&1)
        dp[i] = (dp[i]+dp[i^(1<<j)])%MOD;
    }
  }

//  REP(i,(1<<n))
//    cout<<dp[i]<<endl;
  cout<<dp[(1<<n)-1]<<endl;
}



Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back 
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
int lim=1e12;
const   int  mod=1e9+7;
int foobar=0;
//freopen("filename","r", stdin);
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
//int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0){int q=power(b,p/2);return ((q)*(q));}else return ((b)*(power(b,p-1)));}
int  powerm(int  b, int  p){if(p==0)return 1;else if(p%2==0){int q=powerm(b,p/2);return ((q%mod)*(q%mod))%mod;}else return ((b%mod)*(powerm(b,p-1)%mod))%mod;}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 4 >( n ).to_string();return s;}

signed main()
{
  ios;
  int n;
  cin>>n;
  vector<int> v[n+1];
  int q1;
  cin>>q1;
  int i=0;
  int ans[n+1];
  fill(ans,ans+n+1,0);
  while(i<n-1)
  {
    int n1,n2;
    cin>>n1>>n2;
    v[n1].pb(n2);
    v[n2].pb(n1);
    i++;
  }
  while(q1--)
  {
    int no,val;
    cin>>no>>val;
    ans[no]+=val;
  }
  queue<int> q;
  q.push(1);
  int vis[n+1];
  fill(vis,vis+n+1,0);
  vis[1]=1;
  while(!q.empty())
  {
    int f=q.front();
    q.pop();
    int j=0;
    while(j<v[f].size())
    {
      if(!vis[v[f][j]])
      {
        vis[v[f][j]]=1;
        q.push(v[f][j]);
        ans[v[f][j]]+=ans[f];
      }
      j++;
    }
  }
  i=1;
  while(i<=n)
  {
    cout<<ans[i]<<" ";
    i++;
  }


}




Measured memory_bytes: 19440
/**
 * author:    Ziel
 * created:   17.04.2020 21:43:36
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

#define int ll

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n, m;
	cin >> n >> m;
	
	vector<ll> x(n), y(n), z(n);
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];
	
	
	ll ans = 0;
	for (int mask = 0; mask < (1 << 3); mask++) {
		vector<ll> sum(n);
		for (int i = 0; i < n; i++) {
			if ((1 << 0) & mask) sum[i] += x[i];
			else sum[i] -= x[i];
			if ((1 << 1) & mask) sum[i] += y[i];
			else sum[i] -= y[i];
			if ((1 << 2) & mask) sum[i] += z[i];
			else sum[i] -= z[i];
		}
		sort(all(sum), greater<ll>());
		ll res = 0;
		for (int i = 0; i < m; i++) res += sum[i];
		ans = max(ans, res);
	}
	
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
int main()
{
	int N, M, K;
	std::cin >> N >> M >> K;
	std::vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> A[i];
	}
	std::vector<int> B(M);
	for (int i = 0; i < M; ++i) {
		std::cin >> B[i];
	}
	int totalA = 0;
	int countA = 0;
	for (; countA < N; ++countA) {
		if (totalA + A[countA] > K) {
			break;
		}
		totalA += A[countA];
	}
	int totalB = 0;
	int countB = 0;
	for (; countB < M; ++countB) {
		if (totalB + B[countB] > K - totalA) {
			break;
		}
		totalB += B[countB];
	}
	int countMax = countA + countB;
	while (countA > 0) {
		totalA -= A[--countA];
		for (; countB < M; ++countB) {
			if (totalB + B[countB] > K - totalA) {
				break;
			}
			totalB += B[countB];
		}
		if (countA + countB > countMax) {
			countMax = countA + countB;
		}
		if (countB == M) {
			break;
		}
	}
	std::cout << countMax << std::endl;
	return 0;
}

Measured memory_bytes: 4828
#include <stdio.h>

int main(void){
    
    int x,y;
    int number[13] = {3,0,2,0,1,0,1,0,0,1,0,1,0};
    
    scanf( "%d %d", &x,&y );
    
    if( number[x] == number[y] ){
        printf("Yes");
    }
    else printf("No");
    
    
    
    
    
    return 0;
}

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

#define int long long
#define counter(m)     for(int i=0;i<m;i++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n;
    cin>>n;
    vector<int>v(n+1,0);
    for(int i=1;i<=n;i++)
        cin>>v[i];
    for(int i=1;i<=n;i++)
        v[i]+=v[i-1];
//    for(auto c:v)
//        cout<<c<<" ";
    map<int,int>m;
    for(auto c:v)
        m[c]++;
    int ans=0;
    for(auto c:m)
        ans+=(c.second*(c.second-1))/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16952
#include<bits/stdc++.h>
 
using namespace std;
 
void sw(int &a,int &b){
	int z=a;
  a=b;
  b=z;
}
 
int main(){
	int x,y,z;
  	cin>>x>>y>>z;
  	sw(x,y);
  	sw(x,z);
  	cout<<x<<" "<<y<<" "<<z;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
    int a[110];
    int dp[N];
     
    int f(int n,int k) {
    	if (dp[n] != 0)
    		return dp[n];
    	for (int j = 0; j < k; j++)
    		if (n - a[j] >=0) 
    			if (f(n - a[j], k) == 2)
    				return dp[n] = 1;
    	return dp[n] = 2;
    }
    int main() {
    	int n, k, min = 1;
    	cin >> k >> n;
    	dp[0] = 2;
    	for (int i = 0; i < k; i++) {
    		cin >> a[i];
    		dp[a[i]] = 1;
    		if (min < dp[i])
    			min = dp[i];
    	}
     
    	cout << (f(n , k) == 1 ? "First" : "Second");
    	cin >> n;
    	return 0;
    }

Measured memory_bytes: 5376