akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stack>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll; 
map<ll, ll> mp;
double a[10][2], s;
int n;
int main()
{
	while (~scanf("%d", &n))
	{
		s = 0;
		for (int i = 0; i < n; i++)
		{
			scanf("%lf%lf", &a[i][0], &a[i][1]);
			for (int j = 0; j < i; j++)
			{
				s += sqrt((a[i][0] - a[j][0]) * (a[i][0] - a[j][0]) + (a[i][1] - a[j][1]) * (a[i][1] - a[j][1]));
			}
		}
		printf("%.10lf\n", s * 2 / n);
	}
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T INF = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 2;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T>
istream& operator>>(istream& in, vector<T>& a) { for (T& x : a) cin >> x; }

void LOG(const int& x) { cerr << x << "\n"; }
void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }

int ceil(int a, int b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(vector<i64> v) { return accumulate(ALL(v), 1, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(vector<i64> v) { return v.empty() ? 0 : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }

class UnionFind {
private:
  vector<int> par;
  vector<int> rnk;
  int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
public:
  UnionFind(int size) { par.resize(size); rnk.resize(size); REP(i, size) par[i] = i, rnk[i] = 0; }
  void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; } }
  bool same(int x, int y) { return find(x) == find(y); }
};

struct InitCpp { InitCpp() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
} } initCpp;

