akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int N,M,A,B,countA;
bool num[200000]={0};
vector<int> E[200000];

void dfs(int p,int n){
	for(int i : E[n]){
		if(i==p)continue;
		if(num[i])continue;
		num[i]=true;
		countA++;
		dfs(n,i);
	}
}
int main(){
	int m;
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>A>>B;A--;B--;
		E[A].push_back(B);
		E[B].push_back(A);
	}
	m=0;
	for(int i=0;i<N;i++){
		countA=0;
		if(!num[i]){
			countA++;
			num[i]=true;
		}dfs(-1,i);
		m=max(m,countA);
	}
	cout<<m;
	return 0;
}

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

signed main() {
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;

    vector<int> A(a),B(b),C(c);
    rep(i,a) cin >> A[i];
    rep(i,b) cin >> B[i];
    rep(i,c) cin >> C[i];

    sort(A.begin(),A.end(), greater<int>());
    sort(B.begin(),B.end(), greater<int>());
    sort(C.begin(),C.end(), greater<int>());

    priority_queue<int, vector<int>, greater<>> sum;
    priority_queue<int> que;

    for(int i = 0 ;i < x; i++){
        sum.push(A[i]);
    }
    for(int i = 0; i < y; i++){
        sum.push(B[i]);
    }
    for(int i = 0; i < c; i++){
        que.push(C[i]);
    }

    while(true){
        if(que.top() <= sum.top()) break;
        int P = sum.top();
        int Q = que.top();
        sum.pop();
        que.pop();
        sum.push(Q);
        que.push(P);
    }
    int ans = 0;
    while(!sum.empty()){
        int r = sum.top();
        sum.pop();
        ans += r;
    }
    cout << ans << endl;
}

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

int main(){
  int num[3],f=0,ff=0;

  for(int i=0;i<3;i++){
    cin>>num[i];
    if(num[i]==5)f++;else if(num[i]==7)ff++;
  }

  if(f==2&&ff==1)cout<<"YES"<<endl;else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    long long x,y; cin >> x >>y;
    long long cnt = 0;
    cnt += abs(abs(x) - abs(y));
    if(x < 0 && y  < 0 && x > y)cnt += 2;
    if(((x < 0 && y > 0) || (x > 0 && y < 0)))cnt++;
    if(x > 0 && y > 0 && x > y)cnt += 2;
    if(x == 0 && y < 0)cnt++;
    if(y == 0 && x > 0)cnt++;
    cout << cnt  << endl;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/12/29
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;

int main()
{
	char S[11] = {0}, T[11], U[11];
	int A = 0, B = 0;
	int ret = 0;
	scanf("%s %s", S, T);
	scanf("%d %d", &A, &B);
	scanf("%s", U);

	ret = strcmp(S,U);
	if (ret == 0) {
		A--;
	}
	ret = strcmp(T,U);
	if (ret == 0) {
		B--;
	}
	printf("%d %d\n", A, B);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define int ll
typedef set<int> seti;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	int a,b; cin>>a>>b;
	int t;
	int c1=0,c2=0,c3=0;
	while(n--)
	{
		cin>>t;
		if(t<=a) c1++;
		else if(t<=b) c2++;
		else c3++;
	}
	cout<<min(min(c1,c2),c3)<<"\n";
	return 0;
}









Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
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; }

int main(){
  int n; cin >> n;
  map<int,int> mp;
  bool zero = true;
  rep(i,n){
    int a; cin >> a;
    mp[a]++;
    if(a) zero = false;
  }
  bool ok = true;
  if(n % 3 != 0 || 3 < mp.size()) ok = false;
  for(auto x : mp) if(x.second%(n/3) != 0) ok = false;
  int check = 0;
  for(auto x : mp) rep(i,x.second/(n/3)) check ^= x.first;
  cout << (zero || ok && check==0 ? "Yes" : "No");
  cout << "\n";
  return 0;
}


Measured memory_bytes: 7148
D, N = map(int,input().split())

n_cnt = 0
i = 0

while n_cnt < N:
  i += 1
  
  d_cnt = 0
  tmp = i
  while tmp % 100 == 0:
    tmp = tmp // 100
    d_cnt += 1
    
  if d_cnt == D:
    n_cnt += 1
    
print(i)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> L(n);
    rep(i,n) cin >> L[i];
    int d=0 ,cnt=1;
    rep(i,n){
        int p=d+L[i];
        if(p<=x)cnt++;
        d=p;
    }
    cout << cnt << endl;
    return 0;
}


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

const long long p= 1000000007;

