akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=20000001;


int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n,m;
      cin>>n>>m;
      string a[n];
      for(int i=0;i<n;i++) cin>>a[i];
      int r[n][m];
      int c[n][m];
      for(int i=0;i<n;i++) for(int j=0;j<m;j++) r[i][j]=0,c[i][j]=0;
      for(int i=0;i<n;i++)
      {
            int cnt=-1;
            for(int j=0;j<m;j++)
            {
                  if(a[i][j]=='#')
                  {
                        cnt=j;
                  }
                  else{
                        r[i][j]+=(j-cnt-1);
                  }
            }
            cnt=m;
            for(int j=m-1;j>=0;j--)
            {
                  if(a[i][j]=='#')
                  {
                        cnt=j;
                  }
                  else{
                        r[i][j]+=(cnt-j-1);
                  }     
            }
      }
      for(int j=0;j<m;j++)
      {
            int cnt=-1;
            for(int i=0;i<n;i++)
            {
                  if(a[i][j]=='#')
                  {
                        cnt=i;
                  }
                  else{
                        c[i][j]+=(i-cnt-1);
                  }
            }
            cnt=n;
            for(int i=n-1;i>=0;i--)
            {
                  if(a[i][j]=='#')
                  {
                        cnt=i;
                  }
                  else{
                        c[i][j]+=(cnt-i-1);
                  }     
            }
      }
      int ans=0;
      for(int i=0;i<n;i++)
      {
            for(int j=0;j<m;j++)
            {
                  if(a[i][j]=='#') continue;
                  // cout<<c[i][j]<<" ";
                  ans=max(ans,r[i][j]+c[i][j]+1);
            }
            // cout<<"\n";
      }
      cout<<ans;
}
// nothing is impossible

Measured memory_bytes: 67072
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
 int A,B;
 cin>>A>>B;
 if(A==1){A=14;}
 if(B==1){B=14;}
 if(A>B){cout<<"Alice"<<endl;}
 else if(A<B){cout<<"Bob"<<endl;}
 else if(A==B){cout<<"Draw"<<endl;}
 return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fori(i,a,n) for(i=a;i<=n;i++)
#define ford(i,n,a) for(i=n;i>=a;i--)
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
ull n,k;
int main()
{
	cin>>n>>k;
	n=n%k;
	cout<<min(n,k-n)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
//#include<cstring>
//#include<cmath>
//#include<cstdio>
//#include<algorithm>
using namespace std;

long long len,x,y,a;

int main(){  
    cin>>x>>y;
    a=x;
    while(a<=y){
    	len++;
		a*=2;
	}
	cout<<len<<endl;
	return 0;
}  

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

using namespace std;

int main(void){

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

    cout << max(a+b, max(a-b, a*b)) << endl;

    return 0;
}

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

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    
    vector<int> B(M);
    vector<vector<int>> A(N, vector<int>(M));

    for(int i = 0; i < M; i++) cin >> B[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        int s = 0;
        for(int j = 0; j < M; j++){
            s += A[i][j] * B[j];
        }
        if(s + C > 0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    // https://atcoder.jp/contests/abc147/submissions/8921445
    // 3
    // 1 2
    // 1 3
    // 1 4
    // のようなタイプ
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        N : usize,
        arr : [usize;N],
    );

    let N : usize = N;
    let mut serch = 1;
    let mut ans :i32 = 0;
    for i in 0..N{
        if arr[i] == serch{
            serch += 1;
        }
        else {
            ans += 1;
        }
    }
    if ans == N as i32{
        ans = -1;
    }
    println!("{}",ans);
}

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for(int i=a; i<=b; i++) {
        if(i % k == 0) {printf("OK\n"); return 0;}
    }
    printf("NG\n");
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[200010];
ll kai[200010];
ll beki(ll n,ll k){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=mod;
    }
    now*=now;
    now%=mod;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n){
  return beki(n,mod-2);
}
void nckinit(ll n){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=mod;
  }
  gya[n]=gyaku(kai[n]);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=mod;
  }
  gya[0]=1;
}    
ll nck(ll n,ll k){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  ret*=gya[k];
  ret%=mod;
  return ret;
}
ll npk(ll n,ll k){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  return ret;
}