signed main() {
  int n;
  cin >> n;
  vector<i64> v(n);
  cin >> v;
  cout << lcm(v) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INT long long int
#define oo 987654321
#define MOD 1000000007
using namespace std;
string s;
INT n, m, ans;
char x[200020], q[200020];
bool f(int v)
{
    for(int i = 0 ; v >= 0 and i < m ; i++ )
        if( s[v] == x[i] )
        {
            if( q[i] == 'L' ) v--;
            if( q[i] == 'R' ) v++;
        }
    return v < 0;
}
bool g(INT v)
{
    for(int i = 0 ; v < n and i < m ; i++ )
        if( s[v] == x[i] )
        {
            if( q[i] == 'L' ) v--;
            if( q[i] == 'R' ) v++;
        }
    return v > n-1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m>>s;
    for(int i = 0 ; i < m ; i++ ) cin>>x[i]>>q[i];
    INT lb = -1, rb = n, md;
    while( lb < rb )
    {
        md = (lb+rb+1)/2;
        if( f(md) ) lb = md;
        else rb = md-1;
    }
    ans = rb+1;
    lb = -1, rb = n;
    while( lb < rb )
    {
        md = (lb+rb-1)/2;
        if( g(md) ) rb = md;
        else lb = md+1;
    }
    ans += ((n-1)-lb+1);
    ans = n-ans;
    if( ans < 0 ) ans = 0;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 976
from collections import defaultdict
from math import gcd
import time
import sys
from collections import Counter
import itertools
import math
# read = sys.stdin.buffer.read
# readline = sys.stdin.buffer.readline
# readlines = sys.stdin.buffer.readlines
input = sys.stdin.readline

H1, M1, H2, M2, K = map(int, input().split(' '))

length = (H2*60+M2)-(H1*60+M1)

if length > K:
    print(length-K)
else:
    print(0)


Measured memory_bytes: 9496
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, k, x, y; cin >> n >> k >> x >> y;
    if(n <= k) cout << n*x << endl;
    else cout << k*x + (n-k)*y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int N;
	cin>>N;
	
	vector<long long> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	vector<long long> s(N+1,0),x(N+1,0);
	
	for(int i=0;i<N;i++){
		s[i+1] = s[i] + A[i];
		x[i+1] = x[i] ^ A[i];
	}
	
	long long ans = 0;
	
	for(int i=N;i>0;i--){
		int ok = i-1;
		int ng = -1;
		while(ok-ng>1){
			int mid = (ok+ng)/2;
			long long S = s[i] - s[mid];
			long long X = x[i] ^ x[mid];
			if(S==X)ok=mid;
			else ng=mid;
		}
		ans += (long long)i - ok;
	}
	
	cout<<ans<<endl;			
	
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,x,y,m,n;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
	x=a*p;
	m=p-c;
	n=d*m;
	if(p<=c){
		y=b;
	}
	else if(c<=p){
		y=b+n;
	}
	if(x<=y){
		printf("%d\n",x);
	}
	else if(y<=x){
		printf("%d\n",y);
	}
	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a+b)%2) cout << "IMPOSSIBLE" << endl;
  else  cout << (a+b)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,gcd,lcm,status,temp;
	while(1){
		status=scanf("%d%d",&a,&b);
		
		if (status==EOF) break;
		
		if (a>b){
			temp=b;
			b=a;
			a=temp;
		}
		
		gcd=a;
		
		while(gcd%b!=0){
				gcd+=a;
		}
		
		lcm=(int)(1.0*a*b/gcd);
		
		if (a*b==gcd)lcm=1;
		if (a==gcd) lcm=b;

		printf ("%d %d\n",lcm,gcd);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;

unordered_map<ll,ll> pos;
unordered_map<ll,ll> neg;
int main( ){
    int n;
    cin>>n;
    ll a[n];
    set<ll> s;
    rep(i,0,n){
        cin>>a[i];
        pos[a[i]+1+i]++;
        neg[(1+i)-a[i]]++;
        s.insert(a[i]+(i+1));
    }
    ll ans=0;
    for(ll v:s){
        ans+=pos[v]*neg[v];
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 36520
n = int(input())
s = list(input())

ans = 0

if (len(s) % 2) == 1:
    ans = 1
else:
    length = int(len(s)/2)
    for i in range(length):
        if s[i] != s[i + length]:
            ans = 1
            break

if ans == 1:
    print('No')
else:
    print('Yes')




Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  bool judge = true;
  for(int i = 0;i < n;i++){
    cin >> s[i];
    if(i > 0){
      if(s[i-1][s[i-1].size()-1] != s[i][0]) judge = false;
    }
  }
  if(judge == true){
    sort(s.begin(),s.end());
    for(int i = 1;i < n;i++){
      if(s[i] == s[i-1]) judge = false;
    }
  }
  if(judge == true)cout << "Yes" << endl;
  else cout << "No" << endl;
}
    

Measured memory_bytes: 256
//package cp;
import java.util.*;
import java.io.*;
import java.math.*;;
public class Main{
	BigInteger bi1=new BigInteger("2");//initialize as string
//	1.BigInteger bi=new BigInteger(Readers.next());- take input as biginteger
	StringBuilder sb=new StringBuilder();
//	2.StringBuilder temp=new StringBuilder(str[i-1]);
//	3.String rev=temp.reverse().toString(); convert sb to string
//	4.if(str[i].compareTo(rev)>=0)minn=0;-compare two Strings
//  5.(Initialize as string) - (a.add(b)) - (array initialized with null and not 0)
	Integer[] ARRE=new Integer[5];//Integer sort-TLE-Initialize object elements i.e a[0].
	static final int mod1 = 1000000007;//or 1e9+7
//	6.System.exit(0); to exit from code....esp in recur 
	long gcd(long a,long b) {if(b==0)return a;else return gcd(b,a%b);}
	long ceil(double d) {return (long)Math.ceil(1.0*d);}
	int ch_int(char c) {return Integer.parseInt(String.valueOf(c));}//change char to Integer
	String ch_str(char c) {return String.valueOf(c);}
	String int_str(int num) {return Integer.toString(num);}
	void divisor(long n,int start) {
		int cnt=0;for(int i=start;i<=Math.sqrt(n);i++) {
		if(n%i==0) {if(i==n/i)cnt++;else cnt+=2;}}}
	public static void main(String[] args) throws IOException {
		PrintWriter out = new PrintWriter(System.out);
		Readers.init(System.in);
		//Cf_fiv obj=new Cf_fiv();
		int n=Readers.nextInt();
		long[] a=new long[n];
		for (int i = 0; i < n; i++) {
			a[i]=Readers.nextLong();
		}
		Arrays.sort(a);
		long cnt=0;
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j <n; j++) {
				for (int k = j+1; k < n; k++) {
					if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i]) {
//						System.out.println(i+" "+j+" "+k);
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
		out.flush();
	}

}
class Readers {
	 
    static BufferedReader reader;
 
    static StringTokenizer tokenizer;
 
 
 
    /** call this method to initialize reader for InputStream */
 
    static void init(InputStream input) {
 
        reader = new BufferedReader(
 
                     new InputStreamReader(input) );
 
        tokenizer = new StringTokenizer("");
 
    }
 
 
 
    /** get next word */
 
    static String next() throws IOException {
 
        while ( ! tokenizer.hasMoreTokens() ) {
 
            //TODO add check for eof if necessary
 
            tokenizer = new StringTokenizer(
 
                   reader.readLine() );
 
        }
 
        return tokenizer.nextToken();
 
    }
 
 
 
    static int nextInt() throws IOException {
 
        return Integer.parseInt( next() );
 
    }
 
	
 
    static double nextDouble() throws IOException {
 
        return Double.parseDouble( next() );
 
    }
    
    
    static long nextLong() throws IOException{
    	
		return Long.parseLong(next());
	}
 
}


Measured memory_bytes: 33516
n=int(input())
A=list(map(int,input().split()))
count=0
for i in range(len(A)-2):
    if A[i]> A[i+1] and A[i+1]>A[i+2]:
        count+=1
    elif A[i]< A[i+1] and A[i+1]<A[i+2]:
        count+=1
print(count)

Measured memory_bytes: 3316
package main

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

func main() {
	A := nextInt()
	B := nextInt()

	now := time.Date(0, 0, 0, A, 0, 0, 0, time.UTC)
	fmt.Println(now.Add(time.Duration(B) * time.Hour).Hour())
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

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

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	if x < y {
		return x
	}

	return y
}

// ---------- Util.


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x7f7f7f7f7f7f7f7f;
int main() {
    int n;
    cin >> n;
    long long x, y;
    long long a = -INF, b = INF, c = -INF, d = INF;
    for (int i = 1; i <= n; i++) {
        cin >> x >> y;
        a = max(a, x + y);
        b = min(b, x + y);
        c = max(c, x - y);
        d = min(d, x - y);
    }
    cout << max(a - b, c - d) << '\n';
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 2e5 + 100;
int n;
int SL[21];
int a[N];
void nhap()
{
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        //cout << S[i] << " " << X[i] << '\n';
    }
}
void xoa(int x) {
    for (int i = 20; i >= 0; i--) {
        int bit = (1 & (x >> i));
        if (bit) {
            SL[i]--;
        }
    }
}
void add(int x) {
    for (int i = 20; i >= 0; i--) {
        int bit = (1 & (x >> i));
        if (bit) {
            SL[i]++;
        }
    }
}
bool check() {
    for (int i = 20; i >= 0; i--) {
        if (SL[i] > 1) {
            return false;
        }
    }
    return true;
}
//void vet() {
//    xuat(8);
//    xuat(1);
//    xuat(128);
//    //cout << (892 ^ 885);
//    for (int j = 1; j <= n; j++) {
//        for (int i = 1; i < j; i++) {
//            int S1 = X[j] ^ X[i - 1];
//            int S2 = S[j] - S[i - 1];
//            if ((X[j] ^ X[i - 1]) == (S[j] - S[i - 1])) {
//                //cout << X[j] << " " << X[i] << " " << S[j] << " " << S[i - 1] << " " << i << " " << j << '\n';
//                cout << i << " " << j << '\n';
//            }
//        }
//    }
//}
void solve()
{
    add(a[1]);
    int L = 1;
    long long Res = 1;
    for (int i = 2; i <= n; i++) {
        add(a[i]);
        while (check() == false) {
            xoa(a[L++]);
        }
        Res += (i - L + 1);
    }
    cout << Res;
}
int main()
{
    nhap();
    //vet();
    solve();
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int num=scan.nextInt();
 int numm=scan.nextInt();
  int nummm=scan.nextInt();
  
  if(num+numm+nummm>=22){
  System.out.println("bust");
  }else{
  System.out.println("win");
  }
}
}

Measured memory_bytes: 21844
import sys

for line in sys.stdin:
    try:
        a,b,c = [int(x) for x in line.split()]
        if (a**2+b**2) == c**2:
            print('YES')
        elif (a**2+c**2) == b**2:
            print('YES')
        elif (b**2+c**2) == a**2:
            print('YES')
        else:
            print('NO')
    except(ValueError):
        continue
    

Measured memory_bytes: 7748
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S, T; cin >> S >> T; 
	int s = S.size(); int t = T.size();
	int ans = 114514;  
	for(int i = 0; i <= s-t; i++){
		int ch = 0; 
		for(int j = 0; j < t; j++){
			if(S.at(i+j) != T.at(j)) ch ++; 
		}
		ans = min(ch, ans); 
	}
	cout << ans << "\n"; 
}

