akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template <typename T>
struct edge
{
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x)
  {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template <typename T>
using Edges = vector<edge<T>>;

template <typename T>
vector<T> bellman_ford(Edges<T> &edges, int V, int s)
{

  vector<T> dist(V, INF);
  dist[s] = 0;
  for (int i = 0; i < V; i++)
  {
    for (auto &e : edges)
    {
      if (dist[e.src] == INF)
        continue;

      if (chmin(dist[e.to], dist[e.src] + e.cost))
        if (i == V - 1 and e.to == V - 1)
          return vector<T>();
    }
  }

  return dist;
}

void solve(void)
{

  int n, m;
  cin >> n >> m;
  Edges<int> es;
  for (int i = 0; i < m; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    es.emplace_back(a, b, -1 * c);
  }
  auto res = bellman_ford(es, n, 0);
  // DEBUG(bellman_ford)
  if (res.size() == 0)
    cout << "inf" << endl;
  else
  {
    cout << res[n - 1] * -1 << endl;
  }

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3708
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int N, X, Y, dp[2005][2005], ans[2005];
int main() {
  scanf("%d %d %d", &N, &X, &Y);
  for(int i = 1; i < N; ++i) {
    for(int j = i+1; j <= N; ++j) {
      int iXYj = abs(i-X)+1+abs(j-Y);
      int iYXj = abs(i-Y)+1+abs(j-X);
      dp[i][j] = min({j-i, iXYj, iYXj});
    }
  }
  for(int i = 1; i < N; ++i) {
    for(int j = i+1; j <= N; ++j) ++ans[dp[i][j]];
  }
  for(int i = 1; i < N; ++i) printf("%d\n", ans[i]);
}

Measured memory_bytes: 15232
#include<cstdio>

using namespace std;

int m,n,t[100100],x,y,i,j,ch[100100],c;

int main(){
    scanf("%d %d",&m,&n);
    for(i=1;i<=m;i++)t[i]=1;
    ch[1]=1;
    for(i=0;i<n;i++){
        scanf("%d %d",&x,&y);
        if(ch[x]==1)ch[y]=1;
        if(t[x]==1&&ch[x]==1){
            ch[x]=0;
        }
        t[y]++;
        t[x]--;
    }
    c=0;
    for(i=1;i<=m;i++){
        if(ch[i]==1)c++;
    }
    printf("%d\n",c);
}

Measured memory_bytes: 896
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

ll a[100010];
ll l[100010];
ll r[100010];

int main(){
	ll w;
	scanf("%lld",&w);
	rep(i,0,w)scanf("%lld",a+i);
	ll crr=-INF;//アウト
	rep(i,0,w){
		crr--;
		if(a[i]==0)l[i]=crr=INF;
		if(a[i]>0)l[i]=crr;
		if(a[i]<0)crr=min(crr,-a[i]);
	}
	crr=-INF;
	for(int i=w-1;i>=0;i--){
		crr--;
		if(a[i]==0)r[i]=crr=INF;
		if(a[i]>0)r[i]=crr;
		if(a[i]<0)crr=min(crr,-a[i]);
	}
	ll ans=0;
	rep(i,0,w)if(a[i]>0)ans+=min(a[i],max(0,max(l[i],r[i])));
	printf("%lld\n",ans);
}


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

int main()
{
    int D;
    cin >> D;
    if (D == 25)
    {
        cout << "Christmas" << endl;
    }
    else if (D == 24)
    {
        cout << "Christmas Eve" << endl;
    }
    else if (D == 23)
    {
        cout << "Christmas Eve Eve" << endl;
    }
    else if (D == 22)
    {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
x=int(input())

L=[0]*122
for i in range(1,121):
    ii=i**2
    iii=ii**2
    L[i]=i*iii

ans="ERROR"

for j in range(122):
    a=L[j]
    if x-a in L:
        ans=[int(a**0.2),int(-((x-a)**0.2))]
    elif a-x in L:
        ans=[int(a**0.2),int((a-x)**0.2)]
    else:
        pass

print(*ans)

Measured memory_bytes: 9396
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.nextLine();
		String B = sc.nextLine();
		sc.close();
		if(A.length() > B.length()){
			System.out.println("GREATER");
		}
		else if(A.length() < B.length()){
			System.out.println("LESS");
		}
		else if(A.equalsIgnoreCase(B)){
			System.out.println("EQUAL");
		}
		else{
			BigInteger BgA = new BigInteger(A);
			BigInteger BgB = new BigInteger(B);
			int cmp = BgA.compareTo(BgB);
			if(cmp > 0){
				System.out.println("GREATER");
			}
			else{
				System.out.println("LESS");
			}
		}
	}

}


Measured memory_bytes: 23764
N = int(input())
S = input()

R = set()
G = set()
B = set()
for i, s in enumerate(S):
    if s == "R":
        R.add(i)
    elif s == "G":
        G.add(i)
    else:
        B.add(i)

ans = len(R) * len(G) * len(B)

for a in R:
    for b in G:
        dif = b - a
        if b + dif in B:
            ans -= 1
        if a - dif in B:
            ans -= 1
        if dif % 2 == 0 and (a + b) // 2 in B:
            ans -= 1

print(ans)

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

	using namespace std;
	inline void FAST_IO(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

	int main(){
		FAST_IO();

		long long a,b,c,d;
		cin >> a >> b >> c >> d;

		long long m = (c*d)/__gcd(c,d);
		long long dc = (b/c-((a-1)/c));
		long long dd = (b/d-((a-1)/d));
		long long dm = (b/m-((a-1)/m));

		cout << (b-a+1)-(dc+dd-dm) << endl;
		

		return 0;
	}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define ri register int 
#define il inline
#define pairint pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define LL long long
#define gc getchar
template<class T>il void in(T &x)
{
    x=0;bool f=0;char c=gc();
    while(c<'0'||c>'9') 
    {
        if(c=='-') f=1;
        c=gc();
    }
    while(c>='0'&&c<='9') x=x*10+(c^'0'),c=gc();
    if(f) x=-x;
} 
#undef gc
#define N 100005
#define M N<<1
int n,m;
int val[N];
int v[M],nx[M];
int head[N],cnte=1;
il void adde(int uu,int vv)
{
	v[++cnte]=vv,nx[cnte]=head[uu];
	head[uu]=cnte;
}
bool vis[N];
int cnt;
priority_queue<int,vector<int>,greater<int> > q[N];
void dfs(int x)
{
	q[cnt].push(val[x]);
	vis[x]=1;
	for(ri i=head[x];i;i=nx[i])
		if(!vis[v[i]]) dfs(v[i]);
}
signed main()
{
#ifdef M207
    freopen("in.in","r",stdin);
#endif
	in(n),in(m);
	for(ri i=1;i<=n;++i) in(val[i]);
	for(ri i=1,a,b;i<=m;++i)
	{
		in(a),in(b); ++a,++b;
		adde(a,b);adde(b,a);
	}
	for(ri i=1;i<=n;++i)
		if(!vis[i])
		{
			++cnt;
			dfs(i);
		}
	if(cnt==1)
	{
		puts("0");
		return 0;
	}
	LL ans=0;
	for(ri i=1;i<=cnt;++i)
	{
		ans+=q[i].top();
		q[i].pop();
		while(!q[i].empty()) q[0].push(q[i].top()),q[i].pop();
	}
	cnt-=2;
	if((int)q[0].size()<cnt) 
	{
		puts("Impossible");
		return 0;
	}
	while(cnt--) ans+=q[0].top(),q[0].pop();
	printf("%lld",ans);
    return 0;
}
//64456754

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
const long double PI = 3.141592653589793238462643383279502884197;
const int MAX = 1e4;

int N, ans[MAX + 5];

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

	cin >> N;

	for (int x = 1; x <= sqrt(N); x++) {
		for (int y = 1; y <= sqrt(N); y++) {
			for (int z = 1; z <= sqrt(N); z++) {
				int val = x * x + y * y + z * z + x * y + y * z + z * x;
				if (val <= N) ans[val]++;
			}
		}
	}

	for (int i = 1; i <= N; i++)
		cout << ans[i] << '\n';

	return 0;
}

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

int main(){
int N; cin >> N;
vector<tuple<string, int, int>> table;

for (int i = 0; i < N; i++) {
    string S;
    int p;
    cin >> S >> p;
    table.push_back(make_tuple(S, -p, i + 1));
}

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

for (int i = 0; i < N; i++) {
    cout << get<2>(table[i]) << endl;
}

}

Measured memory_bytes: 256
// ABC 086

//inputに入力データ全体が入る
function Main(input) {
  input = input.split(" ");
  var a = parseInt(input[0],10);
  var b = parseInt(input[1],10);
  var result = "Odd"; //結果表示用 初期値は奇数の時の結果
  if((a*b)%2 == 0) {
    result = "Even";
  }
  console.log(result)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<String> set = new HashSet<>(); 
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                for (int k = 1; k <= n; k++) {
                    set.add(Integer.toString(i) + Integer.toString(j) + Integer.toString(k));
                }
            }
        }
        System.out.println(set.size());
    }
}


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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, cnt = 0; cin >> n; int a[n]; for(int& i : a) cin >> i;
    for(int i = 1; i < n-1; i++) {
        if(a[i] < a[i-1] && a[i] > a[i+1]) cnt++;
        if(a[i] > a[i-1] && a[i] < a[i+1]) cnt++;
    }    
    cout << cnt;
}

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

