akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



void func(long long N, long long M, std::vector<long long> A){

    lli sum = 0;
    REP(i,0,M)sum+=A[i];

    cout<<max(-1LL,N-sum)<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 3716
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i).sort

ans = 0
amx = A.max
tmp = Array.new(amx+1, true)
(0...N).each{|i|
  next if !tmp[A[i]]
  wk = 1
  while wk * A[i] <= amx do
    tmp[wk*A[i]] = false
    wk += 1
  end
  next if i < N-1 && A[i] == A[i+1]
  ans += 1
}

puts ans


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

int main() {
       int h,w,k;
       cin>>h>>w>>k;
       string a[h];
       for(long int i=0;i<h;i++)
       cin>>a[i];
       int power[10];
       int res=1;
       for(long int i=0;i<10;i++)
       {
           power[i]=res;
           res*=2;
       }
       long int ans=0;
       //cout<<power[h]<<" "<<power[k]<<endl;
       for(long int i=0;i<power[h];i++)
       {
           for(long int j=0;j<power[w];j++)
           {
               string b[h];
               for(long int s=0;s<h;s++)
               b[s]=a[s];
               for(long int s=0;s<h;s++)
               {
                   if(power[s]&i)
                   {
                       for(long int ss=0;ss<w;ss++)
                       b[s][ss]='.';
                   }
               }
               for(long int s=0;s<w;s++)
               {
                   if(power[s]&j)
                   {
                       for(long int ss=0;ss<h;ss++)
                       b[ss][s]='.';
                   }
               }
               int temp=0;
               for(long int s=0;s<h;s++)
               for(long int ss=0;ss<w;ss++)
               if(b[s][ss]=='#')
               temp++;
               if(temp==k)
               ans++;
           }
       }
       cout<<ans;
	// your code goes here
	return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
int main(){
FASTIO	
int n,m;
cin>>n>>m;
cout<<((n*(n-1))/2)+((m*(m-1))/2);
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================
	

	ll N;
	cin >> N;
	string S;
	cin >> S;


	int r = 0;
	int b = 0;

	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'R')
		{
			r++;
		}
		else
		{
			b++;
		}
	}

	if (r > b)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}





Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

def Find(x):    #xの根を返す
    global table

    if table[x] == x:
        return x
    else:
        table[x] = Find(table[x])    #親の更新(根を直接親にして参照距離を短く)
        size[x] = size[table[x]]
        return table[x]

def Unite(x,y):    #xとyを繋げる
    global size
    global rank
    x = Find(x)
    y = Find(y)
    sx = Size(x)
    sy = Size(y)

    if x == y:
        return

    if rank[x] > rank[y]:
        table[y] = x
        size[x] = sx + sy
    else:
        table[x] = y
        size[y] = sx + sy
        if rank[x] == rank[y]:
            rank[y] += 1

def Check(x,y):
    if Find(x) == Find(y):
        return True
    else:
        return False

def Size(x):
    return size[Find(x)]

N,M = inpl()

table = [i for i in range(N)]    #木の親 table[x] == x なら根
rank  = [1 for i in range(N)]    #木の長さ
size  = [1 for i in range(N)]    #集合のサイズ

for i in range(M):
    x,y,z = inpl()
    x -= 1
    y -= 1
    if not Check(x,y):
        Unite(x,y)

cnt = [0]*N
for x in table:
    cnt[Find(x)] = 1
print(sum(cnt))


Measured memory_bytes: 10668
r,g,b,n=map(int,input().split())
p=0
i,j=0,0
while j < n+1:
    k=i*r+j*g
    if (n-k)%b==0 and k <= n:
        #print(i,j,n-k)
        p+=1
    i+=1
    if i>n:
        i=0
        j+=1
print(p)