Measured memory_bytes: 3600
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------
int main(void)
{

	int n, r;

	cin >> n >> r;

	if (n > 10)
	{
		cout << r << endl;
		return 0;
	}

	cout << r + 100 * (10 - n) << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int R, C;
int A[10][10000];
int ans;
int B[10];
int D[10000];
int main()
{
	while (true){
		ans = 100000;
		scanf("%d%d", &R, &C);
		if (R == 0 && C == 0)break;
		for (int i = 0; i < R; i++){
			for (int j = 0; j < C; j++){
				scanf("%d", &A[i][j]);
			}
		}
		for (int i = 0; i < (1 << R); i++){
			int SS = 0;
			for (int j = 0; j < R; j++){
				B[j] = (i >> j) & 1;
			}
			for (int j = 0; j < R; j++){
				if (B[j] == 1){
					for (int k = 0; k < C; k++){
						if (A[j][k] == 1)A[j][k] = 0;
						else A[j][k] = 1;
					}
				}
			}
			for (int k = 0; k < C; k++){
				int sum = 0;
				for (int j = 0; j < R; j++)sum += A[j][k];
				SS += min(sum, R - sum);
			}
			for (int j = 0; j < R; j++){
				if (B[j] == 1){
					for (int k = 0; k < C; k++){
						if (A[j][k] == 1)A[j][k] = 0;
						else A[j][k] = 1;
					}
				}
			}
			ans = min(ans, SS);
		}
		printf("%d\n", R*C - ans);
	}
	return 0;
}

Measured memory_bytes: 1584
#include <iostream>

using namespace std;

int main()
{
   int n,k,c=0;
   cin>>n>>k;int a[n];
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   for(int i=0;i<n;i++)
   {
       if(a[i]>=k)
        c++;
   }
   cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 640
N, C = gets.split.map(&:to_i)

max_t = 10**5
 
programs =  Array.new(C){ Array.new(max_t+1, false) }
 
N.times do |i|
  s, t, c = gets.split.map(&:to_i)
  c -= 1
  (s..t).each { |j| programs[c][j] = true }
end

ans = 0
(1..max_t).each do |i|
  tmp = 0
  C.times{ |j| tmp += 1 if programs[j][i] }
  ans = tmp if ans < tmp
end
 
puts ans

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

int main()
{
    int p, q, r;
    cin >> p >> q >> r;
    int pq = p + q;
    int qr = q + r;
    int rp = r + p;

    int minvar = min(pq, min(qr, rp));

    cout << minvar << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j); i <= (int) (k); ++i)
#define Rep(i, j, k) for(R int i = (j); i >= (int) (k); --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 100011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit(ch); dd) f ^= (ch == '-');
		for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write ( ll x ) {
		if (x < 0) x = -x, putchar('-');
		if (x > 9) write(x / 10); putchar(x % 10 | 48);
	}

	inline void wrn ( ll x ) { write(x), putchar(' '); }

	inline void wln ( ll x ) { write(x), putchar('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	ll n;
	
	struct Node {
		ll x, id;
	} a[N];
	
	inline bool cmp ( Node a, Node b ) { return a.x < b.x; }
	
	int main() {
		n = read();
		For ( i, 1, n ) a[i].x = read(), a[i].id = i;
		sort(a + 1, a + n + 1, cmp);
		For ( i, 1, n ) cout << a[i].id << " ";
		return 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	return Cesare :: main();
}

/*

*/






Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
using namespace std;

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

	long long N, temp, C = 0;
	vector<long long> monsters, bravers;

	cin >> N;

	REP(i, N + 1)
	{
		cin >> temp;
		monsters.push_back(temp);
	}
	REP(i, N)
	{
		cin >> temp;
		bravers.push_back(temp);
	}

	REP(i, N + 1)
	{
		if (i > 0)
		{
			if (bravers[i - 1] > 0)
			{
				if (monsters[i] > bravers[i - 1])
				{
					C += bravers[i - 1];
					monsters[i] -= bravers[i - 1];
					bravers[i - 1] = 0;
				}
				else if (monsters[i] <= bravers[i - 1])
				{
					C += monsters[i];
					monsters[i] = 0;
				}
			}
		}
		if (i < N && monsters[i] != 0)
		{
			if (monsters[i] <= bravers[i])
			{
				C += monsters[i];
				bravers[i] -= monsters[i];
				monsters[i] = 0;
			}
			else if (monsters[i] > bravers[i])
			{
				C += bravers[i];
				monsters[i] -= bravers[i];
				bravers[i] = 0;
			}
		}
	}

	cout << C << endl;

	return 0;
}

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

int n,k,p;
int a[100010];
bool flag1=false,flag2=false;

int now,fh;char ch;
inline int get_num()
{
	now=0;fh=1;ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')fh=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){now=(now<<1)+(now<<3)+ch-'0';ch=getchar();}
	return now*fh;
}

inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}

int main()
{
	n=get_num();k=get_num();
	a[1]=get_num();p=a[1];
	for(int i=2;i<=n;i++)
	{
		a[i]=get_num();
		p=gcd(p,a[i]);
	}
    sort(a+1,a+n+1);
    if(k%p!=0)
    {
    	puts("IMPOSSIBLE");
    	return 0;
	}
    for(int i=n;i>=1;i--)
    {
    	if(a[i]>=k)
    	{
    		if(a[i]%p==0)
    		{
    			puts("POSSIBLE");
    			return 0;
			}
		}
		else
		{
			puts("IMPOSSIBLE");
    		return 0;
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

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

int N, M;
#define MAXN 100000
long long B[MAXN], C[MAXN];
typedef tuple<pair<long long, int>, int, int> T;
vector<T> E;

int Rank[MAXN], Par[MAXN], Boss[MAXN];
vector<int> Kids[MAXN]; int Root;

typedef pair<long long, long long> P;

void init() {
  for(int v = 0; v < N; ++v) {
    Rank[v] = 0; Par[v] = Boss[v] = v;
  }
}
int find(int v) {
  if(Par[v] == v) return v;
  else return Par[v] = find(Par[v]);
}
void unite(int u, int v) {
  u = find(u); v = find(v);
  if(u == v) return;
  if(Rank[u] > Rank[v]) swap(u, v);
  Par[u] = v;
  if(Rank[u] == Rank[v]) ++Rank[v];
  if(make_pair(C[Boss[u]], Boss[u])
      > make_pair(C[Boss[v]], Boss[v])) {
    Kids[Boss[u]].push_back(Boss[v]);
    Boss[v] = Boss[u];
  } else {
    Kids[Boss[v]].push_back(Boss[u]);
  }
  Root = Boss[v];
}

P dp(int v) {
  long long b = B[v];
  vector<P> ps;
  for(int w : Kids[v]) {
    auto p = dp(w);
    ps.push_back(p); b += p.second;
  }
  long long q = C[v] + b;
  for(int i = 0; i < (int)ps.size(); ++i) {
    q = min(q, max(ps[i].first, C[v]) + b - ps[i].second);
  }
  return {q, b};
}

int main() {
  cin >> N >> M;
  for(int v = 0; v < N; ++v) {
    long long a, b; cin >> a >> b;
    B[v] = b; C[v] = max(a - b, 0LL);
  }
  for(int e = 0; e < M; ++e) {
    int u, v; cin >> u >> v; --u; --v;
    E.emplace_back(
      max(make_pair(C[u], u), make_pair(C[v], v)),
      u, v);
  }
  sort(E.begin(), E.end());
  init();
  for(int e = 0; e < M; ++e) {
    unite(get<1>(E[e]), get<2>(E[e]));
  }
  cout << dp(Root).first << endl;
  return 0;
}


Measured memory_bytes: 16496
#include<iostream>
int n=1<<18,p[1<<18],i,j;int main(){p[1]=1;for(;++i<n;)if(!p[i]){for(j=i*2;j<n;j+=i)p[j]=1;}for(;std::cin>>n,i=n;){for(j=0;++i<=2*n;)if(!p[i])j++;std::cout<<j<<std::endl;}return 0;}

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

if ((a == 7) & (b == 5) & (c == 5)) | ((a == 5) & (b == 7) & (c == 5)) | ((a == 5) & (b == 5) & (c == 7)):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 38384
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    l = list(map(int, input().split()))
    res = 0
    l.sort()
    for i in range(0, 2*n, 2):
        res += l[i]
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <stdio.h>

typedef long long ll;

ll t[200005];

int main() {

	ll N, T;

	scanf("%lld %lld",&N,&T);

	ll i;

	for (i = 0ll; i < N; i += 1ll) {
		scanf(" %lld",&t[i]);
	}

	ll ans = 0ll;
	for (i = 0ll; i < N-1; i += 1ll) {
		if (t[i + 1] - t[i] <= T) {
			ans += t[i + 1] - t[i];
		}
		else {
			ans += T;
		}
	}
	ans += T;

	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void)
{
	long long int x,ans=1,a,b;
	scanf("%lld",&x);

	a=x/11; b=x%11;
	
	if(b>6)	
		ans++;
	if(b==0)
		ans=0;
	if(a>0)
		ans+=a*2;

	printf("%lld\n",ans);
	return 0;
}

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

// 引数をそれぞれN円, 1円玉A枚として、割り切れたらtrueを返す関数
bool judge_division(int, int);

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

  if(judge_division(N, A))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

  return 0;
}

bool judge_division(int N, int A)
{
  int remain = N % 500; // N円と500円の剰余

  if(remain > A)
    return false;
  else
    return true;
}


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

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	string S;cin>>S;
	ll Q;cin>>Q;
	// printf("%s\n", S.c_str());

	// 解法
	ll turn = 1;
	string header = "";
	string footer = "";
	REP(i,Q){
		ll t;cin>>t;
		if (t==1) turn *= -1;
		else{
			ll f;cin>>f;
			string c;cin>>c;
			// printf("f: %lld c: %s\n", f, c.c_str());
			if (turn==1 & f==1) header += c; // 末尾に追加
			else if (turn==1 & f==2) footer += c;
			else if (turn==-1 & f==1) footer += c;
			else header += c;
		}
		// printf("%lld, %s\n", i, S.c_str());
	}
	string ans;
	if (turn==-1){
		REP(i, footer.size()){
			ans += footer.substr(footer.size()-i-1, 1);
		}
		REP(i, S.size()){
			ans += S.substr(S.size()-i-1, 1);
		}
		ans += header;
	}
	else{
		REP(i, header.size()){
			ans += header.substr(header.size()-i-1, 1);
		}
		ans += S + footer;
	}

	//出力
	// printf("%s\n",header.c_str());
	// printf("%s\n", footer.c_str());
	printf("%s\n", ans.c_str());
}


Measured memory_bytes: 1476
import scala.annotation.tailrec

object Main extends App {
  val n = io.StdIn.readInt()

  @tailrec
  def searchRec(i: Int): Int = {
    if (i == 0) 0
    else {
      val sqrt = math.sqrt(i)
      if (sqrt - sqrt.toInt == 0) i else searchRec(i - 1)
    }
  }

  println(searchRec(n))
}

Measured memory_bytes: 25532
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }

int main(void){
	uint32_t a=nextpint();
	uint32_t b=nextpint();
	uint32_t h=nextpint();
	uint32_t m=nextpint();
	double sa = M_PI*2/12*h+M_PI*2/12/60*m;
	double sb = M_PI*2/60*m;
	double dx = a*sin(sa) - b*sin(sb);
	double dy = a*cos(sa) - b*cos(sb);
	double ans = hypot(dx, dy);
	printf("%.9lf\n", ans);
}


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

int main(){

    int n;
    cin >> n;
    
    int ans = 0;
    const int coin[] = {25, 10, 5, 1};
    // 大きいコインからやるだけ
    for(int i = 0; i < 4; ++i){
        if(coin[i] <= n){
            ans += n / coin[i];
            n = n % coin[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> Pair;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll INFL = 1e18;


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    ans = n*(n-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        List<Integer> aList = new ArrayList<Integer>();
        for (int i=0; i<N; i++) {
            aList.add(Integer.parseInt(sc.next()));
        }

        int AorB = 0;
        int sumA = 0;
        int sumB = 0;
        int aLength = N;

        for (int i=0; i<N; i++) {
            int flag = 0;
            for (int j = 0; j<aLength; j++) {
                if (aList.get(j) > flag) {
                    flag = aList.get(j);
                }
            }
            aList.remove(aList.indexOf(flag));
            aLength -= 1;
            if (AorB == 0) {
                AorB = 1;
                sumA += flag;
            } else {
                AorB = 0;
                sumB += flag;
            }
        }

        System.out.println(sumA - sumB);
    }
}


Measured memory_bytes: 21712
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), ans = 0;
		double T = sc.nextDouble(), A = sc.nextDouble(), H[] = new double[N], min = Double.MAX_VALUE;
		for (int i = 0; i < N; ++i) {
			H[i] = sc.nextDouble();
			H[i] = T - H[i] * .006;
			if (Math.abs(A - H[i]) < min) {
				min = Math.abs(A - H[i]);
				ans = i + 1;
			}
		}
		sc.close();
		System.out.print(ans);
	}
}

Measured memory_bytes: 28628
// ProblemURL : https://atcoder.jp/contests/abc096/tasks/abc096_a
// ---------------------------------------------
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	ans := -1
	if a > b {
		ans = a - 1
	} else {
		ans = a
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int mod = 1e9 + 7;

int rec(int r, int c, string *maze, int **dp, int h, int w) {
  if (r == h - 1 and c == w - 1)
    return dp[r][c] = 1;

  if (r == h or c == w)
    return 0;

  if (dp[r][c] != -1)
    return dp[r][c];

  if (maze[r][c] == '#')
    return dp[r][c] = 0;

  int temp =
      (rec(r + 1, c, maze, dp, h, w) + rec(r, c + 1, maze, dp, h, w)) % mod;
  return dp[r][c] = temp;
}

int main(int argc, char const *argv[]) {

  int h, w;
  cin >> h >> w;
  string *maze = new string[h];
  for (int i = 0; i < h; i++) {
    cin >> maze[i];
  }

  int **dp = new int *[h];
  for (int i = 0; i < h; i++) {
    dp[i] = new int[w];
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      dp[i][j] = -1;
    }
  }

  cout << rec(0, 0, maze, dp, h, w) << endl;

  for (int i = 0; i < h; i++) {
    delete[] dp[i];
  }
  delete[] dp;
  return 0;
}


Measured memory_bytes: 5376
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int c = Integer.parseInt(br.readLine());
			String[] v = br.readLine().split(" ");

			long min = Long.MAX_VALUE;
			long max = Long.MIN_VALUE;
			long sum = 0;

			for (int i = 0; i < c; i++) {
				long n = Long.parseLong(v[i]);
				min = Math.min(n, min);
				max = Math.max(n, max);
				sum += n;
			}

			System.out.println(min + " " + max + " " + sum);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 28520
#include<bits/stdc++.h>
using namespace std;
int n,k;
vector<int> a;
main(){
	cin>>n>>k;
	int sum=0;
	for(int i=0;i<n;i++){
		int c;
		cin>>c;
		if(abs(c-k)>abs(c)) sum+=2*c;
		else sum+=(k-c)*2;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int n;
    scanf("%d", &n);
    int t, a;
    scanf("%d %d", &t, &a);
    int h[1003];
    int i;
    for (i = 0; i < n; i++)
        scanf("%d", &h[i]);
    int ans = 0;
    double min = 2000000000;
    double k;
    for (i = 0; i < n; i++)
    {
        k = t - 0.006*h[i];
        if (min > fabs(a - k))
        {
            min = fabs(a - k);
            ans = i;
        }
    }
    ans++;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int>P;


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

	int ans = 0;
	int flag = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'C')ans++;
		if (ans > 0) {
			if (s[i] == 'F') {
				flag = 1;
				break;
			}
		}
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        aa: [usize; n],
    }
    let ans = aa.iter().fold(0, |v1, v2| v1 + v2 - 1);
    println!("{}", ans);
}


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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cout.precision(10);               \
	cout << fixed;