int mp[200][200],comm;
string s;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		for(int j=0;j<s.length();j++){
			mp[i][s[j]-'a']++;
		}
	}
	for(int i=0;i<26;i++){
		comm=10000;
		for(int j=0;j<n;j++){
			comm=min(comm,mp[j][i]);
		}
		for(int j=0;j<comm;j++){
			cout<<(char)(i+(int)'a');
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		Point p1 = new Point();
		Point p2 = new Point();

		p1.setX(scanner.nextDouble());
		p1.setY(scanner.nextDouble());
		p2.setX(scanner.nextDouble());
		p2.setY(scanner.nextDouble());

		System.out.printf("%.10f\n", calcDistance(p1,p2));
	}

	public static double calcDistance(Point p1,Point p2){
		return Math.sqrt((p1.getX()-p2.getX())*(p1.getX()-p2.getX())+(p1.getY()-p2.getY())*(p1.getY()-p2.getY()));
	}
}

class Point{

	private double x;
	private double y;

	Point(){
		x = 0;
		y = 0;
	}

	public double getX() {
		return x;
	}
	public void setX(double x) {
		this.x = x;
	}
	public double getY() {
		return y;
	}
	public void setY(double y) {
		this.y = y;
	}
}


Measured memory_bytes: 28196
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=1e6+5;
const ll inf=1e17;

