akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

void print(int v, char c){
	printf("%02d:%02d:%02d%c",v/(60*60),(v/60)%60,v%60,c);
}
int main() {
while(1){
	int n;
	cin >> n;
	if(n==0)return 0;
	int num[12*60*60]={0};
	for(int i=0;i<n;i++){
		int in[3];
		cin >> in[0] >> in[1] >> in[2];
		sort(in,in+3);
		do{
			int s=in[0],t=in[1],u=in[2];
			for(int j=0;j<60;j++){
				int r=(t-(s*12%60)+60)%60;
				if(r<12){
					num[12*s*60+r*60+u]|=1<<i;
				}

				s++;s%=60;
				t++;t%=60;
				u++;u%=60;
			}
		} while(next_permutation(in,in+3));
	}
	int len=INT_MAX;
	int start=-1;
	int c[10]={0};
	int d=0;
	int a=0;
	int b=-1;
	while(1){
		if(b<a||d<n){
			b++;
			if(b==12*60*60)break;
			if(num[b]){
			for(int i=0;i<n;i++){
				if(num[b]&(1<<i)){
					if(c[i]==0){
						d++;
					}
					c[i]++;
				}
			}
			}
		}
		else
		{
			if(num[b]){
			for(int i=0;i<n;i++){
				if(num[a]&(1<<i)){
					c[i]--;
					if(c[i]==0){
						d--;
					}
				}
			}
			}
			a++;
		}
		if(d==n&&b-a<len){
			start=a;
			len=b-a;
		}
	}
	print(start, ' ');
	print(start+len,'\n');
}
}

Measured memory_bytes: 1332
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    double x,ma=0,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>x,sum+=x,ma=max(ma,x);
    cout<<sum-ma+ma/2<<endl;
}


Measured memory_bytes: 256
import bisect
A,B,Q=map(int,input().split())
INF=10**18
s=[-INF]+[int(input()) for i in range(A)]+[INF]
t=[-INF]+[int(input()) for i in range(B)]+[INF]
for q in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(s,x),bisect.bisect_right(t,x)
    res=INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2=abs(S-x)+abs(S-T),abs(T-x)+abs(S-T)
            res=min(res,d1,d2)
    print(res)

Measured memory_bytes: 14092
import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000)
n=int(input())
visitedlist=[-1 for  i in range(n)]
kilist=[[] for i in range(n)]
anslist=[0 for i in range(n)]
searchedlist=[-1 for i in range(n)]
for i in range(n-1):
        a,b,c=map(int,input().split())
        kilist[a-1].append((b,c))
        kilist[b-1].append((a,c))        
def search(i):
        searchedlist[i-1]=1
        visitedlist[i-1]=1
        flag=0
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag+=1
                anslist[j[0]-1]=anslist[i-1]+j[1]
        else:
            pass

        if flag>0:    
            for k in kilist[i-1]:
                if searchedlist[k[0]-1]==-1:
                    search(k[0])
q,k=map(int,input().split())
List=[0 for i in range(q)]
search(k)
for i in range(q):
    x,y=map(int,input().split())
    List[i]=anslist[x-1]+anslist[y-1]
for j in List:
    print(j)