#define int long long int
#define pb push_back
#define endl "\n"
#define all(a) a.begin(), a.end()
#define N 500009
#define M 1000009
#define mod 1000000007
int powi(int a,int b){if (b == 0)return 1;int see = powi(a, b / 2);see *= see;see %= mod;if (b % 2)see *= a;see %= mod;return see;}

int n,m;
int dp[1<<13];
int val[1009];
int key[1009];
int v[1009];

void pre()
{
	memset(v, 0, sizeof(v));
	dp[0] = 0;
	int x;
	for (int i = 0; i < m; i++)
	{
		cin >> val[i] >> key[i];
		for (int j = 0; j < key[i]; j++)
		{
			cin >> x;
			x--;
			v[i] = (v[i] | (1 << x));
		}
	}
}

int32_t main()
{
	IOS;
	cin >> n >> m;
	pre();
	for (int i = 1; i < (1 << n); i++)
	{
		dp[i] = INT_MAX;
		for (int j = 0; j < m; j++)
		{
			dp[i] = min(dp[i], dp[(i ^ v[j]) & i] + val[j]);
		}
	}
	if (dp[(1 << n) - 1] == INT_MAX)
	{
		cout << "-1\n";
		return 0;
	}
	cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 384
/*
この問題で知らなかった知識・得られた教訓をまとめる

スタート前に盤面をある程度操作できるとき:
・経路を一つ固定して, その経路が条件を満たすための最小回数を求めてみる
・そのときに必要となった操作・アイデアを他の経路にも当てはめてみる
・色を反転させる系の問題では, 色と色の境界を考える, というタイプの問題はよく出る　

*/


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
const long long INF = 1LL<<60;

int H, W;
vector<vector<char>> grid(1010, vector<char>(1010));
vector<vector<long long>> numberOfOperation(1010, vector<long long>(1010,INF));
vector<int> dx = {1,0};
vector<int>  dy = {0,1};

long long solve(){
    
    if (grid[0][0] == '#') numberOfOperation[0][0] = 1;
    else numberOfOperation[0][0] = 0;
    
    for(int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            for (int k = 0; k < 2; k++){
                
                int nx = i + dx[k];
                int ny = j + dy[k];
                if (nx >= H || ny >= W) continue;
                
                if (grid[i][j] == '.' && grid[nx][ny] == '#') numberOfOperation[nx][ny] = min(numberOfOperation[nx][ny], numberOfOperation[i][j] + 1);
                else numberOfOperation[nx][ny] = min(numberOfOperation[nx][ny], numberOfOperation[i][j]);
            }
        }
    }
    
    return numberOfOperation[H-1][W-1];
}

