akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=15,mod=1e9+7;
int n,m;
int bin[maxn*maxn];
int e[maxn][1<<maxn],f[1<<maxn];
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int main(){
	read(n);read(m);
	bin[0]=1;rep(i,1,m)bin[i]=add(bin[i-1],bin[i-1]);
	rep(i,1,m){
		int x,y;read(x);read(y);
		x--;y--;
		rep2(s,0,1<<n)if(s>>y&1)e[x][s]++;
	}
	f[0]=1;
	rep2(s1,0,1<<n){
		for(int u=((1<<n)-1)^s1,s2=u;s2;s2=(s2-1)&u){
			if((s2>>0&1)^(s2>>1&1))continue;
			int tmp=1;
			rep2(i,0,n)if(!((s1|s2)>>i&1))tmp=1ll*tmp*(bin[e[i][s2]]-1)%mod;
			rep2(i,0,n)if(s2>>i&1)tmp=1ll*tmp*bin[e[i][((1<<n)-1)^s1^s2]]%mod;
			f[s1|s2]=(f[s1|s2]+1ll*f[s1]*tmp)%mod;
		}
	}
	printf("%d\n",(bin[m]-f[(1<<n)-1]+mod)%mod);
	return 0;
}

Measured memory_bytes: 2048
n,x=map(int,input().split())

a=[0]*(n+1)
a[0]=1
p=[0]*(n+1)
p[0]=1

for i in range(n):
  a[i+1]=2*a[i]+3
  p[i+1]=2*p[i]+1


def f(n,x):
  if x==a[n]:
    return p[n]
  elif x==0:
    return 0
  elif x<=1+a[n-1]:
    return f(n-1,x-1)
  elif x>=2+a[n-1]:
    return p[n-1]+1+f(n-1,x-2-a[n-1])
  
print(f(n,x))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main(){
    long long int n;
    cin >> n;
    long long int ans = 0;
    long long int flag = 1;
    
    while(n > 9){
        ans += 9;
        
        if(n%10 != 9){
            flag = 0;
        }
        
        n /= 10;
    }
    
    if(flag){
        ans += n;
    }else{
        ans += n-1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <ostream>
#include <queue>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

inline void init() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
}

int main() {
  init();

  ll a[3], k;

  for (int i = 0; i < 3; ++i) {
    cin >> a[i];
  }
  cin >> k;

  std::sort(a, a + 3);

  cout << a[0] + a[1] + (a[2] << k) << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
  n, a, b, c, d = map(int, input().split())
  s = input()
  possible = True
  cnt = 0
  for i in range(a-1, c):
    if s[i] == ".":
      cnt = 0
    else:
      cnt += 1
    if cnt > 1:
      possible = False
      break
  cnt = 0
  for i in range(b-1, d):
    if s[i] == ".":
      cnt = 0
    else:
      cnt += 1
    if cnt > 1:
      possible = False
      break    
  if c > d:
    cnt = 0
    for i in range(b-2, d+1):
      if s[i] == "#":
        cnt = 0
      else:
        cnt += 1
      if cnt >= 3:
        break
    else:
      possible = False
  print("Yes" if possible else "No")


if __name__ == "__main__":
  main()


Measured memory_bytes: 3572
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL fac(LL a, LL mod){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(mod>0&&ans>mod)ans%=mod;}return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
LL ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
LL scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}

int main(){
  LL N,i,flag=0,ans=0;
  scanf("%lld",&N);
  char s[N][200],X[200];
  LL t[N];
  FOR(i,0,N)scanf("%s%lld",s[i],&t[i]);
  scanf("%s",X);
  FOR(i,0,N){
    if(flag==1)ans+=t[i];
    if(strcmp(s[i],X)==0)flag=1;
  }

  printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 5e5+5;
int bit[N];
void add(int idx){
	for(int i=idx;i>0;i-=(i&-i)){
		bit[i]++;
	}
}
int get(int idx){
	int ret = 0;
	for(int i=idx;i<N;i+=(i&-i)){
		ret+=bit[i];
	}
	return ret;
}
int a[N];
vector<int> qry[N];
int x[N];
int ans[N];
int prv[N];
void solve(){
	int n,q; 
	cin>>n>>q; 
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=q;i++){
		int l,r;
		cin>>l>>r;
		x[i] = l;
		ans[i]=  r-l+1;
		qry[r].pb(i);
	}
	for(int i=1;i<=n;i++){
		add(prv[a[i]]);
		for(int id:qry[i]){
			ans[id]-=get(x[id]);
		}
		prv[a[i]] = i;
	}
	for(int i=1;i<=q;i++){
		cout<<ans[i]<<endl;
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 33536
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  long long x,a=1,ans=5,b=0;
  cin>>x;
  b+=(x/11)*2;
  x%=11;
  while(x>0){
    if(ans==5){
      ans=6;
      x-=6;
   
    }
    else{
      ans-=6;
      ans+=5;
      x-=6;
    
    }
    b++;
  }
  cout<<b<<"\n";

  
  return 0;
}


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


long long n, k, a[100];

long long dp[101][256][101] = {};
long long mod = 1000000007;

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

    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int bit = 0; bit < 256; bit++){
            for(int num = 0; num <= n; num++){
                dp[i+1][bit][num] = dp[i][bit][num];
            }
        }
        for(int bit = 0; bit < 256; bit++){
            for(int num = 0; num <= n; num++){
                dp[i+1][bit^a[i]][num+1] += dp[i][bit][num];
                dp[i+1][bit^a[i]][num+1] %= mod;
            }
        }
    }

    long long ans = 0;
    long long fac = 1;
    for(int num = 0; num <= n; num++){
        //cout << dp[n][k][num] << endl;
        if(num){
            fac *= num;
            fac %= mod;
        }
        ans += fac * dp[n][k][num];
        ans %= mod;
    }
    cout << ans << endl;
}

    

