akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  while(cin >> s) {
    int win=-1;
    if((s[0]=='o' && s[1]=='o' && s[2]=='o') || (s[3]=='o' && s[4]=='o' && s[5]=='o') || (s[6]=='o' && s[7]=='o' && s[8]=='o') || (s[0]=='o' && s[3]=='o' && s[6]=='o') || (s[1]=='o' && s[4]=='o' && s[7]=='o') || (s[2]=='o' && s[5]=='o' && s[8]=='o') ||  (s[0]=='o' && s[4]=='o' && s[8]=='o') || (s[2]=='o' && s[4]=='o' && s[6]=='o')) win=1;
if((s[0]=='x' && s[1]=='x' && s[2]=='x') || (s[3]=='x' && s[4]=='x' && s[5]=='x') || (s[6]=='x' && s[7]=='x' && s[8]=='x') || (s[0]=='x' && s[3]=='x' && s[6]=='x') || (s[1]=='x' && s[4]=='x' && s[7]=='x') || (s[2]=='x' && s[5]=='x' && s[8]=='x') ||  (s[0]=='x' && s[4]=='x' && s[8]=='x') || (s[2]=='x' && s[4]=='x' && s[6]=='x')) win=2;
 if(win==-1) cout << "d" << endl;
 else if(win==1) cout << "o" << endl;
 else cout << "x" << endl;
  }
  return 0;
}


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

int main(){
    int n[101];
    int i;
    int num;
    cin>>num;
    for(i=0;i<num;i++) cin>>n[i];
    cout<<n[num-1];
    for(i=1;i<num;i++) cout<<" "<<n[num-i-1];
    cout<<endl;
    return 0;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	bool unionSet(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	UnionFind uf(2 * N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		uf.unionSet(a, b + N);
		uf.unionSet(b, a + N);
	}
	int r = uf.root(0);
	int A = 0;
	for (int i = 0; i < N; i++) {
		if (uf.root(i) == r) {
			A++;
		}
	}
	vector<int> res(N, 0);
	int n1 = (N + 2) / 3;
	int n2 = (N + 1) / 3;
	if (n1 + n2 <= A) {
		for (int i = 0; i < N; i++) {
			if (uf.root(i) == r) {
				if (n1 > 0) {
					res[i] = 1;
					n1--;
				} else if (n2 > 0) {
					res[i] = 2;
					n2--;
				}
			}
		}
	} else if (n1 + n2 <= N - A) {
		for (int i = 0; i < N; i++) {
			if (uf.root(i) != r) {
				if (n1 > 0) {
					res[i] = 1;
					n1--;
				} else if (n2 > 0) {
					res[i] = 2;
					n2--;
				}
			}
		}
	} else {
		if (n1 <= A && n2 <= N - A) {
			for (int i = 0; i < N; i++) {
				if (uf.root(i) == r) {
					if (n1 > 0) {
						res[i] = 1;
						n1--;
					}
				} else {
					if (n2 > 0) {
						res[i] = 2;
						n2--;
					}
				}
			}
		} else {
			for (int i = 0; i < N; i++) {
				if (uf.root(i) != r) {
					if (n1 > 0) {
						res[i] = 1;
						n1--;
					}
				} else {
					if (n2 > 0) {
						res[i] = 2;
						n2--;
					}
				}
			}
		}
	}
	assert(n1 == 0 && n2 == 0);
	int a[3];
	a[0] = 3;
	a[1] = 1;
	a[2] = 2;
	for (int i = 0; i < N; i++) {
		int t = res[i];
		res[i] = a[t];
		a[t] += 3;
	}
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << res[i];
	}
	cout << endl;
}

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

