akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        Integer[] mochiArr = new Integer[num];

        for (int i = 0; i < num; i++) {
            mochiArr[i] = sc.nextInt();
        }

        Arrays.sort(mochiArr, Collections.reverseOrder());
        int count = 1;
        for (int i = 0; i < mochiArr.length - 1; i++) {
            if (mochiArr[i] == mochiArr[i + 1]) continue;
            if (mochiArr[i] > mochiArr[i + 1]) count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  set<string> s;
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    string ss; cin >> ss;
    s.insert(ss);
  }
  cout << s.size() << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#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()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  int h, w;
  string t, ans;
  cin >> h >> w;
  REP(i, h) REP(j, w) {
    string s;
    cin >> s;
    if(s == "snuke") {
      ans = (char)('A'+j) + to_string(i+1);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int64_t n, k;
	cin >> n >> k;
	vector<int64_t> ps(n);
	for (auto &&p : ps)
	{
		cin >> p;
	}

	vector<int64_t> qs(n);
	for (int64_t i = 0; i < n; i++)
	{
		qs[i] = ps[i] + 1;
	}

	int64_t maxi = 0;

	for (int64_t i = 0, tmp = 0; i < n; i++)
	{
		if (k <= i)
		{
			tmp -= qs[i - k];
		}

		tmp += qs[i];

		maxi = max(maxi, tmp);
	}

	long double ans = maxi / 2.0;

	cout << fixed << setprecision(20) << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,k;
  cin>>n>>k;

  ll a[n+1]={};
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }

  sort(a+1,a+n+1);
  ll sum[n+1]={};
  for(int i=1;i<=n;i++){
    sum[i]=sum[i-1]+a[i];
    //cout<<i<<" "<<a[i]<<" "<<sum[i]<<endl;
  }

  if(sum[n]<k){
    cout<<n<<endl;
    return 0;
  }else if(sum[n]==k){
    cout<<0<<endl;
    return 0;
  }

  ll ma=10000;
  ll con[5001]={};
  con[0]=1;
  for(int i=n-1;i>0;i--){
    for(int j=k-a[i+1]-1;j>=0;j--){
      if(con[j]==1){
        con[j+a[i+1]]=1;
        if(ma>=k) ma=j+a[i+1];
        else ma=max(ma,j+a[i+1]);
      }
    }

    if(sum[i]>=k) continue;
    //if(ma==10000) ma=a[i+1];

    if(sum[i]+ma<k||ma>=k){
      cout<<i<<endl;
      return 0;
    }

    /*for(int j=k-a[i]-1;j>=0;j--){
      if(con[j]==1){
        con[j+a[i]]=1;
        if(ma>=k) ma=j+a[i];
        else ma=max(ma,j+a[i]);
      }
    }*/
  }
  cout<<0<<endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

//素数判定(True/Falseを返却)
int IsPrime_tf(ll num){
    if (num < 2) return false; //0、1は素数でない
    else if (num == 2) return true; //2は素数
    else if (num%2==0) return false; // 偶数はあらかじめ除く
    for (ll i = 3; i*i <= num; i += 2){ //チェックは2～√nで十分
        if (num % i == 0) return false; //素数でない
    }
    return true; //素数である
}

//素数判定(割れる値を返却)
ll IsPrime_value(ll num){
    if (num < 2) return -1; //0、1は素数でない
    else if (num == 2) return 2; //2は素数
    for (ll i = 2; i*i <= num; i += 1){ //チェックは2～√nで十分
        if (num % i == 0) return i; //素数でない
    }
    return num; //素数である
}

int main(){
   int w, h, x, y, r;
   cin >> w >> h >> x >> y >> r;
   int xp, xm, yp, ym;
   xp = x+r;
   xm = x-r;
   yp = y+r;
   ym = y-r;
   if(xp<0 || xm<0 || yp<0 || ym<0) cout << "No" << endl;
   else if(xp>w || xm>w || yp>h || ym>h) cout << "No" << endl;
   else cout << "Yes" << endl;
   return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 510, mod = 1e9+7;
int n,m,a[N],cnt[N],dp[N][N][N];

inline void upd(int &x,int y){
	x+=y;
	if (x>=mod) x-=mod;
}
inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
int fac[N],ifac[N],pw[N][N];
inline void init(int n){
	fac[0]=1;
	For(i,1,n) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=power(fac[n],mod-2);
	Dow(i,n-1,0) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	pw[0][0]=1;
	For(i,1,n){
		pw[i][0]=1;
		For(j,1,n) pw[i][j]=1ll*pw[i][j-1]*i%mod;
	}
}
inline int C(int n,int m){
	if (n<m||m<0) return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int main(){
	n=read(),m=read();
	For(i,1,n) cnt[read()]++;
	init(max(n,m));
	dp[m+1][0][0]=1;
	Dow(k,m+1,2) For(i,0,m) For(j,0,m) if (dp[k][i][j]){
		For(l,0,m/(k-1)){
			//dp[k][i][j]->dp[k-1][i+l*(k-1)][j+l]
			int tmp=1ll*dp[k][i][j]*pw[i+(k-1)*l-(k-2)*(j+l)][cnt[k-1]]%mod;
			//int tmp=dp[k][i][j];
			//For(p,1,cnt[k-1]) tmp=1ll*tmp*(i+(k-1)*l-(k-2)*(j+l))%mod;
			upd(dp[k-1][i+l*(k-1)][j+l],1ll*tmp*ifac[l]%mod);
		}
	} 
	int ans=0;
	For(i,0,m) For(j,0,m) if (dp[1][i][j]){
		if (j-1>m-i) continue;
		int tmp=1ll*dp[1][i][j]*fac[j]%mod,x=m-i-(j-1),y=j+1;
		tmp=1ll*tmp*C(x+y-1,y-1)%mod;
		if ((m-i)&1) upd(ans,mod-tmp);
			else upd(ans,tmp); 
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 385728
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;

int main(){
    ll A,B,Q;
    cin>>A>>B>>Q;
    const ll INF = (ll)2e10;
    vector<ll> s(A+2,INF),t(B+2,INF),x(Q);
    for(ll i=1;i<=A;i++){
        cin>>s[i];
    }
    for(ll i=1;i<=B;i++){
        cin>>t[i];
    }
    s[0] = -INF;
    t[0] = -INF;
    for(ll i=0;i<Q;i++){
        cin>>x[i];
    }
    for(ll i=0;i<Q;i++){
        ll ind_s = lower_bound(s.begin(),s.end(),x[i])-s.begin();
        ll ind_t = lower_bound(t.begin(),t.end(),x[i])-t.begin();
        ll _min = INF;
        ll s1 = x[i]-s[ind_s-1];
        ll s2 = s[ind_s]-x[i];
        ll t1 = x[i]-t[ind_t-1];
        ll t2 = t[ind_t]-x[i];
        // cout<<"s1:"<<s1<<", s2:"<<s2<<", t1:"<<t1<<", t2:"<<t2<<endl;
        _min = min(_min,max(s1,t1));
        _min = min(_min,max(s2,t2));
        _min = min(_min,2*min(s1,t2)+max(s1,t2));
        _min = min(_min,2*min(s2,t1)+max(s2,t1));
        cout<<_min<<"\n";
    }
    
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

#define P pair<int, int>
int memo[52][52];

int main(void){

	int h, w;

	cin >> h >> w;

	char s[52][52];


	int num = 0;

	for (int i = 0; i < 52; i++){
		for (int j = 0; j < 52; j++){
			s[i][j] = '#';
		}
	}

	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			cin >> s[i][j];
			if (s[i][j] == '.')
				num++;
		}
	}



	for (int i = 0; i < 52; i++)
		for (int j = 0; j < 52; j++)
			memo[i][j] = -1;

	queue<P> Q;

	int x = 1, y = 1;
	memo[1][1] = 0;
	while (x != h || y != w){
		if (s[x][y-1] == '.' && memo[x][y-1] == -1){
			Q.push(P(x, y-1));
			memo[x][y-1] = memo[x][y] + 1;
		}
		if (s[x][y+1] == '.' && memo[x][y+1] == -1){
			Q.push(P(x, y+1));
			memo[x][y+1] = memo[x][y] + 1;
		}
		if (s[x-1][y] == '.' && memo[x-1][y] == -1){
			Q.push(P(x-1, y));
			memo[x-1][y] = memo[x][y] + 1;
		}
		if (s[x+1][y] == '.' && memo[x+1][y] == -1){
			Q.push(P(x+1, y));
			memo[x+1][y] = memo[x][y] + 1;
		}

		if (Q.empty()){
			break;
		}

		P temp = Q.front();
		Q.pop();

		x = temp.first;
		y = temp.second;
	}

	if (x != h || y != w)
		cout << -1 << endl;
	else
		cout << num - memo[x][y] - 1 << endl;
}

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

using namespace std;
using L64 = int64_t;

int main(void) {
  int N, num, max = 0;
  L64 total = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> num;
    if (max <= num) {
      max = num;
    } else {
      total += max - num;
    }
  }
  cout << total;
  return 0;
}

Measured memory_bytes: 3500
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define INF 100000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX],finv[MAX],inv[MAX];
typedef vector<vector<int> > Graph;

int main(){
    int h,w,k;cin>>h>>w>>k;
    ll ans=INF;
    vector<string> s(h);
    for(int i=0;i<h;i++) cin>>s[i];
    for(int bit=0;bit<(1<<h-1);bit++){
        ll res=0;
        vector<int> cut(h-1,0);
        for(int j=0;j<h-1;j++){
            if(bit>>j&1){
                res++;
                cut[j]=1;
            }
        }
        ll g=res;
        vector<int> c(g+1,0);
        for(int i=0;i<w;i++){
            int flag=0;
            int idx=0;
            vector<int> c_d(g+1,0);
            for(int j=0;j<h;j++){
                if(j!=0){
                    if(cut[j-1]==1) idx++;
                }
                if(s[j][i]=='1'){
                    c[idx]++;
                    c_d[idx]++;
                    
                }
                if(c[idx]>k){
                    if(flag) res=INF;
                    res++;
                    for(int l=0;l<g+1;l++){
                        c[l]=c_d[l];
                    }
                    flag=1;
                }
            }
        }
        ans=min(ans,res);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

void solve() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i]; 
	}
	bool odd_flg = false;
	int ans = 0;
	while(!odd_flg) {
		for (int i = 0; i < n; ++i) {
			if (a[i] % 2 == 1) {
				odd_flg = true;
				break;
			}
		}
		if (!odd_flg) {
			ans++;
			for (int i = 0; i < n; ++i) {
				a[i] = a[i] / 2;
			}
		}
	}
	cout << ans << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){


    int n;
    cin >> n;
    
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    
    vector<int> sorted = a;
    sort(sorted.begin(), sorted.end(), greater<int>());

    for(int i=0; i<n; i++) {
        if(a[i] == sorted[0]) cout << sorted[1] << endl;
        else cout << sorted[0] << endl;
    }

    return 0;
    
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 2e5 + 10;
int n, c[N], cnt[N], siz[N];
	inline LL count(int n) {
		// C(n,2) + n
		return 1LL*n*(n+1)/2;
	}
LL ans[N];
vector<int>G[N];
	void dfs(int v, int fa) {
		int tmp = cnt[c[v]];
		siz[v] = 1;
		for(int u:G[v]) {
			if(u==fa) continue;
			cnt[c[v]] = 0;
			dfs(u, v);
			siz[v] += siz[u];
			ans[c[v]]+=count(siz[u]-cnt[c[v]]);
		}
		cnt[c[v]] = tmp + siz[v];
	}
	
	#define ADD(a, b) 	\
		do {			\
			G[a].push_back(b);	\
			G[b].push_back(a);	\
		}while(0);		
		
	inline void add(int a, int b) {
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
int main() {
	//scanf("%d", &n);
	std::ios::sync_with_stdio(false);
	cin>>n;
	for (int i = 1; i <= n; i++)
		//scanf("%d", &c[i]);
		cin>>c[i];
	for (int i = 1; i < n; i++) {
		int u, v;
		//scanf("%d%d", &u, &v);
		cin>>u>>v;
		//G[u].push_back(v);
		//G[v].push_back(u);
		add(u, v);
		//ADD(u, v); ADD(v, u);
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++) {
		cout<< count(n) - ans[i] - count(n - cnt[i])<<endl;
	}
	return 0;
}


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

int main(){
	long a;
	cin >> a;
	a=log(a-1)/log(3)+1;
	cout << a <<"\n";
return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=8001 ;
int main()
{
   fast ;
   ll n,k ; cin>>n>>k ;
   vector<ll>a(n+1) ;
   for(ll i=1;i<=n;i++) cin>>a[i] ;

   map<ll,ll>ma ;
   ma.insert({1,0}) ;

   ll p=1 ;
   ll ans ;
   vector<ll>path ;
   path.pb(1) ;
   for(ll i=1;i<=2*n;i++)
   {
      ll nx=a[p] ;
     // bug(i) ; bug(nx) ;
      k-- ;
      p=nx ;
      if(k==0)
      {
          ans=nx ;
          break ;
      }
      if(ma.find(nx)==ma.end())
      {
          path.pb(nx) ;
          ma.insert({nx,i}) ;
      }
      else
      {
          ll len=i-ma[nx] ;
         // bug(ma[nx]) ;
          k%=len ;
          ans=path[ma[nx]+k] ;
         // bug(len) ;
          break ;
      }


   }
   cout<<ans ;




}




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

int main(){
	long long int n,a,b;
	cin>>n>>a>>b;
	vector<long long int> x(n);
	for (int i = 0; i < n; i++) {
		cin>>x[i];
	}
	long long int ans=0;
	for (int i = 0; i < n-1; i++) {
		ans+=min((x[i+1]-x[i])*a,b);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int main() {
    int n, m, r, ta, tb, tc;
    long long ret = 1e16;
    std::cin >> n >> m >> r;
    std::vector<int> town(r);
    std::vector<std::vector<long long>> d(n, std::vector<long long>(n, 1000000000000));
    for (auto i = 0; i < r; i++) std::cin >> town[i], town[i]--;
    for (auto i = 0; i < m; i++) {
        std::cin >> ta >> tb >> tc;
        d[ta - 1][tb - 1] = tc;
        d[tb - 1][ta - 1] = tc;
    }

    for (auto i = 0; i < n; i++) d[i][i] = 0;

    for (auto k = 0; k < n; k++) {
        for (auto i = 0; i < n; i++) {
            for (auto j = 0; j < n; j++) {
                d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    std::sort(town.begin(), town.end());

    do {
        long long tmp = 0;
        for (auto i = 1; i < r; i++) {
            tmp += d[town[i-1]][town[i]];
        }
        if (ret > tmp) ret = tmp;
    } while (std::next_permutation(town.begin(), town.end()));

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include<math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)


long long  A[1111111];
int main() {
    long long   N,M;
    cin >> N >> M;
    long long  total = 0;
    rep(i, M) {
        cin >> A[i];
        total += A[i];
    }
    

    if (total > N)cout << "-1" << endl;
     else cout << N-total << endl;
    
    return 0;
}

Measured memory_bytes: 3712
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = IN()
	s = input()
	rc=0
	rc_max=0
	for c in s:
		if c == ')':
			rc+=1
			rc_max=max(rc_max, rc)
		else:
			rc -= 1
	
	lc=0
	lc_max=0
	for c in s[::-1]:
		if c == '(':
			lc += 1
			lc_max=max(lc, lc_max)
		else:
			lc -= 1
	ret = '(' * rc_max + s + ')'*lc_max
	print(ret)
			
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int a, b;

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


Measured memory_bytes: 256
#include<iostream>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
  int n, m; cin >> n >> m;
  int A[110][110] = {0};
  int b[110] = {0};
  long long Ab[110] = {0LL};
  REP(i, n) {
    REP(j, m) {
      cin >> A[i][j];
    }
  }
  REP(i, m) {
    cin >> b[i];
  }
  REP(i, n) {
    REP(j, m) {
      Ab[i] += A[i][j] * b[j];
    }
  }
  REP(i, n) {
    cout << Ab[i] << endl;
  }
}


Measured memory_bytes: 3148
#include<stdio.h>
#include<stdlib.h>
#include<math.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a ;
}

int main(void){
	int n;
	int l[2000];
	int i;
	int j;
	int c;
	int k;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
	}

	qsort(l, n, sizeof(int), compare_int);
	c = 0;
	for(i=0;i<n-2;i++){
		for(j=i+1;j<n-1;j++){
			for(k=j+1;k<n;k++){
				if(l[j] + l[k] <= l[i]){
					break;
				}
				c++;
			}
		}
	}

	printf("%d\n",c);


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
 
 
//c++ templte for help...........................................................
 
//#define deb(x) cout<<#x<<" "<<x<<endl;/* for debuging  printing variable with name*/
//#define debb(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;										
//#define debbb(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;			
 
typedef long long ll;
	
 
//for loop
//#define fo(i,n) for(int i=0;i<(ll)n;i++)
//#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
//template<typename T>
//void printV(T vec){
	//fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	//cout<<endl;
	//}
	
 
//#define modulo 998244353
//const int INF=1e9+5;
 
 
 
 
//c++ template for help........................................................

int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	//cout<<setprecision(2);
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	 // greedy ma jadatr exceptional case check kr ke dekh lo
	 
	 // WHILE DOING THE QUESTION OF DYNAMIC PROGRAMMING GREEDY KA TRAH SOCHNA BAND KRO
	 // DP M DATA KA BHI USE KRNA PDTA HA BE BHULO MT 
	 // DP BHI WO LEETCODE WALE MATRIX KA QUESTION KI TARAH HA
	 // CONSTRAIN WILL BE THE DIMENSION OF DP
	 // DP MA STATE PTA KRO AUR PHIR FUNCTION GENERATE KRO
	 // OBJECT KO CHOOSE KIA YA NAE KIA AGAR KIA TO KYA HOGA AUR NAE KIA TO KYA HOGA
	 // KYA KYA CHEJ IMPORTANT HA WO STATE BN JYAGA AUR HUM LOG STATE KO CHANGE KR SKTA HA JYSA KNPSACK 2 WALE PROBLEM MA KIA THA
	 
	 
	 
	 int x,y,z;
	 cin>>x>>y>>z;
	 
	 cout<<z<<" "<<x<<" "<<y<<endl;
	

	 

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){

    LL int a,b,c,k;
    cin >> a >> b >> c >> k;

    if(k <= a + b){
        cout << min(a, k);
    }else{
        k -= a + b;
        cout << a - k;
    }

    return 0;
}


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

bool visited[100010];
int dfs(int key, vector<vector<int>> &v){
	visited[key]=1;
	int leaf=0;
	for(int i=0; i<v[key].size(); ++i){
		if(!visited[v[key][i]]){
			int kept=dfs(v[key][i], v);
			if(kept<0) return -1;
			leaf += kept;
		}
	}
	if(leaf>1) return -1;
	return 1-leaf;
}

int main() {
	int N;
	cin >> N;
	vector<vector<int>> g(N+1);
	for(int i=1; i<N; ++i){
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cout << (dfs(1, g) ? "First" : "Second") << endl;
	return 0;
}

Measured memory_bytes: 5888
from collections import defaultdict
dd = defaultdict(int)
n=int(input())
for i in range(1, n+1):
    dd[(str(i)[0],str(i)[-1])]+=1
k=0
for i in range(1, 10):
    for j in range(1, 10):
        k+=dd[str(i), str(j)]*dd[str(j), str(i)]
print(k)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
#define FastIO ios::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
typedef long long ll;


int main()
{
   FastIO;
   string s;
   cin >> s;
   if (s.size() == 2) cout << s;
   else reverse(all(s)), cout << s;
   return 0;
}


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

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

    ll A[1000000];
    ll sum = 0;

    ll ans = 0;

    rep(i, n){
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }

    for (int i = 0; i < n; i++){
        sum -= A[i];

        if (sum < 0){
            sum += mod;
        }
        ans += A[i] * sum;
        ans %= mod;
    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<char> t(q);
    VI d(q);
    FOR(i, 0, q) {
        char c;
        cin >> t[i] >> c;
        d[i] = (c == 'L' ? -1 : 1);
    }

    auto check = [&](int x, string type) {
        FOR(i, 0, q) {
            if (s[x] == t[i])x += d[i];
            if (type == "left") {
                if (x < 0)return true;
                if (n <= x)return false;
            }
            else {
                if (x < 0)return false;
                if (n <= x)return true;
            }
        }
        return false;
    };

    int ok = -1, ng = n;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid, "left"))ok = mid;
        else ng = mid;
    }
    int l = ok;

    ok = n, ng = -1;
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid, "right"))ok = mid;
        else ng = mid;
    }
    int r = ok;

    cout << r - l - 1 << "\n";
}


Measured memory_bytes: 1616
#include <stdio.h>
#include <stdlib.h>
int sum(int x,int y[]){
    int i,j,cnt=0;
    for(i=0;i<x-1;i++){
        for(j=i;j<x;j++){
            if(y[i]>y[j]) cnt++;
        }
        cnt*=x-i-1;
    }
    return cnt;
}
int main(void){
    int n,i,j,cnt=0;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++) scanf("%d",&b[i]);
    printf("%d",abs(sum(n,a)-sum(n,b)));
    return 0;
}