Measured memory_bytes: 20480
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (b - a + 1) - ((b / c - (a - 1) / c) + (b / d - (a - 1) / d) - (b / (c * d / gcd(c,d)) - (a - 1) / (c * d / gcd(c, d)))) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main(){
 ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,m,k;
   cin>>n>>k;
   vector<long long int> A(n);
   for(int i=0;i<n;i++){
   	cin>>A[i];
   }
  sort(A.begin(),A.end());
  long long int mod=1000000007; 
   long long int ans=1;
    if (A[n - 1] == 0 && (k & 1)) 
        {
        	cout<<"0\n";
        	return 0;
		}
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (int i = n - 1; i >= n - k; i--) 
            ans=((ans%mod)*(A[i]%mod))%mod;
            cout<<(ans+mod)<<"\n";
            return 0;
    } 
    int i = 0; 
    int j = n - 1; 
    if (k & 1) { 
       ans=((ans%mod)*(A[j]%mod))%mod;
        j--; 
        k--; 
    } 
    k >>= 1; 
    for (int itr = 0; itr < k; itr++) { 
        long long int left_product =A[i]*A[i+1]; 
        long long int right_product = A[j]*A[j-1]; 
        if (left_product > right_product) { 
            ans=((ans%mod)*(left_product%mod))%mod; 
            i += 2; 
        } 
        else { 
            ans=((ans%mod)*( right_product%mod))%mod;
            j -= 2; 
        } 
    } 
    ans=(ans+mod)%mod;
    cout<<ans<<"\n"; 
   return 0;
}

Measured memory_bytes: 4784
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
def f(n):
    if n == 1:
        return 14
    return n
a,b = LI()
if f(a) < f(b):
    print("Bob")
elif f(a) == f(b):
    print("Draw")
else:
    print("Alice")
"""

#B
n,m = LI()
a = SR(n)
b = SR(m)
for y in range(n-m+1):
    for x in range(n-m+1):
        h = y+m
        w = x+m
        f = 1
        for i in range(y,h):
            for j in range(x,w):
                if a[i][j] != b[i-y][j-x]:
                    f = 0
                    break
            if not f:
                break
        if f:
            print("Yes")
            quit()
print("No")
#C
"""
n,m = LI()
v = LIR(m)
p2 = [1]
for i in range(n):
    p2.append(p2[-1]*2)
dp = [[0 for i in range(p2[n])] for j in range(n)]
dp[0][1] = 1
for i in range(1,p2[n]):
    for k in range(n):
        for a,b in v:
            a -= 1
            b -= 1
            if k==a or k == b:
                c = p2[a]
                d = p2[b]
                if i&c and not i&d:
                    dp[b][i|d] += dp[k][i]
                if (not i&c) and i&d:
                    dp[a][i|c] += dp[k][i]
ans = 0
for i in range(1,n):
    ans += dp[i][-1]
print(ans)
"""

#D
"""
n,p,q = LI()
v = [None for j in range(n)]
sa = 0
sb = 0
for i in range(n):
    a,b,c = LI()
    v[i] = [a,b,c]
    sa += a
    sb += b
dp = [[[float("inf") for i in range(sb+1)] for j in range(sa+1)] for k in range(n+1)]
dp[0][0][0] = 0
for i in range(n):
    for a in range(sa):
        for b in range(sb):
            ai,bi,ci = v[i]
            if a + ai <= sa and b + bi <= sb:
                dp[i+1][a+ai][b+bi] = min(dp[i+1][a+ai][b+bi],dp[i][a][b]+ci,dp[i][a+ai][b+bi])
            dp[i+1][a][b] = min(dp[i+1][a][b],dp[i][a][b])
li = [[p,q]]
while li[-1][0] <= sa and li[-1][1] <= sb:
    li.append([li[-1][0]+p,li[-1][1]+q])
li.pop(-1)
ans = float("inf")
for a,b in li:
    ans = min(ans,dp[n][a][b])
