akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)




using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;


// B貪欲法で決定する．
int main(){
  int d;
  cin>>d;
  vector<int> c(26);
  vector<vector<int>> s(d,vector<int>(26));
  vector<int> last(26);

  rep(i,26){
    cin>> c[i];
    last[i]=-1;
  }
  rep(i,d){//i日目
    int maxs=0;
    int jm=0;

    rep(j,26){
      cin>>s[i][j];
      if(s[i][j]>maxs){
        maxs=s[i][j];
        jm=j;
      }
    }
    cout<<jm+1<<endl;
    
  }

  



  





}


Measured memory_bytes: 3680
s = input()
value = [-1] * (len(s) + 1)

count = 0

for i in range(len(s)):
    if s[i] == '<':
        value[i] = count
        value[i + 1] = count + 1
        count += 1
    else:
        count = 0

count = 0
for j in range(len(s) - 1, -1, -1):
    if s[j] == '>':
        if value[j + 1] < count:
            value[j + 1] = count
        if value[j] < count + 1:
            value[j] = count + 1
        count += 1
    else:
        count = 0
print(sum(value))

Measured memory_bytes: 23328
//SAIKH SERAJ FAHIM, CSE-HSTU, DINAJPUR, BANGLADESH.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,d;
    cin>>a;
    string s=to_string(a);
    d=s.size()-1;
    if(s[d]=='0' || s[d]=='1' || s[d]=='6' || s[d]=='8')
        cout<<"pon"<<"\n";
    else if(s[d]=='2' || s[d]=='4' || s[d]=='5' || s[d]=='7' || s[d]=='9')
        cout<<"hon"<<"\n";
    else
        cout<<"bon"<<"\n";
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
vector<int>edge[100005];
bool used[100005];
vector<int>vi,vi2;
void dfs(int v,int x){
	if(used[v]) return; used[v] = 1;
	if(x==0) vi.pb(v);
	if(x==1) vi2.pb(v);
	int y = 0;
	rep(i,edge[v].size()){
	    //cout<<v<<" "<<edge[v][i]<<endl;
		if(used[edge[v][i]]) continue;
		if(x>=0){
		    dfs(edge[v][i],x);
		    return;
		}
		else if(y<=1){
			dfs(edge[v][i],y); //cout<<edge[v][i]<<endl;
			y++;
		}
		else return;
	}
}