Measured memory_bytes: 128
var
  i,i1,j,j1:integer;
  a:array [0..102,0..102] of char;
  b:array [0..102,0..102] of longint;
begin
  readln(i1,j1);
  j:=j1;
  i:=i1;
  while (i>0) do
    begin
      while (j>0) do
        begin
          read(a[i,j]);
          dec(j);
        end;
      readln;
      dec(i);
      j:=j1;
    end;
  for i:= 1 to i1 do
    for j:= 1 to j1 do
      if a[i,j]='#' then begin
                           if b[i-1,j-1]<>-1 then inc(b[i-1,j-1]);
                           if b[i+1,j-1]<>-1 then inc(b[i+1,j-1]);
                           if b[i-1,j+1]<>-1 then inc(b[i-1,j+1]);
                           if b[i+1,j+1]<>-1 then inc(b[i+1,j+1]);
                           if b[i-1,j]<>-1 then inc(b[i-1,j]);
                           if b[i+1,j]<>-1 then inc(b[i+1,j]);
                           if b[i,j-1]<>-1 then inc(b[i,j-1]);
                           if b[i,j+1]<>-1 then inc(b[i,j+1]);
                           b[i,j]:=-1;
                         end;
  for i:= i1 downto 1 do
    begin
      for j:= j1 downto 1 do
        if b[i,j]=-1 then  write('#')
                      else write(b[i,j]);
      writeln;
    end;