int pr[ms];
int ar[ms];

set<int> ss;

void check()
{
    int n=1e6;
    int i;
    int j;
    for(i=1;i<=n;i++)pr[i]=i;

    for(i=2;i<=1000;i++)
    {
        if(pr[i]==i)
        {
            for(j=i*i;j<=n;j+=i)pr[j]=min(pr[j],i);
        }
    }
}


int main()
{
    idfc;

    check();

    int n;
    cin>>n;
    int i;
    int e;
    int fl=0;
    set<int> s2;
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
        e=ar[i];
        s2.clear();
        while(e>1)
        {
            s2.insert(pr[e]);
            e/=pr[e];
        }
        for(int ii:s2)
        {
            if(ss.count(ii))
            {
                fl=1; break;
            }
            ss.insert(ii);
        }
    }

    if(fl)
    {
        int gc=ar[1];
        for(i=2;i<=n;i++)
        {
         //   cout<<gc<<" "<<ar[i]<<" ";
            gc=__gcd(gc,ar[i]);
         //   cout<<gc<<"\n";
        }
      //  cout<<gc<<"\n";
        if(gc==1)cout<<"setwise coprime";
        else cout<<"not coprime";
    }
    else{
        cout<<"pairwise coprime";
    }

    return 0;
}

Measured memory_bytes: 15100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1005],c[1005][15],b[1005],n,m,ans=1e9,num[15],p[1005],d[5000];
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a[i]>>b[i];
        for(int j=1;j<=b[i];j++){
            cin>>c[i][j];
            num[c[i][j]]++;
        }
    }
    for(int i=1;i<=n;i++){
        if(!num[i]){
            cout<<-1<<endl;
            return 0;
        }
    }
    for(int i=1;i<=m;i++){
        int t=0;
        for(int j=1;j<=b[i];j++){
            t+=(1<<(c[i][j]-1));
        }
        p[i]=t;
    }
    memset(d,0x3f,sizeof(d));
    d[0]=0;
    for(int i=1;i<m;i++){
        for(int j=0;j<(1<<n);j++){
            d[j|p[i]]=min(d[j|p[i]],d[j]+a[i]);
        }
    }
    cout<<d[(1<<n)-1]<<endl;
}  

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  
	public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int n = sc.nextInt();
      int res = n / 3;	  
	  System.out.println(res);
  }
  
  private static void solveC() {
	  FastReader sc = new FastReader();
	  int n = sc.nextInt();
	  long[] dp = new long[5]; // For counting 'm', 'a', 'r', 'c', 'h'.
	  
	  // Choose three from five, there is total ten patterns.
	  int[] p = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
	  int[] q = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
	  int[] r = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
	  
	  long res = 0;
	  
	  for (int i = 0; i < n; i++) {
		  String s = sc.next();
		  
		  if (s.charAt(0) == 'M') {
			  dp[0]++;
		  } else if (s.charAt(0) == 'A') {
			  dp[1]++;
		  } else if (s.charAt(0) == 'R') {
			  dp[2]++;
		  } else if (s.charAt(0) == 'C') {
			  dp[3]++;
		  } else if (s.charAt(0) == 'H') {
			  dp[4]++;
		  }
	  }
	  
	  for (int i = 0; i < 10; i++) {
		  res += (dp[p[i]] * dp[q[i]] * dp[r[i]]);
	  }
	  
	  System.out.println(res);
  }

  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 23380
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;
const ll inf = 1e18;

class Point{
    public:
    int i;
    int j;

    Point(int a, int b){
        i = a;
        j = b;
    }
};

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

    // input
    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    FOR(i, 0, H){
        cin >> S[i];
    }

    // distance
    int d[H][W];
    FOR(i, 0, H){
        FOR(j, 0, W){
            d[i][j] = 10000;
        }
    }

    d[0][0] = 0;
    queue<Point> q;
    q.push(Point(0, 0));
    while(q.size()!=0){
        auto point = q.front();
        q.pop();

        // 周辺を見る
        FOR(i, 0, 4){
            int index_i = point.i + dy[i];
            int index_j = point.j + dx[i];

            if(0<=index_i && index_i < H && 0<=index_j && index_j < W){
                char color = S[index_i][index_j];
                if(color == '.'){
                    // 塗ろうかな
                    int mydist = d[point.i][point.j];
                    if(d[index_i][index_j] > mydist + 1){
                        // 距離を更新
                        d[index_i][index_j] = mydist + 1;
                        q.push(Point(index_i, index_j));
                    }
                }
            }
        }
    }

    if(d[H-1][W-1]==10000){
        p(-1);
    }else{
        int lastWhiteNum = d[H-1][W-1] + 1;

        int initialWhiteNum = 0;
        FOR(i, 0, H){
            FOR(j, 0, W){
                if(S[i][j] == '.'){
                    initialWhiteNum++;
                }
            }
        }

        p(initialWhiteNum - lastWhiteNum);
    }
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            int[] ary = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] aryy = ReadLine().Split(' ').Select(int.Parse).ToArray();

            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                if (ans<SumCal(ary,0,i)+ SumCal(aryy, i,N-1))
                {
                    ans = SumCal(ary, 0,i) + SumCal(aryy, i,N-1);
                }
            }
            WriteLine(ans);
        }

        static int SumCal(int[] s,int begin,int end)
        {
            int sum = 0;
            for (int i = begin; i <= end; i++)
            {
                sum += s[i];
            }
            return sum;
        }
    }
}


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