int main(){
	cin>>n>>m;
	rep(i,m){
		int a,b;cin>>a>>b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	dfs(1,-1);
    reverse(vi.begin(),vi.end());
	cout<<vi.size()+vi2.size()+1<<endl;
	rep(i,vi.size()) cout << vi[i] << " ";
	cout<< 1 << " ";
	rep(i,vi2.size()) cout << vi2[i] << " ";
	cout<<endl;
}

Measured memory_bytes: 11128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <unordered_map>
#include <queue>
#include <map>
#include <sstream>
#include <set>
#include <cstdlib>
#include <ctime>
#include <unordered_set>
#include <bitset>
#include <chrono>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
//#pragma GCC optimize(3, "Ofast", "inline")
#define MAX_INF 0x3f3f3f3f
template <class T, class C>
void print(C name, T a)
{
	cout << name << ": " << a << endl;
}
template <class T>
T gcd(T a, T b)
{
	return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b, ll p)
{
	ll ans = 1;
	a %= p;
	while (b)
	{
		if (b & 1)
			ans = ans * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return ans;
}
template <typename _Tp>
void read(_Tp &x)
{
	char ch;
	bool flag = 0;
	x = 0;
	while (ch = getchar(), !isdigit(ch))
		if (ch == '-')
			flag = 1;
	while (isdigit(ch))
		x = x * 10 + ch - '0', ch = getchar();
	if (flag)
		x = -x;
}
template <class T>
void print(T x)
{
	if (x < 0)
	{
		x = -x;
		putchar('-');
	}
	if (x > 9)
		print(x / 10);
	putchar(x % 10 + '0');
}
const ll mod = 998244353;
const ll inf = 1e18;
ll add(ll x, ll t)
{
	x %= mod;
	t %= mod;
	return (x + t) % mod;
}
ll del(ll ans, ll x)
{
	ans %= mod;
	ans += mod;
	x %= mod;
	return (ans - x) % mod;
}
ll mul(ll ans, ll x)
{
	ans %= mod;
	x %= mod;
	return (ans * x) % mod;
}
#define fir(i, a, b) for (int i = a; i <= b; i++)
const int maxn = 1e5 + 20, N = 2010, M = 3000 + 10;
ll sa[maxn], sb[maxn];
int main()
{
	string str;
	cin>>str;
	int ans=0;
	int tol=0;
	for(int i=0;i<str.size();i++)
	{
		if(str[i]=='R')
		{
			tol++;
			ans=max(ans,tol);
		}
		else
		tol=0;
	}
	cout<<ans<<endl;
}

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

long long a, v, b, w, t;

int main() {
  cin >> a >> v >> b >> w >> t;
  bool ch = 0;
  if (abs(a - b) <= t * (v - w)) ch = 1;
  if (ch)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define fi first
#define se second
#define inf 1000000000
#define mod 1000000007
using namespace std;
template <typename T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <typename T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pi;

int x,m;
ll n;
vector<ll> v;
int vis[100005];

int main()
{
	cin>>n>>x>>m;
	ll num=x;
	while(vis[num]==0)
	{
		v.pb(num);
		vis[num]=1;
		num*=num;
		num%=m;
	}
	int cnt=0;
	ll sum1=0,sum2=0,sum3=0;
	for(vector<ll>::iterator it=v.begin();it!=v.end();it++)
		if(*it==num)
		{
			for(vector<ll>::iterator it2=v.begin();it2!=it;it2++)
				sum1+=*it2;
			n-=cnt;
			v.erase(v.begin(),it);
			break;
		}else cnt++;
	for(int i=0;i<sz(v);i++)
		sum2+=v[i];
	int rem=n%sz(v);
	for(int i=0;i<sz(v)&&rem>0;i++)
		sum3+=v[i],rem--;
	ll ans=sum1+n/sz(v)*sum2+sum3;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4220
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int sum = r * 100 + g * 10 + b;
		if (sum % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 23124
# coding: utf-8

def main():
    n = int(input())
    l = list(map(int, input().split()))
    l.sort(reverse=True)
    m = 0

    for i in range(0, len(l), 2):
        m += min(l[i], l[i+1])

    print(m)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 998244353
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;}

ll modpow(ll x,ll n) {
    ll ret=1;
    while(n>0){
        if(n&1) ret=ret*x%mod;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x=x*x%mod;
        n>>=1;  // n を1bit 左にずらす
    }
    return ret;
}

int main(){
	ll n,s;cin>>n>>s;
	vector<ll> a(n);
	rep(i,n) cin>>a[i];

	vector<vector<ll>> dp(3010,vector<ll>(3010,0));//i個選べるとき　和がjになるような組み合わせの個数
	
	dp[0][0]=1;

	rep(i,n){//i番目まで選べるとき
		rep(j,s+1){//和がjちょうどになるとき	
			if(j+a[i]<=s){
				dp[i+1][j+a[i]]+=dp[i][j];//i番目を選ぶとき
				dp[i+1][j+a[i]]%=mod;
			}
			dp[i+1][j]+=2*dp[i][j];//i番目を選ばないとき(選択肢が1つ減ると、場合の数は2倍)
			dp[i+1][j]%=mod;
		}
	}

	cout<<dp[n][s]<<endl;

	return 0;
}

Measured memory_bytes: 74276
import java.awt.Point;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
  
public class Main {
     
    static int N, M, L, K, A, H;
    static int[] FT;
    static int[] X, Y, T;
    
    static void start()
    {
    	// 最短経路を出す
    	int[][] wf = new int[N][N];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				wf[i][j] = Integer.MAX_VALUE / 2;
			}
		}
    	for (int i = 0; i < K; i++) {
			wf[ X[i] ][ Y[i] ] = wf[ Y[i] ][ X[i] ] = T[i];
		}
    	for (int k = 0; k < N; k++) {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					wf[i][j] = Math.min(wf[i][j], wf[i][k] + wf[k][j]);
				}
			}
		}
    	
    	// 冷凍施設のある町と本国と姫だけの経路に変える
    	int[][] wf2 = new int[N][N];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				wf2[i][j] = Integer.MAX_VALUE / 2;
			}
		}
    	for (int i = 0; i < L; i++) {
    		for (int j = 0; j < L; j++) {
    			if(i == j)
    			{
    				if(0 <= wf[ FT[i] ][ A ] && wf[ FT[i] ][ A ] <= M)
    				{
    					wf2[ A ][ FT[i] ] = wf2[ FT[i] ][ A ] = wf[ FT[i] ][ A ];
    				}
    				
    				if(0 <= wf[ FT[i] ][ H ] && wf[ FT[i] ][ H ] <= M)
    				{
    					wf2[ H ][ FT[i] ] = wf2[ FT[i] ][ H ] = wf[ FT[i] ][ H ];
    				}
    			}
    			else
    			{
    				if(0 <= wf[ FT[i] ][ FT[j] ] && wf[ FT[i] ][ FT[j] ] <= M)
    				{
    					wf2[ FT[i] ][ FT[j] ] = wf[ FT[i] ][ FT[j] ];
    				}
				}
			}
		}
    	if(0 <= wf[ A ][ H ] && wf[ A ][ H ] <= M)
		{
    		wf2[ A ][ H ] = wf2[ H ][ A ] = wf[ A ][ H ];
		}
    	
    	for (int k = 0; k < N; k++) {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					wf2[i][j] = Math.min(wf2[i][j], wf2[i][k] + wf2[k][j]);
				}
			}
		}
    	
    	if(wf2[A][H] == Integer.MAX_VALUE/2)
    		System.out.println("Help!");
    	else if(wf2[A][H] <= M) {
    		System.out.println(wf2[A][H]);
    	}
    	else {
    		System.out.println((wf2[A][H] - M)*2+M);
		}
    }
      
    public static void main(String[] args)
    {
        Scanner sca = new Scanner(System.in);
        
        while(true)
        {
            N = sca.nextInt();
            M = sca.nextInt();
            L = sca.nextInt();
            K = sca.nextInt();
            A = sca.nextInt();
            H = sca.nextInt();
            if(N == 0) break;
            
            FT = new int[L];
            for (int i = 0; i < L; i++) {
				FT[i] = sca.nextInt();
			}
            
            X = new int[K];
            Y = new int[K];
            T = new int[K];
            for (int i = 0; i < K; i++) {
				X[i] = sca.nextInt();
				Y[i] = sca.nextInt();
				T[i] = sca.nextInt();
			}
            
            start();
        }
         
    }
}

