akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    ll n,m; cin >>n>>m;
    vector<ll> a(n); REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    priority_queue<P> q;
    for (int i = 0; i < m; i++) {
        ll b,c; cin >>b>>c;
        q.push(P(c,b));
    }

    ll res = 0;
    int i = 0;
    while (!q.empty()) {
        P p = q.top(); q.pop();
        ll pc = p.first;
        ll pb = p.second;
        if (a[i] >= pc) {
            break;
        }
        int count = 0;
        while (a[i] < pc && count < pb && i < n) {
            res += pc;
            i++;
            count++;
        }
    }
    while (i < n) {
        res += a[i];
        i++;
    }
    
    cout << res << endl;
    
    return 0;
}





Measured memory_bytes: 2168
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
	//printf((a < b) ? "<\n" : (a == b) ? "=\n" : ">\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;

int main(){
    int n;
    cin >> n;
    int maxh=0;
    int inp;
    int ans=0;
    for(int i=0;i<n;i++){
        cin >> inp;
        if(inp>=maxh){
            ans++;
            maxh=inp;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3192
import itertools
N = int(input())
P_list = tuple(map(int,input().split()))
Q_list = tuple(map(int,input().split()))

tem_list = []
for i in range(1,N+1):
    tem_list.append(i)

check_list = list(itertools.permutations(tem_list,N))

for i in range(0,len(check_list)):
    if check_list[i] == P_list:
        tem_1 = i
    if check_list[i] == Q_list:
        tem_2 = i

print(abs(tem_2-tem_1))

Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N;
    cin >>N;
    int ans=0;
    vector<int>vec(N);
    REP(i,N){
        cin >>vec[i];
        ans+=vec[i];
    }
    sort(vec.begin(),vec.end());
    bool check=true;
    if(ans%10==0){
        REP(i,N){
            if(vec[i]%10!=0){
                ans-=vec[i];
                check=false;
                break;
            }
        }
        if(check){
            ans=0;
        }
    }
    cout <<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
 while(1){
        int a,b;
        char aa[100],bb[100],d,dd[10000000];
        scanf("%d",&a);
 if(a==0) break;
        for(int i=0;i<a;i++) scanf(" %c %c",&aa[i],&bb[i]);
        scanf("%d",&b);
        for(int i=0;i<b;i++)
        {
                scanf(" %c",&dd[i]);
                for(int j=0;j<a;j++){
                        if(dd[i]==aa[j])
                        {printf("%c",bb[j]);
                         break;
                        }
if(j==(a-1)) printf("%c",dd[i]);
               }
      }
        printf("\n");
}
return 0;
}

Measured memory_bytes: 812
import java.util.Scanner;
import java.io.BufferedInputStream;
import java.lang.Math;

public class Main{
    static int [] head;
    static int [] next;
    static int [] to;
    static long [] cost;
    static int [] size;
    static int edgeCount = 0;
    static long ans = 0;
    static int N;

    public static void main(String [] args) {
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        N = sc.nextInt();
        head = new int  [N + 1];
        size = new int  [N + 1];
        next = new int  [N + N + 1];
        to   = new int  [N + N + 1];
        cost = new long [N + N + 1];
        for(int i = 0; i < N - 1; i++) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            int C = sc.nextInt();
            addEdge(A,B,C);
            addEdge(B,A,C);
        }
        calcSize(1);
        dfs(1);
        System.out.println(ans);
    }

    public static void dfs(int root) {
        int maxNodeSize = N - size[root];
        long minEdgeCost = Long.MAX_VALUE;

        for(int e = head[root]; e != 0; e = next[e]) {
            int destination = to[e];
            minEdgeCost = Math.min(minEdgeCost,cost[e]);

            if(size[destination] < size[root]) {
                maxNodeSize = Math.max(maxNodeSize,size[destination]);

                long min = Math.min(size[destination], N - size[destination]);
                ans = ans + min * cost[e] * 2;
                dfs(destination);

                if(min + min == N) {
                    ans = ans - cost[e];
                }
            }
        }

        if(maxNodeSize * 2 < N) {
            ans = ans - minEdgeCost;
        }
    }

    public static int calcSize(int root) {
        size[root] = 1;
        for(int e = head[root]; e != 0; e = next[e]) {
            if(size[to[e]] == 0) {
                size[root] += calcSize(to[e]);
            }
        }
        return size[root];
    }

    public static void addEdge(int A, int B, int C) {
        edgeCount += 1;
        to[edgeCount] = B;
        cost[edgeCount] = C;
        next[edgeCount] = head[A];
        head[A] = edgeCount;
    }
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(std::string S){
    REP(i, 26) {
        bool flag = true; 
        REP(j, S.size()) {
            if(S[j] == ('a'+i)){
                flag = false;
                break;
            }
        }

        if(flag){
            cout << (char)('a'+i) << endl;
            return;
        }
    }

    cout << "None" << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
    int N, *p, exchanged_num = 0;

    // input
    cin >> N;

    p = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }

    // process
    for (int i = 0; i < N; i++) {
        if (p[i] != (i + 1)) {
            exchanged_num++;
        }
    }

    // output
    if (exchanged_num > 2) {
        cout << "NO";
    } else {
        cout << "YES";
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int MaxN = 100000;
int n, a[MaxN + 5];

int main()
{
	while (~scanf("%d", &n)) {
		for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
		int t = 0, p = 1, cnt = 0;
		while (p <= n) {
			int q1 = p + 1;
			while (q1 <= n && a[q1] >= a[q1 - 1]) q1++;
			int q2 = p + 1;
			while (q2 <= n && a[q2] <= a[q2 - 1]) q2++;
			p = max(q1, q2);
			cnt++;
		}
		printf("%d\n", cnt);
	}	
	return 0;
}

Measured memory_bytes: 512
#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(); }

ll n, k, a[200005] = {};
lldo l = 0, r = 1000000005;

int main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	while (r - l > 1) {
		lldo mid = (lldo)(r + l) / 2;
		ll cnt = 0;
		rep(i, n) {
			lldo length = a[i];
			cnt += ceil(length / mid) - 1;
			if (cnt > k) {
				l = mid;
				break;
			}
		}
		if (cnt <= k)r = mid;
	}
	for (int i = max((lldo)1, r - 3); i <= r + 3; i++) {
		ll mid = i, cnt = 0;
		rep(j, n) {
			lldo length = a[j];
			cnt += ceil(length / mid) - 1;
		}
		if (cnt <= k) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 5172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace p130.cs
{
    class Program
    {
        static void Main()
        {
            var abcde = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(abcde);
            Console.WriteLine("{0} {1} {2} {3} {4}", abcde[4], abcde[3], abcde[2], abcde[1], abcde[0]);

        }
    }
}

Measured memory_bytes: 9652
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

ll k;

void solve(){
    cin >> k;
    ll ans=0;
    Rep(i,1,k+1){
        ll s=k/i;
        ans+=s*(s+1)/2*(ll)i;
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

/*bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}*/
/*ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/
/*ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}*/
/*ll modpow(ll x, ll y, ll mod) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}*/
/*ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}*/
//printf("%.10f\n", n);

signed main() {
	ll n, m, k, ans = 0;
	cin >> n >> m >> k;
	map<ll, map<ll, ll>> ma;
	vector<vector<ll>> v1(n + 2, vector<ll>(2)), v2(2 + m, vector<ll>(2));
	rep(i, n + 2) { v1[i][1] = i; }
	rep(i, m + 2) { v2[i][1] = i; }
	rep(i, k) {
		ll a, b; cin >> a >> b;
		ma[a][b]++;
		v1[a][0]++; v2[b][0]++;
	}
	sort(all(v1)); reverse(all(v1)); sort(all(v2)); reverse(all(v2));
	rep(i, min((ll)1000, n + 2)) {
		rep(j, min((ll)1000, m + 2)) {
			//cout << v1[i][0] << ' ' << v2[j][0] << endl;
			ans = max(ans, v1[i][0] + v2[j][0] - ma[v1[i][1]][v2[j][1]]);
		}
	}
	rep(i, min((ll)10, n + 2)) {
		rep(j, m + 2) {
			//cout << v1[i][0] << ' ' << v2[j][0] << endl;
			ans = max(ans, v1[i][0] + v2[j][0] - ma[v1[i][1]][v2[j][1]]);
		}
	}
	rep(i, n + 2) {
		rep(j, min((ll)10, m + 2)) {
			//cout << v1[i][0] << ' ' << v2[j][0] << endl;
			ans = max(ans, v1[i][0] + v2[j][0] - ma[v1[i][1]][v2[j][1]]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 519128
/*
 * @Autor: valk
 * @Date: 2020-04-04 14:56:12
 * @LastEditTime: 2020-09-17 16:53:43
 * @Description: 如果邪恶  是华丽残酷的乐章 它的终场 我会亲手写上 晨曦的光 风干最后一行忧伤 黑色的墨 染上安详
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#define emplace_back push_back
#define pb push_back
// #define fuck(a, b) cout << a << ' ' << b << ' ' << endl
// #define fuck(a, b, c) cout << a << ' ' << b << ' ' << c << ' ' << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll seed = 12289;
const double eps = 1e-6;
const ll inf = 0x3f3f3f3f;
const ll N = 2e5 + 10;

ll qpow(ll a, ll b)
{
    ll ans = 1;
    a %= mod;
    while (b) {
        if (b & 1) {
            ans = (ans * a) % mod;
        }
        b >>= 1;
        a = a * a % mod;
    }
    return ans % mod;
}

int main()
{
    ll n;
    scanf("%lld", &n);
    if (n == 1) {
        printf("0\n");
        return 0;
    }
    ll ans = (qpow(10, n) - qpow(9, n) + mod - qpow(9, n) + mod + qpow(8, n)) % mod;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int[] c = new int[26+1];
        for(int i = 1;i<=26;i++){
            c[i] = sc.nextInt();
        }
        int[][] s = new int[d+1][26+1];
        for(int i = 1;i<=d;i++){
            int maxx = 1;
            int va = -999999;
            for(int j = 1;j<=26;j++){ 
                s[i][j] = sc.nextInt();
                if(va < s[i][j]) {
                    maxx = j;
                }
            }
            System.out.println(maxx);
        }
    }
}

Measured memory_bytes: 46512
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
	static double s;
	
    public static void main(String[] args)   throws Exception, IOException{        
//        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n=sc.nextInt();
        String w=sc.nextString();
        String s[]= { "SUN","MON","TUE","WED","THU","FRI","SAT"};
        for (int i = 0; i < s.length; i++) {
			if(s[i].equals(w)) {
				ret((7-i)+"");
			}
		}
        

        out.println();
     	out.flush();
    }


    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//
//class P {
//	int x, y, d;
//	P(int  x, int y, int d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return -p.a+a;//as
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
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 mxN = 5000;
const int P = 1e9+7;
llong fact[mxN+3],facti[mxN+3],inv[mxN+3];

void updsum(llong &x,llong y) {x+=y-P,x+=(x>>31)&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;
}
llong mulinv(llong x) {return quickpow(x,P-2);}
llong comb(llong x,llong y) {return x<0||y<0||x<y?0ll:fact[x]*facti[y]%P*facti[x-y]%P;}
void initfact(int n)
{
	fact[0] = 1ll; for(int i=1; i<=n; i++) fact[i] = fact[i-1]*i%P;
	facti[n] = quickpow(fact[n],P-2); for(int i=n-1; i>=0; i--) facti[i] = facti[i+1]*(i+1ll)%P;
	for(int i=1; i<=n; i++) inv[i] = facti[i]*fact[i-1]%P;
}

int n,en,tot;
int a[mxN+3];
struct Edge
{
	int v,nxt;
} e[mxN*2+3]; int fe[mxN+3];
int cnt[mxN+3];
int uf[mxN+3],sz[mxN+3],sz2[mxN+3];
llong f[2][mxN+3];

int findfa(int u) {return u==uf[u]?u:uf[u]=findfa(uf[u]);}
void unionfa(int u,int v)
{
	int x = findfa(u),y = findfa(v);
	if(x!=y) {uf[x] = y; sz[y] += sz[x]; sz2[y] += sz2[x];} sz[y]--;
}

int main()
{
	initfact(mxN);
	n = read();
	for(int i=1; i<=n; i++) uf[i] = i,sz[i] = 1,sz2[i] = 1;
	for(int i=1; i<=n; i++) {a[i] = read(); if(a[i]!=-1) {unionfa(i,a[i]);} else {tot++;}}
	llong ans = 0ll; int cur = 0; f[0][0] = 1ll;
	for(int i=1; i<=n; i++)
	{
		if(findfa(i)==i)
		{
			memset(cnt,0,sizeof(int)*(n+2));
			if(sz[i]==0)
			{
				updsum(ans,quickpow(n-1,tot));
			}
			else
			{
				cur ^= 1; memset(f[cur],0,sizeof(f[cur]));
				for(int j=0; j<=tot; j++) if(f[cur^1][j])
				{
					updsum(f[cur][j],f[cur^1][j]);
					updsum(f[cur][j+1],f[cur^1][j]*sz2[i]%P);
				}
			}
		}
	}
	for(int i=1; i<=n; i++)
	{
		llong tmp = quickpow(n-1,tot-i)*f[cur][i]%P*fact[i-1]%P;
		updsum(ans,tmp);
	}
	updsum(ans,P-tot*quickpow(n-1,tot-1)%P);
	llong ans2 = 0ll;
	for(int i=3; i<=tot; i++) {updsum(ans2,comb(tot,i)*fact[i-1]%P);}
//	ans = (ans-ans2*mulinv(2ll)%P+P)%P;
	ans = (quickpow(n-1,tot)*n%P-ans+P)%P;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4060
#include <iostream>
using namespace std;
#define ll long long
#include <string>
#include <algorithm>
struct s1
{
    int a;
    int b;
    int c;
};

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1&&b==1)
    {
        cout<<"Draw";
    }
    else if(a==1)
    {
        cout<<"Alice";
    }
    else if(b==1)
    {
        cout<<"Bob";
    }
    else if(a>b)
    {
        cout<<"Alice";
    }
    else if(a==b)
    {
        cout<<"Draw";
    }
    else
    {
        cout<<"Bob";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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() {
    ll N, Z, W; cin >> N >> Z >> W;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    if (N == 1) {
        cout << abs(a[0]-W) << endl; return 0;
    }
    cout << max(abs(a[N-1]-W), abs(a[N-1]-a[N-2])) << endl;
}


Measured memory_bytes: 256
H,W=input().split()
H=int(H)
W=int(W)

#配列の定義
arr = [['#' for c in range(W+2)] for r in range(H+2)]
#配列へ入力
for r in range(H):
    a=input()
    for c in range(W):
        arr[r+1][c+1]=a[c]

#取り出し
for r in range(H+2):
    for c in range(W+2):
        print(arr[r][c],end='')
    print()

Measured memory_bytes: 4468
#include<stdio.h>
int main()
{
  int h,w,i,j;
  while(scanf("%d%d",&h,&w) != EOF)
    {
     if((h==0)&&(w==0)) break;
      for(i=0; i<h; i++)
	{
	  for(j=0; j<w; j++)
	    {
	      if((i+j)%2==0) printf("#");
	      else printf(".");
	    }
	  printf("\n");
	}
      printf("\n");
    }
   return 0;
}

Measured memory_bytes: 572
#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() {
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
ans = [
    {0, 1, 2},
    {3, 4, 5},
    {6, 7, 8},
    {0, 4, 8},
    {2, 4, 6},
    {0, 3, 6},
    {1, 4, 7},
    {2, 5, 8}
]

input_list = []
for i in range(3):
    input_list += input().split(" ")

n = int(input())
call = set()
for i in range(n):
    call_num = input()
    if call_num in input_list:
        call.add(input_list.index(call_num))
        for j in ans:
            if len(call & j) == 3:
                print("Yes")
                sys.exit()
print("No")


Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int N = sc.nextInt();
        int[] a = new int[100];
        int[] x = new int[100];
        int[] y = new int[100];
        int[][] xy = new int[W][H];
        for(int i = 0;i < N;i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }
        for(int i = 0;i < N;i++){
            if(a[i] == 1){
                for(int j = 0;j < x[i];j++){
                    for(int k = 0;k < H;k++){
                        xy[j][k] = 1;
                    }
                }
            }
            if(a[i] == 2){
                for(int j = x[i];j < W;j++){
                    for(int k = 0;k < H;k++){
                        xy[j][k] = 1;
                    }
                }
            }
            if(a[i] == 3){
                for(int j = 0;j < W;j++){
                    for(int k = 0;k < y[i];k++){
                        xy[j][k] = 1;
                    }
                }
            }
            if(a[i] == 4){
                for(int j = 0;j < W;j++){
                    for(int k = y[i];k < H;k++){
                        xy[j][k] = 1;
                    }
                }
            }
        }
        //for(int i = 0;i < W;i++){
        //    for(int j = 0;j < H;j++){
        //        System.out.print(xy[i][j]+" ");
        //    }
        //}
        //System.out.println();
        int S = 0;
        for(int i = 0;i < W;i++){
            for(int j = 0;j < H;j++){
                if(xy[i][j] == 0){
                    S ++;
                }
            }
        }
        System.out.println(S);
    }
}


Measured memory_bytes: 22356
#include <iostream>
using namespace std;
int main(){
string S, T;
cin >> S >> T;
int ans = 0;
int N = S.size();

for (int  i = 0; i< N; i++) {
  if (S[i] != T[i]) {
    ans++;
  }
}
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 3472
import sys
from io import StringIO
import unittest
import os
from operator import ixor

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    #   1行1項目 n = int(input())
    #   1行2項目 x, y = map(int, input().split())
    #   1行N項目 x = [list(map(int, input().split()))]
    #   N行1項目 x = [int(input()) for i in range(n)]
    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()
    #   1行1項目(1文字ずつリストに入れる場合) x = list(input())
    n = int(input())
    a_s = list(map(int, input().split()))

    one_counts = [0 for i in range(61)]
    zero_counts = [0 for i in range(61)]

    # 以下、XORで便利と思われる処理。
    # -------------------------------------------
    # ループ回数の取得(最大の数値の桁数分、ループ処理を行うようにする)
    max_num = max(a_s)
    max_loop = 0
    for i in range(0, 61):
        if max_num < 1 << i:
            break
        max_loop += 1

    # ループ処理にて、各桁の0と1の個数を数え上げる。
    # 例：入力[1(01),2(10),3(11)] -> one_count=[2,2,0・・]とzero_counts[1,1,0・・]を得る。
    for a in a_s:
        for i in range(0, max_loop):
            if a & 1 << i:
                one_counts[i] += 1
            else:
                zero_counts[i] += 1
    # -------------------------------------------
    # 以上、XORで便利と思われる処理。

    # 結果を計算する処理
    ans = 0
    for i in range(0, max_loop):
        # 各桁の「0の個数」*「1の個数」*2^(0～桁数-1乗まで) を加算していく
        ans += (one_counts[i] * zero_counts[i] * pow(2, i)) % (pow(10, 9) + 7)
        ans = ans % (pow(10, 9) + 7)

    # 結果を出力
    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3
1 2 3"""
        output = """6"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """10
3 1 4 1 5 9 2 6 5 3"""
        output = """237"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """10
3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820"""
        output = """103715602"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 130292
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		String strInput = null;
		String strMessage = null;

		int[] intNumList = new int[3];
		try {
			//??\????????????????????????
			BufferedReader strLine = new BufferedReader(new InputStreamReader(System.in));
			strInput = strLine.readLine();

			String[] strNumList = strInput.split(" ");

			//int????????????
			for (int i = 0; i < strNumList.length; i++) {
				intNumList[i] = Integer.parseInt(strNumList[i]);
			}

			for (int i = 0; i < intNumList.length; i++) {

				//
				if (strMessage == null) {
					for (int j = i + 1; j < intNumList.length;j++) {

						if(intNumList[i] >= intNumList[j]){
							//?????¶ a < b < c????????????????????´???
							strMessage = "No";
							break;
						}
					}
				}else {
					break;
				}
			}

			//?????¶ a < b < c??????????????´???
			if (strMessage == null) {
				strMessage = "Yes";
			}

			//???????????????
			System.out.println(strMessage);

		}catch (IOException e1) {
			System.out.println(e1);
		}catch (NumberFormatException e2) {
			System.out.println(e2);
		}

	}

}

Measured memory_bytes: 24092
str = gets.chomp
len = str.length
ans = 0
key = 0
 
if	len%2 == 1
	ans = 1
else
  
len.times do |i|
	if key == 0
		if str[i] == "h"
			key = 1
		else
			ans = 1
          	break
		end
	else
		if str[i] == "i"
			key = 0
		else
			ans = 1
          	break
		end
	end
end
end
 
if ans == 0
	puts "Yes"
else
	puts "No"
end

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

#define INF (INT_MAX / 2)
constexpr int MAXN = 1e5;
int h[MAXN];
int cost[MAXN];

int main(void) {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++)
    cin >> h[i];

  cost[0] = 0;
  for (int i = 1; i < N; i++) {
    cost[i] = INF;
    for (int j = max(0, i - K); j < i; j++)
      cost[i] = min(cost[i], cost[j] + abs(h[j] - h[i]));
  }

  cout << cost[N - 1] << "\n";
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/04  Problem: ABC 100 B / Link: http://abc100.contest.atcoder.jp/tasks/abc100_b  ----- */


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

	LL D, N; cin >> D >> N;
	if (N == 100)N++;
	LL ans = ((LL)pow(100, D))*N;
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
N=int(input())
f=lambda:map(int,input().split())
*A,=f()
*B,=f()

cnt=0
for i in range(len(B)):
  a=min(A[i], B[i])
  cnt+=a
  a=min(A[i+1],B[i]-a)
  cnt+=a
  A[i+1]-=a
print(cnt)

Measured memory_bytes: 24240
N, M = map(int, input().split())
A = []
count = 0
for i in range(N):
    A.append(list(map(int, input().split())))


for i in range(1,M+1):
    flag = 1
    for j in range(N):
        if i not in A[j][1:]:
            flag = 0
    if flag == 1:
        count += 1

print(count)


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

int main() {
	ios::sync_with_stdio(false);
	vector<int> N(5, 0);

	for (auto& i:N) {
		cin >> i;
		if ((i%10) != 0) {
			if ((N.at(0)%10) != 0) {
				if ((i%10) < (N.at(0)%10)) {
					swap(i, N.at(0));
				}
			}
			else {
				swap(i, N.at(0));
			}
		}
	}

	int result=0;
	for (int i = 1; i < 5; i++) {
		if (N.at(i) % 10) {
			result++;
		}
		result += N.at(i) / 10;
	}
	result = result * 10;
	result += N.at(0);

	cout << result << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){
  int x,y,d;
  for(;;){
    scanf("%d %d",&x,&y);
    if(x==0 && y==0) break;
    if(x>y){
      d=x;
      x=y;
      y=d;
      printf("%d %d\n",x,y);
    }else{
      printf("%d %d\n",x,y);
    }
  }
}



Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,int> pii;
const int N = 1e5+5;
const int M = 5e5+5;
#define pi acos(-1)
#define INF 1e18
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
int main()
{
	int r;sd(r);
	cout << 2*pi*r << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 3852
def coun(n,r):
    return n*r+1+r-r**2

def sigma(func,frm,too):
    result=0
    for i in range(frm,too+2):
        #print(i)
        result=result+func(too,i)
        #print(result)
    print(result%mod)

n,k=list(map(int,input().split()))
mod=10**9+7

sigma(coun,k,n)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

// 約数の全列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> P = divisor(N);

    ll ans = INF;
    for(auto p:P){
        if(p > sqrt(N)) break;
        
        if(N%p == 0){
            ll s = to_string(p).size();
            ll t = to_string(N/p).size();
            ans = min(ans, max(s,t));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
ls_pass=[list(map(int,input().split())) for i in range(M)]
#各iと繋がっている部屋の番号
ls=[[] for i in range(N+1)]
for i in range(M):
  ls[ls_pass[i][0]].append(ls_pass[i][1])
  ls[ls_pass[i][1]].append(ls_pass[i][0])
#各部屋に振る道標
ls_mark=[""]*2+[0]*(N-1)

#幅優先探索の実装
from queue import Queue 
S=Queue()
S.put(1)
while not S.empty():
  a=S.get()
  for i in ls[a]:
    if ls_mark[i]==0:
      ls_mark[i]=a
      S.put(i)
if 0 in ls_mark:
  print("No")
else:
  print("Yes")
  for i in range(2,N+1):
    print(ls_mark[i])

Measured memory_bytes: 126012
#!/usr/bin/python
from heapq import*
n=int(input())
a=[-int(e)for e in input().split()]
r=0
heapify(a)
while 1:
	x=heappop(a)
	if x>-n:break
	c=-x//n
	x+=c*n
	a=[e-c for e in a]
	heappush(a,x)
	r+=c
print(r)

Measured memory_bytes: 45400
def main():
  s = int(input())
  ppp = pow(10, 9)
  x = (ppp-s%ppp)%ppp
  y = (s+x) // ppp
  print("%d %d %d %d %d %d" % (0, 0, ppp, 1, x, y))


if __name__ == '__main__':
  main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define MOD 1000000007
#define int long long
#define pb push_back
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
using namespace std;
const int N=1e5+1;
int n, m;
vector<int> adj[N];
int color[N];
int f[2];
bool visit[N];
void dfs(int u,int col) {
	if (color[u]) {
		if (color[u]==col) {
			cout<<n*(n-1)/2-m<<endl;
			exit(0);
		}
		return;
	}
	f[col-1]++;
	color[u]=3-col;
	visit[u]=true;
	fw (j,0,adj[u].size()) {
		int v=adj[u][j];
		dfs(v,3-col);
	}
}
signed main() {
	ios_base::sync_with_stdio(false);
	cin>>n>>m;
	fw (i,0,m) {
		int u,v; cin>>u>>v;
		adj[u].push_back(v); adj[v].push_back(u);
	}
	dfs(1,1);
	cout<<f[0]*f[1]-m<<endl; 
}

Measured memory_bytes: 7552
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif   
    int a,b,c;
    cin>>a>>b>>c;
    int minn = max(b,12);
    for(int i=0;i<=minn;i++)
    {
        int temp = i*a;
        temp-=c;
        if(temp>=0&&temp%b==0&&i!=0)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N, b, a; int move = 0;int max = 0; 
  scanf("%d %d",&N, &b); 
	for (int i = 1; i < N; i++){
		scanf("%d",&a); 
    if(b >= a){
      move++;
    }else{
      if(move > max) max = move;
      move = 0;
    }
    b = a;
	}
  if(move > max) max = move;
  printf("%d", max);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        long ans = 0;
        for (int i = 1; i <= K - 2; i++) {
            for (int j = i + 1; j <= K - 1; j++) {
                for (int k = j + 1; k <= K; k++) {
                    ans += 6 * gcd(gcd(i, j), k);
                }
            }
        }
//        debug(ans);

        for (int i = 1; i <= K - 1; i++) {
            for (int j = i + 1; j <= K; j++) {
                ans += 6 * gcd(i, j);
            }
        }

//        debug(ans);


        for (int i = 1; i <= K; i++) {
            ans += i;
        }

        System.out.println(ans);
    }

    int gcd(int m, int n) {
        if (m < n) return gcd(n, m);
        if (n == 0) return m;
        return gcd(n, m % n);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 27936
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e8;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	string s;	cin >> s;
	cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

A3=[sum(A1[0:i+1]) for i in range(N)]
A4=[0] + [sum(A2[0:i+1]) for i in range(N)]
ans=0
for i in range(N):
  ans = max(ans, A3[i]+A4[N]-A4[i])
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define P pair<int,int>

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;


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

    int x; cin >> x;
    if(x==0) cout << 1 << endl;
    else cout << 0 << endl;
}



Measured memory_bytes: 3636
a = input()

if a[-1]=="2" or a[-1]=="4" or a[-1]=="5" or a[-1]=="7" or a[-1]=="9":
    print("hon")

elif a[-1]=="0" or a[-1]=="1" or a[-1]=="6" or a[-1]=="8":
    print("pon")

else :
    print("bon")

Measured memory_bytes: 9060
#include<stdio.h>
int main(void)
{
	int t,n,i,iti,ni,san,si;
	for(i=1;i<5;i++){
	 scanf("%d%d",&t,&n);
	 switch (t)
	 {
	  case 1:
	  iti=6000*n;
	  break;
	  case 2:
	  ni=4000*n;
	  break;
	  case 3:
	  san=3000*n;
	  break;
	  case 4:
	  si=2000*n;
          break;
	 }
	 if(t==1){
	  printf("%d\n",iti);
	 }
	 else if(t==2){
	  printf("%d\n",ni);
	 }
	 else if(t==3){
	  printf("%d\n",san);
	 }
	 else{
	  printf("%d\n",si);
	 }
	}
	return 0;
}

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

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

int main(){
ll n,m;
cin>>n>>m;
if(n==1&&m==1){
  cout<<1<<endl;
  return 0;
}
else if(n==1){
  cout<<m-2<<endl;
  return 0;
}
else if(m==1){
  cout<<n-2<<endl;
  return 0;
}


cout<<(n-2)*(m-2)<<endl;







return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll> v;
ll dp[3000][3000][2];
ll find(ll l, ll r, ll turn) {
  if(l > r) {
    return 0;
  }
  if(l == r) {
    if(turn == 0) {
  		return dp[l][r][turn] = v[l];
    } else {
    	return dp[l][r][turn] = -v[l];
    }
  }
  if(dp[l][r][turn] != 2e18) {
    return dp[l][r][turn];
  }
  if(turn == 0) {
  	dp[l][r][turn] = max(find(l + 1, r, turn ^ 1) + v[l], find(l, r - 1, turn ^ 1) + v[r]);
  } else {
  	dp[l][r][turn] = min(find(l + 1, r, turn ^ 1) - v[l], find(l, r - 1, turn ^ 1) - v[r]);
  }
  return dp[l][r][turn];
}
int main(void) {
  ll n, i, j;
  cin>>n;
  v.resize(n);
  for(ll& i: v) {
  	cin>>i;
  }
  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      dp[i][j][0] = dp[i][j][1] = 2e18;
    }
  }
  ll ans = find(0, n - 1, 0);
  cout<<ans<<"\n";
}

Measured memory_bytes: 141056
#include <stdio.h>

int main(void) {
	int n,a,y = 0;
	scanf("%d",&n);
	a = 1;
	while(n > a){
		a*=3;
	}
	while(a != 0){
		if (n > 0 && n > a / 2){
			printf("+");
			n-=a;
			y = 1;
		}
		else if(n < 0 && -n > a / 2){
			printf("-");
			n+=a;
			y = 1;
		}
		else{
			if(y) printf("0");
		}
		a /= 3;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 568
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

#define int long long

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<pair<int, int> > b(n);
    for (int i = 0; i < n; i++) b[i] = {a[i], i};
    sort(all(b));
    ll uni = 0;
    sort(all(a));
    a.resize(unique(all(a)) - a.begin());
    uni = a.size() - 1;
    int kek = 0;
    for (int i = 0; i + 1 < n; i++)
    {
        if (b[i].first == b[i + 1].first) continue;
        if (b[i].second < b[i + 1].second)
        {
            kek++;
        }
        if (b[i].second > b[i + 1].second)
        {
            kek = 0;
        }
        uni = min((long long)uni, (long long)a.size() - 1 - kek);
    }
    cout << uni << "\n";
}

signed main()
{
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int q = 1;
    while (q--)
    {
        solve();
    }
}

Measured memory_bytes: 4992