akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using Graph = vector<vector<int>>;
using ll = long long;
using p = pair<int, int>;

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int min_sum = 2000000000;
    int x, y;

    for (int i = 0; i <= 2 * max(X, Y); i += 2)
    {
        x = X - i / 2;
        y = Y - i / 2;
        if (x <= 0)
        {
            x = 0;
        }
        if (y <= 0)
        {
            y = 0;
        }
        min_sum = min(min_sum, A * x + B * y + C * i);
    }

    cout << min_sum << endl;
    return 0;
}

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

int main() {
  string s,t;
  cin>>s;
  cin>>t;

  int c=0;
  for(int i=0;i<3;i++)
  {
    if(s[i]==t[i])
    {
          c++;
    }
  }

cout<<c<<endl;

  //cout<<d<<endl;
}

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

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var S = cin.Read;
            for(int i = 0; i < 26; i++)
            {
                int code = 'a' + i;
                char test = (char)code;
                if (!S.Contains(test))
                {
                    WriteLine(test);
                    return;
                }
            }
            WriteLine("None");
        }

        /*public long C(long n, long r)
        {
            if (r == 0 || r == n) return 1L;
            if (n < r) return 0L;
            long[,] Pascal = new long[n + 1, n + 1];
            Pascal[0, 0] = 1;
            for (long i = 1; i <= n; i++)
            {
                Pascal[i, 0] = 1;
                Pascal[i, i] = 1;
                for (long j = 1; j < n; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[n, r];
        }*/

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

vector<ll>H(N);
REP(i, N){
  cin >> H.at(i);
}
 
reverse(all(H));
bool flag = true;
REP(i, N - 1){
  if(H.at(i) < H.at(i + 1)) H.at(i + 1)--;
  if(H.at(i) < H.at(i + 1)){ 
    flag = false;
  }

}
if(flag)yes;
else no; 
 
 }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if(i%2==0 && a[i]%2==1) ans++;
    }
    cout << ans << endl;
}

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

typedef long long ll;

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

    ll first = a*b*4;
    ll second = (c-a-b);


    if (second < 0){
        cout << "No\n";
        return 0;
    }

    second *= second;


    if (first < second)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(N):
    cost = INF
    for w in range(26):
        now = 0
        if ord(a[i]) != (w + ord('a')):
            now += 1
        if ord(b[i]) != (w + ord('a')):
            now += 1
        if ord(c[i]) != (w + ord('a')):
            now += 1
        cost = min(now, cost)
    ans += cost
print(ans)

Measured memory_bytes: 9476
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;


int main(){
    int n;
    cin >> n;
    int a = n % 10;
    if(a == 0 || a == 1 || a == 6 || a == 8){
        cout << "pon";
    }
    else if(a == 3)cout << "bon";
    else cout << "hon";
    
}




Measured memory_bytes: 3132
#include <bits/stdc++.h>
int gcd(int a,int b)
{
    if (a%b==0)
    {
        return(b);
    }
    else
    {
        return(gcd(b,a%b));
    }
}
using namespace std;
int main(void){
    int n,ans=0; cin>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    bool nopass=false;
    vector <bool> data(n+1,true);
    bool x=true;
    while(!nopass){
        nopass=true;
        int tmp;
        for(int j=0;j<n;j++){
            if(j==0){
           if(x) {
              tmp=a[j+1]; nopass = false; x=false; continue;
           }else tmp=a[j];
            }
           if(tmp!=gcd(tmp,a[j]) && data[j] && nopass ){
               data[j]=false; nopass =false; continue;
           }
           tmp=gcd(tmp,a[j]);
        }
        ans=max(ans,tmp);
        
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	int a;
	cin>>a;
    if(a==22){cout<<"Christmas Eve Eve Eve"<<endl;}
    else if(a==23){cout<<"Christmas Eve Eve"<<endl;}
    else if(a==24){cout<<"Christmas Eve"<<endl;}
    else{cout<<"Christmas"<<endl;}
}

Measured memory_bytes: 3524
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt()%1000;
        if(n == 0){
            System.out.println(0);
        }else {
            System.out.println(1000 - n);
        }
    }


}


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