int main() {
    long long int n, t[100], ans;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> t[i];
    }
    ans = t[0];
    for(int i=0; i<n; i++){
        long long int a=ans, b=t[i], r, g;
        r = a % b;
        while(r != 0){
            a = b;
            b = r;
            r = a % b;
        }
        g = b;
        ans = ans/g*t[i];
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const ll mod = 1e9+7;

int main()
{
  ll n;
  cin>>n;
  ll a[n],suf[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  suf[n-1]=a[n-1];
  for(int i=n-2;i>=0;i--)
    suf[i]=(suf[i+1]+a[i])%mod;
  ll ans=0;
  for(int i=0;i<n-1;i++)
    ans=(ans+(a[i]*suf[i+1])%mod)%mod;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 6756
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

signed main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<string> s(H);
  REP(i, H) cin >> s[i];

  queue<pair<int, int>> q;
  vector<vector<int>> dist(H, vector<int>(W, INF));

  REP(i, H) REP(j, W) if(s[i][j] == 'S'){
    q.emplace(i, j);
    dist[i][j] = 0;
  }

  int ans = INF;
  while(!q.empty()){
    auto p = q.front(); q.pop();

    chmin(ans, min(min(p.first, p.second), min(H-p.first-1, W-p.second-1)));

    if(dist[p.first][p.second] >= K) continue;
    REP(i, 4){
      int x = p.first+dx[i];
      int y = p.second+dy[i];

      if(OUT(0, x, H) || OUT(0, y, W)) continue;
      if(s[x][y] == '#') continue;
      if(dist[x][y] != INF) continue;

      dist[x][y] = dist[p.first][p.second]+1;
      q.emplace(x, y);
    }
  }

  cout << (ans+K-1)/K+1 << endl;

  return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

int main(){

  int N;
    string S;
    cin>>N>>S;
    int cnt=0;
    for(int i=0;i<N;i++){
        if(S[i]=='.') cnt++;
    }
    int ma=cnt;
    for(int i=0;i<N;i++){
        if(S[i]=='.') cnt--;
        else cnt++;
        ma=min(ma,cnt);
    }
    cout<<ma<<endl;
}


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

#define int long long

int n,m,w[105],v[105];
int f[100005];

signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;cin>>w[i]>>v[i],i++);
	for(int i=1;i<=n;i++)
		for(int j=m;j>=w[i];j--)
			f[j] = max(f[j],f[j-w[i]]+v[i]);
	cout<<f[m]<<endl;
	
	return 0;
}

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

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i,n) {
    ll k = n/i;
    ans += i*k*(k+1)/2;
  }
  cout << ans << endl;
}

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

int main() {
  int N,X,ans;
ans=0;
  cin >>N>>X;
while(N!=0||X!=0){
  for(int i=1;i<N+1;i++){
for(int j=i+1;j<N+1;j++){
for(int u=j+1;u<N+1;u++){
if(i+j+u==X){
ans++;
break;
}
}
}
}
  cout <<ans<< endl;
ans=0;
  cin >>N>>X;
}
}


Measured memory_bytes: 3052
n = int(input())
p = list(map(int, input().split()))
lis = sorted(list(range(1, n+1)))
l = len(p)
cache = l
for k, m in zip(lis, p):
    if k != m:
        l -= 1

if cache - l <= 2:
    print("YES")
else:
    print("NO")

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

