akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

struct UnionFind{
    vector<int> data;
    UnionFind(int size){
        data=vector<int>(size,-1);
    }
    bool union_set(int x,int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];
            data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI3(A,B,C);
    print(A==B&&B==C?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int h, w;
	char mat[51][51];

	cin >> h >> w;

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			cin >> mat[i][j];
		}
	}


	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (mat[i][j] == '#') {
				if (mat[i-1][j] == '.' && mat[i+1][j] == '.' && mat[i][j+1] == '.' && mat[i][j-1] == '.') {
					cout << "No" << endl;

					getchar();
					getchar();
					return 0;
				}
			}
		}
	}


	cout << "Yes" << endl;



	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	string N;
	cin >> N;
	if (N[0] == N[N.size() - 1]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

// 配列出力関数
void OutputArray(int A[], int N)
{
    for (int x=0; x<N-1; x++) {
        // 空白区切りで出力
        std::cout << A[x] << " ";
    }
    std::cout << A[N-1] << std::endl;
}

// 結果出力
void DisplayResults(int A[], int N, int Cnt)
{
    OutputArray(A, N);
    std::cout << Cnt << std::endl;
}

// スワップ関数
void Swap(int A, int B)
{
    int tmp = A;
    A = B;
    B = tmp;
}

// バブルソート実行関数
void BubbleSort(int R[], int N)
{
    // ソート回数をカウント
    int cnt_sort = 0;
    // 隣接要素が存在するか
    bool bIsAnyNext = true;
    while(bIsAnyNext) {
        bIsAnyNext = false;
        for (int i=N-1; 0<i; i--) {
            if(R[i] <  R[i-1]) {
                std::swap(R[i], R[i-1]);
                bIsAnyNext = true;
                cnt_sort++;
            }
        }
    }
    DisplayResults(R, N, cnt_sort);
}

int main()
{
    static const int MAX = 100;
    int n, R[MAX];
    std::cin >> n;
    
    for (int i=0; i<n; i++) std::cin >> R[i];
    
    BubbleSort(R, n);
    return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

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

    int n = 0;
    for(int i=0;i<N;++i){
        int x;
        std::cin >> x;

        if(A <= x && x < B){
            
        }else{
            ++n;
        }
    }

    std::cout << n << std::endl;
}


Measured memory_bytes: 256
N=int(input())
city=[0]*N
for i in range(N):
    x,y=map(int,input().split())
    city[i]=(i,x,y)
city.sort(key=lambda x:x[1])
data=[(city[i][0],city[i+1][0],city[i+1][1]-city[i][1]) for i in range(N-1)]
city.sort(key=lambda x:x[2])
data+=[(city[i][0],city[i+1][0],city[i+1][2]-city[i][2]) for i in range(N-1)]
data.sort(key=lambda x:x[2])
f = list(range(N))
costs = [1] * N
def find(x):
    if f[x] != x:
        f[x] = find(f[x])
    return f[x]
res = 0
for i, j, k in data:
    fi, fj = find(i), find(j)
    if fi == fj:
        continue
    else:
        if costs[fi] <= costs[fj]:
            f[fi] = fj
            costs[fj] += costs[fi]
            res += k
        else:
            f[fj] = fi
            costs[fi] += costs[fj]
            res += k
print(res)

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

int main() {
  
  int a=0, b=0;
  
  cin >> a >> b;
  
  if(a<b) {
    
    cout << "a < b" << endl;
    
  } else if(b<a) {
    
    cout << "a > b" << endl;
    
  } else if(a==b) {
    
    cout << "a == b" << endl;
    
  }
  
  return 0;
  
}


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

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

    int A[n];
    int pivot;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        if(A[i] == 1)   pivot = i;
    }  

    int ans = 100000;
    for(int i = 0; i <= k-1; i++){
        int candidate = 1;
        if(pivot-i > 0){
            candidate += (pivot-i)/(k-1) + ((pivot-i)%(k-1)!=0);
        }
        if(n-pivot-1-(k-1-i) > 0){
            candidate += (n-pivot-1-(k-1-i))/(k-1) + ((n-pivot-1-(k-1-i))%(k-1)!=0);
        }
        ans = min(ans, candidate);
    }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll A,V;
  ll B,W;
  ll T;
  cin >> A >> V >> B >> W >> T;
  ll dis = A - B;
  if(dis<0)dis=-dis;
  ll speed = V - W;
  ll res=speed*T;
  if(res>=dis){
    cout << "YES" << endl;    
  }else{
    cout << "NO" << endl;
  }
  
}

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

