akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
N, L, T = map(int, input().split())
gap = 0
X = [0] * N
for i in range(N):
    x, w = map(int, input().split())
    x += ((w + 1) % 3 - 1) * T
    gap += x // L
    gap %= N
    X[i] = x % L
X.sort()
for i in range(N):
    print(X[(i+gap) % N])

Measured memory_bytes: 8116
N = int(input())
ans = [0]

for i in range(1, N+1):
    dp = []
    k = 1
    while i >= k:
        dp.append(ans[i-k]+1)
        k *= 6
    k = 1
    while i >= k:
        dp.append(ans[i-k]+1)
        k *= 9
    ans.append(min(dp))
print(ans[-1])

Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,x;
    cin>>a>>b>>x;
    if(x-a<0||x-a>b){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
from itertools import permutations
from math import ceil
D = []
for _ in range(5):
    D.append(int(input()))
res = float("inf")
for a in permutations(D,5):
    t = 0
    for b in a[:-1]:
        t += ceil(b/10)*10
    t += a[-1]
    res = min(res, t)
print(res)

Measured memory_bytes: 61604
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int,int);

int main(){
  int i,a;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }

  a = partition(0,n -1);

  for(i = 0;i < n;i++){
    if(i > 0){
      printf(" ");
    }
    if(i == a){
      printf("[");
    }
    printf("%d",A[i]);
    if(i == a){
      printf("]");
    }
  }

  printf("\n");

  return 0;
}

int partition(int a,int b){
  int i,j,x,t;

  x = A[b];
  i = a - 1;

  for(j = a;j < b;j++){
    if(A[j] <= x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  
  t = A[i + 1];
  A[i + 1] = A[b];
  A[b] = t;

  return i + 1;
}



Measured memory_bytes: 2204
// https://atcoder.jp/contests/abc071/tasks/abc071_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(a - x) > abs(b - x)) {
        cout << "B\n";
    } else {
        cout << "A\n";
    }
    return 0;
}


Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

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

a,b = inm()
print(max(a-2*b,0))


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

int main()
{
    vector<int> arr(3);
    for(int i = 0; i < 3; i++){
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());

    cout << (arr[0] == 5 && arr[1] == 5 && arr[2] == 7 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
def sigma2(n,i,j):
    if i==j and n<i:
        ncnt= 0
    elif i==j and i<=n:
        ncnt=1
    else:
        ncnt=0    

    if i*10+j<=n:
        ncnt=ncnt+1
        
    mcnt=-1
    nn=0
    for kt in range(1,6,1):
       for kt2 in range(10**kt):
           mcnt=mcnt+1
           nn=i*10**(kt+1)+kt2*10+j
           if nn>n:
               break
       if nn>n:
           break
               
    return mcnt+ncnt                


n=int(input())
ncnt=0
for k in range(1,10,1):
    for m in range(1,10,1):
        s1=sigma2(n,k,m)
        s2=sigma2(n,m,k)
        ncnt=ncnt+s1*s2
#        if s1*s2>0:
#            print(k,m,s1,s2)
print(ncnt)     

Measured memory_bytes: 3064
n,m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]
for i in range(1000):
    num = str(i)
    if len(num) == n and all(num[s-1]==str(c) for s,c in sc):
        print(i)
        break
else:
    print(-1) 

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    vector<int> cnt(1001,0);
    for(int i=1;i<=n;i++){
        int num=i;
        for(int j=2;j*j<=num;j++){
            while(num%j==0){
                cnt[j]++;
                num/=j;
            }
        }
        if(num!=1) cnt[num]++;
    }
    ll ans=1;
    rep(i,1001) ans=(ans*(cnt[i]+1))%MOD;
    cout<<ans<<endl;
}

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

string s;