end.

Measured memory_bytes: 128
# B(700)
import collections

N, M = map(int, input().split())

A = []
for _ in range(N):
    A.append(list(map(int, input().split())))

res = N
for _ in range(M-1):
    count_dict = collections.Counter([a[0] for a in A])
    sport, count = count_dict.most_common(1)[0]
    res = min(res, count)
    for a in A:
        a.remove(sport)

print(res)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    fast;
    string s,t,ans;
    cin>>s;
    cin>>t;
    ll ss = s.length();
    ll st = t.length();
    
    ll dp[ss+1][st+1];
    for(ll i=0;i<=ss;i++)
        dp[i][0] = 0;
    for(ll i=0;i<=st;i++)
        dp[0][i] = 0;
        
    for(ll i=1;i<=ss;i++){
        for(ll j=1;j<=st;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j] = 1 + dp[i-1][j-1];
            } else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    
    ll i=ss,j=st;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            ans = s[i-1]+ans;
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70656
n, l = map(int, input().split())
ans = []
min_l = 99999
des = 9999999
for i in range(n):
    ans.append(l + i)
    if min_l > abs(l + i):
        min_l = abs(l + i)
        des = l + i
print(sum(ans) - des)

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

struct LowestCommonAncestor {
  LowestCommonAncestor() {}
  LowestCommonAncestor(int V) : V(V) { init(); }
  LowestCommonAncestor(int V, int root) : V(V), root(root) { init(); }