int main(){
  
  string s;cin>>s;
  ll d;cin>>d;
  ll n=s.size();
  ll dp[n+1][d][2];
  memset(dp,0,sizeof dp);
  dp[0][0][1]=1;
  rep(i,0,n){
    rep(j,0,d){
      rep(k,0,10){
        int uu=s[i]-'0';
        (dp[i+1][(j+k)%d][0]+=dp[i][j][0])%=mod;
        if(k<uu)(dp[i+1][(j+k)%d][0]+=dp[i][j][1])%=mod;
        if(k==uu)(dp[i+1][(j+k)%d][1]+=dp[i][j][1])%=mod;
      }
    }
  }
  cout<<(dp[n][0][0]+dp[n][0][1]-1+mod)%mod<<endl;
  
}
      


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int &i : v) cin >> i;
    vector<int> t = v;
    if (prev_permutation(t.begin(), t.end())) {
        for (int i = 0; i < n; i++) {
            cout << t[i];
            if (i != n - 1) cout << " ";
            else cout << endl;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << v[i];
        if (i != n - 1) cout << " ";
        else cout << endl;
    }
    if (next_permutation(v.begin(), v.end())) {
        for (int i = 0; i < n; i++) {
            cout << v[i];
            if (i != n - 1) cout << " ";
            else cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3152
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		long K = input.nextLong();
		long ans = 0;
		long[][] arr = new long[N][2];
		for (int i = 0; i < N; i++) {
			arr[i][0] = input.nextInt();
			arr[i][1] = input.nextInt();
		}
		Arrays.sort(arr,(a,b)->Long.compare(a[0],b[0]));
		for (int i = 0; i < N; i++) {
			ans = arr[i][0];
			K-=arr[i][1];
			if (K<=0) break;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 90596
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;
int main()
{
	int n,i,a[105],num=0;
	double sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	int avg;
	if(sum>0) avg=(int)(sum/n+0.5);
	else avg=(int)(sum/n-0.5);
	for(i=0;i<n;i++){
		num+=((a[i]-avg)*(a[i]-avg));
	}
	printf("%d\n",num);
}

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

// UnionFind


struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
  int N , M ; 
  cin >> N >> M ; 
  UnionFind uf(N) ; 
  for(int i = 0 ; i < M ; i++){
    int A ,B ;
    cin >> A >> B ; 
    A-- ; B-- ; 
    uf.unite(A,B) ; 
  }
  map<int , int > MAP ; 
  for(int i= 0 ; i < N ; i++){
    uf.find(i) ; 
    MAP[uf.find(i)]++ ; 
    //cout << uf.find(i) << endl;
  }
  cout << MAP.size()-1 << endl; 
}

Measured memory_bytes: 7656
program test01
 implicit none
 character a
 character alfa(26)
 integer i

 alfa(1)='a'
 alfa(2)='b'
 alfa(3)='c'
 alfa(4)='d'
 alfa(5)='e'
 alfa(6)='f'
 alfa(7)='g'
 alfa(8)='h'
 alfa(9)='i'
 alfa(10)='j'
 alfa(11)='k'
 alfa(12)='l'
 alfa(13)='m'
 alfa(14)='n'
 alfa(15)='o'
 alfa(16)='p'
 alfa(17)='q'
 alfa(18)='r'
 alfa(19)='s'
 alfa(20)='t'
 alfa(21)='u'
 alfa(22)='v'
 alfa(23)='w'
 alfa(24)='x'
 alfa(25)='y'
 alfa(26)='z'

 read *, a

 do i=1,26
 if ( a==alfa(i) ) then
  a=alfa(i+1)
  exit
 end if
 end do

 print '(A)', a

endprogram test01


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    #ifdef TarekHasan
        freopen("input.txt","r",stdin);
    #endif // TarekHasan
    int n,x,t; cin >> n >> x >> t;

    if(n%x==0)
        cout << (n/x)*t << endl;
    else
        cout << ((n/x)+1)*t << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int a,b,k;

void input(){
    cin >> a >> b >> k;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    vector<int> ans;
    k = min(k, (b-a+1)/2+1);
    for(int i=0;i<k;i++){
        ans.push_back(a+i);
    }
    for(int i=k-1;i>=0;i--){
        ans.push_back(b-i);
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    for(int i=0;i<ans.size();i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;

int main() {
	char s;
	cin >> s;
	if (65 <= s && s <= 90) cout << "A" << endl;
	else cout << "a" << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int N ,A, B;

	cin >> N >> A >> B;

	if (B > A * N) {
		cout << A * N ;

	}
	
	else {
		cout << B ;
	}
}

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

int ans = 0;
signed main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int n; cin >> n;
	
	vector<int> tri;
	
	for(int i = 0;i < 10000;i++){
		tri.push_back((i)*(i+1)/2);
	}
	
	for(int p = 2;p <= 1000000;p++){
		int cnt = 0;
		while(n % p == 0){
			n /= p;
			cnt++;
		}
		
		int d = upper_bound(tri.begin(),tri.end(),cnt) - tri.begin();
		d--;
		
		ans += d;
		
	}
	
	if(n != 1) ans++;
	
	cout << ans;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    sort(a.rbegin(), a.rend());
    if(a[0] - a.back() > 1) finish("No");
    if(a[0] == a.back() + 1){
        int x = 0;
        while(a.back() != a[0]){
            x++;
            a.pop_back();
        }
        for(auto &i : a) i -= x;
    }
    else if(a[0] == n - 1) finish("Yes");
    n = a.size();
    if(a[0] > 0 && 2 * a[0] <= n) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
  long long A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  long long sum, tmp;
  
  
  for(int i=0; i<max(X, Y)+1; i++){
 	tmp = i*C*2;
    if(X>i) tmp += (X-i)*A;
    if(Y>i) tmp += (Y-i)*B;
    
    sum = min(sum, tmp);
 
  }
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,j,N,H,W,f,ans=0;
  cin>>N;
  vec v(N);
  rep(i,N)cin>>v[i];
  v.push_back(-1);
  vsort(v);
  rep1(i,N+1){
    For(j,i+1,N+1){
      H=upper_bound(all(v),v[j]-v[i])-v.begin();
      W=lower_bound(all(v),v[j]+v[i])-v.begin();
      f=0;
      if(H<=i&&i<W)f++;
      if(H<=j&&j<W)f++;
      ans+=max(W-H-f,0LL);
    }
  }
  cout<<ans/3LL<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
typedef long long ll;

using namespace std;
char a[200010];
int sum[200010];
int dp[(1<<26)+1];
int main()
{
    cin >> a;
    int len = strlen(a);
    sum[0] = 0;
    for(int i = 1; i <= len; i++)sum[i] = sum[i-1]^(1<<(a[i-1]-'a'));
    memset(dp, 127, sizeof(dp));
    dp[0] = 0;
    int ans;
    for(int i = 0; i < len; i++)
    {
        int best = dp[sum[i+1]];
        for(int j = 0; j < 26; j++)
        {
            best = min(best, dp[sum[i+1]^(1<<j)]);
        }
        best++;
        dp[sum[i+1]] = min(dp[sum[i+1]], best);
        ans = best;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 263424
import sys

N = sys.stdin.readline().strip()

if len(N) == 1:
    print(N)
else:
    N2 = N[1:]
    if all(map(lambda d: d == '9', N2)):
        print(sum(map(int, N)))
    else:
        print(int(N[0]) - 1 + 9 * len(N2))


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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 GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	if (a <= 8 && b <= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<utility>
using namespace std;
struct dir
{
	int x,y;
}dir[4]={{-1,0},{1,0},{0,-1},{0,1}};
char hole[1005][1005];
int d[1005][1005],h,w,factory[10][2];
typedef pair<int,int> P;
int bfs(const int &sx,const int &sy,const int &gx,const int &gy)
{
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			d[i][j] = -1;
		}
	}
	//memset(d,-1,sizeof(d));
	queue<P> que;
	que.push(P(sx,sy));
	d[sx][sy]=0;
	while(que.size())
	{
		P p=que.front();
		que.pop();	
		if(p.first==gx&&p.second==gy)
		break;
		for(int i=0;i<4;i++)
		{
		int nx=p.first+dir[i].x;
		int ny=p.second+dir[i].y;
		if(nx>=0&&ny>=0&&nx<h&&ny<w&&hole[nx][ny]!='X'&&d[nx][ny]==-1)
		{
			d[nx][ny]=d[p.first][p.second]+1;
			que.push(P(nx,ny));
		}
		}
	}
	return d[gx][gy];
}
int main()
{
	int sx,sy,i,j,step=0,n;
	scanf("%d%d%d\n",&h,&w,&n);
	//cin>>h>>w>>n;
	for(i=0;i<h;i++,getchar())
		for(j=0;j<w;j++)
		{
			scanf("%c",&hole[i][j]);
			if(hole[i][j]=='S')
			{
				factory[0][0]=i;
				factory[0][1]=j;
				hole[i][j]='.';
			}
			if(isdigit(hole[i][j]))
			{
				int index=hole[i][j]-'0';
			factory[index][0]=i;
			factory[index][1]=j;
			}
		}
	for(i=0;i<n;i++)
	step+=bfs(factory[i][0],factory[i][1],factory[i+1][0],factory[i+1][1]);
	//cout<<step<<endl;
	printf("%d\n",step);
	return 0;
 } 

Measured memory_bytes: 6140
import itertools

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

s = [i for i in range(n)]

path = list(itertools.permutations(s, len(s)))

ans = 0

for i in range(len(path)):
    for j in range(n-1):
        ans += ((li[path[i][j]][0] - li[path[i][j+1]][0]) ** 2 + (li[path[i][j]][1] - li[path[i][j+1]][1]) ** 2) ** 0.5
        
print(ans/len(path))


Measured memory_bytes: 13868
alist=[]

while True:
	i=[int(x) for x in input().split()]
	if i[0] == 0 and i[1] == 0:
		break
	else:
		alist.append(i)

for j in range(len(alist)):
	alist[j].sort()
	print(alist[j][0],alist[j][1])




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

using namespace std;

int main () {
  int x, n;
  cin >> x >> n;
  vector <bool> used(1e4);
  for (int i = 0; i < n; i++) {
    int val;
    cin >> val;
    used[val] = true;
  }
  int it1 = x;
  while (used[it1]) it1++;
  int it2 = x;
  while (used[it2]) it2--;
  if (x - it2 <= it1 - x) cout << it2;
  else cout << it1;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
//scanf("%lld",&a);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector<long long>v,u;
    pair<long long, long long>n;
    set<string>y;
    long long a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r=0,z,m,h,p[200001];
    string t,s,x,q;
    double w;
    cin>>a>>b;
    d=1;
    for(i=1;i<=a;i++){
        cin>>p[i];
    }
    for(i=b+1;i<=a;i++){
        if(p[i]>p[i-b]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+100;
int main()
{
	int c[maxn],num[maxn],n,q,k,x;
	memset(num,0,sizeof num);
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=q;i++)
	{
		scanf("%d",&x);
		num[x]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(num[i]<=q-k) puts("No");
		else puts("Yes");
	}
	return 0;
}

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

int main(){
  int h,n;
  cin >> h >> n;
  vector<int> a(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  if(h <= sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
x,n = list(map(int, input().split()))
lst = list(map(int, input().split()))

dif = float("INF")
ans = 0

for i in range(102):
    if i not in lst:
        if dif>abs(i-x):
            dif = abs(i-x)
            ans = i
        elif dif==abs(i-x):
            ans = min(ans,i)

print(ans)


Measured memory_bytes: 9128
from scipy.sparse.csgraph import dijkstra as di

n,m = map(int, input().split())
edges = []
grid = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    grid[a][b] = grid[b][a] = c
    edges.append((a,b,c))

g = di(grid)
ans = 0
for a,b,c in edges:
    if g[a][b] < c:
        ans += 1
print(ans)


Measured memory_bytes: 14080
// https://atcoder.jp/contests/arc088/tasks/arc088_c
// 転倒数
// Binary Index Tree
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int,int> P;

#define MAX_N 200005
#define A_NUM 30 // Number of alphabets
int a[MAX_N];
struct BinaryIndexTree{
	int n,tree[MAX_N+1];
	BinaryIndexTree(int _n){
		memset(tree,0,sizeof(tree));
		n=_n;
	}
	int sum(int i){
		int s=0;
		for(int j=i;j>0;j-=j&-j) s+=tree[j];
		return s;
	}
	void add(int i,int v){
		assert(i>0);
		for(int j=i;j<=n;j+=j&-j) tree[j]+=v;
	}
};
int main() {
	string s;
	cin >> s;
	int s_num = s.size();
	deque<int> freq[A_NUM];

	rep(i,s_num) freq[(int)s[i]-97].push_back(i); // (int)'a'=97
	int odd_num=s_num%2;
	// 奇数の文字が1種類以上あれば -1
	rep(k,A_NUM){
		if(freq[k].size()%2 == 1){
			if(!odd_num){
				cout << -1 << endl;
				return 0;
			}
			odd_num--;
		}
	}

	int sorted_index[MAX_N];
	rep(i,s_num) sorted_index[i] = -1;
	int index = 0;
	rep(i,s_num){
		int c = (int)s[i]-97;
		if(freq[c].size()==0)continue;
		if(freq[c].size()==1){
			sorted_index[freq[c][0]] = s_num/2;
		}else{
			int fi = freq[c].front();freq[c].pop_front();
			int bi = freq[c].back();freq[c].pop_back();
			sorted_index[fi] = index;
			sorted_index[bi] = s_num-1-index;
			index++;
		}
	}
	BinaryIndexTree bit(s_num+1);
	ll cnt=0;
	rep(i,s_num){
		cnt += i - bit.sum(sorted_index[i]+1);
		bit.add(sorted_index[i]+1,1);
	}
	cout << cnt << endl;
	// rep(i,s_num)cout<<sorted_index[i]<<endl;

    return 0;
}



Measured memory_bytes: 2820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        char[] s = sc.next().toCharArray();

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

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

using namespace std;
int fv[200002];
int mx(int a,int b)
{
    if(a>b)
        return 1;
    else return 0;
}
int main()

{
    int n , k ;

    cin>>n>>k;

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

    sort(fv,fv+n+1,mx);
    int sum=0;
    for(int i = 0 ; i <  k ; i ++){
        sum += fv[i];
         
}
   cout<<n-sum;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int maxTime = sc.nextInt();
		String str = sc.next();
		int startHS = str.charAt(0) == '1' ? 0 : 1;
		int group[] = new int[num];
		int crt = 1;
		int numG = 0;
		for(int i = 1; i < num; i ++) {
			if(str.charAt(i) == str.charAt(i - 1)) {
				crt ++;
			}else {
				group[numG] = crt;
				numG ++;
				crt = 1;
			}
		}
		group[numG] = crt;
		numG ++;

		if((numG + startHS) / 2 <= maxTime) {
			System.out.println(num);
		}else {
			int sum[] = new int[numG + 1];
			sum[0] = 0;
			for(int i = 1; i < numG + 1; i ++) {
				sum[i] = group[i - 1] + sum[i - 1];
			}
			int can[] = new int[numG + 1];
			for(int i = 0; i <= numG; i ++) {
				can[i] = 0;
			}
			for(int i = startHS; i < numG; i += 2) {
				can[i] = sum[i + 1] - sum[Math.max(0, i - maxTime * 2)];
			}
			if(str.charAt(num - 1) == '0') {
				can[numG] = sum[numG] - sum[Math.max(0, numG - maxTime * 2)];
			}
			int max = 0;
			for(int i = 0; i <= numG; i ++) {
				max = Math.max(max, can[i]);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 27812
N = int(input())
num_iter = map(int, input().split())
flg = True
for i in num_iter:
    if i % 2 == 0:
        if not (i % 3 == 0 or i % 5 == 0):
            flg = False
if flg:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 2940
a, b, x = map(int, input().split())

if a % x == 0:
  if b % x == 0:
    print(b // x - a // x + 1)
  else:
    print(b // x - a // x + 1)
else:
  if b % x == 0:
    print(b // x - a // x)
  else:
    print(b // x - a // x)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

int f(int X, int C, int a) {
  if(X == 0) return a;
  int x = X%C;
  bitset<20> b = x;
  int c = b.count();
  return f(x, c, a+1);
}

signed main() {
  int N; cin >> N;
  bitset<200000> B; cin >> B;
  
  int C = B.count();
  
  int x = 0;
  int k = 1;
  rep(i, N) {
    if(B.test(i)) x += k;
    k *= 2;
    k %= C+1;
  }
  x %= C+1;
  
  int y = 0;
  k = 1;
  if(C-1 > 0) {
    rep(i, N) {
      if(B.test(i)) y += k;
      k *= 2;
      k %= C-1;
    }
    y %= C-1;
  }
  
  vector<int> ans(N);
  

  int kx = 1, ky = 1;
  rep(i, N) {
    if(B.test(i)) {
      if(C-1 == 0) ans[i] = 0;
      else {
        int z = (y-ky+C-1)%(C-1);
        if(z == 0) ans[i] = 1;
        else ans[i] = f(z, C-1, 0);
      }
    } else {
      int z = (x+kx)%(C+1);
      if(z == 0) ans[i] = 1;
      else ans[i] = f(z, C+1, 0);
    }

    kx *= 2;
    kx %= C+1;
    if(C-1 != 0) {
      ky *= 2;
      ky %= C-1;
    }
  }

  reverse(all(ans));
  rep(i, N) cout << ans[i] << endl;

}

Measured memory_bytes: 4716
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
    def find(self, x):
        if self.par[x] == x:
          return x
        else:
          self.par[x] = self.find(self.par[x])
          return self.find(self.par[x])
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def tree_num(self):
        return len([i for i in range(n) if self.par[i] == i])

n, m = map(int, input().split())
uf = UnionFind(n)

for i in range(m):
  x, y, z = map(int, input().split())
  uf.union(x-1, y-1)
print(uf.tree_num())

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

using namespace std;
using ll = long long;

int main()
{
  ll a, b; cin >> a >> b;

  if (a <= 0 and 0 <= b) {
    cout << "Zero" << endl;
  } else if (0 < a) {
    cout << "Positive" << endl;
  } else {
    if (abs(a-b) % 2 == 1) {
      cout << "Positive" << endl;
    } else {
      cout << "Negative" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int convert(char a){
    return a-'0';
}
int convert_s(string a){
    int n = a.size();
    int res = 0;
    rep(i,n){
        res = res*10 + convert(a[i]);
    }
    return res;
}

int main(){
    string S; cin >> S;
    int N = S.size();
    ll ans = 0;
    rep(i, 1<<N-1){
        ll total = 0;
        vector<bool> add(N-1,false);
        string formula = "";
        formula += S[0];
        rep(j, N-1){
            if ((i>>j) & 1 == 1){
                formula += '+';        
            }
            formula += S[j+1];
        }
        ll now = 0;
        ll mid = 0;
        rep(j, formula.size()){
            if (formula[j] == '+'){
                now += mid;
                mid = 0;
            }
            else{
                mid = mid*10+convert(formula[j]);
            }
        }
        ans += (now+mid);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Linq.Expressions;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var S = ReadLine();
            for (var i = 0; i < 3; ++i)
                if (S[i] == S[i + 1])
                { WriteLine("Bad"); return; }
            WriteLine("Good");
        }
        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 25692
#include <iostream>
#include<string> // 文字列を使う
using namespace std;

int main(void){
    string s;
    while(true) {
        cin >> s;
        if(s == "0") {
            break;
        }
        int sum = 0;
        for(int i=0; i < s.size(); i++) {
            // TODO: 文字コードを数値に変換する
            int n = s[i] - '0';
            //cout << "'" << s[i] << "' " << n << endl;
            sum += n;
        }
        cout << sum << endl;
    }
}



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

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    rep(i,n) cin >> a[i+1];
    vector<int> b(n+1);
    for (int i = n; i >= 1; i--) {
        int sum = 0;
        for (int j = i+i; j <= n; j += i) {
            sum ^= b[j];
        }
        b[i] = a[i]^sum;
    }
    vector<int> ans;
    rep(i,n) {
        if (b[i+1]) ans.push_back(i+1);
    }
    cout << ans.size() << endl;
    rep(i,ans.size()) cout << ans[i] << endl;
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()  
#define sz(x) int(x.size()) 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=63;
const int mxn=0;
bool DEBUG=0;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    int len[n];
    for(int i=0;i<n;i++)cin>>len[i];
    sort(len,len+n);
    int ans = 0;
    for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			if(len[j]==len[i])continue;
			for(int k=j+1; k<n; k++){
				if(len[k]==len[j])continue;
				if(len[i]+len[j]>len[k]){
					ans++;
				}
			}
		}
	}
	cout<<ans;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

#define N 50
#define M 1000000007
//estructura de una matriz.

int n;
struct matrix {
	long long m[N][N];
	matrix(){ memset(m,0,sizeof(m));}
	matrix operator *(matrix b){
		matrix c = matrix();
		for (int i = 0; i < n; ++i)
			for (int k = 0; k < n; ++k)
			    for (int j = 0; j < n; ++j)
				c.m[i][j] = (((c.m[i][j]%M) +((m[i][k]%M) * (b.m[k][j]%M))) % M);
	    	return c;
	}

};
// funcion para la matriz identidad
matrix unit(){
	matrix c = matrix();
	for(int i = 0;i<n; i++)
		c.m[i][i]=1;
	return c;
}
// fast matrix MOD pow
matrix modPow(matrix m,ll p){
  if ( p == 0LL )
    return unit(); // the unit matrix - that is 1 for principal diagonal , otherwise 0
  matrix half = modPow(m,p/2);
  matrix out = half * half;
  if ( p % 2 )
    out = out * m;
  return out; 
}
ll k;
void add_self(int &a, int b){
    a+=b;
    if(a>=M)
        a-=M;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    matrix g = matrix();
    cin>>n>>k;
    for(int i =0; i<n; ++i)
        for(int j =0 ; j<n; ++j)
            cin>>g.m[i][j];
    g = modPow(g,k);
    int ans = 0;
    for(int i =0; i<n;++i)
        for(int j =0; j<n; ++j)
            add_self(ans, g.m[i][j]);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

template <int M> class ModInt {
    int x;

  public:
    constexpr ModInt() : x(0) {}
    constexpr ModInt(int64_t y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}
    constexpr ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt &p) {
        if((x += M - p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % M);
        return *this;
    }
    constexpr ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
    constexpr ModInt operator-() const { return ModInt(-x); }
    constexpr ModInt operator+(const ModInt &p) const {
        return ModInt(*this) += p;
    }
    constexpr ModInt operator-(const ModInt &p) const {
        return ModInt(*this) -= p;
    }
    constexpr ModInt operator*(const ModInt &p) const {
        return ModInt(*this) *= p;
    }
    constexpr ModInt operator/(const ModInt &p) const {
        return ModInt(*this) /= p;
    }
    constexpr bool operator==(const ModInt &p) const { return x == p.x; }
    constexpr bool operator!=(const ModInt &p) const { return x != p.x; }
    constexpr ModInt inverse() const {
        int a = x, b = M, u = 1, v = 0, t = 0;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    constexpr ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    constexpr friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    constexpr friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t = 0;
        is >> t;
        a = ModInt(t);
        return (is);
    }
};

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

    using modint = ModInt<998244353>;

    int n;
    cin >> n;
    int cnt[3] = {};

    modint ans(1);
    rep(i, 3 * n) {
        char c;
        cin >> c;
        int tp = 0;
        if(c == 'G') tp = 1;
        if(c == 'B') tp = 2;
        int mn = 1e9;
        rep(j, 3) if(cnt[j] > cnt[tp]) chmin(mn, cnt[j] - cnt[tp]);
        if(mn <= n) ans *= mn;
        cnt[tp]++;
    }
    FOR(i, 1, n + 1) ans *= i;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
A,B,C=map(int,input().split())
X=sorted([A,B,C])
count=0
while X[1]<X[2]:
    count+=1
    X[1]+=1
    X[0]+=1
while X[0]<X[1]:
    count+=1
    X[0]+=2
if X[0]>X[1]:
    count+=1
print(count)

Measured memory_bytes: 3064
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <bitset>
#include <cctype>
#include <fstream>
#include <numeric>
#include <utility>
#include <iomanip>
#include <complex>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
struct fxr
{
   long long a,b;
}p[100007];
bool operator <(const fxr &x,const fxr &y)
{
    return x.a<y.a;
}
int main()
{
    long long n;
    scanf("%lld",&n);

        for(long long i=0;i<n;i++)
    {
        scanf("%lld%lld",&p[i].a,&p[i].b);
    }
    sort(p,p+n);
    printf("%lld\n",p[n-1].b+p[n-1].a);
    return 0;

}





Measured memory_bytes: 1792
package main

import "fmt"

func no() {
	fmt.Println("No")
}

func main() {
	var n int
	fmt.Scanln(&n)
	var s string
	fmt.Scanln(&s)
	if n%2 == 1 {
		no()
		return
	}
	for i := 0; i < n/2; i++ {
		if s[i] != s[i+n/2] {
			no()
			return
		}
	}
	fmt.Println("Yes")
}

Measured memory_bytes: 512
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;


int main(){
    //int ans1=0, ans2=0;
    bool ans=true;
   // int A,B;
    
    vector<int> n;
    int N;
    cin>>N;

    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        n.push_back(a);
    }

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

    for(int i=0;i<N-1;i++){
        if(n[i]==n[i+1]){
            ans=false;
            break;
        }

    }


   if(ans){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

    return 0;
}

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

int main(void) {
	long A, B, C, X, Y;
	long na, nb, nc;

	cin >> A >> B >> C >> X >> Y;
	
	long nc_max = (X < Y ? 2*Y : 2*X);
	long price = 4000000000;
	for(nc = 0; nc <= nc_max; ++nc) {
		na = floor((X - nc * 0.5) + 0.501);
		nb = floor((Y - nc * 0.5) + 0.501);
		if(na <= 0) na = 0;
		if(nb <= 0) nb = 0;
		long price_now = A * na + B * nb + C * nc;
		if(price > price_now) {
			price = price_now;
			//cout << na << " " << nb << " " << nc << endl;
		}
	}

	cout << price << endl;

	return 0;
}



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

typedef long long ll;

int main(void)
{
    string s1;
    cin>>s1;
    int len = s1.size();
    int i;
    for(i = 0; i < len; i++)
    {
        s1[i] = 'x';
    }
    for(i = 0; i < len; i++)
        cout<<s1[i];

    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split(" "))
min_l = 0
max_l = 10**5
for _ in range(m):
    l, r = map(int, input().split(" "))
    if min_l < l:
        min_l = l
    if r < max_l:
        max_l = r
if max_l < min_l:
    print(0)
else:
    print(max_l - min_l + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int zero = 0;
  int ichi = 0;
  
  for (int i = 0; i < S.size(); i ++) {
    
    if ( S.at(i) == '0') {
      zero++;
    }
    
    else {
      ichi++;
    }
  }
  
  if ( zero < ichi ) {
    cout << zero * 2 << endl;
  }
  
  else {
    cout << ichi * 2 << endl;
  }
  
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
using namespace std;
/*
AC  3
WA x 1
TLE x 2
RE x 0
*/
char s[10];
int N, map[10];

int main(){
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> s;
        if(s[0] == 'A') map[1] ++;
        if(s[0] == 'W') map[2] ++;
        if(s[0] == 'T') map[3] ++;
        if(s[0] == 'R') map[4] ++;
    }
    cout << "AC x " << map[1] << endl;
    cout << "WA x " << map[2] << endl;
    cout << "TLE x " << map[3] << endl;
    cout << "RE x " << map[4] << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N; cin >> N;
    string S; cin >> S;

    int ans = 0;
    int dp[N+1][N+1] = {0};
    RFOR(i,N-1,0) RFOR(j,N-1,i) {
        if (S[i] == S[j]) dp[i][j] = min(j-i, dp[i+1][j+1]+1);
        else dp[i][j] = 0;
        ans = max(ans, dp[i][j]);
    }
    cout << ans << '\n';
}



Measured memory_bytes: 97920