int main()
{
	cin>>s;
	for(int i=0;i<s.size();++i) {
		if(s[i]=='U'||s[i]=='D') continue;
		if(s[i]=='R'&&i%2==1) {
			printf("No");
			return 0;
		}
		else if(s[i]=='L'&&i%2==0) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
// BISMILLAHIR_RAHMANIR_RAHIM
    #include <bits/stdc++.h>
    #define ll long long
    #define in1(a) scanf("%lld",&a)
    #define in2(a,b) scanf("%lld %lld",&a,&b)
    #define ins(a) scanf("%s",a)
    #define inf(a) scanf("%lf",&a)
    #define out1(a) printf("%lld", a)
    //Nazmul Hossain Nahid
    #define space printf("\n")
    #define enter printf("\n")
    #define out2(a,b) printf("%lld %lld\n",a,b)
    #define f(x,to) for(int x=0;x<(to);x++)
    #define all(a) (a.begin()),(a.end())
    #define ZERO(a) memset(a,0,sizeof(a))
    #define pb push_back
    #define F first
    #define S second
    #define debug cout<<" OK "<<endl
    #define eps 0.000001


    using namespace std;


    int main()
    {
        ios_base::sync_with_stdio(false);cin.tie(NULL);
        ll x1,y1,x2,y2,x3,y3,i,j,area,q,x,y,xp,yp;
        cin>>x1>>y1>>x2>>y2;

        cin>>q;
        f(i,q)
        {
            cin>>x3>>y3;

            area=x1*y2-x2*y1+x2*y3-x3*y2+x3*y1-x1*y3;
            //ans
            if(area>0)
            {
                cout<<"COUNTER_CLOCKWISE"<<endl;
            }
            else if(area<0)
            {
                cout<<"CLOCKWISE"<<endl;
            }
            else if(area==0)
            {

                ll p1=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
                ll p2=(x2-x3)*(x2-x3)+ (y2-y3)*(y2-y3);
                ll p3=(x3-x1)*(x3-x1)+(y3-y1)*(y3-y1);
                long double p0p1=sqrt(p1);
                long double p0p2=sqrt(p2);
                long double p1p2=sqrt(p3);

                if(((p0p2+p1p2)-p0p1)<=eps || x3==x1 && y3==y1 || x3==x2 && y3==y2 )
                    cout<<"ON_SEGMENT"<<endl;
                else if(((p0p1+p1p2)-p0p2)<=eps)
                    cout<<"ONLINE_BACK"<<endl;
else if(((p0p1+p0p2)-p1p2)<=eps)
                    cout<<"ONLINE_FRONT"<<endl;

            }

        }


    	return 0;
    }

  // ALHAMDULLIAH

  /* ll px1=x2-x1; ll py1=y2-y1;
                ll px2=x3-x1; ll py1=y3-y1;

                if((p0p1+p0p2)==p1p2)
                    cout<<"ONLINE_FRONT"<<endl;
                else if((p0p2+p1p2)==p0p1 )
                    cout<<"ON_SEGMENT"<<endl;
                else if((p0p1+p1p2)==p0p2)
  cout<<"ONLINE_BACK"<<endl;

                */






Measured memory_bytes: 3228
#include<iostream>
#include<string>
#include<algorithm>



using namespace std;
long long t[200002];
int main()
{
	int N;
	long long T;
	long long time=0;
	cin >> N >>T;
	for (int i = 1; i < N+1;++i) cin >> t[i];

	for (int i = 1; i < N; ++i) {
		time = time + min(T,t[i+1]-t[i]);
	}



	cout << time+T << endl;
	return 0;

}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N, K;
    cin >> N >> K;
    int a[N];
    rep(i, N) cin >> a[i];
    int cnt[N] = {0};
    rep(i, N){
        cnt[a[i]-1]++;
    }
    int cnt_ball = 0;
    rep(i, N) if(cnt[i] != 0) cnt_ball++;
    int ans = 0;
    if(cnt_ball > K){
        sort(cnt, cnt+N);
        int sub = cnt_ball - K;
        for(int i = (N-cnt_ball); i < N-K; i++){
            ans += cnt[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

int main() {
  int N;
  std::vector<std::string> s_vec;
  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::string sin;
    std::cin >> sin;
    s_vec.push_back(sin);
  }

  int frontB = 0;
  int endA = 0;
  int fBeA = 0;
  int insertAB = 0;

  for (auto &s : s_vec) {
    const int &size = s.size();
    if (size == 0) {
      continue;
    }
    bool flag = (s[0] == 'B');
    if (flag) ++frontB;

    for (int i = 1; i < size; ++i) {
      if (s[i - 1] == 'A' && s[i] == 'B') {
        ++insertAB;
      }
    }

    if (s[size - 1] == 'A') {
      ++endA;
      if (flag) {
        ++fBeA;
      }
    }
  }
  frontB -= fBeA;
  endA -= fBeA;
  int pair = 0;

  if (fBeA == 0) {
    pair = std::min(frontB, endA);
  } else {
    if ((frontB + endA) == 0) {
      pair = fBeA - 1;
    } else {
      pair = fBeA + std::min(frontB, endA);
    }
  }

  int result = insertAB + pair;

  std::cout << result;

  return 0;
}

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

using namespace std;

bool isp(long long int a){
    for(long long int i=2; i*i<=a; i++){
        if(a%i==0)
            return false;
    }
    return true;
}

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

long long a,b,cnt,p=1;

int main(){
    cin>>a>>b;
    a=gcd(a,b);
    while(isp(a)==0){
        for(int i=2;i*i<=a;i++){
            if(a%i==0){
                if(p!=i)cnt++;
                a/=i;
                p=i;
                break;
            }
        }
    }
    if(p!=a)cnt++;
    cout<<cnt+1;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100005;
int a[N], b[N], c[N];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++)
		cin >> b[i];
	for (int i = 1; i <= n; i++)
		cin >> c[i];
	sort(c + 1, c + n + 1);
	long long ans = 0;
	for (int i = 1; i <= n; i++)
		ans += 1ll * (lower_bound(a + 1, a + n + 1, b[i]) - a - 1) * (n - (upper_bound(c + 1, c + n + 1, b[i]) - c) + 1);
	cout << ans << endl;
	return 0;
}

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

int main()
{
  string a;
  cin>>a;
 // for (int i=0; i<a.length(); i++)
   // cout<<a[i]<<" ";
  if (a[2]==a[3] && a[4]==a[5])
    cout<<"Yes"<<endl;
  else
  {
     // cout<<a[3]<<a[4]<<a[5]<<a[6];
      cout<<"No"<<endl;
  }
    
	
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main() {

    int n, d;
    int sum, max;
    scanf("%d", &n);
	sum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &d);

        sum = sum + d;
        if (max < d) {
            max = d;
        }
    }

    sum = sum - max;
    if (max >= sum) {
        printf("No");
    } else {
        printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 128
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

int main()
{
#ifdef _MSC_VER
	freopen("e.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false);
	int n, m, c;
	cin >> n >> m >> c;
	vector<pair<int, int>> sx(n), sy(m);
	for (int i = 0; i < n; i++) {
		sx[i].second = i;
	}
	for (int i = 0; i < m; i++) {
		sy[i].second = i;
	}
	set<pair<int, int>> a;
	for (int i = 0; i < c; i++) {
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		++sx[x].first;
		++sy[y].first;
		a.insert(make_pair(x, y));
	}
	sort(sx.rbegin(), sx.rend());
	sort(sy.rbegin(), sy.rend());
	int ret = 0;
	for (const auto& gx : sx) {
		for (const auto& gy : sy) {
			int d = a.count(make_pair(gx.second, gy.second));
			ret = max(ret, gx.first + gy.first - d);
			if (d == 0) {
				break;
			}
		}
	}
	cout << ret << endl;
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }

    ll ans = 0;
    int mx = A[0];

    for (int i=1; i<N; i++) {
        if (A[i] < mx) {
            ans += mx - A[i];
        } else {
            mx = A[i];
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3984
// https://atcoder.jp/contests/agc023/tasks/agc023_b
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t = 0;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int i = 0; i < n; i++) {
        bool ok = true;
        for (int j = 0; ok & j < n - 1; j++)
            for (int k = j + 1; ok & k < n; k++)
                if (s[(j + i) % n][k] != s[(k + i) % n][j])
                    ok = false;
        t += ok;
    }
    printf("%d\n", t * n);
}

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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multi_set;

#define mod         1000000007
#define pi          3.1415926535898
#define eps         1e-9


#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define vt vector
#define ar array
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define sz(x) (int)(x).size()
#define revsort(x) sort(all(x));reverse(all(x))

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)
#define EACH(x, a) for (auto& x: a)

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<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;
LL INF=1e9;


 
template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
	cin >> x;
}
void read(double& d) {
	string t;
	read(t);
	d=stod(t);
}
void read(long double& d) {
	string t;
	read(t);
	d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
	read(h);
	read(t...);
}
template<class A> void read(vt<A>& x) {
	EACH(a, x)
		read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
	EACH(a, x)
		read(a);
}

LL powm(LL x, LL y,LL m)
{
    if(y==0)
        return 1;
    if(y==1)
        return x%m;
    if(y&1)
        return (x*(powm((x*x)%m,y/2,m)))%m;
    return powm((x*x)%m,y/2,m)%m;
}

LL inv(LL x, LL m)
{
    return powm(x,m-2,m);
}

int add(int var1, int var2){
    return (((((LL)(var1)) % mod + (LL)(var2)) % mod) + mod) % mod;
}


int mul(int var1, int var2){
    return (((LL)(var1)) % mod * (LL)(var2)) % mod;
}

void solve()
{
    LL n,x,t;
    read(n,x,t);
    cout<< (n+x-1)/x*t <<nl;
}
int main()
{
        solve();
}


Measured memory_bytes: 3600
#include<stdio.h>
#define N 36
typedef struct {
  char mark;
  int value;
}DATA;

void stable(DATA *,DATA *,int);
void display(DATA *,int);

int main()
{
  DATA A[N],B[N],C[N],V;
  int n,i,j,minj,flag,count;
  char sp;
  scanf("%d%c",&n,&sp);
  for(i=0;i<n;i++){
    scanf("%c%d%c",&A[i].mark,&A[i].value,&sp);
    B[i] = A[i];
    C[i] = A[i];
  }

  flag = 1;
  j = 1;

  while(flag){
    flag = 0;
    for(i = n-1;i >= j;i--){
      if(B[i].value < B[i-1].value){
        flag = 1;
        V = B[i];
        B[i] = B[i-1];
        B[i-1] = V;
        count++;
      }
    }
    j++;
  }

  display(B,n);
  printf("Stable\n");

  for(i = 0;i < n;i++){
    minj = i;
    for(j = i;j < n;j++){
      if(C[j].value < C[minj].value) minj = j;
    }
    if(C[i].value != C[minj].value) count++;
    V = C[i];
    C[i]  = C[minj];
    C[minj] = V;
  }

  display(C,n);
  stable(C,A,n);

  return 0;
}

void display(DATA *A,int n){
  int i;
  for(i = 0;i < n;i++){
    printf("%c%d",A[i].mark,A[i].value);
    if(i == n-1) break;
    printf(" ");
  }printf("\n");
}

void stable(DATA *A,DATA *B,int n){
  int i,j,k,l,same = 0,flag = 0;
  for(i = 0;i < n;i++){
    for(l = i+1;l < n;l++){
      if(A[i].value == A[l].value){
        same = 1;
        for(j = 0;j < n;j++){
          if(A[i].value == B[j].value){
            for(k = j+1;k < n;k++){
              if(B[j].value == B[k].value){
                if(A[i].mark != B[j].mark || A[l].mark != B[k].mark){
                  flag = 1;
                }
              }
            }
          }
        }
      }
    }
  }
  if(same == 0 || flag == 0) printf("Stable\n");
  else printf("Not stable\n");
}




Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<60;
const int INF=1<<30;

template <class T> void multiple_transform(::std::vector<T> &a) {
    int n = a.size();
    ::std::vector<bool> sieve(n, true);
    for (int p = 2; p < n; ++p) {
        if (sieve[p]) {
            for (int k = (n - 1) / p; k != 0; --k) {
                sieve[k * p] = false;
                a[k] = (a[k] + a[k * p])%mod;
            }
        }
    }
    for (int i = 0; ++i != n;) {
        a[i] = (a[i] + a[0])%mod;
    }
}

template <class T> void inverse_multiple_transform(::std::vector<T> &a) {
    int n = a.size();
    ::std::vector<bool> sieve(n, true);
    for (int i = 0; ++i != n;) {
        a[i] = (a[i] - a[0] + mod)%mod;
    }
    for (int p = 2; p < n; ++p) {
        if (sieve[p]) {
            for (int k = 1; k * p < n; ++k) {
                sieve[k * p] = false;
                a[k] = (a[k] - a[k * p] + mod)%mod;
            }
        }
    }
}

LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}

int main(){
    int n;cin >> n;
    vector<LL> a(1000001,0),A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        a[A[i]] += A[i];
    }
    multiple_transform(a);
    vector<LL> c(1000001);
    for (int i = 0; i <= 1000000; i++) {
        c[i] = a[i] * a[i];
    }
    inverse_multiple_transform(c);
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        c[A[i]] = (c[A[i]] + mod - (A[i] * A[i] %mod)) %mod;
    }
    for (int i = 1; i <= 1000000; i++) {
        ans = (ans + c[i] * fpow(2*i,mod-2))%mod;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 17536
//https://atcoder.jp/contests/dp/tasks/dp_c
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<vector<int>>arr;
	for(int i=0;i<n;i++)
	{
		vector<int> temp;
		int a,b,c;
		cin>>a>>b>>c;
		temp.push_back(a);
		temp.push_back(b);
		temp.push_back(c);
		arr.push_back(temp);
	}
	vector<int>dp(3,0);
	dp[0]=arr[0][0];
	dp[1]=arr[0][1];
	dp[2]=arr[0][2];
	for(int i=1;i<n;i++)
	{
		vector<int>m(3,0);
		m[0]=max(arr[i][0]+dp[1],arr[i][0]+dp[2]);
		m[1]=max(arr[i][1]+dp[0],arr[i][1]+dp[2]);
		m[2]=max(arr[i][2]+dp[0],arr[i][2]+dp[1]);
		dp=m;		
	}
	cout<<*max_element(dp.begin(),dp.end());
	return 0;
}

Measured memory_bytes: 6836
#include<iostream>
#include<string>
#include<bitset>

int main() {
  std::string str;
  std::bitset<26> bit;
  std::cin >> str;
  for (int i=0; i<str.size(); i++) {
    bit.set(int(str.at(i)) - 'a', 1);
  }
  int flag = 0;
  char ans;
  for (int i=0; i<26; i++) {
    if (!bit.test(i)) {
      ans = 'a'+i;
      flag=1;
      break;
    }
  }
  if (flag) {
    std::cout << ans << std::endl;
  }
  else {
    std::cout << "None" << std::endl;
  }
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define gcd __gcd
using namespace std;

ll twice(ll n) {
  ll ans=0;
  while(n%2==0) {
    n/=2;
    ans++;
  }
  return ans;
}
int main() {
  ll n;
  cin>>n;
  vector<ll>vec(n);
  for(ll i=0;i<n;i++) {
    ll a;
    cin>>a;
    vec.at(i)=twice(a);
  }
  sort(vec);
  cout<<vec.at(0)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a[200000] = {};
  int i = 0;
  int n = 0;
  int max = 0;
  int maxi = 0;
  int niban = 0;
  int nibani = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i] >= max){
      nibani=maxi;
      niban=max;
      max = a[i];
      maxi = i;
    }else if(a[i] > niban){
      niban = a[i];
      nibani=i;
    }
  }
  for(i=0;i<n;i++){
    if(i == maxi){
      printf("%d\n",niban);
    }else{
      printf("%d\n",max);
    }
  }
  return 0;
}
  