  struct edge {
    edge () {}
    edge (int to, long long cost) : to(to), cost(cost) {}

    int to;
    long long cost;
  };

  const int MAX_LOG_V = 30;

  int V, root = 0;
  vector<vector<edge>> G;
  vector<long long> depth, length;
  vector<vector<int> > parent;


  void init() {
    G.resize(V);
    depth.resize(V);
    length.resize(V);
    parent.resize(MAX_LOG_V, vector<int>(V));
  }

  void add_edge(int u, int v, long long c) {
    G[u].push_back(edge(v, c));
    G[v].push_back(edge(u, c));
  }

  void add_edge(int u, int v) {
    add_edge(u, v, 1ll);
  }

  void dfs(int v, int u, int d, long long l){
    depth[v] = d;
    length[v] = l;
    parent[0][v] = u;
    for (edge e : G[v]) if (e.to != u) {
      dfs(e.to, v, d + 1, l + e.cost);
    }
  }

  void build() {
    dfs(root, -1, 0, 0ll);
    for (int k = 0; k + 1 < MAX_LOG_V; k++) {
      for (int v = 0; v < V; v++) {
        if (parent[k][v] < 0) parent[k + 1][v] = -1;
        else parent[k + 1][v] = parent[k][parent[k][v]];
      }
    }
  }