Measured memory_bytes: 40940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0; i<N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  int cnt=1;
  
  for (int i=1; i<N; i++) {
    if(d.at(i)<d.at(i-1)) {
      cnt++;
    }
    else if (d.at(i)=d.at(i-1)){
    }
    else{
      break;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
N, M, X = gets.chomp.split(' ').map(&:to_i)
C = Array.new
N.times do |i|
  C[i] = gets.chomp.split(' ').map(&:to_i)
end
min = Float::INFINITY

N.times do |i|
  combinations = (0..N-1).to_a.combination(i+1).to_a
  combinations.each do |combination|
    sum = Array.new(M+1, 0)
    (M+1).times do |k|
      (i+1).times do |j|
      	sum[k] += C[combination[j]][k]
      end
    end
    if sum.slice(1..-1).all?{ |value| value >= X }
      min = [min, sum[0]].min
    end
  end
end

p (min.infinite? ? -1 : min)

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

using namespace std;

int main()
{
    int n,p[55];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        if(i+1!=p[i]) cnt++;
    }

    if(cnt>2) cout << "NO\n";
    else cout << "YES\n";

    return 0;
}


Measured memory_bytes: 256
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl<T: Copy> Copy for Rev<T> {}

fn main() {
    input! {
        n: i64,
    }

    println!("{}", n*n*n);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define inf 9123456789123456789
//#define M 998244353
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 1000009
#define M5 500009
#define pi 3.14159265
// ll power(ll x,ll n){
//     ll res=1;
//     while(n>0){
//         if(n&1) res=(res*x)%M;
//         n/=2;
//         x=(x*x)%M;
//     }
//     return res;
// }
ll n,m;
vector<pll> l1,l2;
ll dis(pll p1,pll p2){
    return (p1.F-p2.F)*(p1.F-p2.F)+(p1.S-p2.S)*(p1.S-p2.S);
}
int  main()
{   //ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=1,flag,i,j,k,a,b,c;
    //cin>>tc;
    while(t<=tc){
        //cout<<"Case #"<<t<<": ";
        cin>>a>>b>>c;
        if(a==b&&b==c) cout<<"Yes";
        else cout<<"No";
        t++;
    }
    return 0;
} 

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

int main(){
    int n;
    int hour, minute;

    cin >> n;

    for(int i=1; i<=n; i++){
        scanf("%d:%d", &hour, &minute);
        double hour_angle;
        double minute_angle;

        minute_angle = minute * 6.0;
        if(minute_angle == 360.0){
            minute_angle = 0.0;
        }
        hour_angle = (hour * 60.0 + minute) * 360.0 / (12.0 * 60.0);
        if(hour_angle == 360.0){
            hour_angle = 0.0;
        }

        double diff = abs(minute_angle - hour_angle);
        if(diff > 180.0){
            diff = 360.0 - diff;
        }

        if(0<= diff && diff < 30){
            cout << "alert" << endl;
        }else if(90<= diff && diff <= 180){
            cout << "safe" << endl;
        }else{
            cout << "warning" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
char s[300005];
int n,ans,sum[2][300005];
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++){
		sum[0][i]+=sum[0][i-1];
		sum[1][i]+=sum[1][i-1];
		if(s[i]=='E') sum[0][i]++;
		else sum[1][i]++;
	}
	ans=n;
	for(int i=1;i<=n;i++){
		ans=min(ans,sum[1][i-1]+sum[0][n]-sum[0][i]);
//		if(s[i]=='E') ans=min(ans,sum[1][i-1]+sum[0][n]-sum[0][i]);
//		else ans=min(ans,sum[1][i-1]+)
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2944
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    B=[0]*(N+1)
    for i in range(N):
        B[i+1]=(A[i]+B[i]-1)%K
    ans=0
    d={}
    for i in range(1,N+1):
        if i-K<0:
            if B[i-1] in d:
                d[B[i-1]]+=1
            else:
                d[B[i-1]]=1
        else:
            if B[i-1] in d:
                d[B[i-1]]+=1
            else:
                d[B[i-1]]=1
            d[B[i-K]]-=1
        if B[i] in d:
            ans+=d[B[i]]
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 104032
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<random>
#include<ctime>
#include<cstdlib>
#include<complex>
#include<fstream>
using namespace std;

int main(){

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

  ans=(a+b+1)/2;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

typedef struct {
	char A;
	char shogen[14][2];
} hito;

int main() {
	int N;
	hito in[15];
	scanf("%d", &N) + 1;
	for (int i = 0; i < N; i++) {
		scanf("%d", &in[i].A) + 1;
		for (int j = 0; j < in[i].A; j++) {
			scanf("%d%d", &in[i].shogen[j][0], &in[i].shogen[j][1]) + 1;
		}
	}
	int ans = 0;
	int max = pow(2, N);
	for (int i = 1; i < max; i++) {
		// 01作成
		char horu[15];
		for (int j = 0; j < N; j++) {
			horu[j] = (i & (1 << j)) != 0;
		}
		// 矛盾チェック
		bool out = false;
		for (int j = 0; j < N; j++) {
			if (horu[j]) {
				for (int k = 0; k < in[j].A; k++) {
					if (horu[in[j].shogen[k][0]-1] != in[j].shogen[k][1]) {
						out = true;
						break;
					}
				}
			}
			if (out) break;
		}
		// 矛盾なかったら
		if (!out) {
			int count = 0;
			for (int j = 0; j < N; j++) {
				if (horu[j]) count++;
			}
			if (ans < count) ans = count;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline char ch(){
	static char s[1<<16],*S,*T;
	return (S==T)?(T=(S=s)+fread(s,1,1<<16,stdin),*S++):*S++;
}
#define ch() getchar()
template<typename T> void read(T &x){
	x = 0; int f(1); char c = ch();
	for(;!isdigit(c);c = ch()) if(c == '-') f = -1;
	for(;isdigit(c);c = ch()) x = x*10+c-'0';
	x *= f;
}
int main(){
	int a,b,c,k;
	read(a); read(b); read(c); read(k);
	int sum = 0;
	sum += min(a,k); k -= min(a,k);
	if(k){
		k -= min(k,b);
		if(k)	sum -= min(k,c),k -= min(k,c);
	}
	printf("%d\n",sum);
	return 0;
}

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

using namespace std;

int main(){
  int N, D; cin >> N >> D;
  vector<vector<int>> X(N,vector<int>(D));

   for (int i = 0; i < N; ++i) { 
    for (int j = 0; j < D; ++j) {
      cin >> X[i][j]; 
    }
  }
  
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
      int norm = 0;
      for(int k = 0; k < D; ++k) {
        int diff = abs(X[i][k] - X[j][k]);
        norm += diff * diff;
      }
    
      bool flag = false;
      for (int k = 0; k <= norm; ++k) {
        if (k * k == norm) {
          flag = true;
        }
      }
      if (flag) ++ans;
    }
  }

  cout << ans << endl;
}
  

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
ans = sum(a)
b = [str(i) for i in a]
q = int(input())
rep = [list(map(int,input().split())) for _ in range(q)]
now = [0 for i in range(10**5+1)]

c = Counter(b).most_common()
for i in range(len(c)):
    now[int(c[i][0])] = c[i][1]
for i in range(q):
    ans = ans - rep[i][0]*now[rep[i][0]] + rep[i][1]*now[rep[i][0]]
    now[rep[i][1]] += now[rep[i][0]]
    now[rep[i][0]] = 0
    print(ans)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int x;
    cin >> x;
    cout << 800*x-(x/15)*200 << endl;
    return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
# from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
# from heapq import heappop, heappush, heappushpop
# from collections import Counter,defaultdict,deque
# from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
# from bisect import bisect_left,bisect_right
# from copy import deepcopy
from fractions import gcd
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
#mint
class ModInt:
    def __init__(self, x):
        self.x = x % mod
    
    def __str__(self):
        return str(self.x)
    
    __repr__ = __str__

    def __add__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x + other.x)
        else:
            return ModInt(self.x + other)

    __radd__ = __add__
        
    def __sub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x - other.x)
        else:
            return ModInt(self.x - other)

    def __rsub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(other.x - self.x)
        else:
            return ModInt(other - self.x)

    def __mul__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * other.x)
        else:
            return ModInt(self.x * other)

    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * pow(other.x, mod-2,mod))
        else:
            return ModInt(self.x * pow(other, mod - 2, mod))
            
    def __rtruediv(self, other):
        if isinstance(other, self):
            return ModInt(other * pow(self.x, mod - 2, mod))
        else:
            return ModInt(other.x * pow(self.x, mod - 2, mod))
            

    def __pow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(self.x, other.x, mod))
        else:
            return ModInt(pow(self.x, other, mod))
            

    def __rpow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(other.x, self.x, mod))
        else:
            return ModInt(pow(other, self.x, mod))

def main():
    N=I()
    A=LI()
    l = 1
    for a in A:
        l *= a//gcd(l,a)
    ans = 0
    for a in A:
        ans += ModInt(l)/a
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 68056
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=3e5+10;
int NW[mx],NE[mx];
char s[mx];
int main(){
  int n;
  scanf("%d %s",&n,s);
  int ne=0;
  for(int i=0;i<n;i++){
    NE[i]=ne;
    if(s[i]=='W')ne++;
  }
  int nw=0;
  for(int i=n-1;i>=0;i--){
    NW[i]=nw;
    if(s[i]=='E')nw++;
  }
  int ans=1e9;
  for(int i=0;i<n;i++){
    ans=min(ans,NW[i]+NE[i]);
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>

using namespace std;

int max_length(string x, string y)
{
    int n = x.size();
    int m = y.size();
    int dp[n+1][m+1];
    for(int i = 0; i <= m; ++i)
    {
        dp[0][i] = 0;
    }
    for(int i = 1; i <= n; ++i)
    {
        dp[i][0] = 0;
        for(int j = 1; j <= m; ++j)
        {
            if(x[i-1] == y[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    return dp[n][m];
}

int main()
{
    string str1;
    string str2;
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        cin >> str1 >> str2;
        cout << max_length(str1, str2) << endl;
    }
}

Measured memory_bytes: 5132
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";
#define mod 1000000007
#define N 21

int n;
int a[N][N];
int dp[N][(1<<N)];
int allmask;

int solve(int idx, int mask)
{
	if(idx >= n)
		return (mask == allmask);
	
	int &res = dp[idx][mask];
	if(res != -1)
		return res;
	res = 0;
	for(int i = 0; i < n; i++)
	{
		if(mask & (1<<i))
			continue;
		if(a[idx][i] == 0) continue;
		
		res += solve(idx+1, (mask | (1<<i)));
		if(res >= mod)
			res -= mod;
	}
	return res;
}

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

	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> a[i][j];
	allmask = (1<<n) - 1;
	memset(dp, -1, sizeof(dp));
	
	int ans = solve(0, 0);
	
	cout << ans << "\n";

}


Measured memory_bytes: 344320
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, M; cin >> N >> M;
	int C; cin >> C;
	vector<int>B(M); rep(i, 0, M) { cin >> B[i]; }
	vector<vector<int>>A(N, vector<int>(M));
	rep(i, 0, N)rep(j, 0, M) { cin >> A[i][j]; }
	int ans = 0;
	rep(i, 0, N) {
		int x = C;
		rep(j, 0, M)x += A[i][j] * B[j];
		ans += x > 0;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (llong (Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

#include <iostream>
#include <string>
using namespace std;
using llong = long long;

string s, t;

int main() {
    cin >> s >> t;
    llong ans = 1 << 20;
    llong n = s.size();
    llong m = t.size();

    repeat(i, n - m + 1) {
        llong cnt = 0;
        repeat(j, m) {
            if (s[i + j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
};


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int x;
    cin >> x;

    int ans = 0;
    while (ans * (ans + 1) / 2 < x) ++ans;

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



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
int main(void){
    vector<int> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    cout<<a[0]+a[1]<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const string st = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
void solve(int N) {
    map<char, int> mp;
    REP(i, st.length()) mp[st[i]] = i;
    assert(st.length() == 52);
    VI k(N);
    for_each(ALL(k), [](auto &e){cin >> e;});
    string s; cin >> s;
    string ans = "";
    REP(i, s.length()) {
        int kid = i % N;
        int stid = mp[s[i]];
        int id = (stid + 52 - k[kid]) % 52;
        ans += st[id];
    }
    cout << ans <<endl;
    return;
}

signed main(void) {
    int n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n, n) {
        solve(n);
        //return 0;
    }
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) (v.begin(),v.end())
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int l,r;
    cin >> l >> r;
    if(r-l >= 2019) {
        pr(0);
        return 0;
    }
    int ans = INF;
    Rep(i, l, r){
        Rep(j, i+1, r+1){
            chmin(ans, ((i % 2019) * (j % 2019)) % 2019);
        }
    }
    pr(ans);
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rall(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define sz(a) (int)(a).size()
#define mins(a,...) a = min<decltype(a)>({a, ## __VA_ARGS__})
#define maxs(a,...) a = max<decltype(a)>({a, ## __VA_ARGS__})
#define plusMod(a,b) a = (a % mod + b % mod) % mod
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) {
    return os.put(os.widen('\n'));
}
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}

int a, b;
void solve() {
    cin >> a >> b;

    int cnt = 1;
    int ans = 0;
    while (cnt < b) {
        cnt += a - 1;
        ++ans;
    }

    cout << ans << endn;
}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    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 repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
const long long INF = 1LL<<60;
#define pairint pair<int,int>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

signed main(){
  int x=0,y=0,z=0,w=0,n=0;
  string s;
  std::cin >> x;
  rep(i,x){
    std::cin >> y;
    if(y%2==0&&(y%3!=0&&y%5!=0)){
      std::cout << "DENIED" << '\n';
      return 0;
    }
  }
  std::cout << "APPROVED" << '\n';

}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)

	ans := ""
	for N != 0 {
		ans = strconv.Itoa(N&1) + ans
		N = -(N >> 1)
	}
	if len(ans) == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(ans)
	}
}


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





int main() {
  
  int h,w;
  cin>>h>>w;
  
  vector<vector<string>> vec(h,vector<string>(w));
  
  for (int i=0;i<h;i++){
    string tmp;
    cin>>tmp;
    for (int j=0;j<w;j++){
      vec.at(i).at(j)=tmp.at(j);
    }
  }
  
  vector<vector<string>> answer(h+2,vector<string>(w+2));
  
  for (int j=0;j<w+2;j++){
    answer.at(0).at(j)='#';
  }
  
  for (int i=0;i<h;i++){
    answer.at(i+1).at(0)='#';
    answer.at(i+1).at(w+1)='#';
    for (int j=0;j<w;j++){
      answer.at(i+1).at(j+1)=vec.at(i).at(j);
    }
  }
  
  for (int j=0;j<w+2;j++){
    answer.at(h+1).at(j)='#';
  }
  
  
  for (int i=0;i<h+2;i++){
    for (int j=0;j<w+2;j++){
      cout<<answer.at(i).at(j);
    }
    cout<<endl;
  }
  
  
}













Measured memory_bytes: 896
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut s: Vec<Vec<usize>> = vec![vec![]; m];
    let mut p: Vec<usize> = vec![];

    for i in 0..m {
        let k = read();
        for _ in 0..k {
            s[i].push(read());
        }
    }

    for _ in 0..m {
        p.push(read());
    }
    let mut ans = 0;

    'outer: for i in 0..2_u32.pow(n as u32) {
        // println!("i: {}", i);
        for j in 0..m {
            let si = &s[j];
            let mut ons = 0;
            for k in si {
                if i >> (k - 1) & 1 == 1 {
                    ons += 1;
                }
            }
            // println!("ons: {}", ons);
            if ons % 2 != p[j] {
                continue 'outer;
            }
        }
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2084
#include <iostream>
using namespace std;
 
int main() {
	int n,tmp,flag=0;
	cin>>n;
	long long ans=0;
	for(int i=1;i<=n;i++){
		if(i%3==0){
			flag=1;
		}
		if(i%5==0){
			flag=1;
		}
		if(flag==0){
			ans=ans+i;
		}
		flag=0;
	}
	cout<<ans<<endl;
	// your code goes here
	return 0;
}

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

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

 int main() {
   ll N;
   cin >> N;
   int n = (int)sqrt(N);

   for (int i = n; i > 0; i--) {
     if (N % i == 0) {
       cout << i - 1 + N / i - 1 << endl;
       break;
     }
   }
 }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

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

	std::cout << n - (k - 1) << std::endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n;
    cin >> n;
    
    if(n%2){
        cout << 0 << endl;
        return 0;
    }

    ll tmp=10,ans = 0;
    while(n / tmp > 0){
        ans += n / tmp;
        tmp *= 5;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector<bool> ables(100001, false);
    ables[0] = true;
    vector<ll> ss = {100, 101, 102, 103, 104, 105};
    for (auto s: ss){
        REP(i, 100001){
            if ((ables[i] == true) && (i+s <= 100001)){
                ables[i+s] = true;
            }
        }
    }
    cout << ables[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 200100;
vector <pair<int, int>  > v[3 * N];
int n, d[3 * N], m, a, b, c;
map <pair<int, int>, int> mp;

int get(int node, int col){
	if(mp.count({node, col})) return mp[{node, col}];
	int k = mp.size();
	mp[{node, col}] = k + n + 1;
	v[node].push_back({k + n + 1, 1});
	v[k + n + 1].push_back({node, 0});
	return mp[{node, col}];
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n >> m;
	
	for(int i = 1; i <= m; i++) {
		cin >> a >> b >> c;
		int n1 = get(a, c);
		int n2 = get(b, c);
		v[n1].push_back({n2, 0});
		v[n2].push_back({n1, 0});
	}

	memset(d, 0x3f, sizeof d);
	priority_queue <pair<int, int> > q;
	q.push({0, 1});
	d[1] = 0;

	while(!q.empty()) {
		int x = q.top().nd; 
		q.pop();
		
		for(auto i : v[x])
			if(d[i.st] > d[x] + i.nd) {
				d[i.st] = d[x] + i.nd;
				q.push({-d[i.st], i.st});
			}
	}
	// dbg_v(d, 3 * n)
	if(d[n] > 1e7) d[n] = -1;
	cout << d[n] << '\n';
}	

	

Measured memory_bytes: 60924
_n = gets.strip.to_i
s = gets.chomp
count = 0

'0'.upto('9') do |i|
  '0'.upto('9') do |j|
    '0'.upto('9') do |k|
      next unless idx_i = s.index(i)
      next unless idx_j = s.index(j, idx_i + 1)
      next unless s.index(k, idx_j + 1)
      count += 1
    end
  end
end

puts count


Measured memory_bytes: 14312
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch

#include<bits/stdc++.h>

using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}

int main()
{
    ios_base::sync_with_stdio(0);
    //ll n,c,cnt=0,prev;
    string s,s1;
    cin>>s>>s1;
    int len1=s.length();
    int len2=s1.length();
    string ss="";
    for(int i=0;i<len2;i++)
    {
         cout << s[i] << s1[i];
    }
  if (s.size() > s1.size()) cout << s[s.size()-1];
    //cout<<ss<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)



int main(){
    int n,k;cin>>n>>k;
    string s;cin>>s;
    vector<int> z,o;
    int ssz=s.size();
    int prev=1;
    int ctr=0;
    rep(i,ssz){
        if(s[i]=='1'){
            if(prev){
                ctr++;
                prev=1;
            }
            else{
                z.push_back(ctr);
                ctr=1;
                prev=1;
            }
        }
        else{
            if(!prev){
                ctr++;
                prev=0;
            }
            else{
                o.push_back(ctr);
                ctr=1;
                prev=0;
            }
        }
    }
    if(s[ssz-1]=='1')o.push_back(ctr);
    else{
        z.push_back(ctr);
        o.push_back(0);
    }
    int ans=0;
    chmin(k,(int)z.size());
    rep(i,k){
        ans+=(z[i]+o[i]);
    }
    ans+=o[k];
    int zsz=z.size();
    int tmp=ans;
    rep(i,zsz-k){
        tmp-=(z[i]+o[i]);
        tmp+=(z[i+k]+o[i+k+1]);
        chmax(ans,tmp);
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 1020
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct edge
{
	int s, t, c, rev;
	edge(int s, int t, int c, int rev) :s(s), t(t), c(c), rev(rev) {}
	edge() { s = -1, t = -1, c = -1, rev = -1; }
};

vector<vector<edge>> G;
int level[101];
int iter[101];

void bfs(int s)
{
	rep(i, 0, 101)level[i] = -1;
	queue<int> q;
	q.push(s);
	level[s] = 0;
	while (!q.empty())
	{
		int t = q.front(); q.pop();
		rep(i, 0, SZ(G[t]))
		{
			edge e = G[t][i];
			if (e.c > 0 && level[e.t] == -1)
			{
				level[e.t] = level[t] + 1;
				q.push(e.t);
			}
		}
	}
}

int dfs(int v, int t, int f)
{
	if (v == t)
	{
		return f;
	}
	for (int& i = iter[v]; i < SZ(G[v]); i++)
	{
		edge& e = G[v][i];
		if (e.c == 0 || level[v] >= level[e.t])
		{
			continue;
		}
		int d = dfs(e.t, t, min(f, e.c));
		if (d > 0)
		{
			e.c -= d;
			G[e.t][e.rev].c += d;
			return d;
		}
	}
	return 0;
}

int max_flow(int s, int t)
{
	int ans = 0;
	while (true)
	{
		bfs(s);
		if (level[t] == -1)return ans;
		rep(i, 0, 101)iter[i] = 0;
		while (true)
		{
			int f = dfs(s, t, INF);
			if (f == 0)
			{
				break;
			}
			ans += f;
		}
	}
}

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

	int V, E, s, t, c;
	cin >> V >> E;
	G.resize(V);
	rep(i, 0, E)
	{
		cin >> s >> t >> c;
		G[s].push_back(edge(s, t, c, SZ(G[t])));
		G[t].push_back(edge(t, s, 0, SZ(G[s]) - 1));//	<--有向
		//G[t].push_back(edge(t, s, c, SZ(G[s]) - 1));	<--無向
	}

	cout << max_flow(0, V - 1) << endl;

	return 0;
}


Measured memory_bytes: 3232
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
    n = ni()
    A = []
    Onaji = {}
    for i in na():
        i -= 1
        A.append(i)
        if i in Onaji:
            Onaji[i] += 1
        else:
            Onaji[i] = 1

    kumi = {}
    minuskumi = {}
    Sum = 0
    for a in A:
        if Onaji[a] <= 1:
            continue
        if a in kumi:
            continue
        kumi[a] = cmb(Onaji[a], 2)
        if Onaji[a] - 1 <= 1:
            minuskumi[a] = 0
        else:
            minuskumi[a] = cmb(Onaji[a] - 1, 2)
        Sum += kumi[a]
    for a in A:
        if a in minuskumi and a in kumi:
            print(minuskumi[a] + Sum - kumi[a])
        else:
            print(Sum)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 30324
*D, = open(0)
n, m = map(int, D[0].split())
edges = [list(map(int, it.split())) for it in D[1:]]
edges = sorted(edges, key=lambda x:x[1])

bridge = edges[0][1]
cnt = 1
for a, b in edges[1:]:
    if bridge <= a:
        bridge = b
        cnt += 1
print(cnt)

Measured memory_bytes: 36828
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,a[500010];
LL l,r,L,R,A;
int main(){
	cin>>n;
	FOR(i,1,n) getint(a[i]);
	l=r=2;
	FORD(i,n,1){
		A=a[i];
		L=l/A;
		if (l%A) ++L;
		R=r/A;
		if (L>R) return puts("-1"),0;
		l=A*L;
		r=A*(R+1)-1;
	}
	cout<<l<<' '<<r<<endl;
	return 0;
}

Measured memory_bytes: 640