Measured memory_bytes: 2304
// ?????¬???????????¬??????

#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 <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
int H[20], W[20];
int dp[1 << 16];
vector<string> board;
const string alph = "RGB";

int solve() {
    queue<int> q; q.push(0);
    while(!q.empty()) {
        int bit = q.front(); q.pop();
        if(bit == (1 << 16) - 1) return dp[bit];
        // i ????????????????????????????????? (j, k) ?????????????????? s ??§??????
        rep(i,0,N) rep(j,-H[i]+1,4) rep(k,-W[i]+1,4) rep(s,0,3) {
            int nbit = bit;
            rep(x, max(j,0LL), min(j+H[i],4LL)) rep(y, max(k,0LL), min(k+W[i],4LL)) {
                int idx = x * 4 + y;
                if(board[x][y] == alph[s]) nbit |= (1 << idx);
                else if(nbit >> idx & 1) nbit ^= (1 << idx);
            }
            if(dp[nbit] < 0) {
                dp[nbit] = dp[bit] + 1;
                q.push(nbit);
            }
        }
    }
    return 0;
}

signed main() {
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;

    cin >> N;
    rep(i,0,N) cin >> H[i] >> W[i];
    rep(i,0,4) {
        string s; cin >> s;
        board.push_back(s);
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 3876
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, k] <- getIntList
  as <- getIntVec n

  d <- VM.new n
  VM.set d (0::Int)

  let siml1 :: Int -> V.Vector Int -> IO (V.Vector Int)
      siml1 i as
        | i >= n = do forM_ [1..(n-1)] $ \i -> do
                        bi_1 <- VM.read d (i-1)
                        t <- VM.read d i
                        VM.write d i (t + bi_1)
                      as' <- V.freeze d
                      return as'
        | otherwise = do
            let ai = as V.! i
                l = max 0 (i-ai)
                r = min (n-1) (i+ai)
            t <- VM.read d l
            VM.write d l (t+1)
            when (r+1 < n) $ do
              t <- VM.read d (r+1)
              VM.write d (r+1) (t-1)
            siml1 (i+1) as

      solve i as
        | i >= k = return as
        | otherwise = do VM.set d (0::Int)
                         as' <- siml1 0 as
                         if V.minimum as' == n
                           then return as'
                           else solve (i+1) as'

  as' <- solve 0 as
  forM_ [0..(n-1)] $ \i -> do
    putStr $ show (as' V.! i)
    when (i < n-1) $ putStr " "
  putStrLn ""



Measured memory_bytes: 24244
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  int H,W,D;
  cin>>H>>W>>D;
  int a[H+1][W+1];
  int x[H*W+1],y[H*W+1];
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      cin>>a[i][j];
      x[a[i][j]]=i,y[a[i][j]]=j;
    }
  }
  ll S[H*W+1];
  for(int i=1; i<=H*W; i++){
      if(i<D){continue;}
      S[i]=S[i-D]+(abs(x[i-D]-x[i])+abs(y[i-D]-y[i]));
  }
  int Q;
  cin>>Q;
  for(int i=0; i<Q; i++){
    int a,b;
    cin>>a>>b;
    cout<<S[b]-S[a]<<endl;
  }
} 