  int lca(int u, int v) {
    if (depth[u] > depth[v]) swap(u, v);
    for (int k = 0; k < MAX_LOG_V; k++) {
      if ((depth[v] - depth[u]) >> k & 1) {
        v = parent[k][v];
      }
    }

    if (u == v) return u;

    for (int k = MAX_LOG_V - 1; k >= 0; k--) {
      if (parent[k][u] != parent[k][v]) {
        u = parent[k][u];
        v = parent[k][v];
      }
    }

    return parent[0][u];
  }

  long long dist(int u, int v) {
    int z = lca(u, v);
    return length[u] + length[v] - 2 * length[z];
  }
};

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

  LowestCommonAncestor lca(n);

  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;

    for (int j = 0; j < k; ++j) {
      int u;
      cin >> u;

      lca.add_edge(i, u);
    }
  }

  lca.build();

  int q;
  cin >> q;
  while (q--) {
    int u, v;
    cin >> u >> v;

    cout << lca.lca(u, v) << endl;
  }
}

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

int dp[302][302][302];

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int m;
    cin >> m;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    for(int k = 0; k <= m; k++){
        for(int i = 0; i <= n; i++){
            for(int j = 0; j <= n; j++){
                if(i > 0) dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][k]);
                if(j > 0) dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]);
                if(k > 0) dp[i][j][k] = max(dp[i][j][k], dp[i][j][k - 1]);
                if(i > 0 && j > 0){
                    if(s[i - 1] == s[n - j]) dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - 1][k] + 1);
                    else if(k > 0) dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - 1][k - 1] + 1);
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans = max(ans, dp[i][n - i - 1][m] * 2 + 1);
    }
    for(int i = 0; i <= n; i++){
        ans = max(ans, dp[i][n - i][m] * 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 107520
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>

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


int main() {
    int N, A[110];
    cin >> N;

    rep(i, N) cin >> A[i];

    int counter = 0;

    rep(i, N) {
        if(A[i]%2 != 0) {
            counter++;
            continue;
        } else if (A[i]%3==0 || A[i]%5==0) {
            counter++;
            continue;
        } else {
            break;
        }
    }
    if (counter == N)  cout << "APPROVED" << endl;
    else               cout << "DENIED" << endl;

    return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[], int n, int key){
  int i = 0;
  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(){
  int i, n, A[10000+1], q, key, sum=0;
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }
  printf("%d\n", sum);
}

Measured memory_bytes: 1064
#include <stdio.h>
#include <algorithm>
using namespace std;

int N,H[100100],D[100100];
int main()
{
	scanf ("%d",&N);

	for (int i=1;i<=N;i++) scanf ("%d",&H[i]);
	for (int i=2;i<=N;i++){
		D[i] = D[i-1] + abs(H[i-1]-H[i]);
		if (i > 2 && D[i] > D[i-2] + abs(H[i-2]-H[i]))
			D[i] = D[i-2] + abs(H[i-2]-H[i]);
	}
	printf ("%d\n",D[N]);

	return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    n -= k;
    k -= 1;
    int count = 1;
    
    while(n > 0){
      n -= k;
      count++;
    } 
    
    System.out.println(count);
  }
}


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

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

	vector<int> a(n);
	rep(i, n) cin >> a.at(i);

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int alice = 0;
	int bob = 0;
	rep(i, n){
		if(i%2 == 0)
			alice += a.at(i);
		else
			bob += a.at(i);
	}
	cout << alice-bob << endl;
}

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