int main(void){
    cin >> H >> W;
    
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++) cin >> grid[i][j];
    }
    
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 9344
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
using namespace std;

int main() {

	int res = 0;
	int mycol = 100000;
	int count = 1;
	int N; 
	int a[10000]; cin >> N;
	for (int i = 1; i <= N; i++) cin >> a[i];

	for (int j = 1; j <= N; j++) {

		if (mycol == a[j]) ++count; else { 
			mycol = a[j]; 
		    res += (count) / 2;
		    count = 1;
		}

	}

    res += count / 2;
    
	cout << res << endl;

}

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



int main(){
  int N;cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++) cin>>a.at(i);
  ll res=0;
  
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      res+=a.at(i)*a.at(j);
    }
  }
  
  cout<<res;
}
  
  

Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int a = cin.ni();
        int b = cin.ni();
        int c = cin.ni();

        Console.WriteLine(a + b == c ||
            a + c == b ||
            b + c == a ? "Yes" : "No");
    }
}


public class cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public static int ni() {
        return int.Parse(next());
    }

    public static long nextLong() {
        return long.Parse(next());
    }

    public static double nextDouble() {
        return double.Parse(next());
    }

}


Measured memory_bytes: 2648
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int a,b; cin >> a >> b;
    if(a + b >= 24){
        cout << (a+b) % 24 << endl;
    }else{
        cout << a + b << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
    int i=0;
    for(int j=0; j<k; j++) {
        llong s=0;
        while(s+T[i] <= P) {
            s += T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve() {
    llong left=0;
    llong right=100000 * 10000;
    llong mid;
    while(right-1>left) {
        mid = (left + right)/2;
        int v = check(mid);
        if(v>=n) right=mid;
        else left=mid;
    }
    
    return right;
}

int main() {
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3876
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n,d; cin >>n>>d;
    vector<vector<int> > x(n, vector<int>(d)); REP(i,n) REP(j,d) cin >> x[i][j];

    int count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1 ; j < n; j++) {
            int res = 0;
            for (int k = 0; k < d; k++) {
                res += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            for (int s = 1; s < 150; s++) {
                if (res == s*s) {
                    count++;
                    break;
                } 
            }
        }
    }

    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 #define int long long
 #define ll long long
 #define pa pair<int,int>
  #define  mp make_pair
  #define  pb push_back
 using namespace std;


ll extgcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0ll) {
        x = 1ll;
        y = 0ll;
        return a;
    }
    ll d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

ll modinv(ll r,ll mo){// mod mo での r の逆数 ないときは-1
	// r*x +mo*r = 1
	
	ll aa,bb;
	ll gc=extgcd(r,mo,aa,bb);
	if(gc!=-1){
	//	cout<<-1<<endl;
	}
	if(gc!=1) return -1;
	aa%=mo;
	if(aa<0)aa+=mo;
	
	return aa;
}


ll garner(vector<pair<ll,ll>> vec){
	// vec[i]: x % vec[i].first == vec[i].second
	// 0<= vec[i].second<vec[i].first
	
	// vec[i].first はどの2つも互いに素！！！！
	// MOD はどうでもいい
	vec.pb({0ll,0ll});
	
	int siz=vec.size();
	
	vector<ll> ruiseki(siz,1ll);
	vector<ll> teisuu(siz,0ll);
	
	ll val;
	for(int i=0;i<siz-1;i++){
	
		// (teisuu[i] + val*ruiseki[i]) % vec[i].first = vec[i].second
		
		val= (ll)vec[i].second-teisuu[i];
		while(val<0) val+=(ll)vec[i].first;
		val%=(ll)vec[i].first;
		val*= modinv(ruiseki[i],(ll)vec[i].first);
		val%=(ll)vec[i].first;
	
		
		for(int j=i+1;j<siz;j++){
			teisuu[j]+=(ll)ruiseki[j]*val;
			if(j<siz-1)teisuu[j]%=(ll)vec[j].first;
	//		cout<<teisuu[j]<<endl;
			ruiseki[j]*=(ll)vec[i].first;
			if(j<siz-1)ruiseki[j]%=(ll)vec[j].first;
		}
	}
	return teisuu.back();
	
	
}



 signed main(){
 	
 
    cin.tie(0);
	ios::sync_with_stdio(false);
	
 	int n;
 	cin>>n;
 	 	vector<int> p(n),q(n);
 	for(int i=0;i<n;i++){
 		cin>>p[i];
 		p[i]--;
 	}
 	for(int i=0;i<n;i++){
 		cin>>q[i];
 		q[i]--;
 	}
 	vector<pa> ve;
 	for(int i=0;i<n;i++){
 		
 		int v=p[i];
 		int cnt=0;
 		int mo=-1;
 		while(1){
 			
 			if(v==i){
 				mo=cnt;
 			}
 			
 			cnt++;
 			v=q[v];
 			if(v==p[i]){
 				break;
 			}
 		}
 		if(mo==-1){
 			cout<<-1<<endl;
 			return 0;
 		}
 		
 		if(cnt>1)ve.pb(mp(cnt,mo));
 	//	cout<<cnt<<" "<<mo<<endl;
 	}
 	if(ve.size()==0){
 		cout<<0<<endl;
 		return 0;
 	}
 	sort(ve.begin(),ve.end());
 	int m=ve.size();
 	vector<pa> ve2;
 	ve2.pb(ve[0]);
 	for(int i=1;i<m;i++){
 		if(ve[i].first==ve[i-1].first){
 		if(ve[i].second!=ve[i-1].second){
 			cout<<-1<<endl;
 			return 0;
 		}
 		}
 		else ve2.pb(ve[i]);
 	}
 	swap(ve,ve2);
	
 	int ma=1;
 	 m=ve.size();
 	for(auto v:ve){
 	//	cout<<v.first<<" "<<v.second<<endl;
 		 ma=v.first/__gcd(v.first,ma)*ma;
 	}
 	
 	vector<pa> qu;
 	for(int i=2;i<=n;i++){
 	
 		bool bo=1;
 		for(int j=2;j<i;j++){
 			if(i%j==0){
 				bo=0;
 				break;
 			}
 		}
 		if(!bo) continue;
 		
 		// i is prime
 		int ind=-1,cnt=-1; 
 		for(int j=0;j<m;j++){
 			int f=1;
 			int ee=ve[j].first;
 			while(ee%i==0){
 				f*=i;
 				ee/=i;
 			}
 			if(cnt<f&&f>1){
 			
 				cnt=f;
 				ind=j;
 			}
 			
 		}
 		if(cnt>1){
 			qu.pb(mp(cnt,ve[ind].second%cnt));
 		}
 	}
 	
 	int ans=garner(qu);
// 	cout<<ans<<endl;
 	for(auto v:ve){
 		if(ans%v.first!=v.second){
 			cout<<-1<<endl;
 			return 0;
 		}
 	}
 	cout<<ans<<endl;
 	
return 0;

 }


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); i++) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 10000000000000;