int main(){
	const int mod = (int)1e9 + 7;
	
	int n; scanf("%d", &n);
	
	int a[n+1], cnt[n+1], S = 1;
	
	memset(cnt+1, 0, sizeof(int)*n);
	
	for(int i=1;i<=n;++i) scanf("%d", a+i), ++ cnt[a[i]];	
	
	for(int i=n;i;--i){
		cnt[i-1] += cnt[i];
		if((cnt[i] -= n-i) <= 0) return puts("0"), 0;
		S = 1ll*S*cnt[i]%mod;
	}
	
	auto inv = [&](int x){
		int res = 1, k = mod-2;
		for(;k;x=1ll*x*x%mod, k>>=1)
			if(k&1) res = 1ll*res*x%mod; 
		return res;
	};
	
	int d[n+1], x[n+1], pre[n+1];
	
	d[0] = 1, x[0] = 0;
	for(int i=1, last = 1;i<=n;++i){
		d[i] = cnt[i]>1? 1ll*d[i-1]*(cnt[i]-1)%mod*inv(cnt[i])%mod: d[i-1];
		x[i] = cnt[i]>1? x[i-1]: x[i-1]+1;
		if(cnt[i] == 1) last = i;
		pre[i] = last;
	}
	
	auto bit_sum = [&](int* bit, int x){
		int res = 0;
		for(;x;x-=x&-x) res = (res + bit[x])%mod;
		return res;
	};
	
	auto bit_add = [&](int* bit, int x, int y){
		for(;x&&x<=n;x+=x&-x) bit[x] = (bit[x] + y)%mod;	
	};

	int bit[n+1];
	
	memset(bit+1, 0, sizeof(int)*n);
	
	int ans = 0;
	
	for(int i=1;i<=n;++i){
		int tmp = bit_sum(bit, a[i]) - bit_sum(bit, pre[a[i]]-1);
		if(tmp < 0) tmp += mod;
		ans = (ans + 1ll*S*d[a[i]]%mod*tmp)%mod;
		bit_add(bit, a[i], inv(d[a[i]]));
	}

	ans = 1ll*ans*inv(2)%mod;

	int _bit[n+1], _ans = 0, _cnt = 0;
	
	memset(bit+1, 0, sizeof(int)*n);
	memset(_bit+1, 0, sizeof(int)*n);

	for(int i=n;i;--i){
		_cnt = (_cnt + bit_sum(_bit, a[i]-1))%mod;
		bit_add(_bit, a[i], 1);
		int tmp = bit_sum(bit, a[i]-1) - bit_sum(bit, pre[a[i]]-1);
		if(tmp < 0) tmp += mod;
		_ans = (_ans + 1ll*S*d[a[i]]%mod*tmp)%mod;
		bit_add(bit, a[i], inv(d[a[i]]));
	}
	
	_ans = 1ll*_ans*inv(2)%mod;
	
	_ans = (1ll*S*_cnt - _ans + mod)%mod;

	printf("%d\n", (ans + _ans)%mod);

	return 0;	
}
 

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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n"
#define show(a,b) cout<<(#a)<<" is "<<(a)<<" "<<(#b)<<" is "<<(b)<<"\n"
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(n) for(auto i=0;i<n;i++) 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<pi,pi> ppi;

void solve()
{
    ll n,wt;
    cin>>n>>wt;
    vl w(n),v(n);
    for(int i=0;i<n;i++)
    cin>>w[i]>>v[i];
    ll k[n+1][wt+1];
    for(int i=0;i<=n;i++)
    for(int j=0;j<=wt;j++)
    k[i][j]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=wt;j++)
        {
            if(w[i-1]<=j)
            k[i][j]=max(k[i-1][j],v[i-1]+k[i-1][j-w[i-1]]);
            else
            k[i][j]=k[i-1][j];
        }
    }
    cout<<k[n][wt]<<"\n";
}

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

Measured memory_bytes: 79232
#define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int num[2] = {0};
		int flag = 1;
		for (int j = 0; j < 10; j++) {
			int k;
			cin >> k;
			if (num[0] < k && num[1] < k) {
				num[num[0] < num[1]] = k;
			}
			else if (num[0] < k && num[1] >= k) {
				num[0] = k;
			}
			else if (num[0] >= k && num[1] < k) {
				num[1] = k;
			}
			else {
				flag = 0;
			}
		}
		if (flag) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint
import itertools

S = input()
#A = [ int(x) for x in input().split() ]
#B = [ int(x) for x in input().split() ]

bad = False
prev = "a"
for s in S:
    if prev == s:
        bad = True
        break
    prev = s

if bad:
    print("Bad")
else:
    print("Good")
    

Measured memory_bytes: 24992
// 「市が一つも属さない県がある場合」を忘れていて1WA

package main
import (
	"fmt"
	"sort"
)

type D struct{
	id, pref, year int
	order string
}
func main(){
	var N, M int
	fmt.Scan(&N, &M)
	Datas := make([]D, M)
	for i:=0; i<M;i++{
		var p, y int
		fmt.Scan(&p, &y)
		Datas[i] = D{id: i, pref: p, year: y, order: "init"}
	}
	sort.Slice(Datas, func(i, j int)bool{
		if Datas[i].pref < Datas[j].pref{
			return true
		}else if Datas[i].pref > Datas[j].pref{
			return false
		}else{
			return Datas[i].year < Datas[j].year
		}
	})
	p := 1	// これは危険で、「県1は存在する」と決め打っているのでダメ
	idx := 1
	ans := make([]string, M)
	// なぜか構造体のスライスのプロパティを変えることができなかったので答え出力用の配列をつくったけどなんで？？？？？
	for i:=0; i<M; i++{
		d := Datas[i]
		if p != d.pref{
			p = d.pref
			idx=1
		}
			// ほんとはこれだけでorderがセットされてほしいんだけどなんかできない（空になってしまう
		d.order = fmt.Sprintf("%06d", p) + fmt.Sprintf("%06d", idx)
		ans[d.id] = d.order
		idx++
	}
	for _, a := range ans{
		fmt.Println(a)
	}
}

Measured memory_bytes: 14360
import collections
N = int(input())
A = [int(_) for _ in input().split()]
B = [v - i for i, v in enumerate(A)]
C = collections.Counter(B)
ans = 0
for i, b in enumerate(B):
    C[b] -= 1
    ans += C[-(b + 2 * i)]
print(ans)