Measured memory_bytes: 2944
#include<iostream>
#include<deque>
#include<cmath>
#include<cstring>
#include<map>
#include<algorithm>
#include<vector>
#include<ios>
#include<sstream>
#include<locale>
using namespace std;
#define ive(cris) int long long 
#define in(out) long double
#define INF 100000007
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(c<=b && c>=a){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return 0;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
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 main(){
ll n;cin>>n;
vl a(n);rep(i,n)cin>>a[i];
ll sum=0;

vl b(n),c(n);rep(i,n){b[i]=i+1+a[i];c[i]=i+1-a[i];}

vl d(n+1),e(n+1);

rep(i,n){
    if(b[i]<0||b[i]>n){continue;}
    d[b[i]]++;
    
}

rep(i,n){
    if(c[i]<0){continue;}
    e[c[i]]++;
}

rep(i,n)sum+=d[i]*e[i];

cout<<sum<<endl;

}

Measured memory_bytes: 11100
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int x, y;
  cin >> x >> y;
  if (x == 2 || y == 2) {
    dump("No");
    return 0;
  }
  int a[] = {4, 6, 9, 11};
  int cnt = 0;
  for (int i = 0; i < 4; i++) {
    if (a[i] == x || a[i] == y) cnt++;
  }
  if (cnt == 1) dump("No");
  else dump("Yes");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#define F first
#define S second
#define MP make_pair
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
char c[1000][1000];
bool flag[1000][1000];
int w, h, ans;
int cdt[1000][1000];
queue<PP> que, que2;

void fanc(PP p)
{
  for(int i = -1; i < 2; i++)
  {
    for(int j = -1; j < 2; j++)
    {
      if(!i && !j) continue;
      if(p.F.F + i < h && p.F.F + i >= 0 && p.F.S + j < w && p.F.S + j >= 0)
      {
        cdt[p.F.F + i][p.F.S + j]++;
        if(cdt[p.F.F + i][p.F.S + j] == c[p.F.F + i][p.F.S + j] - '0')
        {
          que.push(MP(MP(p.F.F + i, p.F.S + j), p.S));
        }
      }
    }
  }
}
void bfs()
{
  while(!que.empty())
  {
    fanc(MP(que.front().F, que.front().S + 1));
    ans = max(ans, que.front().S);
    que.pop();
  }
}
int main()
{
  cin >> h >> w;
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      cin >> c[i][j];
    }
  }
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      if(c[i][j] == '.')
      {
        fanc(MP(MP(i, j), 1));
      }
    }
  }
  bfs();
  cout << ans << endl;
}