//queue
int main() {
    ll k;
    cin >> k;
    queue<ll> q;
    for (int i=1; i<10; i++){
        q.push(i);
    }
    ll x = 0;
    rep(i,k){
        x = q.front(); q.pop();
        ll d = x%10;
        if (d != 0) q.push(10*x + d-1);
        q.push(10*x + d);
        if (d != 9) q.push(10*x + d+1);
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

int main() {
    int n, p, ch = 0;
    ll ans = 1;
    cin >> n >> p;
    for (int i = 1; i <= n; ++i) {
        int a;
        cin >> a;
        if (a&1) ch = 1;
        ans *= 2;
    }
    if (ch) cout << ans / 2 << endl;
    else if (p) cout << 0 << endl;
    else        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 





int main(void){
    ll n;
    string s;
    cin>>n;
    cin>>s;
    ll ans = 1;
    ll num = 0;
    for(ll i=0;i<2*n;i++){
        if((2*n-1-i)%2==1){
            if(s[i]=='B')num++;
            else{
                ans = ans*num;
                ans = ans%N;
                num--;
            }
        }
        else{
            if(s[i]=='W')num++;
            else{
                ans = ans*num;
                ans = ans%N;
                num--;
            }
        }
    }
    if(num!=0){
        cout<<0<<endl;
        return 0;
    }
    for(ll i=1;i<=n;i++){
        ans = ans*i;
        ans = ans%N;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 640