Measured memory_bytes: 42612
n = int(input())
a_nums = list(map(int, input().split()))
money = 1000
stock = 0
for i in range(n):
    if i != n - 1 and a_nums[i] < a_nums[i + 1]:
        times = money // a_nums[i]
        stock += times
        money -= a_nums[i] * times
    elif i == n - 1 or a_nums[i] > a_nums[i + 1]:
        money += stock * a_nums[i]
        stock = 0
print(money)

Measured memory_bytes: 61964
#include<stdio.h>
int main(){
  int n,a,b,c,ans,ans1,ans2;
  scanf("%d",&n);
  ans=n/3600;
  ans1=n%3600/60;
  ans2=n-ans*3600-ans1*60;
  printf("%d:%d:%d\n",ans,ans1,ans2);
  return(0);
}

Measured memory_bytes: 2720
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Set;
import java.util.HashSet;

public class Main {

    public static void main(String[] args) throws IOException {
        try (InputReader reader = new InputReader(System.in)) {
            solve(reader);
        }
    }

    private static void solve(InputReader reader) throws IOException {
        int age = reader.readInt();
        if (age == 1) {
            System.out.println("Hello World");
        } else {
            int a = reader.readInt();
            int b = reader.readInt();
            System.out.println(a + b);
        }
    }
}

class Util {
    static int gcd(int m, int n) {
        int min = Math.min(m, n);
        int max = Math.max(m, n);
        while (min != 0) {
            int tmp = min;
            min = max % tmp;
            max = tmp;
        }

        return max;
    }

    static int lcm(int m, int n) {
        return m / gcd(m, n) * n;
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

    String readLine() throws IOException {
        return this.br.readLine();
    }

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    double[] readDoublesSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        double[] doubles = new double[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            doubles[i] = Double.parseDouble(strings[i]);
        }

        return doubles;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N,M;
    cin>>N>>M;
    string S;
    cin>>S;
    vector<int> canr(0);
    rep(i,N+1){
        if(S.at(i)=='0'){
            canr.pb(i);
        }
    }
    int count=0,now=N;
    vector<int> ans(0);
    while(now>0){
        auto nex=lower_bound(canr.begin(),canr.end(),now-M);
        int tugi=*nex;
        if(tugi>=now){
            cout<<-1<<endl;return 0;
        }
        ans.pb(now-tugi);
        now=tugi;
        count++;
    }
    reverse(ans.begin(),ans.end());
    rep(i,sz(ans)){
        cout<<ans.at(i)<<" ";
    }
    cout<<endl;
}

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

using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;

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

  int n;
  cin >> n;

  ll ans = 0;