Measured memory_bytes: 134328
def main():
    num = list(map(int, input().split()))
    num.sort()
    if (num[2] - num[1]) % 2 == (num[2] - num[0]) % 2:
        print((2 * num[2] - num[1] - num[0]) // 2)
    else:
        print((2 * num[2] - num[1] - num[0] + 3) // 2)


if __name__ == '__main__':
    main()



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

int main(void)
{
    int A, sum = 0;
    rep(i, 3) { cin >> A; sum += A; }
    if (sum >= 22) printf("bust\n");
    else printf("win\n");
    return 0;
}


Measured memory_bytes: 256
N = int(input())
SP = [[_ for _ in input().split()] + [_ + 1] for _ in range(N)]
SP.sort(key = lambda x:(x[0],-int(x[1])))
ans = [0] * N

for i, sp in enumerate(SP):
    s, p, x = sp
    ans[i] = x

for j in ans:
    print(j)

Measured memory_bytes: 3060
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ld n;
	cin>>n;
	cout<<2*PI*n<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
// Including Policy Based DS
//#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

#define LL long long
#define ULL unsigned long long
LL INF=10000000000000001LL;
#define PI 2.0*acos(0.0)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

//typedef tree<
//int,
//null_type,
//less<int>,
//rb_tree_tag,
//tree_order_statistics_node_update>
//ordered_set;

#define READ 		freopen("in.txt","r",stdin)
#define WRITE  		freopen("out.txt","w",stdout)
#define BOOST		ios_base::sync_with_stdio(false);cin.tie(NULL)
#define sf 			scanf
#define pf 			printf
#define F  			first
#define S  			second
#define pb 			push_back
#define NL			pf("\n")
#define ALL(v)		v.begin(),v.end()
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v,cmp)	sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(int i=0;i<n;i++)
#define cnd			tree[idx]
#define lc			tree[idx*2]
#define rc			tree[idx*2+1]
#define lnd 		(2*idx),(b),((b+e)/2)
#define rnd 		((2*idx)+1),(((b+e)/2)+1),(e)

// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Bishop direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int KX[8] = {1,1,2,2,-1,-1,-2,-2};
//int KY[8] = {2,-2,1,-1,2,-2,1,-1};

bool Check(int N,int pos){return (bool)(N & (1<<pos));} // check bit
int Set(int N,int pos){	return N=N | (1<<pos);}// set bit

const LL mod=2091573227LL;
LL modMul(LL a, LL b){
    LL ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}

LL powerMod( LL a,LL b ){
	if( b==0 )return 1%mod;
	LL x=powerMod( a,b/2 );
	x = ( x%mod * x%mod )%mod;
	if( b%2==1 )x = ( x%mod * a%mod )%mod;
	return x%mod;
}

LL lcm( LL a,LL b ){
	LL g = __gcd(a,b);
	return (a*b)/g;
}
const int mx = 100001;
//-------------------------------------------------------------------------------

LL W[101],V[101];
LL dp[mx];

int main(){
//  READ;
//  WRITE;
//	BOOST;

	int n;
	LL w;

	cin>>n>>w;
	LL tot = 0;
	FOR(i,n)cin>>W[i]>>V[i],tot+=V[i];
	FOR(i,mx)dp[i]=INF;
	dp[0] = 0;
    FOR(i,n){
		for(LL v=tot-V[i];v>=0;v--){
            dp[v+V[i]] = min(dp[v+V[i]],dp[v]+W[i]);
		}
    }

    LL ans = 0;
    for(LL i=0;i<=tot;i++){
		if( dp[i]<=w ){
            ans = max(ans,i);
		}
    }


    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 1024
s = gets.chomp.split(//)

acgt = ["A", "C", "G", "T"]

ar = []
tmpstr = ""
idx = 0
isSplit = true
for i in 0..(s.length - 1) do
  if acgt.include?(s[i]) then
    if isSplit then
      isSplit = false
    end

    tmpstr << s[i]
  else
    unless isSplit then
      isSplit = true
      ar[idx] = tmpstr
      tmpstr = ""
      idx += 1
    end
  end
end

unless isSplit then
  ar[idx] = tmpstr
end

if ar.length == 0 then
  puts "0"
else
  puts ar.map! {|str| str.length}.max
end


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;//list用
using System.Text.RegularExpressions;//正規表現用
using System.Text;//StringBuilder用
class Program
{
    static List<int> s = new List<int>();
    static int result;
    static void Main()
    {
        //string tmp1 = Console.ReadLine();
        //int x = int.Parse(tmp1);
        string[] tmp2 = Console.ReadLine().Split(' ');
        for (int i = 0; i < 2; i++) { s.Add(int.Parse(tmp2[i])); }
        int a, b, c;
        a = s[0] + s[1]; b = s[0] * s[1]; c = s[0] - s[1];
        if (a >= b && a >= c) { result = a; }
        if (b >= a && b >= c) { result = b; }
        if (c >= a && c >= b) { result = c; }
            Console.WriteLine(result.ToString());
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

double cross(Point a, Point b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

char c;
double x[4], y[4];
Point p[4];

int main(){
	while (cin >> x[0] >> c >> y[0] >> c >> x[1] >> c >> y[1] >> c >>
		x[2] >> c >> y[2] >> c >> x[3] >> c >> y[3]){
		REP(i, 4)p[i] = { x[i], y[i] };
		if (cross(p[0] - p[2], p[0] - p[1])*cross(p[0] - p[2], p[0] - p[3]) > 0){
			cout << "NO" << endl;
			continue;
		}
		if (cross(p[1] - p[3], p[1] - p[0])*cross(p[1] - p[3], p[1] - p[2]) > 0){
			cout << "NO" << endl;
			continue;
		}
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 3112
import java.util.Scanner;
import java.util.StringJoiner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String x = scanner.next();
        String y = scanner.next();
        String z = scanner.next();
        String result = String.join(" ", z, x, y);
        System.out.println(result);
    }
}

Measured memory_bytes: 21716
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;	
int main() {
	int a, b, c, d, e;
	string s, ss, sss;
	cin >> a>>b;
	cout<<  (a+b)/2+((a+b)%2!=0?1:0) <<endl;
	return 0;
}

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


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

    string s;
    cin >> s;

    int abcd_table[26] = {};
    int max_num = 0;
    for(int i=0; i<n; i++){
        int count = 0;
        for(int a = 0; a<26; a++){
            abcd_table[a] = 0;
        }
        int j;
        for(j=0; j<i; j++){
            abcd_table[s[j] - 'a'] = 1;
        }
        for(int k=j; k<n; k++){
            if(abcd_table[s[k] - 'a'] == 1){
                count ++ ;
                abcd_table[s[k] - 'a'] ++;
            }
        }

        max_num = max(max_num, count);
    }

    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    getline(cin,s);
    string ans;
    for(char c : s) {
        if(isalpha(c)){
            if(islower(c)) ans += toupper(c);
            else ans += tolower(c);
        }else {
            ans += c;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3196
#include <stdio.h>
int main(){
    int H,W,i,j;
    
    while(1){
    scanf("%d%d",&H,&W);
    if (W==0 && H==0) break;
    
    for(i=0;i<H;i++){
        for(j=0;j<W;j++){
            printf("#");
        }
        printf("\n");
    }
    printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
int N,M;
int D[100010];
std::vector<int> G[100010];
std::deque<int> ans;
int main(){
    std::cin>>N>>M;
    for(int i=0;i<M;i++){
        int A,B;
        std::cin>>A>>B;
        G[A].emplace_back(B);
        G[B].emplace_back(A);
        if(i==0){
            ans.emplace_back(A);
            ans.emplace_back(B);
            D[A]=D[B]=true;
        }
    }
    bool flag=true;
    while(flag){
        flag=false;
        int f=ans.front();
        for(auto u:G[f]){
            if(!D[u]){
                flag=true;
                D[u]=true;
                ans.emplace_front(u);
                break;
            }
        }
        int b=ans.back();
        for(auto u:G[b]){
            if(!D[u]){
                flag=true;
                D[u]=true;
                ans.emplace_back(u);
                break;
            }
        }
    }
    std::cout<<ans.size()<<std::endl;
    for(int i=0;i<ans.size();i++){
        std::cout<<ans[i]<<((i!=ans.size()-1)?" ":"\n");
    }
    return 0;
}


Measured memory_bytes: 7040
n = int(input())
a = list(map(int,input().split()))
dp = [0 for i in range(n)]
dp[0] = 0
dp[1] = abs(a[1]-a[0])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]))

print(dp[-1])


Measured memory_bytes: 90500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

struct P{
    ld x, y;
};

inline ld dist(P& a, P& b){
    return sqrt(pow(a.x-b.x, 2)+pow(a.y-b.y, 2));
}
inline ld area(P& a, P& b, P& c){
    return abs((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y))/2;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    V<P> p(3);
    rep(i, 3){
        cin >> p[i].x >> p[i].y;
    }
    V<ld> len(3);
    rep(i, 3){
        len[i] = dist(p[(i+1)%3], p[(i+2)%3]);
    }
    ld mlen = *max_element(ALL(len));
    ld r = area(p[0], p[1], p[2])*2.0l/accumulate(ALL(len), 0.0l);
    cout << 1.0l/(1.0l/r+2.0l/mlen) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=101000;
int p[N],q[N],vis[N],n,m,t;
char mark[N];
bitset<50001> g[50100],all;
void solve1() {
	rep(i,0,n) g[i][i]=1;
	rep(i,0,m) {
		scanf("%d%d",p+i,q+i);
		p[i]--; q[i]--;
		g[p[i]]=g[q[i]]=g[p[i]]|g[q[i]];
	}
	rep(i,0,n) all[i]=1;
	int rt=-1;
	rep(i,0,n) if (g[i]==all) {
		rt=i;
		break;
	}
	if (rt==-1) {
		puts("-1");
		return;
	}
	vis[rt]=1;
	per(i,0,m) {
		if (vis[p[i]]==vis[q[i]]) { mark[i]='v'; continue; }
		if (vis[p[i]]) mark[i]='^';
		else mark[i]='v';
		vis[p[i]]=vis[q[i]]=1;
	}
	puts(mark);
}

int ff[3][3]={
	{-1,2,1},{2,-1,0},{1,0,-1}
};
int gg[3][3]={
	{-1,1,1},{1,-1,0},{0,0,-1}
};
int nxt[N];
void solve2() {
	if (n==2) {
		puts("-1");
		return;
	}
	VI w;
	rep(i,0,m) {
		scanf("%d%d",p+i,q+i);
		p[i]--; q[i]--;
	}
	int nd=-1,nx=-1;
	per(i,0,m) {
		if (q[i]<=2) {
			int z=p[i]+q[i]-1;
			if (z!=nx) {
				nxt[i]=nx;
			} else {
				nxt[i]=nd;
			}
			nd=nxt[i]; nx=z;
	//		printf("%d %d %d\n",i,z,nxt[i]);
		}
	}
	int st=0;
	rep(i,0,3) if (nx!=i) { st=i; break; }
	rep(i,0,m) {
		if (q[i]>2) { mark[i]='^'; continue; }
		int z=p[i]+q[i]-1;
		assert(st!=z);
		//printf("gg %d %d %d\n",st,ff[st][z],nxt[i]);
		if (ff[st][z]!=nxt[i]) {
			mark[i]=gg[st][z]?'v':'^';
			st=ff[st][z];
		} else {
			mark[i]=gg[st][z]?'^':'v';
		}
	}
	puts(mark);
}
int main() {
	scanf("%d%d%d",&n,&m,&t);
	if (t==1) {
		solve1();
	} else {
		solve2();
	}
}


Measured memory_bytes: 307712
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = rl()
answer = 0
for i in range(N):
    if A[A[i]-1]-1 == i:
        answer += 1

print(answer//2)


Measured memory_bytes: 14388
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) 
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n,cur;string s,ans;
int main()
{
    cin>>n>>s;
    rep(i,0,n-1){
        ans+=s[i];
        if(s[i]=='(') cur++;else cur--;
        if(cur<0) ans='('+ans,cur++;
    }
    while(cur>0){cur--;ans=ans+')';}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int K; int S;
	while (~scanf("%d%d", &K, &S)) {
		int ans = 0;
		rer(X, 0, K)rer(Y, 0, K) {
			int Z = S - X - Y;
			ans += 0 <= Z&&Z <= K;
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define sentinel 1000000000
#define max 500000

int l[max/2 + 2];
int r[max/2 + 2];
int cnt;

void merge(int a[],int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	int i;
	for (i = 0; i < n1; i++) {
		l[i] = a[left + i];
	}
	for (i = 0; i < n2; i++) {
		r[i] = a[mid + i];
	}
	l[n1] = sentinel;
	r[n2] = sentinel;
	i = 0;
	int j = 0;
	for (int k = left; k < right; k++) {
		if (l[i] <= r[j]) {
			a[k] = l[i];
			i++;
		}
		else {
			a[k] = r[j];
			j++;
		}
		cnt++;
	}
}

void mergesort(int a[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergesort(a,left, mid);
		mergesort(a,mid, right);
		merge(a,left, mid, right);
	}
}

int main()
{
	int a[max];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	mergesort(a, 0, n);
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << a[i];
	}
	cout << endl;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 6892
#include<iostream>
#include<algorithm>

using namespace std;

#define INF 2147483647

int tree[1000000];

void Update(int s, int t, int m, int left = 0, int right = (1 << 17), int key = 0){
    if(t < left || right <= s) return;
    if(s <= left && right - 1 <= t){ tree[key] = max(tree[key], m); return; }
    Update(s, t, m, left, (left + right) / 2, 2 * key + 1);
    Update(s, t, m, (left + right) / 2, right, 2 * key + 2);
}

int Query_find(int i){
    i += (1 << 17) - 1;
    int m = tree[i];
    while(i){
        i = (i - 1) / 2;
        m = max(tree[i], m);
    };
    return m;
}



int main(){

  int n, q, x[1000000],i;
  for(i=0; i<1000000; i++) {tree[i]=0; x[i]=INF;}

  cin >> n >> q;
  int c, s, t, value, m=1;
  for (int j=0; j<q; j++) {
    cin >> c;
    if(c){
      cin >> i;
      cout << x[Query_find(i)] << endl;
    }else{
      cin >> s >> t >> value;
      x[m] = value;
      Update(s, t, m);
      m++;
    }
  }
  return 0;
}




Measured memory_bytes: 10924
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ull a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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 aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

int kyotsu(string ss, int st, int ed, string ss2) {
    int ans = 0;
    for ( int i = st; i < ed; ++i ) {
        if (i - st >= ss2.size()) return ans;
        if (ss[i] == ss2[i - st] || ss[i] == '?') {
            ans++;
        } else {
            return -1;
        }
    }
    return ans;
}

//幅探索で探して行って，maze[y][x]での黒い部分の最小値をdistに
//連続で同じ方向に行ってる場合は１とカウントする．
int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> h >> w;
    vector<string> maze(h);
    rep (i, 0, h) cin >> maze[i];
    vector<vector<int> > dist(h, vector<int>(w, 300));
    dist[0][0] = (maze[0][0] == '#');
    rep (i, 0, h) {
        rep (j, 0, w) {
            if (j != 0) {
                if (maze[i][j - 1] == maze[i][j]) dist[i][j] = dist[i][j - 1];
                chmin(dist[i][j], dist[i][j - 1] + (maze[i][j] == '#'));
            }

            if (i != 0) {
                if (maze[i - 1][j] == maze[i][j]) chmin(dist[i][j], dist[i - 1][j]);
                chmin(dist[i][j], dist[i - 1][j] + (maze[i][j] == '#'));
            }
        }
    }

    cout << dist[h - 1][w - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, p;

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

ll solve() {
    map<ll, ll> pf = prime_factor(p);
    ll res = 1;
    for (auto p : pf) {
        for (ll i = 0; i < p.second/n; i++) {
            res *= p.first;
        }
    }
    return res;
}

void input() {
    cin >> n >> p;
}

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

    input();
    cout << solve() << endl;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (n % 2 == 1) {
    cout << b.at(n / 2) - a.at(n / 2) + 1 << '\n';
    return 0;
  }
  //double median_a = (double)(a.at(n / 2 - 1) + a.at(n / 2)) / 2.0;
  //double median_b = (double)(b.at(n / 2 - 1) + b.at(n / 2)) / 2.0;
  int aa = a.at(n / 2 - 1) + a.at(n / 2);
  int bb = b.at(n / 2 - 1) + b.at(n / 2);
  cout << bb - aa + 1 << '\n';
  return 0;
}


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

int main(){
  int n, m, l;
  long long A[100][100], B[100][100], C[100][100];
  
  cin >> n >> m >> l;
  for ( int i = 0; i < n; i++ )
    for ( int j = 0; j < m; j++ ) cin >> A[i][j];
  for ( int i = 0; i < m; i++ )
    for ( int j = 0; j < l; j++ ) cin >> B[i][j];
    
  for ( int i = 0; i < n; i++ ){
    for ( int j = 0; j < l; j++ ){
      C[i][j] = 0;
      for ( int k = 0; k < m; k++ ){
        C[i][j] += A[i][k]*B[k][j];
      }
    }
  }
  
  for ( int i = 0; i < n; i++ ){
    for ( int j = 0; j < l; j++ ){
      if ( j ) cout << " ";
      cout << C[i][j];
    }
    cout << endl;
  }
  
  return 0;
}


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

import math

if math.ceil((a+1)*12.5) <= math.ceil(b*10) or math.ceil(a*12.5) >= math.ceil((b+1)*10):
    print(-1)
else:
    print(max(math.ceil(a*12.5),math.ceil(b*10)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    string s, t;
    cin >> s >> t;
    if(s.size()+1 == t.size()&& t.erase(t.size()-1,1) == s ){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

    cout << (char)(a[0] - 0x20) << (char)(b[0] - 0x20) << (char)(c[0] - 0x20) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    ll A[100001], B[100001], sum = 0;
    for(int i=0;i<N+1;i++){
        cin >> A[i];
        sum += A[i];
    }
    for(int i=0;i<N;i++)
        cin >> B[i];

    for(int i=N-1;i>=0;i--){
        // i+1番目の街
        if(B[i] >= A[i+1]){
            B[i] -= A[i+1];
            A[i+1] = 0;
        }else{
            A[i+1] -= B[i];
            B[i] = 0;
        }
        // i番目の街
        if(B[i] >= A[i]){
            B[i] -= A[i];
            A[i] = 0;
        }else{
            A[i] -= B[i];
            B[i] = 0;
        }
    }

    ll rem = 0;
    for(int i=0;i<N+1;i++)
        rem += A[i];

    cout << sum - rem << endl;

}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;
//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vi to[200005];

mint dfs(int v){
	mint res = 1;
	for(int u: to[v]){
		res *= dfs(u);
	}
	return res + 1;
}

int main(){
	int n; cin >> n;
	vector<pi> p(n); rep(i,n) cin >> p[i].first >> p[i].second;
	sort(p.begin(), p.end());
	set<pi> s;
	for(int i = n-1; i>=0; i--){
		int x = p[i].first, d = p[i].second;
		while(s.size() && s.begin()->first < x+d){
			to[i].push_back(s.begin()->second);
			s.erase(s.begin());
		}
		s.emplace(x, i);
	}
	mint ans = 1;
	for(auto x : s){
		int v = x.second;
		ans *= dfs(v);
	}
	cout << ans << endl;
}

Measured memory_bytes: 22144
import itertools

N, M = [int(x) for x in input().split()]

Nlist = [0]*N
Mlist = [0]*M
for n in range(N):
    Nlist[n] = (n+1) * 2

for m in range(M):
    Mlist[m] = (m+m+1) * 1
count = 0
for x in itertools.combinations(Nlist, 2):
    if (x[0] + x[1]) % 2 == 0:
        count = count + 1
for x in itertools.combinations(Mlist, 2):
    if (x[0] + x[1]) % 2 == 0:
        count = count + 1
print(count)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        int N = in.nextInt();
        int M = in.nextInt();
        int[][] A = new int[N][M];
        for (int i=0;i<N;i++) {
            for (int j=0;j<M;j++) {
                A[i][j] = in.nextInt()-1;
            }
        }

        boolean[][] flag = new boolean[N][M];
        long ans = 1_000_000_000_000_000L;
        for (int l=0;l<M;l++) {
            HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
            int max_val = 0;
            for (int i=0;i<N;i++) {
                for (int j=0;j<M;j++) {
                    // if (flag[i][A[i][j]]) continue;
                    if (flag[i][j]) continue;
                    if (map.containsKey(A[i][j])) {
                        map.put(A[i][j], map.get(A[i][j])+1);
                    } else {
                        map.put(A[i][j], 1);
                    }
                    max_val = Math.max(max_val, map.get(A[i][j]));
                    break;
                }
            }
            // out.println(max_val);
            ans = Math.min(ans, max_val);

            ArrayList<Integer> k = new ArrayList<Integer>(map.keySet());
            ArrayList<Integer> v = new ArrayList<Integer>(map.values());
            int max_key = 0;
            for (int j=0;j<v.size();j++) {
                if (v.get(j)==max_val) {
                    max_key=k.get(j);
                    break;
                }
            }
            // out.println(max_key);
            // for (int j=0;j<N;j++) {
            //     flag[j][max_key]=true;
            // }
            for (int i=0;i<N;i++) {
                for (int j=0;j<M;j++) {
                    if (A[i][j]==max_key) flag[i][j]=true;
                }
            }
        }
        out.println(ans);

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}


Measured memory_bytes: 37348
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e18;
const ll MOD = 1e9 + 7;

template <class T> void mySort(vector<T> &X, bool isAscending) {
  // 昇順
  if (isAscending) {
    sort(all(X));
  } else {
    // 降順
    sort(all(X), greater<T>());
  }
}

class BinaryIndexedTree {
  int N;
  vl bit;

public:
  BinaryIndexedTree(int N) {
    this->N = N;
    bit = vl(N);
  }

  // v[i] += w;
  void add(int i, int w) {
    for (int x = i; x < N; x |= x + 1) {
      bit[x] += w;
    }
  }

  // v[0] + ... + v[a-1]
  int sum(int a) {
    int ret = 0;
    for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) {
      ret += bit[x];
    }
    return ret;
  }
};

void solve(long long N, long long K, std::vector<long long> a) {
  vector<pll> acc(N + 1);
  acc[0] = mp(0, 0);
  ll sum = 0;
  rep(i, 0, N) {
    sum += a[i];
    acc[i + 1] = mp(sum - (i + 1) * K, i + 1);
  }

  mySort(acc, true);

  BinaryIndexedTree bit(N + 1);
  ll ans = 0;
  rep(i, 0, N + 1) {
    bit.add(acc[i].sc, 1);
    ans += bit.sum(acc[i].sc);
  }
  print(ans);
}

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


Measured memory_bytes: 6528
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();

        double a = x1 - x2;
        double b = y1 - y2;
        System.out.println(Math.sqrt(a*a + b*b));
    }
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n / 3 << endl;
    return 0;
}

Measured memory_bytes: 256
//#define DEBUG
#define MAXN 2000000000
#define ll long long int
#include <bits/stdc++.h>
using namespace std;

int main() {
#ifdef DEBUG
    freopen("in.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

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

    ll ans = a*c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    while(cin >> n >> k, n + k > 0)
    {
        vector<bool> a(n+1, 0);
        REP(i, k)
        {
            int x; cin >> x;
            a[x] = true;
        }

        int ans = 0;
        int cnt = 0;
        vector<vector<int>> dp(n+1, vector<int>(2, 0));

        REP(i, n)
        {
            if(a[i+1]) dp[i+1][0] = dp[i][0] + 1, dp[i+1][1] = dp[i][1] + 1;
            else dp[i+1][0] = 0, dp[i+1][1] = dp[i][0] + 1;

            ans = max({ans, dp[i+1][0], a[0] ? dp[i+1][1] : 0});
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 8448
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<vector<int> > xy(n, vector<int>(2));
  for (auto &x: xy) cin >> x[0] >> x[1];

  vector<int> perm(n);
  for (int i = 0; i < n; i++) perm[i] = i;
  double total = 0.0;
  int count = 0;
  do {
    for (int i = 0; i < n-1; i++) {
      total += sqrt((xy[perm[i+1]][0] - xy[perm[i]][0]) * (xy[perm[i+1]][0] - xy[perm[i]][0]) + (xy[perm[i+1]][1] - xy[perm[i]][1]) * (xy[perm[i+1]][1] - xy[perm[i]][1]));
    }
    count++;
  } while (next_permutation(perm.begin(), perm.end()));

  double ans = total / count;

  cout << setprecision(16) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;

vector<vector<int>> enuCmb(int n, int k) {
    vector<vector<int>> res;
    if (n==0 || k==0 || n<k) {
      	return res;
    } else { 
		res=enuCmb(n-1,k);
		vector<vector<int>> res1=enuCmb(n-1,k-1);
		rep(i,res1.size()) {
			res1[i].push_back(n-1);
			res.push_back(res1[i]);
		}
		if (k==1) {
			vector<int> ins={n-1};
			res.push_back(ins);
		}
		return res;
    }
}

int main() {
    ios_base::sync_with_stdio(false); 

    int n;
    cin >> n;
    vector<int> a(5);
    string b="MARCH";
    rep(i,n) {
        string t;
        cin >> t;
        rep(j,5) {
            if (t[0]==b[j]) ++a[j];
        }
    }
    vector<vector<int>> c=enuCmb(5,3);
    ll ans=0;
	rep(i,c.size()) {
        ll tans=1;
        rep(j,3) tans*=a[c[i][j]];
        ans+=tans;
	}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
double a, b, c, d;
int main(){
    scanf("%lf %lf %lf %lf",&a,&b,&c,&d);

    double e = 30 * c + d / 2, f = 6 * d;

    double k = abs(e - f);

    double A = sin(k * acos(-1) / 180) * a, B = b - a * cos(k * acos(-1) / 180);
    printf("%.10f",sqrt(A*A + B*B));
}

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

void solve(){
    ll n, m;
    cin >> n >> m;
    if(m < n){
        ll x = n/m;
        n -= m*x;
    }
    cout << min(n,m-n) << endl;
}

int main()
{
    //ll t; cin >> t; while(t--)
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lnt long long int
int main()
{
   lnt l,r;
   cin>>l>>r;
   if(r-l>2*2020)
   {

       cout<<0<<endl;
       return 0;
   }
   else
   {
       lnt ans=100000;
       for(int i=l;i<=r;i++)
       {
           for(int j=i+1;j<=r;j++)
           {

               lnt val = ((i%2019)*(j%2019))%2019;
               ans=min(ans,val);

           }
       }
       cout<<ans;
   }





}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  ll ai, ao, at, aj, al, as, az;
  cin >> ai >> ao >> at >> aj >> al >> as >> az;

  ll su = 0;
  su += ai / 2 * 2;
  su += aj / 2 * 2;
  su += al / 2 * 2;
  su += ao;
  if(ai % 2 && aj % 2 && al % 2) su += 3;
  else if(ai > 0 && aj > 0 && al > 0 && (ai % 2 + aj % 2 + al % 2) == 2) su += 1;

  cout << su << endl;

}








Measured memory_bytes: 3632
main(){float d,e,f,g,h,i,m,n,o,p,q;for(;~scanf("%f%f%f%f%f%f%f%f",&d,&e,&f,&g,&h,&i,&m,&n);puts(((f-d)*(n-e)-(m-d)*(g-e))*p>0&&p*q>0?"YES":"NO"))p=(h-f)*(n-g)-(m-f)*(i-g),q=(d-h)*(n-i)-(m-h)*(e-i);return 0;}

Measured memory_bytes: 0
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	set <char> S;
	string s;

	cin >> s;

	for(char ch : s) {
		S.insert(ch);
	}

	if (S.size() == 2)
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
a,b,c,x,y=list(map(int,input().split()))
temp=0
ans=float("Inf")
import math
while temp<=max(x,y)*2:
  xt=math.ceil(x-0.5*temp)
  yt=math.ceil(y-0.5*temp)
  ans=min(ans,max(0,xt)*a+max(0,yt)*b+temp*c)
  temp=temp+1
print(ans)

Measured memory_bytes: 3064