int main(){
    LL N;
    cin >> N;
    vector<LL> c(N), s(N), f(N);
    for(LL i = 1;i < N;i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(LL i = 1;i <= N;i++){
        LL T = 0;
        for(LL j = i;j < N;j++){
            if(T < s[j])  T = s[j];
            if(T%f[j])  T += f[j]-T%f[j];
            T += c[j];
        }
        cout << T << endl;
    }
}

Measured memory_bytes: 256
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
	int L;
	cin >> L;

	double x = L / 3.0;
	col(x * x * x);

	return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
//#include<numeric>
using namespace std;
int cal_gcd(int a, int b){
	if(a%b==0){
		return b;
	}else{
		return cal_gcd(b, a%b);
	}
}
int main()
{
	int A,B,K;
	cin >> A >> B >> K;
	
	if(A<B){
		int tmp=A;
		A=B;
		B=tmp;
	}
	int max=cal_gcd(A,B);
	
	for(int i=max; i>=1; i--){
		if(max%i==0){
			K--;
		}
		if(K==0){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n,q = map(int,input().split())

node = [[] for _ in range(n+1)]
counter = [0 for _ in range(n+1)]
visited = [0 for _ in range(n+1)]
point_dic = defaultdict(int)

for _ in range(n-1):
    a,b = map(int,input().split())
    node[a].append(b)
    node[b].append(a)

for _ in range(q):
    p,x = map(int,input().split())
    point_dic[p] += x

def dfs(now,before):
    global counter
    global visited

    if visited[now]:
        return
    
    if point_dic[now]:
        point = point_dic[now]+before
    else:
        point = before
    
    visited[now] = 1
    counter[now] += point

    for i in node[now]:
        if visited[i]:
            continue

        dfs(i,point)

dfs(1,0)

print(' '.join(map(str, counter[1:])))

Measured memory_bytes: 253160
A, B, C, D, = input().split()
A, B, C, D, = int(A), int(B), int(C), int(D)
def lcm(a,b):
    m = a*b
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return m // (a+b)
for_D_start = B // D
for_C_start = B // C
sum_start = for_C_start + for_D_start - B // lcm(C,D)
for_C_A = (A-1) // C
for_D_A = (A-1) // D
sum_A = for_C_A + for_D_A - (A-1) // lcm(C,D)
print(B - A + 1 - (sum_start - sum_A))
#print(for_D_A, for_C_A, for_D_start, for_C_start, sum_A, sum_start)

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

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

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}


int main(){

    ll k, s; cin >> k >> s;

    ll ans1 = 0;
    rep(x, k-1){
        rep2(y, x+1, k){
            rep2(z, y+1, k+1){
                if(x+y+z==s) ans1++;
            }
        }
    }

    ll ans2 = 0;
    rep(x, k){
        rep2(y, x+1, k+1){
            if(x+x+y==s) ans2++;
            if(x+y+y==s) ans2++;
        }
    }

    ll ans3 = 0;
    rep(x, k+1){
        if(x+x+x==s) ans3++;
    }

    cout << ans1*6 + ans2*3 + ans3 << endl;

    return 0;
}

Measured memory_bytes: 3604
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextLong();
        long r = sc.nextLong();
        long min = Long.MAX_VALUE;
        int cnt = 0;
        if(r-l>=2018) {

            System.out.println(0);
            return;
        }
        for(long i = l; i<r; i++) {
            for(long j = i+1; j<=r; j++) {
                cnt++;
                //if(cnt>=2020) break;
                min = Math.min((i*j)%2019, min);
            }
            //if(cnt>=2020) break;
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cassert>
#include<vector>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const long long inf = 1145141919810000;
typedef pair<int, int> P;

signed main() {
	int d; cin >> d;
	cout << "Christmas";
	for (int i = 24; i >= d; i--) {
		cout << " Eve";
	}
	cout << endl;
}

Measured memory_bytes: 768
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l1=[]
l2=[]
for i in range(n):
  a,b=nii()
  l1.append(a)
  l2.append(b)

l1.sort()
l2.sort()

if n%2==1:
  ans=l2[n//2]-l1[n//2]
else:
  m1=(l2[n//2]+l2[n//2-1])
  m2=(l1[n//2]+l1[n//2-1])
  ans=m1-m2

print(ans+1)

Measured memory_bytes: 25364
#include<cstring>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

#define ran 303333

int n;
long long l;
string s;

int nxt[ran][2], tail = 1;
long long ans;

long long sg(int dep) {
	long long rem = l-dep+1;
	return rem & -rem;
}

void dfs(int cur, int dep) {
	for(int i=0;i<2;i++)
		if (nxt[cur][i] == -1) ans ^= sg(dep);
		else dfs(nxt[cur][i], dep+1);
}

int main() {
	memset(nxt, -1, sizeof nxt);
	cin>>n>>l;
	for(int i=0;i<n;i++) {
		cin>>s;
		int it = 0;
		for(int j=0;j<s.size();j++) {
			int dir = s[j] - '0';
			if (nxt[it][dir]==-1) nxt[it][dir] = tail++;
			it = nxt[it][dir];
		}
	}
	ans = 0LL;
	dfs(0, 1);
	puts(ans==0 ? "Bob" : "Alice");
	
	return 0;
}

Measured memory_bytes: 7552
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=1;
		int d=0;
		while(c<b) {
			c+=(a-1);
			d++;
		}
		System.out.println(d);

	}

}


Measured memory_bytes: 24276
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 1000, N;
vll A, diff;

void solve(){
    rep(i, N-1){
        if(diff[i+1] > 0){
            ans += diff[i+1]* (ans / A[i]);
        }
    }

    cout << ans << endl;
}

int main(){
    cin >> N;
    A.resize(N);
    diff.resize(N+1);

    rep(i, N) cin >> A[i];
    
    rep(i, N-1){
        diff[i+1] = A[i+1] - A[i];
    }

    solve();
}


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

int main() {
  long long N;
  cin >> N;

	vector<long long> L(N+1);
	L.at(0) = 2;
	L.at(1) = 1;
	for(int i=2;i<=N;i++){
		L.at(i) = L.at(i-1) + L.at(i-2);
	}

  cout << L.at(N) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 100005

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    int n,a,b;
    cin>>n>>a>>b;
    int val = (a%n==0?0:n-a%n);
    val += a;
    if(val<=b){
        cout<<"OK";
    }
    else{
        cout<<"NG";
    }
}


Measured memory_bytes: 3608
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
 
parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine
 
main = do
  s <- getLine
  putChar . chr . (+) 1 . ord . head $ s
  putStrLn ""



Measured memory_bytes: 380
n, m, X, Y = map(int, input().split())
xlist = list(map(int, input().split()))
ylist = list(map(int, input().split()))
xlist.append(X)
ylist.append(Y)
xlist.sort()
ylist.sort()
xlist.reverse()

if xlist[0] < ylist[0]:
   print("No War")
else:
   print("War")


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

typedef long long ll;

int main(int argc, char *argv[]) {
  ll H, W;
  cin >> H >> W;

  ll a[H][W];
  for (ll i = 0; i < H; ++i) {
    for (ll j = 0; j < W; ++j) {
      cin >> a[i][j];
    }
  }

  vector<string> ans;
  for (ll i = 0; i < H; ++i) {
    for (ll j = 0; j < W-1; ++j) {
      if (a[i][j] == 0) continue;
      if (a[i][j] % 2 == 0) continue;
      a[i][j]--;
      a[i][j+1]++;
      stringstream ss;
      ss << i+1 << " " << j+1 << " " << i+1 << " " << j+2;
      ans.push_back(ss.str());
    }
  }

  for (ll i = 0; i < H-1; ++i) {
    if (a[i][W-1] == 0) continue;
    if (a[i][W-1] % 2 == 0) continue;
    a[i][W-1]--;
    a[i+1][W-1]++;
    stringstream ss;
    ss << i+1 << " " << W << " " << i+2 << " " << W;
    ans.push_back(ss.str());
  }

  cout << ans.size() << endl;
  for (auto itr = ans.begin(); itr != ans.end(); ++itr) {
    cout << *itr << endl;
  }

  return 0;
}

Measured memory_bytes: 10868