  for (ll i = 1; i * i <= n; i++) {
    ans = i * i;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
	double ans = 0;
	double x[3];
	double y[3];
	for(int i = 0; i < 3; i++) cin >> x[i] >> y[i];
	double d[3];

	for(int i = 0; i < 3; i++){
		d[i] = sqrt((x[i]-x[(i+1)%3])*(x[i]-x[(i+1)%3])+(y[i]-y[(i+1)%3])*(y[i]-y[(i+1)%3]));
	}
	double a = x[0]*y[1]+x[1]*y[2]+x[2]*y[0]-x[1]*y[0]-x[2]*y[1]-x[0]*y[2];
	a /= 2.0;
	if(a < 0) a = -a;
	double r = a/((d[0]+d[1]+d[2])/2.0);
	for(int i = 0; i < 3; i++){
		ans = max(ans,d[i]*r/(d[i]+2.0*r));
	}
	printf("%.10lf\n", ans);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fast {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
typedef long long int ll;
typedef string S;
#define M 1e18
#define AS 250005
#define sp cout<<' '
#define nw cout<<endl
#define rt return
#define __ template<typename T, typename... Types>
void in() {rt;} __ void in(T &a, Types&... b){cin>>(a); in(b...);}
void o() {rt;}  __ void o(T a, Types... b){cout<<(a);sp; o(b...);}
#define fr(i,a,n) for(ll i=a;i<=n;i++)
#define frm(i,a,n) for(ll i=n;i>=a;i--)
#define P pair<ll,ll>
#define vc vector<ll>
#define pb push_back
#define MP map<ll,ll>
bool sortin(const pair<ll,ll> &e,const pair<ll,ll> &f){return (e.first<f.first);}
bool POT(ll x){return x && (!(x&(x-1)));}
ll i,j,k,l,m,n,p,q,r,a,b,c,x,y,z,ts,mn=1e18,mod=1e9+7;
ll ar[AS],br[AS],xr[AS],tem[AS];
int main()
{
    fast;
    in(x);
    o(!x);
}



Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
    //int N;
    //int A[100000]={};
    long long a,b,c,k;
    long long i=0;
    //int j=0;
    //int x=0;
    //int num=0;
    long long cnt=0;
    
    scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
    
   for(i=0;i<k;i++){
       if(a!=0){
           cnt++;
           a--;
       }else if(b!=0){
           b--;
       }else{
           cnt--;
           c--;
       }
   }
   
   printf("%d",cnt);
   
   
   return 0;
}

Measured memory_bytes: 1688
import java.util.*;
import java.io.*;

public class Main{

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	        int n=sc.nextInt();
	       long a[]=new long[3*n];
	        for(int i=0;i<3*n;i++) {
	          a[i]=sc.nextLong();  
	        }
	        long ans=Long.MIN_VALUE;
	        PriorityQueue<Long> pq=new PriorityQueue<>();
	        long sum[]=new long[n+2];
	        long sum2[]=new long[n+2];
	        long summ=0;
	        for(int i=0;i<n;i++) {
	          pq.add(a[i]);
	          summ+=a[i];
	          
	        }
	       sum[0]=summ;
	        for(int i=n;i<2*n;i++) {
	          if(a[i]>pq.peek()) {
	           summ-= pq.poll();
	            pq.add(a[i]);
	            summ+=a[i];
	            sum[i-n+1]=summ;
	          }else {
	            sum[i-n+1]=sum[i-n];
	          }
	        }
	        PriorityQueue<Long> pq1=new PriorityQueue<>(Collections.reverseOrder());
	         summ=0;
         for(int i=3*n-1;i>=2*n;i--) {
           pq1.add(a[i]);
           summ+=a[i];
           
         }
         sum2[n]=summ;
         for(int i=2*n-1;i>=n;i--) {
           if(a[i]<pq1.peek()) {
            summ-= pq1.poll();
             pq1.add(a[i]);
             summ+=a[i];
             sum2[i-n]=summ;
           }else {
             sum2[i-n]=sum2[i-n+1];
           }
         }
         
         for(int i=0;i<=n;i++) {
           ans=Math.max(sum[i]-sum2[i],ans);
         }
         
	        System.out.println(ans);
	}
	static long solve(PriorityQueue<Long> pq) {
	  
	  long sum=0;
	    
	       while(!pq.isEmpty()) {
	         sum+=pq.poll();
	       
	       }
	       return sum;
	}
 static long solve1(long a[],int i,int j,int n) {
   
   PriorityQueue<Long> pq=new PriorityQueue<>();
   for(int k=i;k<j;k++) {
   
     pq.add(a[k]);
   }
   
   long sum=0;
  while(n!=0) {
    sum+=pq.poll();
    n--;
  }
  return sum;
}
	
	static int  prime[]=new int[100001];
	static void sieve() {
	  Arrays.fill(prime,1);
	  prime[0]=0;
	  prime[1]=1;
	  for(int i=2;i*i<100001;i++) {
	   if(prime[i]!=0) {
	     for(int j=i;j<10001;j+=i) {
	       prime[j]=0;
	     }
	   }
	  }
	}
	      static long gcd(long a, long b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 

static long nCr(int n,int r) {
  int dp[][]=new int[2001][2001];
  for(int i=0;i<2001;i++) {
    dp[0][i]=0;
  }
  for(int i=0;i<2001;i++) {
    dp[i][0]=1;
  }
  for(int i=1;i<2001;i++) {
    for(int j=1;j<2001;j++) {
      if(i==j) {
        dp[i][j]=1;
      }else {
        dp[i][j]=dp[i-1][j-1]+dp[i][j-1];
      }
    }
  }
  return dp[n][r];
}


      
}
class pair {
  int src;
 int  des;
 long val;
  pair(int src,int des,long val){
    this.src=src;
    this.des=des;
    this.val=val;
    
  }

//  @Override
//  public int compareTo(pair o) {
//   
//    return this.wt-o.wt;
//  }
}


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

using namespace std;

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

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

    return 0;
}


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

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

  stack<int> S;
  int a, b;
  string s;

  while(cin >> s){
    if(s[0] == '+'){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a + b);
    }else if(s[0] == '-'){
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a - b);
    }else if(s[0] == '*'){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a * b);
    }else{
      S.push(strtol(s.c_str(), NULL, 10));
    }
  }
  cout << S.top() << endl;
}


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

int main() {
	int N, A[150][150];
	int num = 0, max=0;

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

	for (int i = 0; i<N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (j <= i) num += A[0][j];
			if (j == i) num += A[1][j];
			if (j > i) num += A[1][j];
		}
		if (num > max) max = num;
		num = 0;
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")

import sys,collections
sys.setrecursionlimit(100000)

INF = float("inf")

V,E = map(int,sys.stdin.readline().split())
st = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(E)) # multi line with multi param

G = [[] for _ in range(V)]

for s,t in st:
    G[s].append(t)
    G[t].append(s) #not directed

visited = set()
prenum = [0]*V
parent = [0]*V
lowest = [0]*V
timer = 0

def dfs(current,prev):
    global timer
    parent[current]=prev
    prenum[current]=lowest[current]=timer
    timer += 1
    visited.add(current)
    for nex in G[current]:
        if not nex in visited:
            dfs(nex,current)
            lowest[current]=min(lowest[current],lowest[nex])
        elif nex != prev:
            lowest[current]=min(lowest[current],prenum[nex])
dfs(0,-1)
ret = []

for i in range(1,V):
    p = parent[i]
    if prenum[p] < lowest[i]:
        if p < i:
            ret.append([p,i])
        else:
            ret.append([i,p])
ret = sorted(list(ret))

for s,t in ret:
    print(s,t)



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