int main(){
    int N;
    cin >> N;
    long long A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    long long sum = 0;
    long long ct = 0;
    for(int i = 0; i < N; i++){
        sum = (sum + A[i])%p;
        ct = (ct +  A[i]*A[i])%p;
    }
    long long pinv = (p+1)/2;
    cout << pinv*((p + sum*sum -ct)%p)%p<< endl;
}

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

int main() {
    int n;
    long long k;
    cin >> n >> k;
    vector<pair<long long, long long>> a(n);
    for (auto& e : a) cin >> e.first >> e.second;
    sort(a.begin(), a.end());
    
    long long seen = 0;
    long long ans = -1;
    for (const auto& e : a) {
        int c, v; tie(v, c) = e;
        seen += c;
        if (seen >= k) {
            ans = v;
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int main(){
	int N, M, C, check;
	int count = 0;
	cin >> N >> M >> C;
	int B[M], A[N][M];
	for(int i = 0; i < M; i++){
		cin >> B[i];
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cin >> A[i][j];
		}
	}
	for(int i = 0; i < N; i++){
		check = 0;
		for(int j = 0; j < M; j++){
			check += B[j]*A[i][j];
		}
		if(check + C > 0){
			count++;
		}
	}	
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
  $n = 0;
  $k = 0;
  $mod = 0;

  list($n, $k) = sscanf(fgets(STDIN), "%d %d");
  
  $mod = $n % $k;
  if($mod > abs($mod - $k))
    print(abs($mod - $k));
  else
    print($mod);

?>


Measured memory_bytes: 4728
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int mem = sc.nextInt();
		int minHeight = sc.nextInt();
		int count = 0;

		for (int i = 0; i < mem; i++) {
			if (minHeight <= sc.nextInt()) {
				count++;
			}
		}

		System.out.println(count);

	}
}


Measured memory_bytes: 46752
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=101010;
struct kek{
    int a,b,c;
}a[N];

int32_t main(){
    int x,y,z;
    cin>>x>>y>>z;
    int n=x+y+z;
    forn(i,n)cin>>a[i].a>>a[i].b>>a[i].c;
    sort(a,a+n,[](const kek&p1,const kek&p2){
        return p1.a-p1.b>p2.a-p2.b;
    });
    set<pii> sleva_a;
    // set<pii,greater<pii>> sleva_c;
    // set<pii> sprava_b;
    set<pii,greater<pii>> sprava_c;
    int cur=0;
    forn(i,x){
        sleva_a.insert({a[i].a-a[i].c,i});
        cur+=a[i].a;
    }
    for(int i=x;i<n;++i){
        sprava_c.insert({a[i].b-a[i].c,i});
        cur+=a[i].c;
    }
    while(sz(sprava_c)>z){
        pii v=*sprava_c.begin();
        sprava_c.erase(sprava_c.begin());
        cur+=a[v.s].b-a[v.s].c;
        // sprava_b.insert(v);
    }
    int ans=cur;
    for(int i=x;i<x+z;++i){
        {
            pii v={a[i].b-a[i].c,i};
            auto it=sprava_c.find(v);
            if(it!=sprava_c.end()){
                sprava_c.erase(it);
                cur-=a[i].c;
            }else{
                // sprava_b.erase(v);
                cur-=a[i].b;
                pii u=*sprava_c.begin();
                cur+=a[u.s].b-a[u.s].c;
                sprava_c.erase(u);
                // sprava_b.insert(u);
            }
        }
        {
            sleva_a.insert({a[i].a-a[i].c,i});
            cur+=a[i].a;
            pii v=*sleva_a.begin();
            sleva_a.erase(sleva_a.begin());
            cur+=a[v.s].c-a[v.s].a;
            // sleva_c.insert(v);
        }
        upx(ans,cur);
    }
    cout<<ans<<'\n';

    return 0;
}

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

using namespace std;

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> vec(n);
    for (int i = 0; i < n && cin >> vec[i]; i++);
    sort(vec.begin(), vec.end());
    for (int i = 0; i < n; i++)
        cout << vec[i];
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define ci(n) cin >> n
#define co(n) cout << n << endl
using namespace std;

int main(){
  string s;
  cin >> s;
  bool f=false;
  int a, ans;
  s[s.size()-1]='A';
  a=s.size()/2;
  int c=0, d=0;
  while(f==false){
    rep(i,0,a){
      if(s[i]==s[i+a]) c++;
    }
    if(c==a){
      ans=2*a;
      f=true;
    }
    else{
      a--;
      c=0;
    }
  }
  co(ans);
      
         
         
    
    
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

ll dp[100010];

int main()
{
  int N,M;
  cin >> N >> M;

  for( int i=0;i<N+3;i++ )
    dp[i] = 0;
  
  for( int i=0;i<M;i++ )
    {
      int tmp;
      cin >> tmp;
      dp[tmp] = -1;
    }

  dp[0] = 1;
  
  for( int i=0;i<N+1;i++ )
    {
      if(dp[i] == -1)
	continue;
      
      if(dp[i+1] != -1)
	dp[i+1] = (dp[i+1]+dp[i])%1000000007;
      if(dp[i+2] != -1)
	dp[i+2] = (dp[i+2]+dp[i])%1000000007;
    }
  
  //  for( int i=0;i<N+1;i++ )
  //    cout << i << " " << dp[i] << endl;;
  
  cout << dp[N] << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int l, r, a[210], now;
ll m;
int main(){
	scanf("%lld", &m); m++; l=0; r=201; now=0;
	while(m>=2){
		if(m&1){now++; a[++l]=now; m--;}
		now++; a[--r]=now; m>>=1;
	}
	printf("%d\n", now<<1);
	for(int i=1; i<=l; i++)printf("%d ", a[i]);
	for(int i=r; i<=200; i++)printf("%d ", a[i]);
	for(int i=now; i>=2; i--)printf("%d ", i); printf("1");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main(){
  int n;
  int *p;
  int i;
  int count=1;
  int min;
  
  scanf("%d",&n);
  p=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  min=p[0];
  
  for(i=1;i<n;i++){
    if(min>=p[i]){
      count++;
      min=p[i];
    }
  }
  
  printf("%d",count);
  free(p);
}


Measured memory_bytes: 896
#include <cstdio>

#define MAXN 1000010
#define mod 1000000007

unsigned long long n,f[MAXN],add;

int main()
{
    scanf("%d",&n);
    f[n]=n;
    f[n-1]=n*n%mod;
    for(int i=n-2;i>=1;--i)
    {
        add=(add+f[i+3])%mod;
        f[i]=(f[i+1]+(n-1)*(n-1)%mod)%mod;
        f[i]=(f[i]+add+i+1)%mod;
    }
    printf("%d\n",f[1]);
}

Measured memory_bytes: 7936
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> Point;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, PP> PPP;
typedef pair<double, Point> P2;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

Point Ps[500];
bool used[500];

double dis(Point p1, Point p2){
	return sqrt((p1.real() - p2.real())*(p1.real()-p2.real()) + (p1.imag() - p2.imag())*(p1.imag() - p2.imag()));
}

int main(){
	int n;
	while(cin >> n && n){
		memset(used, false,sizeof(used));
		for(int i = 0; i < n; i++){
			int x, y;
			cin >> x >> y;
			Ps[i] = Point(x, y);
		}
		Point pre = Point(0, 0);
		double res = 0.0;
		double theta = M_PI;
		for(int i = 0; i < n; i++){
			int best = 0;
			double bestang = 1e10;
			for(int j= 0; j < n; j++){
				if(used[j]) continue;
				double a = atan2(Ps[j].imag() - pre.imag(), Ps[j].real() - pre.real());
				double b;
				if(theta - a < 0.0) b = 2 * M_PI + theta - a;
				else b = theta - a;
				if(b < bestang - EPS || (b < bestang + EPS && b > bestang - EPS &&
					dis(pre, Ps[best]) > dis(pre, Ps[j]))) 
				{
					best = j;
					bestang = b;
				}
			}

			used[best] = true;
			res += dis(pre, Ps[best]);
			theta = atan2(Ps[best].imag()-pre.imag(), Ps[best].real()-pre.real());
			pre = Ps[best];
		}
		cout << fixed << setprecision(1) << (int)(res * 10 + 0.5) / 10.0 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll n,k;cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    vvi dp(n,vi(k+1));
    rep(i,v[0]+1)dp[0][i]=1;
    REP(i,1,n){
        vi rui(k+2);
        rep(j,k+1)rui[j+1]=(rui[j]+dp[i-1][j])%mod;
        rep(j,k+1){
            dp[i][j]=(rui[j+1]-rui[max(0ll,j-v[i])]+mod)%mod;
        }
    }
    out(dp[n-1][k]);
}

Measured memory_bytes: 79472
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n, max=0;
  cin >> n;
  map<string, int> memo;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    memo[s]++;
  }
  for(const auto& x: memo){
    int v = x.second;
    if(max < v){
      max = v;
    }
  }
  
  for(auto it = memo.begin(); it != memo.end(); it++){
    if(it->second == max){
      cout << it->first <<endl;
    }
  }
  
}

Measured memory_bytes: 25216
import itertools
N = int(input())
count = 0
for i in range(3, len(str(N)) + 1):
    for j in itertools.product('753', repeat=i):
        if int(''.join(j)) <= N and '3' in str(j) and '5'in str(j) and '7' in str(j):
            count += 1

print(count)


Measured memory_bytes: 9132
R,G,B,N = map(int,input().split())
rgb = [R,G,B]
rgb.sort()
cnt = 0

N_b = N//rgb[2]
for i in range(N_b,-1,-1):
    x = N - i*rgb[2]
#    print(x)
    N_g = x//rgb[1]
    for j in range(N_g,-1,-1):
#        print(i,j)
        if (x - j*rgb[1])%rgb[0]==0:
            cnt += 1
print(cnt)
    

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  int i,j,k,n,v;
  int A[1000];

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

  for (k = 0 ; k < n ; k++){
    printf ("%d",A[k]);
    if (k < n-1) printf (" ");
    else if (k == n-1) printf ("\n");
  }

  for (i = 1 ; i <= n-1 ; i++){
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for (k = 0 ; k < n ; k++){
      printf ("%d",A[k]);
      if (k < n-1) printf (" ");
      else if (k == n-1) printf ("\n");
    }
  }
  
  return 0;
}

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

int main() {
  long N;
  cin >> N;
  vector<long> A(N);
  for (long i = 0; i < N; i++) cin >> A.at(i);
  sort(A.rbegin(), A.rend());
  long a = 0, b = 0;
  for (long i = 0; i + 1 < N; i++) {
    if (A.at(i) == A.at(i + 1)) {
      if (!a) a = A.at(i++);
      else b = A.at(i++);
      if (b) break;
    }
  }
  cout << a * b << "\n";
}

Measured memory_bytes: 3892
N, K = map(int, input().split())
A = list(map(int, input().split()))

table = {}
init_table = {}
move = {}

for i in range(N):
    if A[i] not in table:
        table[A[i]] = i
        init_table[A[i]] = i
    else:        
        move[table[A[i]]], move[i] = i+1, init_table[A[i]]+1
        table[A[i]] = i

T = K
idx = 0
remain = [0]
for i in range(1, K+1):
    while idx in move and idx < move[idx]:
        idx = move[idx]
    remain.append(idx)
    if(idx == N and i != K):
        T = K % i
        break
    if idx in move:
        idx = move[idx]
    else:
        idx += 1

if(T == 0):
    print()
    exit()
idx = remain[T]
ret = []
while idx < len(A):
    while idx in move and idx < move[idx]:
        idx = move[idx]
    if(idx < len(A)):
        ret.append(A[idx])
    idx += 1

print(*ret)



Measured memory_bytes: 122816
#include<iostream>
#include<vector>
#include<string>
#include<set>
using namespace std;

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

	vector<string>sina(n);
	int i;
	for (i = 0; i < n; i++)cin >> sina[i];
	vector<string>ans;
	set<string> s;
for(i=0;i<n;i++){
  s.insert(sina[i]);
}
	cout << s.size()<< endl;

	return 0;
}



Measured memory_bytes: 25136
h,w = map(int, input().split())

if h == 1 or w == 1:
    print(1)
    exit()

if h % 2 == 0:
    print((h//2)*w)
    exit()

elif w % 2 == 0:
    print((w//2)*h)
    exit()



print(h * (w//2) + ((h // 2) + 1))


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

int main() {
	vector<int>v;
	int q; cin >> q;
	rep(i, q) {
		int a; cin >> a;
		if (a == 0) {
			int x; cin >> x;
			v.push_back(x);
		}
		else if (a == 1) {
			int x; cin >> x;
			cout << v[x] << endl;
		}
		else v.pop_back();
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  int a[200001], b[200001];
  cin >> n;
  rep(i, 0, n) cin >> a[i], b[i] = a[i];

  sort(a, a + n);

  rep(i, 0, n) {
    if(b[i] > a[n / 2 - 1]) {
      cout << a[n / 2 - 1] << endl;
    }else {
      cout << a[n / 2] << endl;
    }
  }
}


Measured memory_bytes: 3712
def rm_bit(n, i):
    return n // (2**(i+1)) * (2**i) + (n % (2**i))


def ins_bit(n, i, b):
    return n // (2**i) * (2**(i+1)) + (n % (2**i)) + b * (2**i)


def solve(N, A, B):
    if N == 1:
        return [A, B]
    idx = -1
    for i in range(N):
        if (A ^ B) & (2**i):
            idx = i
            break
    ra = rm_bit(A, idx)
    rb = rm_bit(B, idx)
    a = list(map(lambda x: ins_bit(x, idx, (A >> idx) & 1), solve(N-1, ra, ra ^ 1)))
    b = list(map(lambda x: ins_bit(x, idx, (B >> idx) & 1), solve(N-1, ra ^ 1, rb)))
    return a + b


def main():
    N, A, B = map(int, input().split())
    x = A ^ B
    cnt = 0
    for i in range(N):
        if x & (2**i):
            cnt += 1
    if cnt % 2 == 0:
        print("NO")
    else:
        print("YES")
        print(*solve(N, A, B))


if __name__ == "__main__":
    main()


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


long long int solveknapsack(long long int w[],long long int v[],long long int N,long long int weight, long long int** dp)
{
	if(N<0)
    return 0;
  if(dp[N][weight]!=-1)
    return dp[N][weight];
  if(w[N]<=weight)
  {
    dp[N][weight]=max(solveknapsack(w,v,N-1,weight,dp),v[N]+solveknapsack(w,v,N-1,weight-w[N],dp));
    return dp[N][weight];
  }
  else
  {
     dp[N][weight]=solveknapsack(w,v,N-1,weight,dp);
     return dp[N][weight];
  }
}
long long int knapsack(long long int wt[], long long int val[], long long int n, long long int W) 
{ 
    long long int** dp; // double pointer to declare the table dynamically 
    dp = new long long int*[n]; 
  
    for (int i = 0; i < n; i++)  
        dp[i] = new long long int[W+1];     
  
    for (long long int i = 0; i < n; i++)  
        for (long long int j = 0; j < W+1; j++)  
            dp[i][j] = -1; 
    return solveknapsack(wt, val, n-1, W, dp); 
} 
  
               
int main()
{
	long long int n,W;
	scanf("%lld %lld", &n,&W);
	long long int v[n],w[n];
	for(long long int a=0;a<n;a++)
	scanf("%lld %lld", &w[a],&v[a]);
	long long int res=knapsack(w,v,n,W);
	printf("%lld", res);
}

Measured memory_bytes: 78592
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
using namespace std;
int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] - a[0] << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
title = str(input())
leng = len(title)
times = 0
if not leng % 2:
  for i in range(1, int(leng/2)+1):
    if not title[-i] == title[-leng+i+-1]:
      title[-i].replace(title[-i], title[-leng+i-1])
      times += 1
else:
  for i in range(1, int(leng/2)+1):
    if not title[-i] == title[-leng+i-1]:
      title[-i].replace(title[-i], title[-leng+i-1])
      times += 1
print(times)

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

int main(){
  string s,t;
  int n=0;
  cin >> s >>t;
  for (int i = 0; i < t.size(); i++)
  {
    if (s.at(i)!=t.at(i))n++;
    
  }
  cout << n;
}


Measured memory_bytes: 3920
import java.util.*;
public class Main{
  
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int abc[] = new int[3];
    for(int i = 0;i < 3;i++){
        abc[i] = sc.nextInt();
    }

    int answer = abc[0] + abc[1];

    if(answer >= abc[2]){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }
}
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n, r;
    cin >> n >> r;
    cout << r + 100 * max(10 - n, 0) << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n;
    cin>>n;
    vector<pll> a(n*2);
    ll sum1=0;
    ll sum2=0;
    for(int i=0;i<n;i++){
        cin>>a[i*2].F>>a[i*2+1].F;
        sum1+=a[i*2].F;
        sum2+=a[i*2+1].F;
        a[i*2].S=i;
        a[i*2+1].S=i;
    }
    sort(a.begin(),a.end());
    ll ans=min(sum1,sum2);
    sum1=0;
    vector<ll> count(n,0);
    bool done=false;
    for(int i=0;i<n;i++){
        sum1+=a[i].F;
        count[a[i].S]++;
        if(count[a[i].S]==2){done=true;}
    }
    if(done){ans=sum1;}
    else{
        for(ll i=n;i<2*n;i++){
            if(a[n-1].S==a[i].S){
                ans=min(ans,sum1+a[i].F-a[n-2].F);
            }
            else{
                ans=min(ans,sum1+a[i].F-a[n-1].F);
            }
        }
    }
    cout<<ans<<endl;
    
    
    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i = 0; i < W+2; i++) {
    cout << '#';
  }
  cout << endl;
  
  for (int j = 0; j < H; j++) {
    string a;
    cin >> a;
    cout << '#' << a << '#' << endl;
  }
  for (int i = 0; i < W+2; i++) {
    cout << '#';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


template<std::size_t T>
class ncr_t {
public:
  ncr_t() {
    memo_ = std::unique_ptr<std::unique_ptr<long long[]>[]>(new std::unique_ptr<long long[]>[T]);

    for (int i = 0; i < T; i ++) {
      memo_[i] = std::unique_ptr<long long[]>(new long long[T]);

      memo_[i][0] = memo_[i][i] = 1;
    }

    for (int i = 1; i < T; i ++)
      for (int j = 1; j < i; j ++)
        memo_[i][j] = memo_[i - 1][j - 1] + memo_[i - 1][j];
  };

public:
  long long operator()(int n, int r) const {
    assert(r <= n);

    return memo_[n][r];
  };

private:
  std::unique_ptr<std::unique_ptr<long long[]>[]> memo_;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(9);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A, B;

  long long v[55];

  std::cin >> N >> A >> B;

  for (int i = 0; i < N; i ++)
    std::cin >> v[i];

  std::sort(v, v + N, std::greater<long long>());

  std::vector<std::pair<long long, int>> a;

  long long sp = 0, np = 1;

  long long s = 0;
  
  for (int i = 1; i <= N; i ++) {
    s += v[i - 1];

    if (A <= i && i <= B) {
      double m = 1. * s / i;

      a.emplace_back(s, i);

      if (s * np > sp * i) {
        sp = s;
        np = i;
      }
    }
  }

  std::cout << 1. * sp / np << std::endl;

  long long C = 0;

  ncr_t<100> ncr;

  for (const auto& pair : a) {
    long long s = pair.first, n = pair.second;

    if (s * np == sp * n) {
      long long target = v[n - 1];
      
      int c1 = std::count(v, v + N, target), c2 = std::count(v, v + n, target);

      C += ncr(c1, c2);
    }
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double ave = (a + b) / 2;
        
        System.out.println(Math.round(ave));
    }
}


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

int main(void){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d;
  if(a>=b)e=b;
  else e=a;
  if(c>=d)f=d;
  else f=c;
  cout<<e+f;
  return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d",$N);
// var_dump($N);
$arr = explode(" ",trim(fgets(STDIN)));//1000000000 1000000000
// var_dump($arr);
$res = 0;
//0が配列の中になければ実行される
if(!array_search(0,$arr)){//もし0が$arrの中になければ
    $res = 1;//$resを1にする
    for($i=0; $i<$N; $i++){//2回ループする
        $res = $res * $arr[$i];//
    }
    if($res > pow(10,18)){
        $res = -1;
    }
}
echo $res;


Measured memory_bytes: 25496
<?php
list($n, $m) = array_map("intval", explode(" ", trim(fgets(STDIN))));
$di = new Di($n);
for($i = 0; $i < $m; $i++){
  list($from, $to, $d) = array_map("intval", explode(" ", trim(fgets(STDIN))));
  $di->connect($from, $to, $d);
}
for($i = 2; $i <= $n; $i++){
  $di->connect($i, $i - 1, 0);
}
$distance =  $di->solve(1)[$n];
if($distance == $di->inf){
  echo -1;
}else{
  echo $distance;
}

class Di{
  public $pq;
  public $distance;
  public $G;
  public $inf = 10**18;
  function __construct($n) {
    $this->pq = new SplPriorityQueue();
    for($i = 1; $i <= $n; $i++){
      $this->distance[$i] = $this->inf;
    }
  }
  function connect($from, $to, $cost){
    $this->G[$from][] = [$to, $cost];
  }
  function solve($from){
    $this->pq->insert($from, 0);
    $this->distance[$from] = 0;
    while($this->pq->count()){
      $f = $this->pq->extract();
      if(!isset($this->G[$f]))continue;
      foreach($this->G[$f] as list($t, $dist)){
        $new = $this->distance[$f] + $dist;
        if($this->distance[$t] > $new){
          $this->distance[$t] = $new;
          $this->pq->insert($t, -$new);
        }
      }
    }
    return $this->distance;
  }
}

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

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

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

const int INF = 1 << 30;

int main() {
    int N; cin >> N;
    int h[N+10];
    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }
    int dp[N+10];
    for (int i = 1; i <= N; i++) {
        dp[i] = INF;
    }
    dp[1] = 0;
    for (int i = 2; i <= N; i++) {
        if (2 < i) {
            chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

	int s, n, i, j, check, num[100000];

	scanf("%d", &s);
	n = s;
	num[1] = n;
	i = 2;
	check = 0;

	while(1){
		if(n % 2 == 0){
			n = n / 2;
		}else{
			n = 3 * n + 1;
		}
		num[i] = n;
		for(j = 1; j < i; j++){
			if(num[i] == num[j]){
				check = 1;
			}
		}
		if(check == 1) break;
		i++;
	}

	printf("%d", i);
	
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    long long A = 0;
    vector<int>d(N);
    rep(i, N)cin >> d[i];
    rev(i, N) rev(j, i)A += d[i] * d[j];
    cout << A << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        boolean isOK = true;
        int prev = 0;
        for(int i=0; i<n; i++) {
            int h = in.nextInt();
            isOK = isOK && (h >= prev);
            prev = Math.max(prev, h-1);
        }
        System.out.println(isOK ? "Yes" : "No");
    }
}


Measured memory_bytes: 48428
// ABC171D
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
vector<ll>v(100000+1);
int main() {
	int n,t,q;
	cin >>n;
	ll s1=0;
	rep(i,n){
		cin >> t;
		v[t]++;
		s1+=t;
	}
	cin >>q;
	vector<ll>s(q+1);
	s[0]=s1;
	rep(i,q){
		int b,c;
		cin >>b>>c;
		s[i+1]=s[i]+=(c-b)*v[b];
		cout << s[i+1]<<endl;
		v[c]+=v[b];
		v[b]=0;
	}
	return 0;
}


Measured memory_bytes: 4760
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;

const int N = 1000 + 5;

int c, n;
struct node{
    int total_time = 0, total_solve = 0, num;
    map<int, int> state;
}Node[N];

int main(){
    double a, b;
    cin >> a >> b;
    cout << b * 2 - a <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define rep(i,a,b) for(re int i=a,i##end=b; i<=i##end; i++)
#define drep(i,a,b) for(re int i=a,i##end=b; i>=i##end; i--)
#define repp(i,a,b) for(re int i=a,i##end=b; i<i##end; i++)
#define drepp(i,a,b) for(re int i=a,i##end=b; i>i##end; i--)
#define Erep(i,x) for(int i=head[x]; ~i; i=Edge[i].nxt)
#define ll long long
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define lowbit(x) (x&-x)
#define ms(x,a) memset(x,a,sizeof x)
using namespace std;
template <class T> inline bool Max(T &x, T y){
	return x<y?x=y,1:0;
}
template <class T> inline bool Min(T &x, T y){
	return x>y?x=y,1:0;
}
template <class T> inline T rd() {
	static char ch;static bool neg;
	static T x=0;
	for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
	for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
	return x=(neg?-x:x);
}
const int mod=1e7,oo=1e9,M=1e5+5;

char str[M];
int l[M],r[M],cnt[M];//r->左边第一个R ,l->右边第一个L 

int main(){
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	scanf("%s",str+1);
	int n=strlen(str+1);
	rep(i,1,n){
		r[i]=r[i-1];
		if(str[i]=='R') r[i]=i;
	}
	l[n]=n;
	drep(i,n-1,1){
		l[i]=l[i+1];
		if(str[i]=='L') l[i]=i;
	}
	rep(i,1,n){
		if(str[i]=='L'){
			int res=(i-r[i])&1;
			cnt[r[i]+res]++;
		}else{
			int res=(l[i]-i)&1;
			cnt[l[i]-res]++;
		}
	}
	rep(i,1,n) printf("%d ",cnt[i]);
	return 0;
}



Measured memory_bytes: 1664
import java.util.*;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if( x + y >=10){
		System.out.println("error");
		}else{
		System.out.println(x + y);
		}
	}
}


Measured memory_bytes: 21716
n, k = map(int, input().split())
d_list, a_list = [], []
ans_list = [1] * n

for i in range(k):
    d_list.append(int(input()))
    a_list = list(map(int, input().split()))
    for j in a_list:
        if ans_list[j-1] == 1:
            ans_list[j-1] = 0
print(sum(ans_list))


Measured memory_bytes: 9192
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, Q = LI()
s = input()
TD = []
T, D = [], []
for i in range(Q):
    t,d = LS()
    TD.append([t,d])

def get_mid(lb, ub):
    if lb + ub < 0:
        return 0
    else:
        return (lb + ub) // 2
# 左から落ちるものの探索
# 2回midが同じならやめる
def find_left_dropped():
    lb, ub = -1, N
    while True:
        if lb + ub < 0:
            mid = 0
        else:
            mid = (lb + ub) // 2
        original_mid = mid
        for td in TD:
            if td[0] == s[mid]:
                if td[1] == "L":
                    mid -= 1
                else:
                    mid += 1

                if mid == -1:
                    # 左に落ちた
                    lb = original_mid
                    if get_mid(lb, ub) == original_mid:
                        return original_mid+1
                    break
                
                if mid == N:
                    # 右に落ちた
                    ub = original_mid
                    if get_mid(lb, ub) == original_mid:
                        return original_mid
                    break
        else:
            # 落ちなかった
            ub = original_mid
            if get_mid(lb, ub) == original_mid:
                return original_mid

def find_right_dropped():
    lb, ub = -1, N
    while True:
        if lb + ub < 0:
            mid = 0
        else:
            mid = (lb + ub) // 2
        original_mid = mid
        for td in TD:
            if td[0] != s[mid]:
                continue

            if td[1] == "L":
                mid -= 1
            else:
                mid += 1

            if mid == -1:
                # 左に落ちた
                lb = original_mid
                if get_mid(lb, ub) == original_mid:
                    return original_mid+1
            
            if mid == N:
                # 右に落ちた
                ub = original_mid
                if get_mid(lb, ub) == original_mid:
                    return original_mid
                break
        else:
            # 落ちなかった
            lb = original_mid
            if get_mid(lb, ub) == original_mid:
                return original_mid + 1

left_survived = find_left_dropped()
#  print(left_survived)
right_survived = find_right_dropped()
#  print(right_survived)

result = right_survived - left_survived
print(result)


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

int main()
{
    int a, l;

    while (cin >> a >> l, l){
        vector<int> v;
        v.push_back(a);
        for (int i = 1; ; i++){
            char num[128];
            sprintf(num, "%0*d", l, a);
            sort(num, num + l);
            int mini = atoi(num);
            reverse(num, num + l);
            int maxi = atoi(num);
            a = maxi - mini;
            int j = find(v.begin(), v.end(), a) - v.begin();
            if (j == v.size()){
                v.push_back(a);
            }
            else {
                printf("%d %d %d\n", j, a, i - j);
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<algorithm>
using namespace std;

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

    int T[n];
    for(int i = 0; i < n; i++)  cin >> T[i];
    sort(T, T+n);

    int cnt = 0, first = T[0], tmpcnt = 1;
    for(int i = 1; i < n; i++){
        if(tmpcnt < c && T[i] <= first+k){
            tmpcnt++;
        }else{
            cnt++;
            first = T[i];
            tmpcnt = 1;
        }
    }

    cnt++;

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 640
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
using ll =long long;
const ll INF = (1ULL << 63) - 1;

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

    // n * n の longlongの配列をINFで初期化
    vector<vector<ll>> dist(n, vector<ll>(n, INF));
    
    for (int i = 0; i < n; ++i) {
        dist[i][i] = 0;
    }
    for(int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        if (c > l) continue;
        a--;
        b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (dist[i][k] == INF || dist[k][j] == INF) continue;
                if (dist[i][j] > dist[i][k] + dist[k][j])
                    dist[i][j] = dist[i][k] + dist[k][j];
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            dist[i][j] = (dist[i][j] <= l) ? 1 : INF;
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (dist[i][k] == INF || dist[k][j] == INF) continue;
                if (dist[i][j] > dist[i][k] + dist[k][j])
                    dist[i][j] = dist[i][k] + dist[k][j];
            }
        }
    }

    int q;
    cin >> q;
    REP(i, q) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        cout << (dist[s][t] == INF ? -1 : dist[s][t] - 1) << endl;
    }
}


Measured memory_bytes: 1280
import numpy as np
N = int(input())
A=[]
for i in range(N):
    A.append(int(input()))

sec = sorted(A)[-2]
a = np.array(A)
maxA=max(a)
maxIndex = [i for i, x in enumerate(a) if x == maxA]
l=len(maxIndex)
for i in range(N):
    if l !=1:
        print(maxA)
    elif i in maxIndex:
        print(sec)
    else:
        print(maxA)

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

int main(){
	string s;
	cin >> s;
	int ans = 700;
	for(int i = 0;i < 3;i++){
		if(s[i] == 'o') ans += 100; 
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	ll c[n-1],s[n-1],f[n-1];
	rep(i,n-1) cin>>c[i]>>s[i]>>f[i];

	ll ans[n-1]={};
	for(int i=0;i<n-1;i++){
		ll T=s[i]+c[i];
		for(int j=i+1;j<n-1;j++){
			if(T<s[j]) T=s[j];
			else if(T%f[j]!=0) T+=f[j]-T%f[j];
			T+=c[j];
		}
		ans[i]=T;
	}

	rep(i,n-1) cout<<ans[i]<<"\n";
	cout<<0<<"\n";
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n,m,road int
	fmt.Scan(&n,&m)
	
	cities := make(map[int]int)
	
	for i := 0; i < m * 2; i++ {
		fmt.Scan(&road)
		cities[road]++
	}

	for i := 1; i <= n; i ++ {
		fmt.Println(cities[i])
	}
}

Measured memory_bytes: 512