if ans == float("inf"):
    print(-1)
else:
    print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int a, b, k, s=0;
    cin >> a >> b >> k;
    for(int i=min(a,b); i!=0; i--)
    {
        if(a%i==0&&b%i==0)
            s++;
        if(s==k)
        {
        cout << i <<'\n';
        return 0;
        }
    }
}

Measured memory_bytes: 256
import math

def main():
    N = int(input())
    X = tuple(map(int, input().split()))
    Y = tuple(map(int, input().split()))

    for i in (1, 2, 3):
        print(dist(X, Y, N, i))
    max_ = -float('inf')
    for i in range(N):
        max_ = max(max_, abs(X[i] - Y[i]))
    print(max_)

def dist(x, y, n, p):
    ret = 0
    for i in range(n):
        ret += abs(x[i] - y[i]) ** p
    return round(math.pow(ret, 1 / p), 6)
    
main()

Measured memory_bytes: 7852
#include<iostream>
using ll = long long;
using namespace std;
int main(){
  ll S;cin>>S;
  ll v=1000000000;
  ll hoge=(v-S%v)%(v);
  ll hoge2=(hoge+S)/(v);
  cout<<0<<" "<<0<<" "<<v<<" "<<1<<" "<<hoge<<" "<<hoge2<<endl;
  //cout<<abs(hoge-hoge2*v)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
     int t,x,y;
}q[100010];
int main(void)
{
     int a,b,i,j,k,n,m;
     scanf("%d",&n);
     q[0].x=q[0].y=q[0].t=0;
     for(i=1;i<=n;i++)
     {
          scanf("%d%d%d",&q[i].t,&q[i].x,&q[i].y);
     }
     b=0;
     for(i=1;i<=n;i++)
     {
          k=abs(q[i].x-q[i-1].x)+abs(q[i].y-q[i-1].y);
          int t=q[i].t-q[i-1].t;
          if(k>t)
          {
               b=1;
               break;
          }
          else if(k<t)
          {
               t=t-k;
               if(t%2==1)
               {
                    b=1;
                    break;
               }
          }
     }
     if(b==0)
          printf("Yes\n");
     else
          printf("No\n");
     return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int a, b;
	cin>>a>>b;
	// if(a == b) cout<<0<<endl;
	// else if(a > b && b >= 0) cout<<a-b+1<<endl;
	// else if(a > b && a < 0) cout<< a-b+2<<endl;
	// else if(a > b) cout<< abs(abs(a) - abs(b)) + 1<<endl;
	// else if(a < b && a >= 0) cout<<b - a<<endl;
	// else if(a < b && b < 0) cout<< b-a<<endl;
	// else if(a < b) cout<< abs(abs(a) - abs(b)) + 1 << endl;
	ll ans = abs(abs(a)-abs(b));
	if(a > b){
		if(b > 0) ans += 2;
		else if(a >= 0) ans += 1;
		else ans += 2;
	}
	else{
		if(a >= 0) ;
		else if(b > 0) ans++;
		else ;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< VI > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;

template < typename T > inline void input_n( vector< T > &out ) { copy_n( istream_iterator< T >( cin ), out.size(), out.begin() ); };
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) (c).begin(), (c).end()
#define AALL( a, t ) (t*)a, (t*)a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define EM emplace
#define EB emplace_back
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int solve( int c, int n, int s )
{
	if ( c < 0 )
	{
		return n == 0 && s == 0;
	}

	return solve( c - 1, n, s ) + solve( c - 1, n - 1, s - c );
}


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

	for ( int n, s; cin >> n >> s, ( n | s ); cout << solve( 9, n, s ) << endl );

	return 0;
}

Measured memory_bytes: 1192
#A
"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""
#B