using namespace std;

using ll = long long;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

inline void solve() {
    string s;
    cin >> s;

    int n = (int)s.size();

    if (s[n-1] != 's') {cout << s + 's' << endl;}
    else {cout << s + "es" << endl;}
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3652
package main
 
import (
  "fmt"
  "os"
  "bufio"
  "strconv"
  "sort"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  a := make([]int, n)
  for i := range a {
    a[i] = nextInt()
  }
  
 //整数列をソートしてから隣接する要素を比較
  sort.Sort(sort.IntSlice(a))
  res := "YES"
  for i := 1; i < n; i++ {
    if a[i-1] == a[i] {
      res = "NO"
      break
    }
  }
  fmt.Println(res)
}


Measured memory_bytes: 4992
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std ;

const int N=2e5+10 ;

vector<int> V[N] ;
int n ;

int main ()
{
	int i , x , res=0 ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i++ )
		scanf("%d",&x),
		V[x].push_back(i);
	x=0;
	vector<int>::iterator it ;
	for ( i=1 ; i<=n ; i++ )
	{
		it=upper_bound(V[i].begin(),V[i].end(),x);
		if ( it==V[i].end() ) break;
		x=*it,++res;
	}
	if ( !res ) puts("-1");
	else printf("%d\n",n-res);
	return 0 ;
}


Measured memory_bytes: 11136
# -*- coding: utf-8 -*-
import sys
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def slv(N, M, H, AB):
    g = [list() for _ in range(N+1)]
    for a, b in AB:
        g[a].append(b)
        g[b].append(a)

    ans = 0
    for u in range(1, N+1):
        h = H[u-1]
        for v in g[u]:
            if H[v-1] >= h:
                break
        else:
            ans += 1

    return ans