int main(){
    int a; cin >> a;
    string s; cin >> s;
    int ans = 0;
    for(int i = 2; i < s.size(); i++){
        if(s[i] == 'C' && s[i-1] == 'B' && s[i-2] == 'A'){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  string s; cin >> s;
  cout << s.front() << s.size() - 2 << s.back() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, 1};

int main(void){
    ll x;
    cin >> x;
    ll ans = (x/11)*2;
    if(x%11!=0){
        if(x%11<=6) ans++;
        else ans+=2;
    }
    cout << ans << endl;
    return 0;
}


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


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

    int n;
    cin >> n;
    if (n <= 999) cout << "ABC" << endl;
    else cout << "ABD" << endl;
    return 0;
}

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


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

    string S;
    cin >> S;

    int n=0,w=0,s=0,e=0;
    rep(i,S.size()){
        if(S.at(i)=='N') n++;
        else if(S.at(i)=='W') w++;
        else if(S.at(i)=='S') s++;
        else if(S.at(i)=='E') e++;
    }
    string ans="No";
    if(((n>0 && s>0) || (n==0 && s==0)) && ((w>0 && e>0) ||(w==0&&e==0))) ans="Yes";
    cout << ans << endl;

}

Measured memory_bytes: 256
N = gets.to_i

points = []
0.upto(100) do |i|
  0.upto(100) do |j|
    points.push([i, j, -1])
  end
end

info = []
N.times do
  x, y, h = gets.split(' ').map(&:to_i)
  info.push([x, y, h])
end
info.sort_by!{|i| -i[2]}

N.times do |i|
  x, y, h = info[i]
  if h > 0
    newpoints = []
    points.each do |c|
      height = h + (c[0] - x).abs + (c[1] - y).abs
      if c[2] == -1 || c[2] == height
        newpoints.push([c[0], c[1], height])
      end
    end
    points = newpoints
  else
    points.delete_if{|c| c[2] > (c[0] - x).abs + (c[1] - y).abs}
  end
  break if points.size == 1 && points[0][2] > 0
end

puts points[0].map(&:to_s).join(' ')

Measured memory_bytes: 3448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	int n,m; cin>>n>>m;
	int arr[m], ans=0;
	memset(arr, 0, sizeof(arr));
	for(int i=0; i<n; i++){
		int k; cin>>k;
		for (int i = 0; i < k; i++){
			int x; cin>>x;
			arr[x-1]++;
		}
	}
	for(int i=0; i<m; i++){
		if(arr[i]==n)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;
double memo[305][305][305];
int n;

double dp(int cnt1, int cnt2, int cnt3) {
    if (cnt1 < 0 || cnt2 < 0 || cnt3 < 0)
        return 0.0;
    if (cnt1 == 0 && cnt2 == 0 && cnt3 == 0)
        return 0.0;

    double &ans = memo[cnt1][cnt2][cnt3];

    if (ans != -1)
        return ans;

    // n/(a+b+c) = geometric distribution expected value
    ans = n+cnt1*dp(cnt1-1,cnt2,cnt3)+cnt2*dp(cnt1+1,cnt2-1,cnt3)+cnt3*dp(cnt1,cnt2+1,cnt3-1);
    ans *= 1.00/(double)(cnt1 + cnt2 + cnt3);

    return ans;
}

int main() {
    cin >> n;
    int x;
    int cnt[4] = {0, 0, 0, 0};
    for (int i = 0;i < n; i++)
        cin >> x, cnt[x]++;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= n; k++) {
                memo[i][j][k] = -1.00;
            }
        }
    }
    cout << fixed << setprecision(17) << dp(cnt[1], cnt[2], cnt[3]) << endl;
    return 0;
}

Measured memory_bytes: 219392
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll H, W;
    cin >> H >> W;

    if (H == 1 || W == 1) {
        cout << 1 << "\n";
        return 0;
    }
    if ((H * W) % 2 == 0) {
        cout << H * W / 2 << endl;
    } else {
        cout << (H * W / 2) + 1 << endl;
    }

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

import javax.lang.model.element.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionA(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		int N = nextInt();
		int K = nextInt();

		long ans = 0;
		for(long a=1;a<=N;a++){
			long b = K-a%K;
			if(K-a%K==K-b%K){
				long c=K-b%K;
				//cの初期値が取得できる場合
				long b_cnt=(N-b)/K+1;
				long c_cnt=(N-c)/K+1;

				ans+=b_cnt*c_cnt;
			}

		}
		pw.println(ans);

	}



	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  int a[n],b[m];
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  for (int i=0;i<m;i++){
    cin >> b[i];
  }
  int p=-101;
  int q=101;
  for (int i=0;i<n;i++){
    p=max(p,a[i]);
  }
  for (int i=0;i<m;i++){
    q=min(q,b[i]);
  }
  if (p<q&&x<=q-1&&y>=p+1){
    cout << "No War" << endl;
  }
  else{
    cout << "War" << endl;
  }
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