a, b, k = map(int, input().split())
for i in range(max(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)


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

const ll INIT = 0;
vector<ll> dat;
int N2;

void update(int k, int a) {
  k += N2 - 1;
  dat[k] = a;
  while (k > 0) {
    k = (k - 1) / 2;
    dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
}

int find(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) return INIT;
  if (a <= l && r <= b) return dat[k];
  else {
    int vl = find(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = find(a, b, k * 2 + 2, (l + r) / 2, r);
    return max(vl, vr);
  }
}

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

  ll MOD = 998244353;
  ll N; cin >> N;
  vector<pair<ll,ll>> XD(N);
  for (ll i = 0; i < N; i++) {
    ll x, d; cin >> x >> d;
    XD[i] = make_pair(x, d);
  }

  N2 = 1;
  while (N2 < N) N2 *= 2;
  dat = vector<ll>(2 * N2 - 1, INIT);
  
  sort(XD.begin(), XD.end());
  vector<ll> X(N);
  for (ll i = 0; i < N; i++) {
    X[i] = XD[i].first;
  }

  for (ll i = 0; i < N; i++) {
    ll i2 = N - 1 - i;
    pair<ll, ll> xd = XD[i2];
    ll r = xd.first + xd.second;
    ll l = lower_bound(X.begin(), X.end(), r) - X.begin();
    // auto l = lower_bound(XD.begin(), XD.end(), make_pair(r, 0));
    // ll l = lower_bound(XD.begin(), XD.end(), make_pair(r, 0)) - XD.begin();
    update(i2, i2);
    update(i2, find(i2, l, 0, 0, N2));
  }
  // cout << dat[0]; for (int i = 1; i < dat.size(); i++) { cout << ' ' << dat[i]; }
  // cout << '\n';

  vector<ll> dp(N + 1, 0);
  dp[N] = 1;
  for (ll i = 0; i < N; i++) {
    ll i2 = N - 1 - i;
    ll r = dat[i2 + (N2 - 1)];
    // cout << r << '\n';
    dp[i2] = (dp[i2 + 1] + dp[r + 1]) % 998244353;
  }
  cout << dp[0] << '\n';

  return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N,R=0;
	cin >> N;
	vector<int> d(N);
	for (int i=0; i<N; i++){
		cin >> d.at(i);
	}
	for (int i=0; i<N; i++){
		for (int j=i+1; j<N; j++){
			R += d.at(i)*d.at(j);
		}
	}
	cout << R << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  ll a, b, n;
  cin >> a >> b >> n;

  ll ans = 0;
  ll x = n;
  chmax(ans, ((a * x)/ b) - (a * (x/b)));
  x = n-1;
  chmax(ans, ((a * x)/ b) - (a * (x/b)));
  x = (n / b) * b - 1;
  chmax(ans, ((a * x)/ b) - (a * (x/b)));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define sz size()
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e17
    const int N=1e3+6;
    const int M=998244353;
    vector<int> a;
    int n,m;
    bool chk(int x)
    {
    	int temp=0;
    	for(int i=0;i<n;i++)
    	{
    		int tt=x-a[i];
    		int pp=lower_bound(a.begin(),a.end(),tt)-a.begin();
    		temp+=n-pp;
    	}
    	if(temp>=m)
    	return true;
    	return false;
    }
    signed main()
    {
        FAST
        cin>>n>>m;
        
        for(int i=0;i<n;i++)
        {
        	int pp;
        	cin>>pp;
        	a.pb(pp);
        }
        sort(a.begin(),a.end());
        int pre[n+2]={0};
        for(int i=n-1;i>=0;i--)
        pre[i]=pre[i+1]+a[i];
        int low=2,high=1e16;
        int ans=-1;
        while(low<=high)
        {
        	int mid=(low+high)/2;
        	if(chk(mid))
        	{
        		ans=mid;
        		low=mid+1;
        	}
        	else
        	high=mid-1;
        }
        int res=0,temp=0;
        //cout<<ans<<endl;
		for(int i=0;i<n;i++)
    	{
    		int tt=ans-a[i];
    		int pp=lower_bound(a.begin(),a.end(),tt)-a.begin();
    		temp+=n-pp;
    		res+=(pre[pp]+(n-pp)*a[i]);
    		//cout<<pre[pp]<<" "<<a[i]<<endl;
    	}
    	// cout<<temp<<endl;
    	res-=(temp-m)*ans;
    	cout<<res;
    }


Measured memory_bytes: 1908
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    
    //変数a, bを宣言と入力
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    //計算結果の表示
    
    System.out.printf("%d %d %.10f\n", a/b, a%b, (double)a/b);
        
    }
}