Measured memory_bytes: 66936
import fractions 
length,target = (int(n) for n in raw_input().split(" "))
ball = [int(n) for n in raw_input().split(" ")]
gcd = ball[0]
for i in range(1,length):
    gcd = fractions.gcd(gcd,ball[i])
if target % gcd == 0 and target <= max(ball):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 13148
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>

using namespace std;

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

    vector<int> A(4);

    for(int i = A.size(); i > 0; i--) {
        int mod = S % 10;
        A[i - 1] = mod;
        S = (S - mod) / 10;
    }



    int front_num = 10 * A[0] + A[1];
    int back_num = 10 * A[2] + A[3];

    if(front_num > 0 && front_num < 13 && back_num > 0 && back_num < 13) {
        cout << "AMBIGUOUS" << endl;
    } else if(front_num > 0 && front_num < 13) {
        cout << "MMYY" << endl;
    } else if(back_num > 0 && back_num < 13) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from itertools import permutations

N = int(input())
xy = [[int(i) for i in input().split()] for _ in range(N)]

ret = 0
for perm in permutations(range(N)) :
    for i in range(1, N) :
        cx, cy = xy[perm[i]]
        px, py = xy[perm[i-1]]
        
        ret += pow((cx - px) ** 2 + (cy - py) ** 2, 0.5)

x = 1
for i in range(1, N + 1) :
    x *= i
    
print(ret / x)