def main():
    N, M = read_int_n()
    H = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    print(slv(N, M, H, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 102520
#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;


signed main() {
  int A, B, C, D, E, F, G; 
  cin >> A >> B >> C >> D >> E >> F >> G;

  int ans = A/2*2+D/2*2+E/2*2+B;

  if(A >= 1 && D >= 1 && E >= 1){
    A--; D--; E--;
    chmax(ans, A/2*2+D/2*2+E/2*2+3+B);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;


int32_t main(){
    FAST;

    int a, b ,c;
    cin >> a >> b >> c;
    cout << (a ^ b ^ c) << endl;

    return 0;
}




Measured memory_bytes: 256
n, m, l = list(map(int, input().split()))
a = [[int(j) for j in input().split()] for i in range(n)]
b = [[int(j) for j in input().split()] for i in range(m)]
c = [[0 for j in range(l)] for i in range(n)]

for i in range(n):
    for j in range(l):
        value = 0
        for k in range(m):
            value = value + a[i][k] * b[k][j]
        c[i][j] = value

for i in c:
    print(*i)


Measured memory_bytes: 7056
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c[4], i, maxx=-10000;
	cin >> a >> b;
	c[1]=a+b;
	c[2]=a-b;
	c[3]=a*b;
	for (i=1; i<=3; i++) maxx=max(maxx, c[i]);
	cout << maxx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b;
    int sum=0,sum2=0;
    int cnt=0;
    while(scanf("%d,%d",&a,&b)!=EOF){
        sum+=a*b;
        sum2+=b;
        cnt++;
    }
    printf("%d\n%d\n",sum,(sum2+(cnt/2))/cnt);
    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 100;
int P;
llong pw[N+3][N*N+3];
llong comb[N+3][N+3];
llong f[2][N+3][N+3];
llong trans[N+3][N+3];
int n,m,p;

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}

void initmath()
{
	for(int i=0; i<=N; i++)
	{
		pw[i][0] = 1ll; for(int j=1; j<=N*N; j++) pw[i][j] = pw[i][j-1]*i%P;
	}
	comb[0][0] = 1ll;
	for(int i=1; i<=N; i++)
	{
		comb[i][0] = comb[i][i] = 1ll;
		for(int j=1; j<i; j++) comb[i][j] = (comb[i-1][j]+comb[i-1][j-1])%P;
	}
}

llong updsum(llong &x,llong y) {x = x+y>=P?x+y-P:x+y;}

int main()
{
	scanf("%d%d%d%lld",&n,&m,&p,&P);
	initmath();
	int curk = 0; f[0][0][0] = 1ll;
	for(int k=1; k<=p; k++)
	{
		curk^=1; memset(f[curk],0,sizeof(f[curk]));
		for(int j=0; j<=m; j++) for(int ii=0; ii<=n; ii++) trans[j][ii] = pw[k][ii*(m-j)]%P*pw[p-k+1][ii*j]%P;
		for(int i=0; i<=n; i++)
		{
			for(int j=0; j<=m; j++)
			{
				llong x = f[curk^1][i][j]; if(!x) continue;
				for(int ii=0; ii+i<=n; ii++)
				{
					updsum(f[curk][i+ii][j],x*comb[i+ii][i]%P*trans[j][ii]%P);
				}
			}
		}
		curk^=1; memset(f[curk],0,sizeof(f[curk]));
		for(int i=0; i<=n; i++) for(int jj=0; jj<=m; jj++) trans[i][jj] = pw[k][jj*(n-i)]%P*pw[p-k+1][jj*i]%P;
		for(int i=0; i<=n; i++)
		{
			for(int j=0; j<=m; j++)
			{
				llong x = f[curk^1][i][j]; if(!x) continue;
				for(int jj=0; jj+j<=m; jj++)
				{
					updsum(f[curk][i][j+jj],x*comb[j+jj][j]%P*trans[i][jj]%P);
				}
			}
		}
		curk^=1; memset(f[curk],0,sizeof(f[curk]));
		for(int j=0; j<=m; j++) for(int ii=0; ii<=n; ii++) trans[j][ii] = pw[k][ii*(m-j)]%P*pw[p-k][ii*j]%P;
		for(int i=0; i<=n; i++)
		{
			for(int j=0; j<=m; j++)
			{
				llong x = f[curk^1][i][j]; if(!x) continue;
				for(int ii=0; ii+i<=n; ii++)
				{
					llong y = x*comb[i+ii][i]%P*trans[j][ii]%P;
					updsum(f[curk][i+ii][j],ii&1?P-y:y);
				}
			}
		}
		curk^=1; memset(f[curk],0,sizeof(f[curk]));
		for(int i=0; i<=n; i++) for(int jj=0; jj<=m; jj++) trans[i][jj] = pw[k][jj*(n-i)]%P*pw[p-k][i*jj]%P;
		for(int i=0; i<=n; i++)
		{
			for(int j=0; j<=m; j++)
			{
				llong x = f[curk^1][i][j]; if(!x) continue;
				for(int jj=0; jj+j<=m; jj++)
				{
					llong y = x*comb[j+jj][j]%P*trans[i][jj]%P;
					updsum(f[curk][i][j+jj],jj&1?P-y:y);
				}
			}
		}
	}
	printf("%lld\n",f[curk][n][m]);
	return 0;
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;

vi v;

void read() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.pb(x);
  }
}

int gcd(int a, int b) {
  while (b) {
    int c = a % b;
    a = b;
    b = c;
  }
  return a;
}
int l[100001], r[100001];
void solve() {
  l[1] = v[0];
  for(int i = 1; i < n; ++i) {
    l[i + 1] = gcd(l[i], v[i]);
  }
  r[1] = v[n - 1];
  for(int i = n - 2; i >= 0; --i) {
    r[n - i] = gcd(r[n - i - 1], v[i]);
  }
  int sol = 0;
  for(int i = 0; i < n; ++i) {
    int nr = gcd(l[i], r[n - i - 1]);
    if (nr > sol)
      sol = nr;
  }
  cout << sol;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  read();
  solve();
  return 0;
}


Measured memory_bytes: 1528
#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)
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    int a; cin >> a;
    string s; cin >> s;
    
    if (a%2==0 && s.substr(0,a/2) == s.substr(a-a/2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    


}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ code.cpp
./a.out

サンプルのダウンロードは oj d URL
テストは oj t
*/

Measured memory_bytes: 256
N , M = (map(int , input().split()))
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
ans = Base_10_to_n(N , M)
print(len(str(ans)))

Measured memory_bytes: 3060
<?php
$n = int();
echo floor(($n-1)/2);
function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4728
console.log((args=>{
  const S = args.trim().split``.map(v=>v|0);
  const L = S.length;
  const M = Array(2019).fill(0);
  let e = 0, d = 1;
  for ( let i = L-1; i >=0; i-- ) {
    e = (e + S[i] * d)%2019;
    M[e]++;
    d = d*10%2019;
  }
  let a = M[0];
  for ( let i = 0; i < 2019; i++ ) {
    if ( M[i] < 2 ) continue;
    a += M[i] * (M[i]-1) / 2;
  }
  return `${a}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

int main() {
    int   A,B;
    cin >> A >> B;

    int w = 2*B;

     if (w >= A){
       cout << 0 << endl;
     }
     else if(w < A) {
        cout << A-w << endl;
       
     }

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

i64 solve(i64 a, i64 b, i64 c, i64 d) {

	for(int level = 30; level > 0; level--) {

		i64 width = 1;
		for(int i = 0; i < level - 1; i++) {
			width = width * 3;
		}

		i64 x1 = a / width;
		i64 y1 = b / width;
		i64 x2 = c / width;
		i64 y2 = d / width;

		if(x1 != x2 && y1 != y2) {
			return abs(c - a) + abs(d - b);
		}

		if(x1 == x2 && y1 == y2) {
			continue;
		}

		if(x1 != x2) {
			swap(x1, y1);
			swap(x2, y2);
			swap(a, b);
			swap(c, d);
		}

		if(x1 % 3 != 1) {
			continue;
		}

		if((y1 + 1) / 3 == (y2 + 1) / 3) {
			continue;
		}

		i64 p = a % width;
		i64 q = c % width;
		return abs(b - d) + min(p + q + 2, 2 * width - p - q);
	}

	return abs(c - a) + abs(d - b);
}

int main() {

	const int Q = read_item();

	for(auto i : range(Q)) {
		i64 a = read_item();
		i64 b = read_item();
		i64 c = read_item();
		i64 d = read_item();
		a -= 1;
		b -= 1;
		c -= 1;
		d -= 1;
		i64 ans = solve(a, b, c, d);
		printf("%lld\n", ans);
	}

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 384
n = int(input())
A = list(map(int,input().split()))
cnt = 0
for a in A:
    if a < 0:
        cnt += 1
res = 0
A = [abs(a) for a in A]
A.sort()
for a in A:
        res += a
if cnt%2 == 1:
    res -= 2*A[0]
print(res)

Measured memory_bytes: 14284
//Header files include.
#include <bits/stdc++.h>
#define TEST(T) int T;In(T);int testno = 0;while(testno++ != T)
#define nextIntVector(V,base) for(unsigned int i = base;i<V.size();i++){In(V[i]);}
#define In(i) cin>>i
#define FOR(i,l,r) for(int i=0;i<l;i+=r)
#define gc getchar
#define fastinout() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

//Type definitions.
typedef unsigned int uint;
typedef long long int lli;
typedef long int li;
typedef unsigned long long int ulli;

//Name spaces.
using namespace std;

//Global Variables.

//Start coding here.

int main(){
	//fastinout();
	map<int,int> a;int N,ele;
	cin>>N;
	for(int i = 0; i < N; i++){
		cin>>ele;
		a[ele]++;
	}
	int ans = 0,i;
	for(auto it = a.begin(); it != a.end(); ++it){
		i = it->first;
		if(a[i] > 0 && a[i] < i) ans += a[i];
		else if(a[i] > 0) ans += a[i]-i;
	}
	cout<<ans;
}


Measured memory_bytes: 4736
#include <stdio.h>

int main(){
  int a,b,c,x;
  
  if(scanf("%d",&a)==1);
  if(scanf("%d",&b)==1);
  if(scanf("%d",&c)==1);
  if(scanf("%d",&x)==1);
  
  int count = 0;
  int value;
  int i,j,k;
  for(i=0;i < a+1;i++){
    value = 500*i;
    for(j=0;j < b+1;j++){
      value = 500*i + 100*j;
      for(k=0;k < c+1;k++){
        value = 500*i + 100*j + 50*k;
        if(value==x)count++;
      }
    }
  }
  printf("%d",count);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <cstdio>
#include <stdlib.h>
#include <math.h>
using namespace std;

long long ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main(){
    char a[2000000];

    scanf("%s", a);

    //printf("%s\n", a);

    int amari[2019];
    long long length = strlen(a); 
    long long ten = 1;

    //printf("%lld\n", length);
    
    long long T[length + 1];
    T[length] = 0;

    for(long long i = length; i > 0; i--){
        //printf("%c\n", a[i - 1]);
        //ten = (long long)  pow(10, length - i);
        T[i - 1] = ten * ctoi(a[i - 1]) + T[i];
        //printf(" : %f\n", pow(10, length - i));
        T[i - 1] = T[i - 1] % 2019;
        ten = ten * 10;
        ten = ten % 2019;

        //printf("%lld : %lld\n", i, T[i-1]);
        //printf("%lld\n", ten);
    }

    /*for(long long i = 0; i <= length; i++){
        T[i] = T[i] % 2019;
    }*/

    /*for(long i = 0; i <= length; i++){
        printf("%ld : %lld\n", i, T[i]);
    }*/

    for(int j = 0; j < 2019; j++){
        amari[j] = 0;
    }

    for(long long i = 0; i <= length; i++){
        amari[T[i]]++;
    }

    for(int j = 0; j < 2019; j++){
        if (amari[j] > 0){
        amari[j] = amari[j] * (amari[j] - 1)/2;
        }
    }

    int count = 0;

    for(int j = 0; j < 2019; j++){
        count = count + amari[j];
    }

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





    

    return 0;
    
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


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

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll n;
  cin >> n;
 vector<string> s(n);
 map<string,ll> mp;
  rep(i,0,n) {
    cin >> s[i];
    mp[s[i]]++;
  }
  ll res=0;
  for(auto p:mp) res=max(res,p.second);
  
  vector<string> ans;
 for(auto p:mp) if(p.second==res) ans.push_back(p.first);
  sort(ans.begin(),ans.end());
  
  rep(i,0,ans.size()) cout << ans[i] << endl;
  
  
}


Measured memory_bytes: 27120
if __name__ == '__main__':
	n = int(input())
	while n != 0:
		s = [int(s) for s in input().split()]
		m = 0
		for i in s:
			m += i
		m = m/n
		tmp = 0 
		for i in s:
			tmp += (i - m)**2
		print("%.10f" % ((tmp/n)**0.5))
		n = int(input())


Measured memory_bytes: 5676
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> a;
  Cout(a * a);
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll h, w;
vector<string> a;
/******* define variable end *******/
int solve() {
	cin >> h >> w;
	a.resize(h);
	REP(i, h){
		cin >> a[i];
	}
	vector<string> ans;
	REP(i, h){
		bool flag = true;
		REP(j, w){
			if(a[i].substr(j, 1) == "#"){
				flag = false;
			}
		}
		if(!flag){
			ans.push_back(a[i]);
		}
	}
	vector<vector<string>> ans2(ans.size());
	REP(i, ans[0].size()){
		bool flag = true;
		REP(j, ans.size()){
			if(ans[j].substr(i, 1) == "#"){
				flag = false;
			}
		}
		if(!flag){
			REP(j, ans.size()){
				ans2[j].push_back(ans[j].substr(i, 1));
			}
		}
	}
	REP(i, ans.size()){
		REP(j, ans2[0].size()){
			cout << ans2[i][j];
		}
		cout << endl;
	}
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int n;
    cin >> n;
    vector<int> a(n), ind(n);
    for(size_t i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        ind[a[i]] = i;
    }
    set<int> A;
    A.insert(-1);
    A.insert(n);
    vector<ll> al(n, 0); //閉区間
    vector<ll> ar(n, 0); //閉区間
    for(int i = 0; i < n; i++) {
        auto itr = A.lower_bound(ind[i]);
        ar[ind[i]] = *itr;
        itr--;
        al[ind[i]] = *itr;
        A.insert(ind[i]);
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++) {
        ans += (i + 1) * (ind[i] - al[ind[i]]) * (ar[ind[i]] - ind[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
a, b = map(int, input().split())

def check(s: str):
    if (not str) or len(s) == 1:
        return True
    if s[0] == s[-1]:
        return check(s[1:-1])
    return False

res = 0
for i in range(a, b + 1):
    if check(str(i)):
        res += 1

print(res)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
//#define int long long
const int maxn=1e5+1;
int n;
int a[maxn][5],f[maxn][5];

main()
{
    cin>>n;
    forinc(i,1,n)
    forinc(j,1,3) cin>>a[i][j];
    f[1][1]=a[1][1];
    f[1][2]=a[1][2];
    f[1][3]=a[1][3];
    forinc(i,1,n)
    {
        forinc(j,1,3)
        {
            forinc(k,1,3) if(k!=j)
            {
                f[i][j]=max(f[i][j],f[i-1][k]+a[i][k]);
            }
        }
    }
    cout<< max({f[n][1],f[n][2],f[n][3]});
}


Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

int main() {
    int X, N; cin >> X >> N;
    vector<int> L(N); rep(i, N) cin >> L[i];

    if (N == 0) {
        cout << X << endl;
        exit(0);
    }
    
    set<int> s;
    for (auto v : L) s.insert(v);

    int ans = INF;
    reps(-500, i, 500) {
        if (s.find(i) == s.end()) {
            if (abs(X - ans) > abs(X - i)) {
                ans = i;
            } else if (abs(X - ans) == abs(X - i)) {
                ans = min(ans, i);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3660
while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print() #データセットの区切り



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

int main(){
  int h, n; cin >> h >> n;
  int a;
  for(int i=0; i<n; i++) {
    cin >> a;
    h -= a;
  }
  cout << (h > 0 ? "No" : "Yes") << endl;

  return 0;
}

// EOF


Measured memory_bytes: 256
#include<stdio.h>
int main (void)
{
  int A, B, C;
  int X;
  int Y;
  scanf("%d%d%d",&A, &B, &C);
  switch (A+B+C) {
    case 17:
      if (A == 5) X++;
      if (A == 7) Y++;
      if (B== 5) X++;
      if (B== 7) Y++;
      if (C== 5) X++;
      if (C== 7) Y++;
      if (X == 2 && Y == 1) printf("YES");
      break;
    default:
      printf("NO");
      break;
  }
}

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

using namespace std;

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

    int n;
    cin >> n;
    long long ans = 0;
    for(int i = 1; i <= n; i++)
        ans += (double)(i + (i * (n / i))) / 2 * (n / i);
    cout << ans;

    return 0;
}


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

    using namespace std;

    const int INF=1e9+7;
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        long long n,k;
        cin>>n>>k;
        vector<long long>h(n);
        for(int i=0;i<n;i++)
            cin>>h[i];
        vector<long long>dp(n,INF);
        dp[0]=0;
        for(long long i=0;i<n;i++){
            for(long long j=i+1;j<=i+k;j++){
                if(j<n)
                    dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
        cout<<dp[n-1];
        return 0;
    }


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct MinimumCostFlow {
	using Flow = int;
	using Cost = int;
	struct Edge {
		int to, rev;
		Flow cap;
		Cost cost;
		Edge() {}
		Edge(int to, int rev, Flow cap, Cost cost) :to(to), rev(rev), cap(cap), cost(cost) {}
	};
	int n;
	vector<vector<Edge>> g;
	vector<int> dist;
	vector<int> prevv, preve;
	MinimumCostFlow(int n) :n(n), g(n), dist(n), prevv(n), preve(n) {}
	void addEdge(int from, int to, Flow cap, Cost cost) {
		g[from].emplace_back(to, (int)g[to].size(), cap, cost);
		g[to].emplace_back(from, (int)g[from].size() - 1, 0, -cost);
	}
	// s??????t????????????f???????°??????¨???
	// ??????????????´?????? -1
	Cost minimumCostFlow(int s, int t, Flow f) {
		Cost total = 0;
		while (f > 0) {
			// Bellman-Ford
			fill(dist.begin(), dist.end(), INF);
			dist[s] = 0;
			bool update = true;
			while (update) {
				update = false;
				for (int v = 0; v < n; v++) {
					if (dist[v] == INF)continue;
					for (int i = 0; i < g[v].size(); i++) {
						Edge &e = g[v][i];
						if (e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
							dist[e.to] = dist[v] + e.cost;
							prevv[e.to] = v;
							preve[e.to] = i;
							update = true;
						}
					}
				}
			}
			// ????????\???????????????
			if (dist[t] == INF)
				return -1;
			// ?????????????????£??????????????????
			int d = f;
			for (int v = t; v != s; v = prevv[v])
				d = min(d, g[prevv[v]][preve[v]].cap);
			f -= d;
			total += d*dist[t];
			for (int v = t; v != s; v = prevv[v]) {
				Edge &e = g[prevv[v]][preve[v]];
				e.cap -= d;
				g[v][e.rev].cap += d;
			}
		}
		return total;
	}
};

template<typename T>
vector<T> compress(vector<T> v) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	return v;
}

template<typename T>
int index(const vector<T> &zip, T i) { return lower_bound(zip.begin(), zip.end(), i) - zip.begin(); }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v;
	vector<int> A(N), B(N); rep(i, 0, N) {
		cin >> A[i] >> B[i];
		v.emplace_back(A[i]);
		v.emplace_back(B[i]);
	}
	vector<int> zip = compress(v);
	dump(zip);
	int n = N + zip.size() + 3;
	int d = n - 3, s = n - 2, t = n - 1;
	MinimumCostFlow mcf(n);
	rep(i, 0, N) {
		mcf.addEdge(s, i, 1, 0);
		mcf.addEdge(i, N + index(zip, A[i]), 1, -B[i]);
		mcf.addEdge(i, N + index(zip, B[i]), 1, -A[i]);
		mcf.addEdge(i, d, 1, 0);
	}
	rep(i, 0, zip.size()) {
		mcf.addEdge(N + i, t, 1, 0);
	}
	mcf.addEdge(d, t, INF, 0);
	cout << -mcf.minimumCostFlow(s, t, N) << endl;
	return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;




bool solve(const vector<int>&ys,int u,int d,
	const vector<int>&xs,int l,int r, int plusy, int plusx) {
	if (l==r || u==d) {
		if (l == r) {
			return all_of(ys.begin() + u, ys.begin()+d, [&](const int a) {return a == plusy;});

		}
		else {
			return all_of(xs.begin() + l, xs.begin() + r, [&](const int a) {return a == plusx; });
		}
		return true;
	}
	else {
		if (xs[l] == plusx) {
			return solve(ys,u,d,xs,l+1,r,plusy,plusx);
		}
		else if (xs[l] < plusx) {
			return false;
		}

		if (xs[r - 1] - plusx == d-u) {
			return solve(ys,u,d,xs,l,r-1,plusy+1,plusx);
		}
		else if (xs[r - 1] - plusx > ys.size()) {
			return false;
		}

		if (ys[u] == plusy) {
			return solve(ys,u+1,d,xs,l,r,plusy,plusx);
		}
		else if (ys[u] < plusy) {
			return false;
		}

		if (ys[d - 1] - plusy == r-l) {
			return solve(ys,u,d-1,xs,l,r,plusy,plusx+1);
		}
		else if (ys[d - 1] - plusy > xs.size()) {
			return false;
		}

		return false;
	}
}

int main() {
	
	while (true) {
		int T;cin>>T;
		if(!T)break;
		vector<int>ys,xs;
		for (int i = 0; i < T; ++i) {
			int a;cin>>a;ys.push_back(a);
		}
		for (int i = 0; i < T; ++i) {
			int a;cin>>a;xs.push_back(a);
		}
		sort(ys.begin(),ys.end());
		sort(xs.begin(),xs.end());

		bool ok=solve(ys,0,T,xs,0,T,0,0);
		if (accumulate(xs.begin(), xs.end(), 0) 
			!= accumulate(ys.begin(), ys.end(), 0)) {
			ok=false;
		}
		if (ok) {
			cout<<"Yes"<<endl;
		}
		else {
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3268
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e10
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)

	a, v := nextInt(), nextInt()
	b, w := nextInt(), nextInt()
	t := nextInt()

	if b < a {
		w *= -1
		v *= -1
	}
	if abs(a+v*t) >= abs(b+w*t) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func intSlicePrint(el ...int) {
	first := true
	for _, v := range el {
		if v < 0 {
			continue
		}
		if !first {
			fmt.Printf(" ")
		}
		fmt.Printf("%v", v)
		first = false
	}
	fmt.Println("")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1756
n = int(input())
m = int((n*2)**0.5)
if m*(m+1)!=n*2:
    print('No')
else:
    print('Yes')
    print(m+1)
    ans = [[0]*m for _ in range(m+1)]
    for i in range(m+1):
        for j in range(m):
            if i==0 and j==0:
                ans[i][j] = 1
            elif i==j:
                ans[i][j] = ans[i-1][j-1] + m-i + 1
            else:
                if i>j:
                    if i==j+1:
                        ans[i][j] = ans[i-1][j]
                    else:
                        ans[i][j] = ans[i-1][j] + 1
                else:
                    ans[i][j] = ans[i][j-1] + 1
    for a in ans:
        print(len(a), *a)

Measured memory_bytes: 12376
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        long input = in.nextLong();

        long round = input / 11;
        long mod = input % 11;

        long result = round * 2;

        if (0 < mod) {
            result++;
        }
        if (6 < mod) {
            result++;
        }

        out.print(result);
    }
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;
}


Measured memory_bytes: 9800
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  string s;
  cin >> s;
  vector<char> fig = {'A', 'C', 'G', 'T'};
  
  int ans = 0, cnt = 0;
  bool flag = false;
  for (int i = 0; i < s.size(); i++) {
    
    for (int j = 0; j < 4; j++) {
      
      if (s[i] == fig[j]) {
        flag = true;
        cnt++;
        break;
      }
      
    }
    
    if (!flag) {
      cnt = 0;
    }
    
    ans = max(ans, cnt);
    flag = false;
  
  }
  
  cout << ans << endl;
  
  return 0;
}




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

int main() {
  int n,x;
  cin>>n>>x;
  int a[110];
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  sort(a,a+n);
  int ans=0;
  int i;
  for (i=0; i<n; i++) {
    if (x>=a[i]) {
      x-=a[i];
      ans++;
    }
    else
      break;
  }
  if (x&&i==n) ans--;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define hhhhh main
#define hhhhhhh cin
#define hhhhhhhh cout
#define hhhhhh int
hhhhh(){hhhhhh h,hh,hhh,hhhh;hhhhhhh>>h>>hh>>hhh>>hhhh;hhhhhhhh<<(h-hhh)*(hh-hhhh);}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <algorithm>
using Int = long long;
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
struct edge {
    int src, dst, weight;
};
bool solve(vector<vector<edge>>& graph, Int &score)
{
    int N = graph.size();
    vector<int> prev(N, -1);
    vector<Int> dist(N, -1e18); dist[0] = 0;
    REP(k, N) REP(i, N) for(auto e:graph[i]) {
        if (dist[e.dst] < dist[e.src] + e.weight) {
            dist[e.dst] = dist[e.src] + e.weight;
            prev[e.dst] = e.src;
            if (k == N-1 && e.dst == N-1) {
                return false;
            }
        }
    }
    score = dist[N-1];
    return true;
}
int main()
{
    int N, M; cin >> N >> M;
    vector<vector<edge>> graph(N);
    REP(i, M) {
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        graph[a].push_back({a, b, c});
    }
    Int score;
    if (solve(graph, score)) {
        cout << score << endl;
    } else {
        cout << "inf" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<bitset>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int N, M;
bool A[700][700];
int D[700];
bool dame;
int dfs(int v, int d) {
	D[v] = d;
	int ret = (d & 2) - 1;
	for (int to = 0; to < N; to++) if (!A[v][to]) {

		if (!D[to]) ret += dfs(to, d ^ 2);
		else if (D[to] == d) dame = 1;
	}
	return ret;
}

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


	N = getint();
	M = getint();
	rep(i, M) {
		int a = getint() - 1, b = getint() - 1;
		A[a][b] = true;
		A[b][a] = true;
	}
	rep(i, N) A[i][i] = true;

	int kouho[700];
	int k = 0;
	int mannnaka = 0;
	rep(i, N) if (!D[i]) {
		int tmp = abs(dfs(i, 1));
		mannnaka += tmp;
		kouho[k++] = tmp * 2;
	}

	if (dame) {
		printf("-1");
		return 0;
	}

	bitset<1410> BS(0);
	BS[0] = 1;
	rep(i, k) BS |= BS << kouho[i];

	int saishou = 1e9;
	for (int i = 0; i <= mannnaka * 2; i++) {
		if (BS[i]) chmin(saishou, abs(i - mannnaka));
	}
	int X = (N + saishou) / 2;
	int Y = (N - saishou) / 2;
	int kotae = X * (X - 1) / 2 + Y * (Y - 1) / 2;

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 768