/*覚えよう！！
  
〇キャスト演算子・・・通常は宣言時のデータ型しか使用できない！！！

　　　　　　　　　　　しかし、キャスト演算子を使用することでデータの型を変更ができる
　　　　　　　　　　　
　　　　　　　　　　　注意：まず、変数の宣言をしないと、キャスト演算子は使用できない！！！！！！！！！！
　　　　　　　　
　　　　　　　　　　　
　・例：まず、変数を宣言　int a; ← int(整数)しか表現できない。　
　
　　　　system.out.println( a ); ⇒　表示は　1,  2 ,  3 , 4 ,  ･･････　小数は表現できない
　
　　　　system.out.println( (double)a ); ←  表示は　1.00 ,  2.10  ,  3.145  , 45.555 ,  ･･････　小数は表現できる
　
　
　・書き方: 変数名の前に括弧「（　）」と括弧内にデータ型を書く ⇒　答え：　(double)a  と書く
　

*/
   
   
/*前回の内容！！
 
〇import java.util.Arrays;は重要↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
 
・Arrays：ソート（並べ変え）や検索など、配列を操作するための機能
 
・並べ変えするとき
　import java.util.Arrays;を上に書く
　class Main内に Arrays.sort(a); と書く　←　このとき()内は配列の変数名
　
〇配列とは、同じ変数名に複数の値を入力できる箱
 
　※イメージ
    前回まで、a = 1, b = 2, c = 3など各変数名は1箱に値を代入できない
    今回の配列はa[0] = 1, a[1] = 2, a[2] = 3 のように変数名aは3つの箱に値を代入できる。
    注意：配列の箱は｢ 0 ｣から開始する
 
 
・複数のif(条件)：かつ｢ && ｣とまたは｢ || ｣の２つを使用する
　※かつ｢ && ｣：「真 && 真 = 真」, 「真 && 偽 = 偽」, 「偽 && 真 = 偽」 ,「偽 && 偽 = 偽」の4つの条件
　　または｢ || ｣：「真 && 真 = 真」, 「真 && 偽 = 真」, 「偽 && 真 = 真」 ,「偽 && 偽 = 偽」の4つの条件
 
 
・関係を比較する：if(条件式)
　例：if(2 < 3) この条件は｢真（成立）｣　→　何か命令があれば実行する
　　　if(5 < 3) この条件は｢偽（不成立）｣　→　何か命令があれば実行しない
　　　
・比較の条件式：等しいか比較｢==｣、等しくないか比較｢!=｣ 
　　　　　　　　大きいか比較｢<｣、小さいか比較｢>｣
　　　　　　　　以上の比較｢<=｣、以下の比較｢>=｣
  
  
・else；ifの条件以外の場合に使用する。
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else System.out.println("傘を持って行かない");
　
  
・else if：詳細な場合分けしたいときに使用
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else if(雨 == 午後から降るかも) System.out.println("念のため傘を持って行く");
　　　else System.out.println("傘を持って行かない");
  
 
  
・変数に計算結果を代入する：面積　＝　縦　×　横
　※計算は変数名でも数値でもいける
   
・四則演算：足し算｢＋｣、引き算｢－｣、掛け算｢＊｣、割り算｢／｣
　1 + 2 = 3;
　4 - 3 = 1;
　2 * 5 = 10;
　8 / 2 = 4;
   
・余りの計算：割り算の余り｢％｣
  5 % 3 = 2;
     
     
・printlnの複数表示：｢＋｣を使用
　例：println("Kobe" + "Kagikou"); = KobeKajikou
　　　println("明治 + 20 + "年"); = 明治20年　数値が入ってもOK！
   
   
   
・変数の宣言は｢型｣と｢変数名｣の２つ必要
　例：型＿変数名　→　int x;
　
・キーボードから入力するときは・・・｢ import java.util.Scanner; ｣ と ｢  Scanner sc = new Scanner(System.in) ; ｣が必要
   
・入力するとき・・・変数名 = sc.nextInt(); nextの後は型を書く、頭文字は大文字　
　※  scは変更しても大丈夫しかし全て変更後の文字に統一　例：nyuryoku
   
・println・・・画面に出力するときに使用
   
・文字列の表示・・・"〇〇〇の間に入力"ことが約束
   
*/


Measured memory_bytes: 26484
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//


ll n, h[100100];
ll dp[100100];

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

  for(int i = 0; i < 100100; i++) dp[i] = inf;
  dp[0] = 0;

  for(int i = 0; i < n; i++) {
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
  }

  cout << dp[n-1] << endl;
}




Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    ll ans=0;
    vector<ll> minus;
    vector<ll> plus;
    rep(i,N){
        ll tmp; cin>>tmp;
        if(tmp<0) minus.pb(tmp);
        else plus.pb(tmp);
    }
    sort(all(plus));
    sort(all(minus));
    if(sz(minus)%2==0){
        rep(i,sz(minus)){
            ans-=minus[i];
        }
        rep(i,sz(plus)){
            ans+=plus[i];
        }
    }
    else{
        rep(i,sz(minus)-1){
            ans-=minus[i];
        }
        rep1(i,sz(plus)-1){
            ans+=plus[i];
        }
        if(sz(plus)>0) ans+=abs(abs(minus[sz(minus)-1])-abs(plus[0]));
        else ans+=minus[sz(minus)-1];
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4476
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, A[SIZE], counter[SIZE] = {};

  scanf("%d", &N);

  ll ans = 0;

  for (int i = 0; i < N; i++) {
    scanf("%d", A + i);
    ans += counter[A[i]];
    counter[A[i]]++;
  }

  for (int i = 0; i < N; i++) {
    printf("%lld\n", ans - (counter[A[i]] - 1));
  }

  return 0;
}

Measured memory_bytes: 5344
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    string N;
    cin >> N;
    ll now = 0;
    for(auto e: N){
        now+=(e-'0');
    }
    cout << (now%9==0?"Yes":"No") << '\n';
}


Measured memory_bytes: 3728
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  k=I()
  st=7
  if k==1 or k==7:
    return 1
  for i in range(1,1000001):
    st+=7*pow(10,i,k)
    st%=k
    if st==0:
      return i+1

  return -1

# main()
print(main())


Measured memory_bytes: 10732
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