signed main(void){
  int N;
  scanf("%d", &N);
  if(N%2==0){
    printf("%d", N);
  }else{
    printf("%d", N*2);
  }
  return 0;

}


Measured memory_bytes: 256
MOD = 1000000007

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % MOD

MOD = 10**9+7 #出力の制限
MAX_N = 10**5+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, MAX_N + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )

# 鳩ノ巣原理より重複する数が唯一つ存在する
# a_1,a_2,...,a_m,...,a_l,a_l+1,...,a_n
# 左サイドの個数をx,右サイドサイドの個数をyとしたら
# k番目の出力で重複する組合せは(x+y)から(k-1)選んだもの

def solve():
  N = int(input())
  A = list(map(int, input().split()))
  counter = [-1]*(N+2)
  multi_num = -1
  left_element_num = -1
  right_element_num = -1
  for i, a_i in enumerate(A):
    if counter[a_i] != -1:
      left_element_num = counter[a_i]
      right_element_num = N-i
      break
    else:
      counter[a_i] = i

  # print(left_element_num, right_element_num)
  output = []
  for i in range(1, N+2):
    if i == 1:
      output.append(str(N))
      # print(N)
    elif i == N+1:
      output.append(str(1))
      # print(1)
    else:
      ret = cmb(N+1, i)%MOD
      ret = (ret-cmb(left_element_num+right_element_num, i-1)%MOD)%MOD
      output.append(str(ret))
  
  print('\n'.join(output))
  
solve()

Measured memory_bytes: 33336
#include<iostream>

using namespace std;

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

	int h = S / 3600;

	S -= h * 3600;

	int m = S / 60;

	int s = S - m * 60;


	cout << h << ":" << m << ":" << s << "\n";
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

const int e = 2e5 + 69;

int main()
{
    char a;
    cin >> a;
    if(a >= 'A' && a <= 'Z'){
        int t = 'A';
        cout << char(t);
    }
    else{
        int t = 'a';
        cout << char(t);
    }
}


Measured memory_bytes: 3632
# coding: utf-8

(n, m) = map(int, input().split())
begin_to = set()
end_from = set()
for i in range(m):
    (a, b) = map(int, input().split())
    if a == 1:
        begin_to.add(b)
    if b == n:
        end_from.add(a)

if begin_to.isdisjoint(end_from):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Measured memory_bytes: 19024
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
    d,t,s = map(int, input().split())
    if (s * t) < d:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Measured memory_bytes: 61692
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n, m;
	ll k;
	cin >> n >> m >> k;
	ll* a = new ll[n];
	ll* b = new ll[m];

	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];

	REP(i, 1, n) a[i] += a[i - 1];
	REP(i, 1, m) b[i] += b[i - 1];

	int t = 0;
	rep(i, n) {
		if (a[i] > k) break;
		++t;
	}

	int ans = 0;
	int counter = 0;
	rrep(i, t - 1) {
		int r = counter;
		REP(j, counter, m) {
			if (b[j] > k - a[i]) break;
			++r;
		}
		counter = r;

		ans = max(ans, i + 1 + counter);
	}

	int r = counter;
	REP(i, counter, m) {
		if (b[i] > k) break;
		++r;
	}

	ans = max(ans, r);

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 6776
#include <bits/stdc++.h>
using namespace std;
//解説動画写し
long long f(long long x){
  if(x==1)return 1;
  long long a=f(x/2);
  return a*2+1;
}
int main() {
  long long h;
  cin>>h;
  cout<<f(h)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;

int main() {
    ll X;
    cin >> X;
    ll base = 100;
    int n = 0;
    while(base<X) {
        base += base/100;
        n++;
    }
    print(n);

    return 0;
}

Measured memory_bytes: 3612
import collections
n = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
cc = collections.Counter(ais)
ais.sort()
m = max(ais)
p = [True for _ in range(m + 1)]

count = 0
for ai in ais:
	if p[ai] is True:
		x = 2 * ai
	 	while(x < len(p)): 
	 		p[x] = False
	 		x += ai
for ai in ais:
	if p[ai] is True:
		if cc[ai] == 1:
			count +=1
print count

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

int main()
{
	string t;
	cin >> t;
	t = 'x' + t + 'x';
	for (int i = 1; i < t.length() - 1; i++) {
		if (t[i] != '?') {
			continue;
		}
		else {
			if (t[i - 1] == 'P') {
				t[i] = 'D';
			}
			else if (t[i + 1] == 'D') {
				t[i] = 'P';
			}
			else if (t[i + 1] == '?') {
				t[i] = 'P';
			}
			else {
				t[i] = 'D';
			}
		}
	}
	t.erase(0, 1);
	t.erase(t.length() - 1, 1);
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 3936
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
 

    class Program
    {
        static void Main(string[] args)
        {
            int[] ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            if (ab[0] < ab[1] && ab[1] < ab[2])
            {
                Console.WriteLine("Yes");
            }else
            {
                Console.WriteLine("No");
            }

        }
        
    }
}

Measured memory_bytes: 9308
K, N = map(int, input().split())
A = list(map(int, input().split()))
maxBetween = -1
for i in range(N):
    if i == 0:
        continue
    else:
        between = A[i] - A[i-1]
        if between > maxBetween:
            maxBetween = between
lastBetween = K - A[-1] + A[0]
if lastBetween > maxBetween:
    maxBetween = lastBetween
print(K-maxBetween)


Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    int aa=0;
    for(int i=1;i<n;i++){
        for(int j=1;j<n;j++){
                if(i*j>=n){
                    break;
                }
                    aa++;
        }
    }
    cout<<aa<<endl;
    return(0);
    }