int main() {
    int N;
    cin >> N;
    vector<int> nm(N - 1);
    rep(i, N - 1) cin >> nm[i];
    map<int, int> ma;
    int ba = 1;
    rep(i, N - 1) {
        if(ba == nm[i]) {
            ma[ba]++;
        }

        if(ba != nm[i]) {
            ma[nm[i]]++;
            ba = nm[i];
        }
    }
    rep2(i, N) cout << ma[i] << endl;
    return 0;
}


Measured memory_bytes: 13556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

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

  for(int i = 0; i < 1000; i++) {
    c = c - b;
    if(c < 1) {
      cout << "Yes" << endl;
      return 0;
    }
    a = a - d;
    if(a < 1) {
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
  int n,j=0,v=0;
  int a[100];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
	for(int i=0;i<n;i++){
		v=a[i];
		j=i-1;
		while(j>=0 && a[j]>v){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		for(int i=0;i<n;i++){
			cout<<a[i];
			if(i!=n-1){
				cout<<" ";
			}
		}
		cout<<"\n";
	}
  return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n,m,g[15][15],p[15],cnt[15];

int main()
{
    fastio();
    cin>>n>>m;
    rep(i,0,m-1){ int k,x;
        cin>>k;
        rep(j,1,k){
            cin>>x; g[--x][i] = 1;
        }
    }
    rep(i,0,m-1) cin>>p[i];
    int ans = 0;
    rep(i,0,(1<<n)-1){
        memset(cnt,0,sizeof(cnt));
        rep(j,0,n-1){
            if((i>>j)&1){
                rep(k,0,m-1){
                    if(g[j][k]) cnt[k]++;
                }
            }
        }
        int flag = 1;
        rep(i,0,m-1) if(cnt[i]%2 != p[i]) flag = 0;
        ans += flag;
    }cout<<ans<<endl;
    return 0;
}


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

int DIV = 1e+9 + 7;

int main() {
  int N; cin >> N;
  long a=1, b=1, c=1;
  for (int i = 0; i < N; i++) {
    a = a * 10 % DIV;
    b = b * 9 % DIV;
    c = c * 8 % DIV;
  }
  cout << (a+c-b-b+DIV+DIV) % DIV;
}

Measured memory_bytes: 3632
N = int(input())
R = []
for i in range(N):
  s_i, p_i = input().split()
  R.append([s_i, -int(p_i), i+1])
R = sorted(R, key=lambda x: x[1])
R = sorted(R, key=lambda x: x[0])
for r_i in R:
  print(r_i[-1])

Measured memory_bytes: 3060
#include "stdio.h"

//???????????????x,y???????????????r, r??????r, H -r??????W-r, r??????W-r, H-r?????§??¨?????????????????¢?????????????????????????????§????????????
int circle_include(int W,int H,int x,int y,int r){
    int rtn = 0;
    if( r <= x 
        && 
        x <= W - r
        &&
        r <= y
        &&
        y <= H - r
    ){
        rtn = 1;
    }
    return rtn;
}

int main(void){
    int W,H,x,y,r;
    int inside = 0;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    
    inside = circle_include(W,H,x,y,r);
    
    if(inside) printf("Yes\n");
    else       printf("No\n");
    
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A < B)
	{
		if (B < C)
		{
			cout << A + B + C * 10 << endl;
		}
		else
		{
			cout << A + B * 10 + C << endl;
		}
	}
	else
	{
		if (A < C)
		{
			cout << A + B + C * 10 << endl;
		}
		else
		{
			cout << A * 10 + B + C << endl;
		}
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,i,j,cnt=0;
	scanf("%d",&n);
	for(i=1;i<=n;i*=100){
		for(j=i;j<=n;j++){
			if(10*i<=j){
				break;
			}
			cnt++;
		}
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 1716
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
const int maxn=500+10;
bool bz[maxn][maxn],pd[maxn][maxn],a[maxn][maxn],b[maxn][maxn];
int i,j,k,l,t,n,m,mi,mx;
char get(){
	char ch=getchar();
	while (ch!='.'&&ch!='#') ch=getchar();
	return ch;
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n)
		fo(j,1,m){
			if (get()=='#') bz[i][j]=1;
			a[i][j]=b[i][j]=bz[i][j];
		}
	fo(i,1,n) a[i][1]=1,b[i][m]=1;
	fo(i,2,n-1)
		if (i%2==1)
			fo(j,2,m-1) a[i][j]|=1;
	fo(i,2,n-1)
		if (i%2==0)
			fo(j,2,m-1) b[i][j]|=1;
	fo(i,1,n){
		fo(j,1,m) printf("%c",a[i][j]?'#':'.');
		printf("\n");
	}
	fo(i,1,n){
		fo(j,1,m) printf("%c",b[i][j]?'#':'.');
		printf("\n");
	}
}

Measured memory_bytes: 1408
#include <stdio.h>

int main()
{
	long long n; scanf("%lld", &n);
	long long p = 1; int l = 0;
	while (p <= n) p *= 10, l++; p /= 10; l--;

	int ans = 0, s = 0;
	while (p) {
		for (int d = 0; d < n / p; d++) {
			int now = s + d + l * 9;
			if (ans < now)
				ans = now;
		}
		s += n / p;
		n %= p;
		p /= 10; l--;
	}
	if (ans < s)
		ans = s;

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

Measured memory_bytes: 128