void disp(vector<ll> cand){
	rep (i, cand.size()){
		cerr << cand[i] << ' ';
	} // end rep
	cerr << endl;
}

ll s2ll(string s){
	stringstream ss(s);
	ll res;
	ss >> res;

	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;
	int n = S.length();

	ll res = 0LL;
	for (int i = 0; i < (1<<(n-1)); ++i){
		int prev = 0;
		vector<ll> cand; cand.clear();
		for (int j = 0; j < (n-1); ++j){
			if (i & (1<<j)){
				string T = S.substr(prev, j - prev + 1);
				ll val = s2ll(T);
				cand.push_back(val);
				prev = j + 1;
			} // end if
		} // end for
		string T = S.substr(prev);
		ll val = s2ll(T);
		cand.push_back(val);
//		disp(cand);
		res += accumulate(ALL(cand), 0LL);
	} // end for
	
	cout << res << endl;			

	return 0;
}

Measured memory_bytes: 256
open System
open System.Collections.Generic;

let input=stdin.ReadLine().Split()|>Array.map int
let N=input.[0]
let K=input.[1]
let Q=input.[2]
[<EntryPoint>]
let sf argv =
    let mutable P =[|for i in [0..N-1] -> K-Q|]
    for i in [0..Q-1] do
        let A =stdin.ReadLine()|> int
        P.[A-1] <- P.[A-1] + 1
    for i in [0..N-1] do
        match P.[i] > 0 with
        |true -> printf "Yes\n"
        |_ -> printf "No\n"
    0 


Measured memory_bytes: 27852
import sys
n = int(input())
ps = [list(map(int, input().split())) for _ in range(n)]

if n == 1:
	#x, y, h = map(int, input().split())
	print(ps[0][0], ps[0][1], ps[0][2])
else:
	for X in range(101):
		for Y in range(101):
			valid = True
			const = -1
			for p in ps:
				x, y, h = p[0], p[1], p[2]
				if h != 0:
					if const < 0:
						const = abs(X - x) + abs(Y - y) + h
					else:
						if abs(X - x) + abs(Y - y) + h != const:
							valid = False
							break
				else:
					if const >= 0:
						if const - abs(X - x) - abs(Y - y) > 0:
							valid = False
							break
			for p in ps:
				x, y, h = p[0], p[1], p[2]
				if h == 0:
					if const >= 0:
						if const - abs(X - x) - abs(Y - y) > 0:
							valid = False
							break

			if valid == True:
				print(X, Y, const)
				sys.exit()

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

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

    int N;
    cin >> N;

    cout << N << ":";

    for (int i=2; i*i<=N; ++i) {
        while (N % i == 0) {
            N /= i;
            cout << " " << i;
        }
    }

    if (N > 1) cout << " " << N;

    cout << endl;
}


Measured memory_bytes: 3220
#include <iostream>
using namespace std;
int main(){
  char C[6] = {'A','B','C','D','E','F'};
  char A,B;
  int a,b;
  cin >> A >> B;
  for(int i = 0; i < 6; i++){
    if(C[i] == A) a = i;
    if(C[i] == B) b = i;
  }
  if(a > b) cout << ">" << endl;
  else if(a < b) cout << "<" << endl;
  else cout << "=" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;

int main() {
	int n;
	cin>>n;
	vector<int> dp(n), a(n);
	for(int &i : a) {
		cin>>i;
	}
	rep(i, 0, n)
		dp[i] = INT_MAX;
	dp[0] = 0;
	for(int i = 0; i < n; i++) {
		for(int k = 1; k <= 2; k++) {
			dp[i + k] = min(dp[i] + abs(a[i] - a[i + k]), dp[i + k]);
		}
	}
	cout<<dp[n  - 1];
	return 0;
}


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

using namespace std;

#define sp << " " <<

long long a[3000];

long long r(long long n)
{
    long long dp[n][n];
    for(long long i=0;i<n;i++)
    {
        for(long long d=0,p=i;p<n;d++,p++)
        {
            long long s=((d+2)<=p)?dp[d+2][p]:0;
            long long h=((d+1)<=(p-1))?dp[d+1][p-1]:0;
            long long t=(d<=(p-2))?dp[d][p-2]:0;
            dp[d][p]=max(a[d]+min(s,h),a[p]+min(h,t));
        }
    }
    return dp[0][n-1];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,b=0;
    cin >> n;
    for(long long d=0;d<n;d++)
    {
        cin >> a[d];
        b+=a[d];
    }
    long long m=r(n);
    cout << 2*m-b;
    return 0;
}

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

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<pair<long long int,long long int>> drink;
    for(int i=0; i<N; i++) {
        int A, B;
        cin >> A >> B;
        drink.emplace_back(A, B);
    }
    sort(drink.begin(), drink.end());

    long long int price = 0;
    for(int j=0; j<N; j++) {
        if(drink.at(j).second < M) {
            M -= drink.at(j).second;
            price += drink.at(j).first * drink.at(j).second;
        } else {
            price += drink.at(j).first * M;
            break;
        }
    }
    cout << price << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;



VV G;
int s, t;

int dfs(int u, int p=-1) {
  if (u == s) return 1;
  if (u == t) return 2;
  for (int v : G[u]) if (v != p) {
    int z = dfs(v, u);
    if (z) return z;
  }
  return 0;
}


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

  G.assign(n, V());
  V dg(n);

  rep(_, m) {
    int u, v; cin >> u >> v;
    u--; v--;
    G[u].push_back(v);
    G[v].push_back(u);
    ++dg[u];
    ++dg[v];
  }

  rep(i, n) if (dg[i]%2) {
    cout << "No" << "\n";
    return 0;
  }

  V cnt(7);
  rep(i, n) ++cnt[min(dg[i], 6)];

  bool ans = false;
  int z = cnt[4] + 2*cnt[6];
  if (z >= 3) ans = true;
  else if (z <= 1) ans = false;
  else if (cnt[6] >= 1) ans = true;
  else {
    int i = 0;
    for (; i < n; ++i) {
      if (dg[i] == 4) {
        s = i;
        break;
      }
    }
    for (++i; i < n; ++i) {
      if (dg[i] == 4) {
        t = i;
        break;
      }
    }

    int k = 0;
    for (auto &u : G[s]) {
      int z = dfs(u, s);
      if (z == 2) ++k;
    }
    if (k == 4) ans = false;
    else ans = true;
  }

  cout << (ans ? "Yes" : "No") << "\n";
  return 0;
}