Measured memory_bytes: 8024
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long

ll a[2009], d[2009][2009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; ll x; cin >> n >> x;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; d[0][i] = a[i]; ans += a[i];
	}
	for (int i = 0; i < n; i++) {
		ll r = 1LL * x * i;
		for (int j = 0; j < n; j++) {
			if (i > 0) d[i][j] = min(d[i - 1][j], ((j - i >= 0) ? a[j - i] : a[n + j - i]));
			r += d[i][j];
		}
		ans = min(ans, r);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 31616
#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 llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
    
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
    
struct Boat{
    int to;
    int cost;
    
    bool operator <(const Boat& right) const {
        return cost > right.cost;
    }
};

int n, k;
vector<struct Boat> v[105];

int dijkstra(int u, int goal){
    vector<int> d(n, INF);
    d[u] = 0;
    priority_queue<struct Boat> que;
    REP(i, v[u].size()){
        que.push(v[u][i]);
        d[v[u][i].to] = v[u][i].cost;
    }

    while(!que.empty()){
        int to = que.top().to;
        que.pop();
        
        REP(i, v[to].size()){
            if(d[to] + v[to][i].cost < d[v[to][i].to]){
                que.push(v[to][i]);
                d[v[to][i].to] = d[to] + v[to][i].cost;
            }
        }
    }
    
    return d[goal];
}

int solve(){
    vector<vector<int> > ve(n, vector<int>(n, INF));
    REP(i, k){
        int j;
        cin >> j;
        if(j == 0){
            int a, b;
            cin >> a >> b;
            a--; b--;
            int ans = dijkstra(a, b);
            if(ans != INF) cout << ans << endl;
            else cout << -1 << endl;
        }
        else{
            int a, b, c;
            cin >> a >> b >> c;
            a--; b--;
            if(c < ve[a][b]){
                v[a].push_back((Boat){b, c});
                ve[a][b] = c;
            }
            if(c < ve[b][a]){
                v[b].push_back((Boat){a, c});
                ve[b][a] = c;
            }
        }
    }
}

int main(){
    while(true){
            REP(i, 105) v[i].erase(v[i].begin(), v[i].end());
            cin >> n >> k;
            if(n == 0) return 0;
            solve();
    }
}

        

Measured memory_bytes: 1296
#include <iostream>

#define DEBT 100000

using namespace std;

int main() {
	int		n;
	double	tmp;
	int		debt = DEBT;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		debt *= 1.05;
		tmp = debt / 1000.0;
		if ((debt > (int)tmp * 1000)) {
			debt = (int)tmp * 1000 + 1000;
		}
		else {
			debt = (int)tmp * 1000;
		}
	}
	cout << debt << endl;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
const int mod = 1'000'000'007;

void solve()
{
    int arr[5];
  int res;
    for(int i=0; i<5; i++){
        cin >> arr[i];
        if(arr[i]==0)
            res = i+1;
    }
    cout << res << endl;
}

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

    solve();
  
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main() {
    int n,k;
    cin >> n >> k;
    vector<bool> flag(n,true);
    int d,tmp;
    for(int i=0;i<k;i++){
        cin >> d;
        for(int j=0;j<d;j++){
            cin >> tmp;
            flag[tmp-1] = false;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=flag[i];
    }
    cout << ans << endl;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	set<int> st1 = {1, 3, 5, 7, 8, 10, 12};
	set<int> st2 = {4, 6, 9, 11};
	set<int> st3 = {2};
	int x, y; cin >> x >> y;
	if(st1.count(x) == 1 && st1.count(y) == 1) puts("Yes");
	else if (st2.count(x) == 1 && st2.count(y) == 1) puts("Yes");
	else if (st3.count(x) == 1 && st3.count(y) == 1) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
n, @a, @b=gets.split.map(&:to_i)
@hp=[]
n.times{@hp << gets.to_i}

def check(t)
  _t=0
  @hp.each do |e|
    res=e-@b*t
    next if res<=0
    _t+=[0, (res+@a-@b-1)/(@a-@b)].max
  end
  _t<=t
end

l, u=0, (@hp.max+@b-1)/@b
while u-l>1
  m=(u+l)/2
  if check(m)
    u=m
  else
    l=m
  end
end

puts u


Measured memory_bytes: 2996
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int n, k;

    cin >> n >> k;

    cout << (n % k == 0 ? 0 : 1) << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int cnt[26]={0};
    string s;
    while(getline(cin,s)){
    lol(i,s.size()){
	if('a'<=s[i]&&s[i]<='z')cnt[s[i]-'a']++;
	if('A'<=s[i]&&s[i]<='Z')cnt[s[i]-'A']++;
    }
    }
    lol(i,26){
	char z=i+'a';
	cout<<z<<" : "<<cnt[i]<<endl;
    }
    return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

#define DEBUG(x) cout<<#x<<": "<<(x)<<endl

int n;
ll m;
ll a[25];
int p[25];

double P[1<<20];
ll f[1<<20];
ll V[1<<20];
const ll INF = 1ll<<60;

int main(){
	scanf("%d%lld",&n,&m);
	REP(i,n)scanf("%lld",a+i);
	REP(i,n)scanf("%d",p+i);
	// P
	REP(msk,1<<n){
		P[msk] = 1.0;
		REP(i,n)P[msk] *= (double)((msk>>i&1)==1 ? p[i] : 100-p[i])/100.0;
	}
	// f
	FOR(msk,1,1<<n){
		ll lcm = 1;
		REP(i,n)if(msk>>i&1){
			ll mul = a[i] / __gcd(a[i], lcm);
			// lcm * mul >= 1<<60
			// mul >= (1<<60) / lcm
			if(mul >= (INF+lcm-1)/lcm){
				lcm = INF;
			}else{
				lcm = lcm * mul;
			}
		}
		f[msk] = m / lcm;
		if(__builtin_popcount(msk)%2==0)f[msk] = -f[msk];
		// DEBUG(f[msk]);
	}
	// V
	REP(msk,1<<n)V[msk] = f[msk];
	REP(i,n)REP(msk,1<<n)if(msk>>i&1)V[msk]+=V[msk^(1<<i)];
	// REP(msk,1<<n)DEBUG(V[msk]);
	// ans
	double ans = 0.0;
	REP(msk,1<<n)ans += P[msk]*V[msk];
	printf("%.9f\n",ans);
	return 0;
}


Measured memory_bytes: 27784
/*       Rohan Balot
    NSIT, New Delhi, India  */
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <utility>

#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
 
#define ALL(t) (t).begin(), (t).end()
#define ALLR(t) (t).rbegin(), (t).rend()
#define MP make_pair
 
const int N = int( 1e6 ) + 1;
const int M = int( 1e6 ) + 1;
const int MOD = int( 1e9 ) + 7;
const double PI = acos(-1);
const double eps = 1e-6;

void __answer()
{
	string a, b, c;
	cin >> a >> b >> c;
	cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << '\n';
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #ifdef LOCAL
        freopen("sample_input.txt", "r", stdin);
    #endif
    __answer();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

bool visited[200];
int c[200];

bool dfs(vector<vector<pair<int, int> > > &edge, int now, int cost) {
    if (visited[now])return cost == c[now];
    c[now] = cost;
    visited[now] = true;
    bool res = true;
    rep(i, edge[now].size()) {
        int next = edge[now][i].first;
        int ncost = edge[now][i].second;
        res &= dfs(edge, next, cost + ncost);
    }
    return res;
}

int main() {
    std::ios_base::sync_with_stdio(false);
    int n;
    while(1) {
        cin >> n;
        map<string, int> v;
        vector<vector<pair<int, int> > > edge(2*n);
        if (n == 0)break;
        int cnt = 0;
        rep(i,n) {
            int idummy;
            char cdummy;
            string s[2],sdummy;
            int cost;
            cin >> idummy >> s[0] >> sdummy >> idummy >> cdummy >> cost >> s[1];
            rep(j,2) {
                if (v.find(s[j]) == v.end()) {
                    v[s[j]] = cnt;
                    cnt++;
                }
            }
            edge[v[s[0]]].push_back(make_pair(v[s[1]], cost));
            edge[v[s[1]]].push_back(make_pair(v[s[0]], -cost));
        }
        bool ok = true;
        rep(i, cnt) {
            rep(j,cnt) {
                visited[j] = false;
            }
            ok &= dfs(edge, i, 0);
        }
        cout << (ok ? "Yes" : "No") << endl;
    } 
    return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main(){
    ll n,a,b; cin >> n >> a >> b;
    ll ans = 0;
    vector<ll> x(n);

    rep(i,n) cin >> x[i];
    rep(i,n-1){
        if(b < a*(x[i+1]-x[i])){
            ans += b;
        }else ans += a*(x[i+1]-x[i]);
    }
    cout << ans;


}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    int H,W;cin>>H>>W;
    vector<string> s(H);
    REP(i,H) cin>>s[i];
    int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
    REP(i,H) REP(j,W){
        if(s[i][j]=='.') continue;
        bool ok=false;
        REP(k,4){
            int nx=i+dx[k],ny=j+dy[k];
            if(0<=nx&&nx<H&&0<=ny&&ny<W&&s[nx][ny]=='#') ok=true;
        }
        if(!ok){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

int a[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  map<int, int> h;
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
    if (i) a[i] += a[i-1];
    a[i] %= m;
    ++h[a[i]];
  }
  for (const auto &e: h) {
    if (e.first == 0) continue;
    ans += 1LL*e.second*(e.second-1)/2;
  }
  ans += 1LL*h[0]*(h[0]+1)/2;
  printf("%lld", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 7016
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i++)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm


signed main(){
  int n;
  cin >> n;
  Vi a(n), b(n), c(n);
  rep(i,0,n) cin >> a[i];
  rep(i,0,n) cin >> b[i];
  rep(i,0,n) cin >> c[i];
  
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  
  int ans = 0;
  
  rep(i,0,n){
    ans += ( lower_bound(ALL(a),b[i]) - a.begin() )*( c.end() - upper_bound(ALL(c),b[i]) );
  }
  
  cout << ans << endl;
}


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

int main(){
  double n, k;
  cin >> n >> k;
  
  double ans = 0;
  
  for ( int me = 1; me <= n; me++ ){
    double ten = me;
    int seq = 0;
    for ( ; ten < k ; seq++) ten *= 2;
    
    double tmp = 1.;
    for ( int i = 0; i < seq; i++ )
      tmp /= 2.0;
    
    ans += tmp / n;
  }
  
  cout << setprecision(12) << ans << endl;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define popb pop_back
#define beg begin()
#define en end()
#define sz(v) (int)((v).size())
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define endl "\n"
#define forn(i,a,n) for(int i=a;i<int(n);++i)
#define forb(i,a,n) for(int i=int(n)-1;i>=a;--i)
#define cout(ans) cout<< ans << "\n"
void speed()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
}


const ll mod=1e9+7;


void solve()
{
	int r,c;cin>>r>>c;
	char cc[r+1][c+1];
	ll dp[r+1][c+1];
	forn(i,0,r)
	{
		cin>>cc[i];
	}
	forn(i,0,r)
	{
		forn(j,0,c)
		{
			
			{
				dp[i][j]=-1;
			}
		}
	}
	int flag=1;
	forn(i,0,r)
	{
		if(cc[i][0]=='#')
		{
			flag=0;
		}
		dp[i][0]=flag;
	}
	flag=1;
	forn(i,0,c)
	{
		if(cc[0][i]=='#')
		{
			flag=0;
		}
		dp[0][i]=flag;
	}
	forn(i,0,r)
	{
		forn(j,0,c)
		{
			if(cc[i][j]=='#')
			{
				dp[i][j]=0;
			}
		}
	}
	forn(i,1,r)
	{
		forn(j,1,c)
		{
			if(dp[i][j]!=0)
			{
				dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
			//	cout(dp[i][j]);
			}

		}
	}
	cout(dp[r-1][c-1]%mod);

}


int main()
{   
    speed();
    //int tc;cin>>tc;
    //while(tc--)
    {
        solve();
    }
}


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

using namespace std;

const int MAXN = 1e6+5;
int main()
{
  string s;
  cin >> s;
  bool czy = 1;
  for (int i = 0; i < 3; i++)
  {
    if (s[i] != s[0]) czy = 0;
  }
  if (czy)
  {
    cout << "Yes\n";
    return 0;
  }
  czy = 1;
  for (int i = 1; i < 4; i++)
  {
    if (s[i] != s[1]) czy = 0;
  }
  if (czy)
  {
    cout << "Yes\n";
  }
  else cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string alp = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> ll gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(ll H, ll W, ll h, ll w){return 0 <= h && h < H && 0 <= w && w < W;}

int main(){
    ll N, s; cin >> N >> s;
    pt(N * s);
    return 0;
}

Measured memory_bytes: 3616