int main() {
  //freopen("in.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  int cnt[100002] = {0};
  for(int i = 0;i < n;i++){
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  int mx = 0;
  for(int i = 0;i < 100001;i++){
    mx = max(mx, cnt[i] + cnt[i + 1] + (i ? cnt[i - 1] : 0));
  }
  cout << mx;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int f[333][333];
int d[333][333];
int l[333][333];
int main()
{
	int n=io::F();
	for(register int i=1;i<=n;++i)
		for(register int j=1;j<=n;++j)
			f[i][j]=io::F(),d[i][j]=1011111111;
	for(register int i=1;i<=n;++i)d[i][i]=0;
	long long ans=0;
	for(register int i=1;i<=n;++i)
		for(register int j=i+1;j<=n;++j)
		{
			int fl=1;
			for(register int k=1;k<=n;++k)
				if(k!=i&&k!=j&&f[i][k]+f[k][j]==f[i][j])fl=0;
			if(fl)ans+=d[i][j]=d[j][i]=l[i][j]=l[j][i]=f[i][j];
		}
	for(register int k=1;k<=n;++k)
		for(register int i=1;i<=n;++i)
			for(register int j=1;j<=n;++j)
				cmin(d[i][j],d[i][k]+d[k][j]);
	int fl=1;
	for(register int i=1;i<=n;++i)
		for(register int j=1;j<=n;++j)
			if(d[i][j]!=f[i][j])fl=0;
	if(fl)printf("%lld\n",ans);
		else printf("-1\n");
	return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int N;
  scanf("%d", &N);
  int x[N],y[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d%d", &x[i],&y[i]);
  }

  map<pair<int,int>,int> v;
  int max = 0;

  FOR(i,0,N-1){
    FOR(j,0,N-1){
      if(i==j) continue;
      ++v[MP((x[i]-x[j]),(y[i]-y[j]))];
      chmax(max,v[pair<int,int>((x[i]-x[j]),(y[i]-y[j]))]);
    }
  }

  cout << N - max << endl;



}



Measured memory_bytes: 384
func readInts() -> [Int64]{
    return readLine()!.split(separator: " ").map{Int64($0)!};
}
var N = Int(readLine()!)!, ans = Int64(0), A: Array<(Int64, Int)> = Array(repeating: (0,0), count: 2020), dp: Array<Array<Int64>> = Array(repeating: Array(repeating: 0, count: 2020), count: 2020)
let a = readInts()
for i in 0 ..< N {
    A[i].0 = a[i]
    A[i].1 = i
}
A.sort { $0 > $1 }
for j in 1 ... N {
    dp[0][j] = dp[0][j - 1] + A[j - 1].0 * Int64(N - j - A[j - 1].1)
}
for i in 1 ... N {
    dp[i][0] = dp[i - 1][0] + A[i - 1].0 * Int64(A[i - 1].1 - i + 1)
    for j in 1 ..< N - i + 1 {
        dp[i][j] = max(dp[i][j - 1] + A[i + j - 1].0 * Int64(N - j - A[i + j - 1].1), dp[i - 1][j] + A[i + j - 1].0 * Int64(A[i + j - 1].1 - i + 1 ))
    }
    ans = max(ans, dp[i][N - i])
}
print(ans)

Measured memory_bytes: 40044
#include <iostream>
using namespace std;
 
int main(){
	int a,b,c,count;
  	cin >> a >> b;
  	for(int i=0;i < a; i++){
    	cin >> c;
      	if(c >= b) count++;
    }
  
  cout << count;
  
  return 0;
 
 
 
 
}

Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    from collections import defaultdict

    NIL = -1

    n = int(input())

    # pythonは構造体を用意するのに手間取るので、辞書型を使う
    T = defaultdict(lambda: {'l':NIL, 'r':NIL, 'p':NIL})

    for _ in range(n):
        u, l, r = map(int, input().split())
        T[u]['l'] = l
        T[u]['r'] = r
        if l != NIL:
            T[l]['p'] = u
        if r != NIL:
            T[r]['p'] = u

    for u, info in T.items():
        if info['p'] == NIL:
            root = u
            break

    # 先行順巡回
    def pre_parse(u):
        if u == NIL:
            return
        print(' ' + str(u), end='')
        pre_parse(T[u]['l'])
        pre_parse(T[u]['r'])

    # 中間順巡回
    def in_parse(u):
        if u == NIL:
            return
        in_parse(T[u]['l'])
        print(' ' + str(u), end='')
        in_parse(T[u]['r'])

    # 後行順巡回
    def post_parse(u):
        if u == NIL:
            return
        post_parse(T[u]['l'])
        post_parse(T[u]['r'])
        print(' ' + str(u), end='')

    print('Preorder')
    pre_parse(root)
    print('')

    print('Inorder')
    in_parse(root)
    print('')

    print('Postorder')
    post_parse(root)
    print('')


Measured memory_bytes: 6008
#include<stdio.h>
//大きい順にソート
int c[200002];
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]>s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int n,k,sum=0,i;
  scanf("%d%d",&n,&k);
  int a[n+1],count[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    count[i]=0;
  }
  merge(0,n-1,a);
  int countnum=0;
  count[countnum]=1;
  for(i=0;i<n-1;i++){
    if(a[i]==a[i+1])
      count[countnum]++;
    else{
      countnum++;
      count[countnum]=1;
    }
  }
  merge(0,countnum,count);
  for(i=k;i<=countnum;i++){
    sum+=count[i];
  }
  printf("%d\n",sum);
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<double> t(N+2, 0);
    vector<double> v(N+2, 0);
    for (int i = 1; i <= N; i++){
        double n;
        cin >> n;
        t[i] = t[i-1] + 2*n;
    }
    t[N+1] = t[N];
    for (int i = 1; i <= N; i++){
        cin >> v[i];
    }
    
    vector<double> s(t[N], 100000);
    for (int i = 0; i <= t[N]; i++) {
        for (int j = 0; j <= N+1; j++) {
            double f;
            if (i >= t[j]) {
                f = v[j] + 0.5 * (i-t[j]);
            }else if (i >= t[j-1]) {
                f = v[j];
            }else {
                f = v[j] + 0.5 * (t[j-1] - i);
            }
            s[i] = min(s[i], f);
        }
    }
    double ans = 0;
    for (int i = 1; i <= t[N]; i++) {
        ans += 0.25 * (s[i] + s[i-1]);
    }
    printf("%.5lf", ans);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,m;
	int island[101][101];
	int d[101];
	int flg[101];
	int i,j;
	int u;
	int a,b,c;
	int x,y;
	int t,s;
	while(1){
		cin>>n>>m;
		if(n==0&&m==0)	break;
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				if(i==j)	island[i][j]=0;
				else		island[i][j]=INT_MAX;
			}
		}
		for(i=0;i<m;i++){
			cin>>u;
			if(u==0){
				cin>>x>>y;
				for(j=1;j<=n;j++){
					flg[j]=0;
					d[j]=INT_MAX;
				}
				d[x]=0;
				while(1){
					t=INT_MAX;
					for(j=1;j<=n;j++){
						if(flg[j]==0&&d[j]<t){
							s=j;
							t=d[j];
						}
					}
					flg[s]=1;
					if(t==INT_MAX)	break;
					for(j=1;j<=n;j++){
						if(island[s][j]!=INT_MAX)	d[j]=min(d[j],d[s]+island[s][j]);
					}
				}
				//for(j=1;j<=n;j++)	cout<<d[j]<<endl;
				if(d[y]==INT_MAX)	cout<<-1<<endl;
				else				cout<<d[y]<<endl;
			}
			else{//u!=0
				cin>>a>>b>>c;
				island[a][b]=min(island[a][b],c);
				island[b][a]=min(island[b][a],c);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double a = scan.nextDouble();
		double b = scan.nextDouble();
		double c = scan.nextDouble();
		scan.close();
		double s = a * b * Math.sin(Math.toRadians(c)) / 2;
		double l = a + b + Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(Math.toRadians(c)));
		double h = b * Math.sin(Math.toRadians(c));
		System.out.println(s);
		System.out.println(l);
		System.out.println(h);
	}
}