Measured memory_bytes: 3568
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        double sum = 0;
        long [] pow = new long[21];
        pow[0] = 1;
        for (int i = 1; i <= 20; ++i) {
            pow[i] = pow[i - 1] * 2;
          //  System.out.println("pow: " + pow[i]);
        }
        List<Long> pows = new ArrayList<>();
        for (int i = 0 ;i <= 20; ++i) {
            pows.add(pow[i]);
        }
        for (int i = 1; i <= n; ++i) {
            long target = k / i;
         //   System.out.println("target: " + target);
            int find = Collections.binarySearch(
                    pows,
                    target);
            int times;
            if (find >= 0 && find <= 20) {
                if (pows.get(find) == target) {
                    times = find;
                } else {
                    times = -1 * (find + 1);
                }
            } else {
                times = -1 * (find + 1);
            }
            if (Math.pow(2, times) * i < k) {
                times++;
            }

        //    System.out.println("i: " + i + " times: " + times + " add: " + Math.pow(2, times));
            sum += Math.pow(0.5, times);
       //     System.out.println("sum: " + sum);
        }
        sum /= n;
        System.out.println(sum);
    }

    public static int log(int x, int base)
    {
        return (int) (Math.log(x) / Math.log(base));
    }
}


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

using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (auto& x: a) {
        cin >> x;
    }
    if (n >= m) {
        cout << 0; return;
    }
    sort(a.begin(), a.end());
    for (int i = m-1; i >= 1; i--) {
        a[i] -= a[i-1];
    }
    sort(a.begin()+1, a.end());
    int k = m - n;
    int res = 0;
    for (int i = 1; i <= k; i++) {
        res += a[i];
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 640
from collections import deque

def main():
    K = int(input())
    if K <= 9:
        print(K)
        return

    que = deque(range(1,10))
    # print(que)
    cnt = 9
    while True:
        x = que.popleft()
        mod = x % 10

        if mod != 0:
            que.append(10 * x + mod - 1)
            # print(que)
            cnt += 1
            if cnt == K:
                print(que[-1])
                return

        que.append(10 * x + mod)
        # print(que)
        cnt += 1
        if cnt == K:
            print(que[-1])
            return

        if mod != 9:
            que.append(10 * x + mod + 1)
            # print(que)
            cnt += 1
            if cnt == K:
                print(que[-1])
                return

main()


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

int main()
{
    int n; cin>>n;
    int res=0;
    vector<int> s(n); for(auto& e: s) cin>>e, res+=e;
    sort(begin(s), end(s));
    for(auto& e: s) if (res%10==0 && e%10>0) res-=e;
    cout<<(res%10 ? res : 0)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,N;
    cin >> N;
    cin >> A;
    int zan;
    zan = N % 500;
    zan = A - zan;
    if (zan >= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int n,k;
int disl[10];

bool like(int a){
    while(a > 0){
        if(disl[a % 10]) return false;
        a /= 10;
    }
    return true;
}

int main(){
    cin >> n >> k;
    rep(i,k){
        int b;
        cin >> b;
        disl[b] = 1;
    }
    while(!like(n)) n ++;
    cout << n << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<ll> a(n), b(n);
    for(int i=0; i<n; i++) cin>>a[i];
    for(int i=0; i<n; i++) cin>>b[i];

    priority_queue<pair<ll, ll>> pq;
    for(int i=0; i<n; i++){
        pq.emplace(b[i], i);
    }

    ll ans = 0;
    bool valid = true;
    while(pq.size()){
        ll val, index;
        tie(val, index) = pq.top(); pq.pop();

        ll A = b[(index-1+n)%n];
        ll C = b[(index+1)%n];

        if((b[index] - a[index]) % (A + C) == 0){
            ans += (b[index] - a[index]) / (A + C);
            b[index] = a[index];
            continue;
        }

        if(b[index] <= A + C){
            valid = false;
            break;
        }

        ans += val / (A + C);
        b[index] %= (A + C);
        
        if(b[index] < a[index]){
            valid = false;
            break;
        }

        pq.emplace(b[index], index);
    }

    cout << (valid ? ans : -1) << endl;
}

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

//point
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
	bool cmp_y(const P &a, const P &b){
		return a.imag() != b.imag() ? a.imag() < b.imag() : a.real() < b.real();
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}
// circle
struct C {
	P p; double r;
	C(const P& p, double r) : p(p), r(r) {}
};

int intersectCC(const C& a, const C& b) {
	double dist = sqrt(norm(a.p-b.p)), r1 = a.r + b.r, r2 = abs(a.r - b.r);
	if(r1 < dist) return 4;		//??\?????????
	if(dist == r1) return 3;	//?????\
	if(r2 < dist && dist < r1) return 2; //?????????
	if(dist == r2) return 1; //?????\
	return 0;	//??????
}

int main() {
	double x1, y1, r1, x2, y2, r2;
	cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
	C c1(P{x1, y1}, r1), c2(P{x2, y2}, r2);
	cout << intersectCC(c1, c2) << endl;
}

Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n),c(n);
  REP(i,n)cin>>a[i];
  REP(i,n)cin>>b[i];
  REP(i,n)cin>>c[i];
  sort(ALL(a));
  sort(ALL(b));
  sort(ALL(c));
  int ans=0;
  REP(i,n){
    auto x=lower_bound(ALL(a),b[i])-a.begin();
    auto y=c.end()-upper_bound(ALL(c),b[i]);
    //cout<<x<<' '<<y<<endl;
    ans+=x*y;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1000005;
LL ans=0;


int n,m;
int main()
{
    LL n,s;
    scanf("%lld%lld",&n,&s);
    if(s>n)
    {
        printf("-1\n");
        return 0;
    }
    if(s==n)
    {
        printf("%lld\n",s+1);
        return 0;
    }
    LL up=sqrt(n)+1;
    for(LL i=2; i<=up; i++)
    {
        ans=0;

        LL temp=n;
        while(temp)
        {
            ans+=temp%i;
            temp=temp/i;
        }

        if(ans==s)
        {
            printf("%lld\n",i);
            return 0;
        }
    }
    
    n-=s;
    for(LL x1=sqrt(n)+1;x1>=1;x1--)
	{
		if(n%x1==0)
		{
			ans=n/x1+1;
			LL x0=s-x1;
			if(x0>=0&&ans>=2&&x0<ans&&x1<ans)
			{
				printf("%lld\n",ans);
				return 0;
			}
		}
	}
    
    
    
    printf("-1\n") ;
}


Measured memory_bytes: 384
# 配列の長さを取得
n = gets.chomp.to_i

# 配列を取得
arr = gets.chomp.split(" ").map{|e| e.to_i}

# 配列をチェック
order = 0
group = 1
for i in 1...n
	# 数字が変わらなければ何も考えない
	if arr[i - 1] != arr[i]
		# 最初や、切り替わった直後はOK
		if order == 0
			if arr[i - 1] < arr[i]
				# 上昇が始まる
				order = 1
			else
				# 下降が始まる
				order = -1
			end
			
		# 上昇中の場合
		elsif order == 1
			# 下がれば切り替え
			if arr[i - 1] > arr[i]
				group += 1
				order = 0
			end
			
		# 下降中の場合
		else
			if arr[i - 1] < arr[i]
				group += 1
				order = 0
			end
			
		end
	end
end

# 結果を表示
puts group

Measured memory_bytes: 9484
#include <stdio.h>

int main(void)
{
  int n;
  
  scanf("%d", &n);
  if(1>=n && n>=0)
    printf("1");
  if(3>=n&&n>=2)
    printf("2");
 if(7>=n&&n>=4)
    printf("4");
 if(15>=n&&n>=8)
    printf("8");
 if(31>=n&&n>=16)
    printf("16");
 if(63>=n&&n>=32)
    printf("32");
 if(100>=n&&n>=64)
    printf("64");
  

  return 0;
}



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

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    
    if(e - a <= k) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi p;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;p.resize(n);
    rep(i,n)cin>>p[i];    
    ll ans = 0;
    rep(i,n){
        if(i<n-1)if(p[i]==i+1){
            swap(p[i],p[i+1]);
            ans++;
        }
        if(i==n-1){
            if(p[i]==i+1){
                swap(p[i],p[i-1]);
                ans++;
            }
        }
    }
    print(ans);
    return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define endl "\n"
#define ar array
#define pb push_back
#define sz(X) ((int)(X).size())
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define get_pos(c, x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define all(X) (X).begin(), (X).end()
#define  No cout<<"NO"<<endl;
#define  Yes cout<<"YES"<<endl;
#define  nl cout<<endl;

template<typename T>
ostream &operator+(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out << x << " ";
    }
    out << "\n";
    return out;
}

template<typename T>
ostream &operator*(ostream &out, const vector<T> &vec) {
    for (const auto &x : vec) {
        out + x;
    }
    return out;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &vec) {
    for (auto &x : vec) {
        in >> x;
    }
    return in;
}

// DEBUG
void DBG() { cerr << "]" << endl; }

template<class H, class... T>
void DBG(H h, T... t) {
    cerr << ts(h);
    if (sizeof...(t)) cerr << ", ";
    DBG(t...);
}

#ifdef _DEBUG // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

template<class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }


const int mod = 1e9 + 7;
const int mod2 = 998244353;
const ll INF = 1e9 + 6;

ll add(ll a, ll b) {
    a += b;
    return a % mod;
}

ll mul(ll a, ll b) {
    a *= b;
    return a % mod;
}

inline ll power(ll x, ll y, ll p) {
    ll res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

inline ll modInverse(ll x, ll p) {
    return power(x, p - 2, p);
}

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

const int MXN = 3e3+1;
double p[MXN];
double cache[MXN][MXN];
int n;
double dp(int idx,int heads){
    if(idx>n){
        if(heads>n/2)return 1;
        else return 0;
    }
    double &ans=cache[idx][heads];
    if(ans!=-1){
        return ans;
    }

    ans=dp(idx+1,heads+1)*p[idx]+dp(idx+1,heads)*(1-p[idx]);
    return ans;
}
void solve() {

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    for(int i=0;i<MXN;i++){
        for (int j = 0; j <MXN ; ++j) {
            cache[i][j]=-1;
        }
    }
    cout<<fixed<<setprecision(10)<<dp(1,0);
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--)solve();
    // cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}
//look if it requires ll

Measured memory_bytes: 74388
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int N;
	cin >> N;
	
	vector< lint > A(N);
	for_(i,0,N) cin >> A[i];
	
	vector< lint > ans(N, 0);
	for_(i,0,N) {
		if (i & 1) ans[0] -= A[i];
		else ans[0] += A[i];
	}
	for_(i,1,N) ans[i] = 2 * (A[i-1] - ans[i-1]/2);
	for_(i,0,N) cout << ans[i] << (i<N-1 ? " " : "\n");
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 2816
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

s=input()
t=input()
ans=INF
for i in range(len(s)-len(t)+1):
    tmp=0
    for x,y in zip(t,s[i:i+len(t)]):
        tmp+=(x!=y)
    ans=min(ans,tmp)
print(ans)

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

int main(){
  char b; cin >> b;
  if(b=='A') cout << 'T' << endl;
  else if(b=='T') cout << 'A' << endl;
  else if(b=='C') cout << 'G' << endl;
  else cout << 'C' << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(int argc, char const* argv[])
{
	double r;
	double area, circumference;
	scanf("%lf", &r);

	area = M_PI * r * r;
	circumference = 2 * M_PI * r;

	printf("%.5lf %.5lf\n", area, circumference);

	return 0;
}



Measured memory_bytes: 2716
#include<iostream>
#include<vector>

using std::begin;
using std::end;

int main() {
  int n;
  std::vector<int> v;
  std::cin >> n;
  for(int i{0}; i < n; ++i) {
    int t;
    std::cin >> t;
    v.push_back(t);
  }

  bool e{true};
  int cnt{0};
  while(e) {
    e = false;
    for(int i{n - 1}; i > 0; --i) {
      if(v[i] < v[i - 1]) {
        e = true;
        ++cnt;
        int t{v[i]};
        v[i] = v[i - 1];
        v[i - 1] = t;
      }
    }
  }
  bool f{true};
  for(int e: v) {
    if(f) {
      f = false;
    } else {
      std::cout << ' ';
    }
    std::cout << e;
  }

  std::cout << std::endl << cnt << std::endl;

  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

	int cl = 0;
	int cr = 0;
	int po = 0;
	const int ss = static_cast<int>(s.size());
	vector<int> ret(ss, 0);
	for (int i = 0; i < ss; ++i) {
		if (s[i] == 'L') {
			if (cr) {
				ret[i - 1] += cr / 2 + cr % 2;
				ret[i] += cr / 2;
				cr = 0;
				po = i - 1;
			}
			++cl;
		}
		else {
			if (cl) {
				ret[po] += cl / 2;
				ret[po + 1] += cl / 2 + cl % 2;
				cl = 0;
			}
			++cr;
		}
	}

	if (cl) {
		ret[po] += cl / 2;
		ret[po + 1] += cl / 2 + cl % 2;
		cl = 0;
	}

	for (auto& i : ret) {
		cout << i << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(x, u) for (int x = 1; x <= u; x++)
typedef long long ll;
using namespace std;
void solve()
{     
    ll n,i,sum=0;
    cin>>n;
    FOR(i,n)
    {
        if(i%3==0 && i%5==0)
            continue;
        if(i%3==0)
            continue;
        if(i%5==0)
            continue;
        sum+=i;
    }
    cout<<sum;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    //cin>>t;
    while (t--)
    {
        solve();
        cout << "\n";
    }
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

Measured memory_bytes: 3800
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

vector<ll> S;
int b[200010];
int a[10010];

bool vis[10010];

void DFS(int u,ll s)
{
	if(vis[u])return;
	
	vis[u]=1;
	
	s+=b[u];
	
	S.pb(s);
	
	DFS(a[u],s);
}

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	int n,k;cin>>n>>k;
	for(int i=0;i<n;i++){cin>>a[i];a[i]--;}
	for(int i=0;i<n;i++)cin>>b[i];
	
	ll ans=-ll(1e18);
	
	for(int i=0;i<n;i++)
	{
		memset(vis,0,sizeof(vis));
		
		DFS(i,0);
		
		if(S.back()>0&&k>=int(S.size()))
		{
			ll q=k/int(S.size());
			
			if(q>=1)
			{
				ll mx=-ll(1e18);
				
				if(q-1>0)mx=0;
				
				for(int i=0;i<int(S.size());i++)mx=max(mx,S[i]);
				
				ans=max(ans,(q-1)*S.back()+mx);
			}
			
			{
				int r=k%int(S.size());
				
				ll mx=0;
				
				for(int i=0;i<r;i++)mx=max(mx,S[i]);
				
				ans=max(ans,mx+q*S.back());
			}
		}
		else for(int j=1;j<=k;j++)
		{
			if(j-1<S.size())ans=max(ans,S[j-1]);
			else break;
		}
		
		S.clear();
	}
	
	cout<<ans;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(int n;cin>>n&&n;){
		vvi g(n);
		rep(i,n-1){
			int u,v; cin>>u>>v; u--,v--;
			g[u].push_back(v);
			g[v].push_back(u);
		}

		// between 0 and n-1
		vi path;
		{
			vi prev(n,-1);
			queue<int> q;
			q.push(0);
			while(q.size()){
				int u=q.front(); q.pop();
				for(int v:g[u]){
					if(prev[v]==-1){
						prev[v]=u;
						q.push(v);
					}
				}
			}
			for(int v=n-1;;v=prev[v]){
				path.push_back(v);
				if(v==0) break;
			}
			reverse(all(path));
		}

		queue<int> bq,wq;
		rep(i,path.size()){
			bq.push(path[i]);
			wq.push(path[path.size()-1-i]);
		}

		vi vis(n,-1);
		string res;
		for(int player=0;;player^=1){  // 0: Fennec, 1: Snuke
			bool played=false;

			queue<int>& q=player==0?bq:wq;
			while(!played&&q.size()){
				int u=q.front(); q.pop();
				if(vis[u]!=-1) continue;
				vis[u]=player;
				for(int v:g[u])
					q.push(v);
				played=true;
			}

			if(!played){
				res=player==0?"Snuke":"Fennec";
				break;
			}
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 7792
def main():
    n, k = map(int, input().split())
    v = [int(x) for x in input().split()]
    
    ans = 0
    r = min([n, k])
    for i in range(r+1):
        for j in range(r+1-i):
            sub = sum(v[:i])+sum(v[n-j:n])
            minus = []
            for l in range(n):
                if (l < i or n-j < l) and v[l] < 0:
                    minus.append(v[l])
            minus.sort()
            sub -= sum(minus[:min([len(minus), k-i-j])])
            if ans < sub:
                ans = sub
        
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll N,K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i,N) cin >> p[i];
    sort(p.begin(), p.end());
    ll ans=0;
    rep(i,K)
        ans += p[i];
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<char> v(n);
    for (auto &i : v) cin >> i;

    vector<string> str(n, "");
    set<int> s;
    int res = 0, j = 0;
    for (int i = 0; i < n; i++) {
        str[i] += v[i];
        s.insert(stoi(str[i]));
    }
    while (1) {
        if (s.find(res) != s.end()) {
            res++;
            continue;
        }
        j++;
        for (int i = 0; i < n; i++) {
            if (i - j >= 0) 
                str[i] = v[i - j] + str[i];
            s.insert(stoi(str[i]));
        }
        if (s.find(res) != s.end()) continue;
        else break;
    }
 
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3336
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd,numbers)
K=int(input())
a=1
c=1
if 1<=K<=200:
    sum_abc=K*(K+1)/2
    sum_abc=int(sum_abc)
    for a in range(1,K+1):
        for c in range(1,K+1):
            if a==c:
                c+=1
            else:
                d=math.gcd(a,c)
                d=3*d
                sum_abc=sum_abc+d
                c+=1
        a+=1
    if K>=3:
        i=1
        j=2
        k=3
        for k in range(3,K+1):
            for j in range(2,k):
                for i in range(1,j):
                    e=gcd(i,j,k)
                    e=6*e
                    sum_abc=sum_abc+e
                    i+=1
                j+=1
            k+=1
    print(sum_abc)

Measured memory_bytes: 9652
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char s[200000];
    cin >> s;
    int i=0;
    int x = strlen(s);
    while(i<x){
        if(s[i] == 'A') break;
        i++;
    }
    int j=x;
    while(j>0){
        if(s[j] == 'Z') break;
        j--;
    }
    cout << j-i+1 << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

    int sum = 0;

    for (int i = 0; i < (int) n.size(); ++i)
    {
        sum += n[i] - '0';
    }

    if (sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

}

Measured memory_bytes: 3716
n,m = map(int,input().split())

ng = [0]*(n+1)
for i in range(m):
    ng[int(input())] = 1

mod = (10**9)+7
dp = [0]*(n+1)
dp[0] = 1

for i in range(1,n+1):
    if ng[i] == 1:
        dp[i] = 0
        continue
    if i == 1:
        dp[1] = 1
        continue
    dp[i] = (dp[i-2] + dp[i-1])%mod

print(dp[n])


Measured memory_bytes: 7668