Measured memory_bytes: 41964
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if(n < k)
    return 0;
  if(n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int n;
  cin >> n;
  if(n < 3) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  COMinit();
  for(int i = 1; i < n; i++) {
    if(i * 3 > n) {
      break;
    }
    int tmp = n - i * 3;
    ans += COM(i + tmp - 1, tmp);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define inf 0x3f3f3f3f3f3f3f3f
#define FASTIO cin.sync_with_stdio (0); cin.tie (0); cin.exceptions (cin.failbit); cout.tie(0);
typedef vector<int> vi;
typedef long long ll;
main(){
    FASTIO;
    ll N, W;
    cin >> N >> W;
    vector<ll> dp(100009, inf);
    for (ll i = 0; i < N; ++i){
        ll w, v;
        cin >> w >> v;
        if (i == 0) dp[v] = w;
        else{
        for (ll valor = 100009 - v - 1; valor >= 0; valor--){
            dp[valor + v] = min(dp[valor + v], w + dp[valor]);
        }
        dp[v] = min(dp[v], (ll)w);
        }
    }
    for (ll i = 100008; i > -1; --i){
        if (dp[i] <= W){
            cout << i << '\n';
            return 0;
        }
    }
}

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

int main() {
  int N,n1,n2,n3,n4;
  cin >> N;
  n1 = N % 10;
  n2 = N /10 % 10;
  n3 = N /100 % 10;
  n4 = N /1000 % 10;
  if ((n2==n3) && ((n1==n2)||(n3==n4))) {
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

bool isPrime(ll n){
    if(n==2) return true;
    if(n==1 || (n&1)==0) return false;

    ll d = (n-1)>>1;
    while((d&1)==0) d=d>>1;
    for(int k=0;k<100;k++){
        //ll a = (ll)abs(rand()) << (sizeof(int)*8);
        ll a = (ll)abs(rand()) << (sizeof(int)*7);
        a = 1 + (abs(a|(ll)rand()) % (n-1));
        ll t = d;
        //ll y = modpow(a,t,n);
        ll y = 1;
        //modpow
        while (t > 0) {
            if (t & 1) y = y * a % n;
            a = a * a % n;
            t >>= 1;
        }
        t = d;

        while(t != n - 1 && y != 1 && y != n - 1){
            y = (y * y) % n;
            t <<= 1;
        }

        if(y != n - 1 && (t & 1) == 0)
            return false;
    }
    return true;
}

int sieve(ll n){
    if(n<=1) return 0;
    if(n==2) return 1;

    int ret=2;
    int i, j, iskip;
    const int IMX = (int)sqrt(n)+1;
    const int NUM_INTBIT = sizeof(int) * 8;
    const int FLGS_SIZE = n/NUM_INTBIT + 1;
    vector<int> flgs(FLGS_SIZE);
    auto getflg = [&](){return (flgs[i / NUM_INTBIT] >> (i % NUM_INTBIT)) & 1;};

    for(i=5, iskip=2; i<=IMX; i+=iskip, iskip^=6){
        if(!getflg()){
            ret++;
            j = n/i;
            j = j-!(j&1);
            for(; j>=i; j-=2){
                if(!getflg())
                    flgs[(j*i) / NUM_INTBIT] |= 1 << ((j*i) % NUM_INTBIT);
            }
        }
    }
    for(;i<=n; i+=iskip, iskip^=6){
        if(!getflg())
         ret++;
    }

    return ret;
}

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

    ll m = sqrt(n)+1;
    ll ans = 0;
    FOR(i,2,m+1){
        if(n%i==0) ans = i;
    }

    if(ans==0) //prime
        ans = n-1;
    else
        ans = max(0LL,(ll)(ans-1)) + ((n/ans)-1);

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

Measured memory_bytes: 256
N, M, C = map(int, input().split())                                                                                                                         
B = list(map(int, input().split()))
 
S = [[0]*M for i in range(N)]
for i in range(N):
    S[i] = list(map(int, input().split()))
 
b = 0
 
for i in range(N):
    a = 0
    for ii in range(M):
        a += S[i][ii] * B[ii]
    a += C
    if a > 0:
        b += 1
 
print(str(b))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
        int a, b, c, x, y;

        scanf("%d %d %d", &a, &b, &c);

        if( a<=b && a<=c ){
                x = ( b<=c ) ? b : c ;
                y = ( b<=c ) ? c : b ;
                printf("%d %d %d", a, x, y);

        }else if( b<=a && b<=c ){
                x = ( a<=c ) ? a : c ;
                y = ( a<=c ) ? c : a ;
                printf("%d %d %d", b, x, y);

        }else{
                x = ( a<=b ) ? a : b ;
                y = ( a<=b ) ? b : a ;
                printf("%d %d %d", c, x, y);
        }

        putchar('\n');

        return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int num1 = sc.nextInt(),num2 = sc.nextInt();
			String Result = "";
			if(num1 * num2 % 2 == 0){
				Result = "Even";
			}else if(num1 * num2 % 2 != 0){
				Result = "Odd";
			}
			System.out.println(Result);
			sc.close();
		}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin>>N>>M;
    int ans=0;
    vector<vector<int>> s(M);
    for(int i=0; i<M; i++){
        int k; cin>>k;
        for(int j=0; j<k; j++){
            int a; cin>>a;
            a--;
            s[i].emplace_back(a);
        }
    }

    vector<int> p(M);
    for(int i=0; i<M; i++) cin>>p[i];

    for(int bit=0; bit<(1<<N); bit++){
        bool ok=true;
        for(int i=0; i<M; i++){
            int cnt=0;
            for(auto v: s[i]){
                if(bit&(1<<v)) cnt++;
            }
            if(cnt%2!=p[i]) ok =false;
        }
        if(ok) ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X, T):
    return X/T


def main():
    # N = read_int()
    X, T = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(X, T))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7740
#include <iostream>
using namespace std;
int C[105];
int main() {
  ios::sync_with_stdio(false);
  int N, K, D, A;
  cin >> N >> K;
  for (int i=0; i<K; i++) {
    cin >> D;
    for (int j=0; j<D; j++) {
      cin >> A;
      C[A]++;
    }
  }
  int ret = 0;
  for (int i=1; i<=N; i++) {
    if (C[i] == 0) ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 3652
n=int(input())
li=[]
for i in range(1,n+1):
    li.append(i)
sum=0
for j in li:
    if j%15==0:
        sum+=j
    elif j%3==0:
        sum+=j
    elif j%5==0:
        sum+=j
print(int(((n+1)*n/2) - sum))


Measured memory_bytes: 48368
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a = 0
b = 0
c = []
for i in range(n):
    c.append(i + 1)
d = list(itertools.permutations(c))
count = 1
for lis in d:
    if p == lis:a = count
    if q == lis:b = count
    count += 1
print(abs(a - b))

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

int main(){
    ll ans = 0;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int l, r;
        cin >> l >> r;
        ans += r-l+1;
    }    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> H(N), A(N);
	for (int i = 0; i < N; ++i) cin >> H[i];
	for (int i = 0; i < N; ++i) cin >> A[i];
	vector<int> ord(N);
	for (int i = 0; i < N; ++i) {
		ord[H[i] - 1] = i;
	}
	int S = 1;
	while (S < N) S *= 2;
	vector<long long> segtree(2 * S);
	function<void(int, long long)> update = [&](int pos, long long val) {
		pos += S;
		segtree[pos] = val;
		while (pos > 1) {
			pos >>= 1;
			segtree[pos] = max(segtree[pos * 2], segtree[pos * 2 + 1]);
		}
	};
	function<long long(int, int, int, int, int)> _rangemax = [&](int a, int b, int k, int l, int r) {
		if (a <= l && r <= b) return segtree[k];
		if (r <= a || b <= l) return (long long)(0);
		long long lres = _rangemax(a, b, k * 2, l, (l + r) >> 1);
		long long rres = _rangemax(a, b, k * 2 + 1, (l + r) >> 1, r);
		return max(lres, rres);
	};
	function<long long(int, int)> rangemax = [&](int a, int b) {
		return _rangemax(a, b, 1, 0, S);
	};
	for (int i = 0; i < N; ++i) {
		long long res = rangemax(0, ord[i]);
		update(ord[i], res + A[ord[i]]);
	}
	long long ans = rangemax(0, N);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6656
import sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,M = LI()
A = LI()

B = [0]
for i in range(N):
    B.append((B[-1]+A[i]) % M)

from collections import Counter

count = Counter(B)

ans = 0
for i in count.keys():
    ans += count[i]*(count[i]-1)//2

print(ans)

Measured memory_bytes: 98748
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string color[] = {"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"};

    for(;;){
        string s;
        cin >> s;
        if(s == "0")
            return 0;

        int a[3] = {0};
        for(int i=0; i<6; ++i){
            a[i/2] *= 16;
            if('0' <= s[i+1] && s[i+1] <= '9')
                a[i/2] += s[i+1] - '0';
            else
                a[i/2] += s[i+1] - 'a' + 10;
        }

        int k;
        int minD = INT_MAX;
        for(int i=0; i<8; ++i){
            int d = 0;
            for(int j=0; j<3; ++j){
                if(i & (1<<(2-j)))
                    d += (255 - a[j]) * (255 - a[j]);
                else
                    d += a[j] * a[j];
            }
            if(d < minD){
                minD = d;
                k = i;
            }
        }

        cout << color[k] << endl;
    }
}

Measured memory_bytes: 0
n = int(input())
a = []
for i in range(n):
    a.append(int(input()) - 1)

hst = [0] * n
btn = 0
cnt = 0

while hst[btn] != 1:
    hst[btn] = 1
    btn = a[btn]

    cnt += 1
    if btn == 1:
        print(cnt)
        exit()

print(-1)

Measured memory_bytes: 50136
#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    vector<int> a(N);
    
    for(int i=0;i<N;i++)
    {
        cin >> a[i];
    }
    
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    int A,B;
    A=0;
    B=0;
    for(int i=0;i<N;i++)
    {
        if(i%2 == 0)
        {
            A += a[i];
        }
        else
        {
            B += a[i];
        }
    }
    
    int c = A-B;
    
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
)

const Inf = math.MaxInt64 / 10

func main() {
	N := ReadInt()
	a := ReadInts(3 * N)

	sum := 0
	h := Heap{}
	leftSum := make([]int, 3*N)
	for i := 0; i < 3*N; i++ {
		h.push(a[i])
		sum += a[i]
		if len(h) > N {
			sum -= h.pop()
		}
		if len(h) == N {
			leftSum[i] = sum
		} else {
			leftSum[i] = -Inf
		}
	}

	sum = 0
	h = Heap{}
	rightSum := make([]int, 3*N)
	for i := 3*N - 1; i >= 0; i-- {
		h.push(-a[i])
		sum += a[i]
		if len(h) > N {
			sum -= -h.pop()
		}
		if len(h) == N {
			rightSum[i] = sum
		} else {
			rightSum[i] = Inf
		}
	}

	ans := -Inf * 5
	for i := 0; i < 3*N-1; i++ {
		ans = Max(ans, leftSum[i]-rightSum[i+1])
	}
	fmt.Println(ans)
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

type HeapElement = int
type Heap []HeapElement

func (h Heap) Less(i, j int) bool    { return h[i] < h[j] }
func (h Heap) Len() int              { return len(h) }
func (h Heap) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *Heap) Push(x interface{})   { *h = append(*h, x.(HeapElement)) }
func (h *Heap) Pop() (x interface{}) { *h, x = (*h)[:len(*h)-1], (*h)[len(*h)-1]; return }
func (h *Heap) push(v HeapElement)   { heap.Push(h, v) }
func (h *Heap) pop() HeapElement     { return heap.Pop(h).(HeapElement) }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 17140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        ulong n = ulong.Parse(Console.ReadLine());
        if (n % 2 == 1)
        {
            Console.WriteLine(0);
            return;
        }
        ulong res = 0;
        for (ulong i = 10; i <= 1000000000000000000; i *= 5)
        {
            res += n / i;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
int main(void)
{
	int Vertical=0;
	int Horizontal=0;
	int Square_area=0;
	int Square_circumference=0;
	
	scanf("%d %d",&Vertical,&Horizontal);
	
	Square_area=Vertical*Horizontal;
	Square_circumference=2*Vertical+2*Horizontal;
	
	printf("%d %d\n",Square_area,Square_circumference);
	return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
#include <queue>
typedef long long ll;
using namespace std;
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; }
const int MOD = 1000000007;
const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

int N;
vector<ll> h;

ll dp[100010];

void func(int n)
{
	if(dp[n] < INF) return;
	if(n == N + 1) return;

	chmin(dp[n], dp[n - 1] + abs(h[n] - h[n - 1]));
	if(n > 1) chmin(dp[n], dp[n - 2] + abs(h[n] - h[n - 2]));
	func(n + 1);
}

int main()
{
	cin >> N;
	h.resize(N);
	for(int i = 0; i < N; i++)
	{
		cin >> h[i];
	}
	for(int i = 0; i < 100010; i++) dp[i] = INF;
	dp[0] = 0;
	func(1);
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

/*lld fac[100001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}*/


lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;


void solve()
{
    cin>>x>>y;
    if(y%2==1)
    {
        cout<<"No";
        return;
    }
    if(y<2*x)
    {
        cout<<"No";
        return;
    }
    else if(y>4*x)
    {
        cout<<"No";
        return;
    }
    cout<<"Yes";

}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    ll j=0;
    ll sum=a[0];
    rep(i,0,n-2){
        if(sum*2>=a[i+1]){
            sum+=a[i+1];
        }else{
            j=i+1;
            sum+=a[i+1];
        }
    }
    cout<<n-j<<endl;
    
    
    return 0;
}



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int x = obj.nextInt(),y = obj.nextInt();
        for(int i=1;i<=1010;i++)
        {
            if(Math.floor(0.08 *i)==x && Math.floor(0.1*i)==y)
            {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 23252
package main

import (
	"fmt"
)

func main() {

	var K int
	fmt.Scanf("%d", &K)

	var S string
	fmt.Scanf("%s", &S)

	if len(S) <= K {
		fmt.Println(S)
	} else {
		fmt.Println(S[0:K] + "...")
	}
}


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

const int MAXN = 11;
int n;
int g[MAXN][MAXN];

int getSum(int bi, int bj, int ei, int ej) {
  int sum = 0;
  for(int i = bi; i < ei; ++i) {
    for(int j = bj; j < ej; ++j) {
      sum += g[i][j];
    }
  }
  return sum;
}

int main() {
  while(cin >> n && n) {
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < n; ++j) {
        cin >> g[i][j];
      }
    }
    for(int i = 0; i < n+1; ++i) {
      for(int j = 0; j < n+1; ++j) {
        int value = 0;
        if(i == n && j == n) {
          value = getSum(0, 0, n, n);
        } else if(i == n) {
          value = getSum(0, j, n, j+1);
        } else if(j == n) {
          value = getSum(i, 0, i+1, n);
        } else {
          value = g[i][j];
        }
        printf("%5d", value);
      }
      printf("\n");
    }
  }
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int ans = d[d.size() / 2] - d[d.size() / 2 - 1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  const int N = 100;
  vector<vector<char> > ans(N, vector<char>(N, '.'));
  REP(i, N / 2) fill(ALL(ans[i]), '#');
  int a, b; cin >> a >> b;
  int white = 1, black = 1;
  for (int i = 0; i < N / 2; i += 2) {
    for (int j = 0; j < N; j += 2) {
      if (white < a) {
        ans[i][j] = '.';
        ++white;
      }
    }
  }
  for (int i = N - 1; i > N / 2; i -= 2) {
    for (int j = 0; j < N; j += 2) {
      if (black < b) {
        ans[i][j] = '#';
        ++black;
      }
    }
  }
  cout << N << ' ' << N << '\n';
  REP(i, N) {
    REP(j, N) cout << ans[i][j];
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = s[2];
    auto B = s[3];
    auto ans = new dchar[][](N, M);

    bool solve(bool hoge) {
        foreach (i; 0..N) fill(ans[i], '.');

        int a = A;
        int b = B;
        
        if (N >= 3 && M >= 3 && N % 2 == 1 && M % 2 == 1 && hoge) {
            if (a >= 1) {
                ans[$-3][$-3] = '<';
                ans[$-3][$-2] = '>';
            }
            if (a >= 2) {
                ans[$-1][$-2] = '<';
                ans[$-1][$-1] = '>';
            }
            if (b >= 1) {
                ans[$-3][$-1] = '^';
                ans[$-2][$-1] = 'v';
            }
            if (b >= 2) {
                ans[$-2][$-3] = '^';
                ans[$-1][$-3] = 'v';
            }
            a -= 2;
            b -= 2;
        }

        if (N % 2 == 1)
            for (int c = 0; c < M - M % 2 && ans[$-1][c] == '.' && ans[$-1][c+1] == '.' && a > 0; c += 2)
                ans[$-1][c] = '<', ans[$-1][c+1] = '>', a -= 1;
        if (M % 2 == 1)
            for (int r = 0; r < N - N % 2 && ans[r][$-1] == '.' && ans[r+1][$-1] == '.' && b > 0; r += 2)
                ans[r][$-1] = '^', ans[r+1][$-1] = 'v', b -= 1;

        int r = 0, c = 0;
        while (r < N - N % 2 && c < M - M % 2 && a > 0 && ans[r][c] == '.') {
            ans[r][c] = '<';
            ans[r][c+1] = '>';
            if (a >= 2) {
                ans[r+1][c] = '<';
                ans[r+1][c+1] = '>';
            }
            a -= 2, c += 2;
            if (c >= M - M % 2) r += 2, c = 0;
        }

        while (r < N - N % 2 && c < M - M % 2 && b > 0 && ans[r][c] == '.') {
            ans[r][c] = '^';
            ans[r+1][c] = 'v';
            if (b >= 2) {
                ans[r][c+1] = '^';
                ans[r+1][c+1] = 'v';
            }
            b -= 2, c += 2;
            if (c >= M - M % 2) r += 2, c = 0;
        }

        return a <= 0 && b <= 0;
    }

    
    if (solve(false)) {
        writeln("YES");
        ans.each!writeln;
    } else if (solve(true)) {
        writeln("YES");
        ans.each!writeln;
    } else {
        writeln("NO");
    }
}


Measured memory_bytes: 5244
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()

ans=n*(n-1)//2

print(ans)

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

int main()
{   int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int ok=i*1.08;
        if(ok==n){
            printf("%d",i);
            return 0;
        }
    }
    printf(":(");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int A, B,ans = 0;
	cin >> A >> B;
	if (A > B) {
		ans += A;
		A--;
	}
	else {
		ans += B;
		B--;
	}
	if (A > B) {
		ans += A;
		A--;
	}
	else {
		ans += B;
		B--;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, k;
vector<int> a;

bool f(int m){
    int cnt = 0;
    for(int i=0;i<n;i++){
        cnt += (a[i]-1)/m;
    }
    return cnt <= k;
}

int main(void){
    cin >> n >> k;
    a.assign(n, 0);
    for(int i=0;i<n;i++) cin >> a[i];

    int ng = 0, ok = 1e9;
    while(ng + 1 < ok){
        double m = (ng+ok) /2;
        if(f(m)) ok = m;
        else ng = m;
    }
    cout << ok << endl;
}


Measured memory_bytes: 3540
import java.io.*;
import java.util.*;
public class Main
{
BufferedReader br;
BufferedWriter bw;
public static void main(String args[]) throws IOException
{
  (new Main()).run();
}

void run() throws IOException
{
  br =new BufferedReader(new InputStreamReader(System.in));
  bw =new BufferedWriter(new OutputStreamWriter(System.out));
  // code starts here
  String s[]=line().split(" ");
  int n=toInt(s[0]);
  int k=toInt(s[1]);
  int ar[]=na();
  if(k>=n)
  {
      System.out.println("1");
      return;
  }
  else
  System.out.println((int)Math.ceil((n-k)/(double)(k-1))+1);


 bw.flush();
}

String line() throws IOException
{
return br.readLine();
}
int[] na() throws IOException
{
String s[]=line().split(" ");
int len=s.length;
int ar[]=new int[len];
for(int i=0;i<len;i++)
ar[i]=toInt(s[i]);
return ar;
}

int[][] matrix(int n,int m) throws IOException
{
int ar[][]=new int[n][m];
for(int i=0;i<n;i++)
ar[i]=na();
return ar;
}
int toInt(String s) throws IOException
{
return Integer.parseInt(s);
} 
long toLong(String s) throws IOException
{
return Long.parseLong(s);
}
double toDouble(String s) throws IOException
{
return Double.parseDouble(s);
}
private void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}


Measured memory_bytes: 36052
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;



bool test(int N, ll K, ll a[1000], ll sum, ll x) {
	if (sum%x != 0) { return false; }

	ll b[1000];

	ll amari=0;
	
	for (int i = 1; i <= N; i++) {
		b[i] = a[i] % x;
		amari = amari + b[i];
	}

	amari = N - amari / x;

	
	sort(b + 1, b + N + 1);

	ll t=0;

	for (int i = 1; i <= amari; i++) {
		t = t + b[i];
	}

	
	if (t <= K) { return true; }
	else { return false; }

}



int main() {

	int N;
	ll K;
	ll a[1000];
	ll sum=0;//入力の合計
	
	cin >> N >> K;

	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		sum += a[i];

	}

	ll ans=1 ;


	for (int i = 1; i*i <= sum;i++) {
		if (sum%i == 0) {
			if (test(N, K, a, sum, i)&&ans<i) { ans=i; };
			if (test(N, K, a, sum, sum/i) && ans < sum/i) { ans = sum/i; };
		}
	}

	cout << ans;
	


	

	system("PAUSE");


}


Measured memory_bytes: 504
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	vint adj[10001];
	ll a[10001],b[10001];
	ll c[10001];
	ll ans=0;
	int d[10001];
	set<pint> SI;
	int shutu[10001]={};
	bool alre[10001]={};
	scan(N);
	rep(i,N-1){
		scan(a[i]>>b[i]);
		a[i]--; b[i]--;
		adj[a[i]].push_back(b[i]);
		adj[b[i]].push_back(a[i]);
	}
	rep(i,N) scan(c[i]);
	sort(c,c+N);
	rep(i,N){
		SI.insert({adj[i].size(),i});
	}
	rep(i,N){
		shutu[i]=adj[i].size();
	}
	for(int i=0;i<N&&(!SI.empty());i++){
		auto itr=SI.begin();
		int mins=(*itr).first,v=(*itr).second;
		SI.erase(itr);
		ans+=(ll)shutu[v]*c[i];
		d[v]=c[i];
		alre[v]=1;
		shutu[v]=0;
		vpint tmp;
		rep(j,adj[v].size()){
			int u=adj[v][j];
			if(alre[u]) continue;
			SI.erase({shutu[u],u});
			if(shutu[u]>0) shutu[u]--;
			tmp.push_back({shutu[u],u});
		}
		rep(j,tmp.size()){
			SI.insert(tmp[j]);
		}
	}
	prin(ans);
	rep(i,N){
		printf("%d ",d[i]);
	}
	kaigyo;
	return 0;
}


Measured memory_bytes: 1664
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

int main() {
  int n; cin >> n;
  vector<int> A(n+1);
  loop(i,1,n+1) cin >> A[i];
  int cnt = 0;
  loop(i,1,n) {
    if (A[i] != i) continue;
    swap(A[i], A[i+1]);
    cnt++;
  }
  if (A[n] == n) swap(A[n], A[n-1]), cnt++;
  cout << cnt << endl;
  return 0;
}


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

int main() {
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << a[1] - a[0] + a[2] - a[1] << endl;
}

Measured memory_bytes: 256