Measured memory_bytes: 18352
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  for (int i = 0; i + K - 1 < N; i++) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3516
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int i = ((A + B) % 24);
		System.out.print(i);
	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll a[100000];
ll kk[100001]; //普通の累積和
ll b[100001]; //理想的な塗り方の累積和

int main()
{
	int k,n;
	int maxl,maxr;
	ll ans=0;
	ll maxini=0;
	
	cin>>n>>k;
	kk[0]=0;
	b[0]=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		kk[i+1]=kk[i]+a[i];
		b[i+1]=b[i]+max(0LL,a[i]);
	}
	
	//全範囲を調べる
	for(int i=k;i<n+1;i++)
	{
		//cerr<<b[i-k]<<" "<<kk[i]-kk[i-k]<<" "<<b[n]-b[i]<<endl;
		ll temp = b[i-k]+max(kk[i]-kk[i-k],0LL)+(b[n]-b[i]);
		ans = max(ans,temp);
	}

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

Measured memory_bytes: 2560
// Problem : B - Substring
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    string s,t;
    cin>>s>>t;
    int ans = inf;
    for(int i=0;i<sz(s);i++){
        if(i+sz(t)-1 >= sz(s)) break;
        int cur = 0;
        for(int j=0;j<sz(t);j++){
            if(s[i+j] != t[j]) cur++;
        }
        ans = min(ans,cur);
    }
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    for(int test=1;test<=tests;test++){
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	const Int MOD = 1e9 + 7;
	int N, M;
	cin >> N >> M;
	vector<int> a(N), b(M);
	vector<Int> cnt_a(1000010, 0), cnt_b(1000010, 0);
	bool ok = true;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		++cnt_a[a[i]];
		if (cnt_a[a[i]] > 1) { ok = false; }
	}
	for (int i = 0; i < M; ++i) {
		cin >> b[i];
		++cnt_b[b[i]];
		if (cnt_b[b[i]] > 1) { ok = false; }
	}
	if (!ok) {
		cout << 0 << endl;
		return 0;
	}

	Int ans = 1;
	for (int i = N * M; i > 0; --i) {
		if (cnt_a[i] == 0 && cnt_b[i] == 0) {
			Int tmp = cnt_a[i + 1] * cnt_b[i + 1] % MOD;
			tmp = (tmp + MOD - (N * M - i)) % MOD;
			(ans *= tmp) %= MOD;
		} else if (cnt_a[i] != 1 || cnt_b[i] != 1) {
			if (cnt_a[i] > 0) {
				(ans *= cnt_b[i + 1]) %= MOD;
			} else {
				(ans *= cnt_a[i + 1]) %= MOD;
			}
		}

		cnt_a[i] += cnt_a[i + 1];
		cnt_b[i] += cnt_b[i + 1];
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int c[11][11];
int h, w;
int wall[200][200];
int ans;

int main() {
	cin >> h >> w;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> wall[i][j];
			if (wall[i][j] != -1) {
				ans += c[wall[i][j]][1];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	bool ans = (abs(a-c) <= d) || (abs(a-b) <= d && abs(b-c) <=d);
	cout << (ans? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	s.erase(unique(s.begin(),s.end()),s.end());
	
	int ns=0,we=0;
	for (int i = 0; i < s.size(); i++){
		switch(s[i]){
			case 'N':ns++;break;
			case 'S':ns--;break;
			case 'W':we++;break;
			case 'E':we--;break;
		}
	}

	if(ns==0&&we==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

H, N = map(int, input().split())
AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

inf = 10**12
dp = [[inf for j in range(H+1)] for i in range(N+1)]
for i in range(N+1):
    dp[i][0] = 0

for i in range(N):
    for j in range(1,H+1):
        if j <= AB[i][0]:
            dp[i+1][j] = min(AB[i][1], dp[i][j])
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j - AB[i][0]]+AB[i][1])

print(dp[N][H])

Measured memory_bytes: 125532
s = input()
s += " "
K = int(input())
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
k = 0

k = K
for i in range(len(s) - 1):
	gap = (26 - alphabet.index(s[i])) % 26
	if K >= gap:
		K -= gap
		s = s[:i] + "a" + s[i+1:]
s = s[:-1]

if K:
	n = alphabet.index(s[-1])
	n += K
	n %= 26
	s = s[:-1] + alphabet[n]

print(s)

Measured memory_bytes: 3508
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,i,j,f,g,c[500][500],v;
	char z[1000][1000],x;
	while(1){
		v=0;
		scanf("%d %d",&a,&s);
		if(a==0&&s==0)	break;
		for(i=0;i<a;i++){
			for(j=0;j<s;j++)
				z[i][j]=0;
		}
		for(i=0;i<a;i++){
			scanf("%s",z[i]);
		}
		for(i=0;i<a;i++){
			for(j=0;j<s;j++){
				c[i][j]=0;
			}
		}
		f=0;
		g=0;
		while(1){
			if(z[f][g]=='>'){
				g++;
				c[f][g]++;
			//	printf("%d %d\n",f,g);
			}
			else if(z[f][g]=='<'){
				g--;
				c[f][g]++;
			//	printf("%d %d\n",f,g);
			}
			else if(z[f][g]=='^'){
				f--;
				c[f][g]++;
			//	printf("%d %d\n",f,g);
			}
			else if(z[f][g]=='v'){
				f++;
				c[f][g]++;	
			//	printf("%d %d\n",f,g);
			}
			if(z[f][g]=='.')	break;
			if(c[f][g]==2){
				v=1;
				break;
			}
		}
		if(v==1)
			printf("LOOP\n");
		else
			printf("%d %d\n",g,f);
	}
		return 0;
}

Measured memory_bytes: 2868
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << c << ' ' << a << ' ' << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector<int>gr[100005];
int dp[100005]={-1};
int dfs(int x)
{
    if(dp[x]!=-1)
    return dp[x];
    dp[x]=0;
    int mx=0;
    for(int i=0;i<gr[x].size();i++)
    {
        mx=max(mx,dfs(gr[x][i]));
    }
    return dp[x]=1+mx;
}
int main()
{
    int n,m;
    cin>>n>>m;
    int u,v;
    while(m--)
    {
        cin>>u>>v;
        gr[u].pb(v);
    }
    for(int i=0;i<=n;i++)
    dp[i]=-1;
    for(int i=1;i<=n;i++)
    {
        if(dp[i]==-1)
        int x=dfs(i);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    ans=max(ans,dp[i]);
    cout<<max(0,ans-1)<<"\n";
    return 0;
}

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

int main()
{
    bool flags[52];
    for (int i = 0; i < 52; i++) {
        flags[i] = false;
    }
    int n;
    cin >> n;
    while (n--) {
        int t;
        char c;
        cin >> c >> t;
        t--;
        switch (c) {
        case 'S': break;
        case 'H': t += 13; break;
        case 'C': t += 26; break;
        case 'D': t += 39; break;
        }
        flags[t] = true;
    }
    for (int i = 0; i < 52; i++) {
        if (!flags[i]) {
            int c, t;
            char cc;
            c = i / 13;
            t = i % 13 + 1;
            switch (c) {
            case 0: cc = 'S'; break;
            case 1: cc = 'H'; break;
            case 2: cc = 'C'; break;
            case 3: cc = 'D'; break;
            }
            cout << cc << " " << t << endl;
        }
    }
}



Measured memory_bytes: 3088
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

S = input()
T = input()

ans = ''

index = -1
matched = False
for i in range(len(S)-len(T), -1, -1):
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
    else:
        matched = True
        S = S[0:i] + T + S[i+len(T):len(S)]
        break
if not matched:
    print('UNRESTORABLE')
else:
    for i in range(len(S)):
        if S[i] == '?':
            ans += 'a'
        else:
            ans += S[i]
    print(ans)


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

int main() {
    long long n, m, ans=1;
    cin >> n >> m;
    if(abs(n-m)==1) {
        for(int i=0; i<n; i++) {
            ans *= (i+1);
            ans %= 1000000007;
        }
        for(int j=0; j<m; j++) {
            ans *= (j+1);
            ans %= 1000000007;
        }
    }
    else if(abs(n-m)==0) {
        for(int i=0; i<n; i++) {
            ans *= (i+1);
            ans %= 1000000007;
        }
        for(int j=0; j<m; j++) {
            ans *= (j+1);
            ans %= 1000000007;
        }
        ans *= 2;
        ans %= 1000000007;
    }
    else ans=0;
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<climits>

using namespace std;

const int eMax = 1000000;

int main() {
  int e;
  while(cin>>e && e) {
    int ans = e;
    for(int z=0; z*z*z<=e; z++) {
      for(int y=0; y*y+z*z*z<=e; y++) {
	int x = e-y*y-z*z*z;
	if(x+y+z < ans) {
	  ans = x+y+z;
	}
      }
    }
    /*
    int ans = INT_MAX;
    bool flag = false;
    for(int x=0; x<e; x++) {
      for(int y=0; y<=sqrt(e) && x+y*y<=e; y++) {
	int yy = y*y;
	for(int z=0; z<=pow(e,0.333)+1 && x+yy+z*z*z<=e; z++) {
	  int zzz = z*z*z;
	  if(x+yy+zzz==e && x+y+z<ans) {
	    ans = x+y+z;
	  }
	  if(flag == true) break;
	}
	if(flag == true) break;
      }
      if(flag == true) break;
    }
    */
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, A, B, C; cin >> N >> A >> B >> C;
	vector<string> s(N);
	for (int i = 0; i < N; i++) {
		cin >> s[i];
	}

	bool flag = true;
	string ans;
	for (int i = 0; i < N - 1; i++) {
		if (s[i] == "AB") {
			if (s[i+1] == "AB") {
				if (A >= B)A--, B++,ans.push_back('B');
				else A++, B--,ans.push_back('A');
			}
			if (s[i+1] == "AC") {
				if (B != 0)A++, B--, ans.push_back('A');
				else A--, B++, ans.push_back('B');
			}
			if(s[i+1]=="BC"){
				if (A != 0)A--, B++, ans.push_back('B');
				else A++, B--, ans.push_back('A');
			}

		}
		if (s[i] == "AC") {
			if (s[i+1] == "AB") {
				if (C != 0)A++, C--, ans.push_back('A');
				else A--, C++, ans.push_back('C');
			}
			if (s[i+1] == "AC") {
				if (A >= C)A--, C++, ans.push_back('C');
				else A++, C--, ans.push_back('A');
			}
			if (s[i+1] == "BC") {
				if (A != 0)A--, C++, ans.push_back('C');
				else A++, C--, ans.push_back('A');
			}
			

		}

		if (s[i] == "BC") {
			if (s[i+1] == "AB") {
				if (C != 0)B++, C--, ans.push_back('B');
				else B--, C++, ans.push_back('C');
			}
			if (s[i+1] == "AC") {
				if (B != 0)B--, C++, ans.push_back('C');
				else B++, C--, ans.push_back('B');
			}
			if (s[i+1] == "BC") {
				if (B >= C)B--, C++, ans.push_back('C');
				else B++, C--, ans.push_back('B');
			}

		}

		if (A < 0 || B < 0 || C < 0) {
			flag = false;
			break;
		}
	}

	if (s[N-1] == "AB") {
		if (A >= B)A--, B++, ans.push_back('B');
		else A++, B--, ans.push_back('A');
	}
	if (s[N-1] == "AC") {
		if (A >= C)A--, C++, ans.push_back('C');
		else A++, C--, ans.push_back('A');
	}
	if (s[N-1] == "BC") {
		if (B >= C)B--, C++, ans.push_back('C');
		else B++, C--, ans.push_back('B');
	}

	if (A < 0 || B < 0 || C < 0) {
		flag = false;
	}

	if (!flag) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		for (int i = 0; i < N; i++){
			cout << ans[i] << endl;
		}
	}
}


Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
int L;
vector<pair<pair<int,int>,int> > g;
int main(){
	cin>>L;
	int C,P;
	for (C=0,P=1; P<=L; ++C,P<<=1); --C; P>>=1;
	for (int i=1; i<=C; ++i){
//		cout<<i<<" "<<i+1<<" "<<(1<<(C-i))<<endl;
//		cout<<i<<" "<<i+1<<" "<<0<<endl;
		g.push_back(make_pair(make_pair(i,i+1),(1<<(C-i))));
		g.push_back(make_pair(make_pair(i,i+1),0));
	}
	int LL=L;
	L-=P;
	int pre=1<<C;
	for (int i=C-1; i>=0; --i){
		if (L&1<<i){
			g.push_back(make_pair(make_pair(1,C-i+1),(LL-1)&pre));
		}
		pre|=1<<i;
	}
	cout<<C+1<<" "<<g.size()<<endl;
	for (size_t i=0; i<g.size(); ++i) cout<<g[i].first.first<<" "<<g[i].first.second<<" "<<g[i].second<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
int main()
{
  int n; cin >> n;
  map<int,int> mp;
  int x = 7;
  int res = 1;
  while(1) {
    int tmp = x % n;
    if(mp[tmp] > 0) {
      cout << -1 << "\n";
      return 0;
    }
    mp[tmp]++;
    if(tmp == 0) {
      cout << res << "\n";
      return 0;
    }
    res++;
    x = tmp*10 + 7;
  }
  return 0;
}


Measured memory_bytes: 50468
def f(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d
n=int(input())
a=list(map(int,input().split()))
l=[0]
for i in range(n):
    l.append(l[i]+a[i])
d=dict()
for i in l:
    d=f(d,i)
print(sum([i*(i-1)//2 for i in d.values()]))

Measured memory_bytes: 41076
#include<stdio.h>

int main(){
	int N;
	int T , A;
	scanf("%d %d %d",&N ,&T ,&A);
	int H[N];
	for(int i=0;i<N;i++){
		scanf("%d",&H[i]);
	}
	int x[N];
	for(int j=0;j<N;j++){
		x[j] = 1000*A - (1000*T - 6*H[j]);
		if(x[j]<0){
			x[j] *= -1;
		}
	}
	int min = 0;
	for(int k=1;k<N;k++){
		if(x[k] < x[min]){
			min = k;
		}
	}
	printf("%d\n",min+1);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
#define N 100009
#define LL long long
#define INF 0x7fffffff
#define mymin(x,y) (x>=y?y:x)
#define mymax(x,y) (x>=y?x:y)
struct input {
	int a, index;
}inp[N];
bool cmp(input a, input b) {
	return a.a < b.a;
}
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> inp[i].a;
		inp[i].index = i;
	}
	sort(inp + 1, inp + n + 1, cmp);
	for (int i = 1; i <= n; i++) {
		cout << inp[i].index << " ";
	}
	return 0;
}

Measured memory_bytes: 4384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin >> n >> m;
    vector<vector<int>> e(n);
    REP(i,m){
        int a,b;cin >> a >> b;
        a--,b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    vector<int> d(n,-1);
    queue<int> q;
    q.push(0);
    d[0]=0;
    bool f=true;
    while(!q.empty()){
        int p=q.front();
        q.pop();
        for(int x:e[p]){
            if(d[x]==-1){
                d[x]=1-d[p];
                q.push(x);
            }
            else{
                if(d[x]==d[p]){
                    f=false;
                    break;
                }
            }
        }
    }
    if(f){
        ll u=0,v=0;
        REP(i,n){
            if(d[i]) u++;
            else v++;
        }
        cout << u*v-m << endl;
    }
    else{
        cout << n*(n-1)/2-m << endl;
    }
}



Measured memory_bytes: 9264
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}


fn main() {
    input!{
        n: i64,
        k: i64,
    }
    let mods: i64 = 1000000007;
    let mut result: i64 = 0;
    for i in k..n+2 {
        result = (result + i*(2*n-i+1)/2 - i*(i-1)/2 + 1)%mods;
    }
    println!("{}", result);
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

class UnionFind{
private:
  vector<int> node;

public:
  UnionFind(int n){
    node=vector<int>(n);
    iota(all(node),0);
  }
  int root(int x){
    if(node[x]==x) return x;
    else return node[x]=root(node[x]);
  }
  bool uni(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y) return false;
    node[y]=x;
    return true;
  }
};

struct sta{
  LL cost;
  LL w; 
  LL totalb;
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<LL> a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];
  vector<vector<int>> e(n);
  int u,v;
  rep(i,m){
    cin >> u >> v;
    e[u-1].push_back(v-1);
    e[v-1].push_back(u-1);
  }
  vector<int> p(n);
  iota(all(p), 0);
  sort(all(p),[&](const int &l, const int &r){
    return a[l]-b[l] < a[r]-b[r];
  });
  vector<bool> merged(n, false);
  UnionFind uf(n);
  vector<sta> tmp(n);
  rep(i,n){
    int x = p[i];
    merged[x] = true;
    LL mic = LINF;
    for(auto ad:e[x]){
      if(!merged[ad]) continue;
      ad = uf.root(ad);
      if(tmp[ad].cost+max(a[x]-b[x]-tmp[ad].w,0LL) < mic){
        mic = tmp[ad].cost+max(a[x]-b[x]-tmp[ad].w,0LL);
      }
    }
    sta now = {0, 0, 0};
    if(mic==LINF) now.cost = max(a[x]-b[x],0LL);
    else now.cost = mic;
    now.totalb = b[x];
    for(auto ad:e[x]){
      if(!merged[ad]) continue;
      LL t = tmp[uf.root(ad)].totalb;
      if(uf.uni(x,ad)){
        now.totalb+=t;
      }
    }
    now.w = now.cost + now.totalb;
    tmp[uf.root(x)] = now;
  }
  cout << tmp[uf.root(0)].w << endl;
  return 0;
}


Measured memory_bytes: 10620
/******************************************************************************

                              facts dont care about your feelings

*******************************************************************************/

#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
   vector<int>vec;
   int x, y, z;
   
   cin>>x>>y;
   
   for(int i=0; i<x; i++){
       cin>>z;
       
       vec.push_back(z);
       
      
   }
   sort(vec.begin(), vec.end());
   
   int count=0; 
   for(int i=0; i<y; i++){
       
       count+=vec[i];
       
   }
   
   cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if(A + B > C + D)
    {
        cout << "Left" << endl;
    }
    else if(A + B == C + D)
    {
        cout << "Balanced" << endl;
    }
    else
    {
        cout << "Right" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
var lines = [];
var result = 0;
var readline = require("readline");

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]);

    if (N % 2 === 0) { console.log(N) }
    else { console.log(N * 2) }
});

Measured memory_bytes: 7500
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

vector<string> s(3);
const ll MX = 2005;
bool d[3][3][MX] = {};
ll ans = MX * 3;

int main() {
	rep(i, 3)cin >> s[i];
	stable_sort(s.begin(), s.end());
	do {
		rep(i, 3) {
			rep(j, 3) {
				rep(k, sz(s[i])) {
					if (i >= j)continue;
					bool ok = true;
					rep(l, min(sz(s[j]), sz(s[i]) - k)) {
						if (s[i][k + l] != s[j][l] && s[i][k + l] != '?' && s[j][l] != '?')ok = false;
					}
					d[i][j][k] = ok;
				}
			}
		}
		auto f = [&](ll i, ll j, ll k) {
			if (k >= sz(s[i]))return true;
			return d[i][j][k];
		};
		rep(i, MX) {
			rep(j, MX) {
				if (f(0, 1, i) && f(1, 2, j) && f(0, 2, i + j))ans = min(ans, (ll)max(sz(s[0]), max(i + sz(s[1]), i + j + sz(s[2]))));
			}
		}
	} while (next_permutation(s.begin(), s.end()));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 149 A - Strings
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/29
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

char s[100];
char t[100];

void solve() {

    printf("%s%s\n", t, s);
}

int main() {

    scanf("%s", s);
    scanf("%s", t);

    solve();

}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    vector<int> V(1),W(1);
    int zero = 0,one = 0;
    REP(i,S.size()){
        if(S[i] == '0'){
            zero++;
            V.pb(zero);
        }
        else{
            one++;
            W.pb(one);
        }
    }
    sort ALL(V);
    sort ALL(W);
    reverse ALL(V);
    reverse ALL(W);

    cout << min(V[0],W[0])*2 << endl;
}

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


void func(long long N, long long K, std::vector<long long> H){
    sort(H.begin(), H.end());
    ll ans = 0;
    rep(i,N-K) ans+=H[i];
    cout << ans << endl;
}

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

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


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

int main() {
  int a;
  int b = 0;
  int c = 0;
  int d;
  cin >> a;
  for(int i = 0;i < a;i++){
    cin >> d;
    if(d > b){
      c += b;
      b = d;
    }else{
      c += d;
    }
  }
  if(b < c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main() {
		int N,u=0,baikai=0,count=0;
		cin >> N;
		vector<int> data(200);
		for (int i = 0; i < N; i++) {
			cin >> data.at(i);
		}

		for (int i = 0; u == 0; i++) {
			for (int i = 0; i < N; i++) {
				int a;
				a = data.at(i) / pow(2, baikai);
				if (a % 2 != 0) {
					u++;
				}
			}
			if (u == 0){baikai++;	}
		}
			
		cout << baikai << endl;

	}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int N = 20;
const int inf = 1e18;
int n, a[N];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
int solve(int l, int r, int xl, int xr)
{
	if(r - l <= 1) return 0; int res = inf;
	for(int i = l + 1; i <= r - 1; i ++) res = min(res, solve(l, i, xl, xl + xr) + solve(i, r, xl + xr, xr) + a[i] * (xl + xr));
	return res;
}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	for(int i = 1; i <= n; i ++) a[i] = read();
	printf("%lld\n", solve(1, n, 1, 1) + a[1] + a[n]);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const double PI=3.14159265358979323846;
constexpr long long int MOD = 1000000007;

int main(){
    ll N,K; cin>>N>>K;
    ll ans=0;
    ll L,R;
    for(ll i=K;i<=N+1;i++){
         L=i*(i-1)/2;
         R=N*i-L;
        ans+=R-L+1;
    }
    cout<<ans%MOD;
    return 0;
}

Measured memory_bytes: 3636
# for i in range(1,101):
#   for j in range(1,i):
#     a=i//j
#     b=i%j
#     if a==b:
#       print(str(i)+'を'+str(j)+'で割った商は'+str(a)+'、余りは'+str(b))

n=int(input())

c=0
for i in range(1,n):
  x=(n-i)%i
  y=(n-i)//i
  if y<=i:
    break
  if x==0:
    c+=y
print(c)

Measured memory_bytes: 3064