Measured memory_bytes: 7296
#include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)


//??????????????°?????????(????????´??°or??????) verified AOJ DSL_2,DSL_3
template<class T>
class segtree{
private:
    vector<T> dat;
    int _size;  //the number of leaves
    T _init;
    
public:
    segtree(int __size=0 , T init=numeric_limits<T>::max() ):_size(__size) , _init(init) , dat(4*__size,init){
        if(__size==0)return ;
        int x=1;
        while(x<_size)x*=2;
        _size = x;
    }
    
    void update(int m,T x){
        int i = m+_size;
        //      dat[i] += x;   If uou want addition when update.
        dat[i] = x;
        while(i!=1){
            dat[i/2] = min(dat[i],dat[i^1]);
            i/=2;
        }
    }
    
    // call find(s,t)
    T find(int s,int t,int num=1,int a=0,int b=-1){
        if(b==-1)b=_size-1; //I couldn't "int b=_size".
        if(b<s||t<a)return _init;
        if(s<=a&&b<=t)return dat[num];
        return min( find(s,t,num*2,a,(a+b)/2) , find(s,t,num*2+1,(a+b)/2+1,b) );
    }
    int size(){return _size;}
};

/*
 segtree<int> x(100);                                                //100 datas
 segtree<pair<int,int>> x( 100,make_pair( 1<<31-1 , 1<<31-1 ) );     //100 datas
 */



int main(){
    int n,q;
    cin>>n>>q;
    segtree<int> st(n);
    rep(i,q){
        int com,x,y;
        cin>>com>>x>>y;
        
        if(com==0)st.update(x,y);
        else cout<<st.find(x,y)<<endl;
    }
}

Measured memory_bytes: 4412
#include <stdio.h>

int main(void){
	int a,b,c;
	do{
		scanf("%d %d %d",&a,&b,&c);
	}while(a<0 || a>100 || b<0 || b>100 || c<0 || c>100);
	
	if(a<b){
		if(b<c)
			puts("Yes");
		else
			puts("No");
	}else
		puts("No");	

	return 0;
}

Measured memory_bytes: 580
#include <tuple>
#include <iostream>
#include <algorithm>
using namespace std;
int P[10010]; 
tuple<int,int,int> a[10010];
void init(int N) { 
    for (int i=0; i<N; ++i) P[i] = i;
}
int root(int a) { 
    if (P[a] == a) return a; 
    return (P[a] = root(P[a])); 
}
bool is_same_set(int a, int b) {
    return root(a) == root(b);
}
void unite(int a, int b) {
    P[root(a)] = root(b);
}
int main(void){
    int n,value;
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> value;
            a[n*i+j] = make_tuple(value,i,j);
        }
    }
    init(n*n);
    sort(a,a+n*n);
    int sum =0;
    int x,y;
    for(int i =0;i<n*n;i++){
        x = get<1>(a[i]);
        y = get<2>(a[i]);
        if(is_same_set(x,y)!=1){
            if(get<0>(a[i])!=-1){
                sum += get<0>(a[i]);
                unite(x,y);
            }
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e4+4;
ll n,p[N],a[N],b[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=1;i<=n;i++)cin>>p[i];
    for(ll i=1;i<=n;i++)a[i] = i*(n+2);
    for(ll i=1;i<=n;i++)b[p[i]]=1e9 - a[p[i]]+i;
    for(ll i=1;i<=n;i++)cout<<a[i]<<" ";cout<<"\n";
    for(ll i=1;i<=n;i++)cout<<b[i]<<" ";cout<<"\n";
}



Measured memory_bytes: 1152
import sys

input = sys.stdin.readline

def main():
    n,k = map(int,input().split())

    ans = 0
    for i in range(n):
        p = 1
        tokuten = i+1
        while k-1 >= tokuten:
            p /= 2
            tokuten *= 2
        ans += p/n

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39536
D = 10**9+7
S = input()
mod_table = [[0]*13]
mod_table[0][0] = 1

for i, s in enumerate(S):
    mod_table.append([0]*13)
    if s == "?":
        for num in range(10):
            for d in range(13):
                mod_table[i+1][(d*10+num)%13] += mod_table[i][d]
    else:
        num = int(s)
        for d in range(13):
            mod_table[i+1][(d*10+num)%13] += mod_table[i][d]
    mod_table[i+1] = [m%D for m in mod_table[i+1]]

print(mod_table[-1][5] % D)

Measured memory_bytes: 68444
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << min(A+B+1, C)+B << endl;
  return 0;
}

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

void main() {
    int N = readln.chomp.to!(int);
    int[] a = readln.chomp.split.to!(int[]);

    int ans;
    for (int i = 0; i < a.length - 1; i++) {
        if (a[i] == a[i + 1]) {
            ans += 1;
            i += 1;
        }
    }

    writeln(ans);
}


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();
    List<List<Integer>> from = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      from.add(new ArrayList<>());
    }
    
    for (int i = 0; i < N-1; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      from.get(a-1).add(b-1);
      from.get(b-1).add(a-1);
    }
    int[] c = new int[N];
    for (int i = 0; i < N; i++) {
      c[i] = sc.nextInt();
    }
    Arrays.sort(c);
    
    int idx = N-1;
    int[] d = new int[N];
    boolean[] visit = new boolean[N];
    long M = 0;
    Queue<Integer> q = new LinkedList<>();
    d[0] = c[idx--];
    q.offer(0);
    visit[0] = true;
    while (!q.isEmpty()) {
      int now = q.poll();
      for (int next : from.get(now)) {
        if (!visit[next]) {
          d[next] = c[idx--];
          M += Math.min(d[now], d[next]);
          q.offer(next);
          visit[next] = true;
        }
      }
    }
      
    StringBuilder ans = new StringBuilder();
    ans.append(M+"\n");
    for (int i = 0; i < N; i++) {
      ans.append(d[i]);
      if (i < N-1) {
        ans.append(' ');
      } else {
        ans.append('\n');
      }
    }
    System.out.print(ans.toString());
  }
}

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

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;
lint Q, H, S, D, N;

int main(void) {
	scanf("%lld %lld %lld %lld %lld", &Q, &H, &S, &D, &N);

	H = std::min(H, Q * 2);
	S = std::min(S, H * 2);
	D = std::min(D, S * 2);

	lint ans = 0;
	ans += N / 2 * D;
	N %= 2;
	ans += N / 1 * S;

	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int x, y;
	cin >> x >> y;
	bool ok = false;
	rep(i, x+1) {
		int j = x - i;
		int leg = i*2 + j*4;
		if (leg == y) ok = true;  
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	if sc.Scan() {
		s := sc.Text()
		switch s {
		case "a", "i", "u", "e", "o":
			os.Stdout.WriteString("vowel")
		default:
			os.Stdout.WriteString("consonant")
		}
	}
}


Measured memory_bytes: 640
#define N 100
main()
{ 
  int a,b[N],i,key,j,l;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  for(i=0;i<a;i++)
    {
      key=b[i];
      j=i-1;
      while(j>=0&&b[j]>key){
	b[j+1]=b[j];
	j--;
      }
      b[j+1]=key;
      for(l=0;l<a-1;l++)
	{
	  printf("%d ",b[l]);
	}
      printf("%d",b[l]);
      printf("\n");
    }
  return 0;
}

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

int main(){
    int N; cin >> N;
    int a[N]; cin >> a[0];
    int X = a[0];
    for (int i = 1; i < N; i++)
    {
        cin >> a[i];
        X = X xor a[i];
    }
    for (int i = 0; i < N; i++)
    {
        int ans = X xor a[i];
        cout << ans << endl;
    }
    
    
}	


Measured memory_bytes: 4392
#include <iostream>
#include <vector>
#include <set>
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int &x : a) cin >> x;
  for (int &x : b) cin >> x;
  set<int> s(b.begin(), b.end());
  if (s.size() == n) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  rep(i, n) cout << a[0] << " \n"[i == n - 1];
  rep(i, n) cout << (s.count(a[i]) ? a[0] : a[1]) << " \n"[i == n - 1];
}


Measured memory_bytes: 8392