akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

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

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

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

    rep(i, n) s ^= a[i];
    rep(i, n) a[i] ^= s;
    rep(i, n) cout << a[i] << "  ";


    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <list>
#include <iomanip>
#include <numeric>
#include <fstream>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> a;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		a.push_back(make_pair(x, y));
	}
	sort(a.begin(), a.end());
	for (auto item : a) {
		cout << item.first << " " << item.second << endl;
	}
}


Measured memory_bytes: 3888
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(){
    int n;
    string str,str2;
    set<string> s;
    set<string>::iterator it;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>str>>str2;
        if(str=="insert"){
            s.insert(str2);
        }
        else{
            it=s.find(str2);
            if(it!=s.end()){
                cout<<"yes"<<endl;
            }
            else{
                cout<<"no"<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 32424
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,26)last[i] = -1;
    rep(i,d){
        res += s[i][t[i]];
        last[t[i]] = i;
        rep(j,26) res -= c[j] * (i - last[j]);
    }
    return res;
}

int main(){
    auto start = std::chrono::system_clock::now();      // 計測スタート時刻を保存
    random_device seed;
    mt19937 mt(seed());
    uniform_int_distribution<int> rnd1(0,25);
    uniform_int_distribution<int> rnd3(1,16);
    uniform_int_distribution<int> rnd4(0,1);

    cin >> d;
    uniform_int_distribution<int> rnd2(0,d-1);

    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);
    rep(i,d)t[i] = rnd1(mt);
    best = score();
    // vecprint(t);
    while(true){
        auto end = std::chrono::system_clock::now();       // 計測終了時刻を保存
        auto dur = end - start;        // 要した時間を計算
        auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
        if(msec>=1900) break;

        if(rnd4(mt) == 0){
            int day = rnd2(mt);
            int con = rnd1(mt);
            int old = t[day];
            t[day] = con;
            ll now_s = score();
            if(best < now_s) best = now_s;
            else t[day] = old;
        }else{
            int day1 = rnd2(mt);
            int day2 = day1 + rnd3(mt);
            if(day2 >= d)continue;
            swap(t[day1], t[day2]);

            ll now_s = score();
            if(best < now_s) best = now_s;
            else swap(t[day1], t[day2]);
        }
    }

    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>

void quick(long *,int,int);


int main(){
  long X=0,Y=0,ans=0;
  int N;
  scanf("%d",&N);
  long A[N];
  for (int i = 0; i < N; i++)
  {
    scanf("%ld",&A[i]);
  }
  
  quick(A,0,N-1);

  for (int i = N-1; i > 0; i--)
  {
    if (A[i]==A[i-1])
    {
      int j=0;
      while (A[i]==A[i-1]){i--;j++;}
      if (j>2&&X==0)
      {
        ans=A[i]*A[i];
        break;
      }else{
        if (X>0)
        {
          Y=A[i];
          ans=X*Y;
          break;
        }else{
          X=A[i];
        }
      }
    }
  }
  
  printf("%ld",ans);

  return 0;
}

void quick(long a[],int left,int right)
{
    int s,t,i,j;

    if (left<right){
        s=a[left];            
        i=left; j=right+1;      
        while (1){              
            while (a[++i]<s);
            while (a[--j]>s);
            if (i>=j) break;
            t=a[i]; a[i]=a[j]; a[j]=t;
        }
        a[left]=a[j]; a[j]=s;

        quick(a,left,j-1);
        quick(a,j+1,right);
    }
}

Measured memory_bytes: 2484
import sys

input = sys.stdin.readline


def main():
    N, X = map(int, input().split())
    m = [None] * N
    for i in range(N):
        m[i] = int(input())

    min_m = min(m)
    X -= sum(m)
    ans = N + X // min_m

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

constexpr long long MOD = 1000000007;

using namespace std;

namespace atc {
	long long pow(long long n, long long b) {
		if (n == 0) {
			return 1;
		}
		long long result = b;
		long long exp = 1;
		while (true) {
			if (exp * 2 < n) {
				result = (result * result) % MOD;
				exp *= 2;
			}
			else {
				return (result * pow(n - exp, b)) % MOD;
			}

		}
	}
	long long pos_mod(long long a, long long b) {
		return a - (int)floor(float(a) / b) * b;
	}

}

int main() {
	long long N;
	cin >> N;
	long long all_case =  atc::pow(N, 10);
	long long bad_case =  atc::pow(N, 9);
	long long bad_case2 = atc::pow(N, 8);
	long long result = (all_case - (bad_case * 2) % MOD) % MOD;
	result = atc::pos_mod(result + bad_case2, MOD);
	cout << result << endl;
}

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

int main(void){
  int n, ans = 0, m;
  scanf("%d", &n);
  string s;
  vector<int> cnt(3, 0);
  for (int i = 0; i < n; i++){
    cin >> s;
    m = s.length();
    for (int j = 0; j < m - 1; j++)
      if (s[j] == 'A' && s[j + 1] == 'B') ans++;
    if (s[0] == 'B' && s[m - 1] == 'A') cnt[0]++;
    else if (s[0] == 'B') cnt[1]++;
    else if (s[m - 1] == 'A') cnt[2]++;
  }
  // B A A A A BA BA BA BA BA
  // B A BA -> ABAB
  if (!cnt[0]){
    printf("%d\n", ans + min(cnt[1], cnt[2]));
  }else{
    ans += cnt[0] - 1 + (cnt[1] >= 1) + (cnt[2] >= 1);
    ans += max(0, min(cnt[1] - 1, cnt[2] - 1));
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
struct dish
{
	int need;
	int le;
};
dish k[5];
bool cmp(dish a,dish b)
{
	if(a.le==0)
	{
		return true;
	}
	if(b.le==0)
	{
		return false;
	}
	return a.le>b.le;
}
int main()
{
 for(int i=0;i<5;i++)
 {
 	cin>>k[i].need;
 	k[i].le=k[i].need%10;
 }
sort(k,k+5,cmp);
int ans=0;
for(int i=0;i<4;i++)
{
	ans+=k[i].need;
	if(k[i].le)
	{
		ans+=10-k[i].le;
	}
	//cout<<ans<<endl;
}
ans+=k[4].need;
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 200005
#define inf 1e18L + 5
#define ll long long
#define MOD 1000000007
using namespace std;
ll h[maxn] ,a[maxn];
ll tree[maxn*4];
ll dp[maxn],n; // for ith height dp[i] is the maximum beauty possible
void update(ll l ,ll r, ll rt, ll x, ll val){
    if(l>r) return;
    if(l==r && x==l){ //
        tree[rt] = val; return;
    }
    ll m = (l+r)/2;
    tree[rt] = max(tree[rt], val);
    if(x<=m){ // l x m
        update(l, m, rt*2, x, val);
    }
    else {
        update(m+1, r, rt*2+1, x, val);
    }
}

ll query(ll l ,ll r, ll rt, ll x, ll y){
    if(l>r) return -1;
    if(y<l || r<x){ // x y l r x y
        return -1;
    }
    if(x<=l && r<=y){ // x l r y
        return tree[rt];
    }
    ll m = (l+r)/2;
    return max(query(l, m, rt*2, x, y), query(m+1, r, rt*2+1, x, y));
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(ll i =0;i<n;i++){
        cin>>h[i]; // height
    }
    for(ll i =0;i<n;i++){
        cin>>a[i]; // beauty
    }
    for(ll i =0;i<n;i++){
        ll k = query(0, maxn-1, 1, 0, h[i]-1); // for 0 height to (h[i]-1), we will get maximum beauty possible
        dp[h[i]] = k + a[i];
        update(0, maxn-1, 1, h[i], dp[h[i]]);
    }
    ll ans = -1;
    for(ll i =0;i<n;i++){
        ans = max(ans, dp[h[i]]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t;
    cin>>n>>t;
    vector<int> ts(n);
    for(int i=0;i<n;i++)cin>>ts[i];
    int ans=0;
    int mn=ts[0],mx=ts[0]+t;
    for(int i=1;i<n;i++){
        if(ts[i]>=mn&&ts[i]<=mx){
            mx=ts[i]+t;
        }else{
            ans+=mx-mn;
            mn=ts[i];mx=ts[i]+t;
        }
    }
    ans+=mx-mn;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma comment(linker, "/STACK:33554432")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cmath>
#include <cstring>
#include <bitset>

using namespace std;
void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
using ld = long double;


void precalc() {}

void solve() {
    int n, k;

    cin >> n >> k;


    vector<ld> answr;
    vector<ld> pref;

    pref.push_back(0);

    for (int i = 0; i < n; ++ i){
        ld curr;

        cin >> curr;

        answr.push_back((curr + 1) / 2);
        pref.push_back(pref.back() + answr.back());
    }
    sort(answr.rbegin(), answr.rend());

    ld s = 0;

    for (int i = k; i <= n; ++ i){
        s= max(s, pref[i] - pref[i - k]);
    }

    cout << s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(20);
    precalc();
    solve();

}

Measured memory_bytes: 9952
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			string s = Console.ReadLine();
			int ans = 700;
			if (s[0] == 'o') {
				ans += 100;
			}
			if (s[1] == 'o') {
				ans += 100;
			}
			if (s[2] == 'o') {
				ans += 100;
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 25912
import io.StdIn._
object Main extends App {
    val Array(d, n) = readLine.split(" ").map(_.toInt)

    val result: Int = n match {
        case 100 => d match {
            case 0 => 101
            case 1 => 10100
            case 2 => 1010000
        }
        case _ => d match {
            case 0 => n
            case 1 => 100*n
            case 2 => 10000*n
        }
    }
    println(result)
}

Measured memory_bytes: 54864
S = input()

if S == "SUN":
    print("7")
elif S == "MON":
    print("6")
elif S == "TUE":
    print("5")
elif S == "WED":
    print("4")
elif S == "THU":
    print("3")
elif S == "FRI":
    print("2")
elif S == "SAT":
    print("1")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int n;
int a[301];
int dp[301][301];

int dfs(int l, int r) {
    if (l >= r) return 0;
    int &ret = dp[l][r];
    if (ret != -1) return ret;
    ret = 0;
    rep2(i, l + 1, r) {
        chmax(ret, dfs(l, i) + dfs(i, r));
    }
    if (l < r - 1 && abs(a[l] - a[r - 1]) <= 1 && dfs(l + 1, r - 1) == (r - 1) - (l + 1)) {
        chmax(ret, r - l);
    }
    return ret;
}

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

    while (cin >> n, n) {
        rep(i, n) cin >> a[i];
        rep(i, n + 1) rep(j, n + 1) dp[i][j] = -1;
        cout << dfs(0, n) << endl;
    }
}

Measured memory_bytes: 3828
N = int(input())
A = list(map(int,input().split()))

check = False
for i in range(0,N):
    if A[i] % 2 == 0:
        if A[i] % 3 != 0 and A[i] % 5 != 0:
            check = True

if check:
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 1000000005LL

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

int n;
P A[SIZE];
int B[SIZE];
int C[SIZE];

int main()
{
	scanf("%d",&n);
	int a;
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		A[i] = make_pair(a,i);
	}
	sort(A,A+n);
	int cnt=0;
	for(int i=0;i<n;i++){
		B[A[i].second] = cnt;
		if(A[i].first < A[i+1].first)cnt++;
	}
	int c=0;
	bool b=false;
	for(int i=0;i<n;i++){
		int f = B[i];
		int s = B[n-1-i];
		if(f!=s){
			C[f]++;
			C[s]--;
			if(C[f] == 0)c--;
			if(C[s] == 0)c--;
			if(C[f] == 1)c++;
			if(C[s] == -1)c++;
		}
		if(c==0){
			if(!b)b=true;
			else printf(" ");
			printf("%d",i+1);
		}
	}
	printf("\n");
	return 0;
}



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

const int INF = (1 << 20);

int main(){
    int n, m, x1, x2, y1, y2;
    int G[25][25];
    for(int i = 1; i <= 20; i++){
        for(int j = 1; j <= 20; j++){
            if( i == j ) G[i][j] = 0;
            else G[i][j] = INF;
        }
    }
    scanf("%d\n%d", &n, &m);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            G[i][j] = INF;
            if( i == j ) G[i][j] = 0;
        }
    }
    while( m-- > 0 ){
        int a, b, c, d;
        scanf("%d,%d,%d,%d", &a, &b, &c, &d);
        G[a][b] = c;
        G[b][a] = d;
    }
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                G[i][j] = min( G[i][j], G[i][k] + G[k][j] );
            }
        }
    }
    scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
    printf("%d\n", y1 - y2 - G[x1][x2] - G[x2][x1]);
    return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int card[] = new int[n];

		for (int i = 0; i < n; i++) {
			card[i] = scan.nextInt();
		}

		int alice = 0;
		int bob = 0;

		int temp = 0;
		int kaisu = 0;
		int num = -1;

		for (int j = 0; j < n; j++) {

			// 最大値を求める箇所
			for (int i = 0; i < n; i++) {
				if (temp < card[i]) {
					temp = card[i];
					num = i;
				}
			}

			// 得点を計算する箇所
			if (j % 2 == 0) {
				alice = alice + temp;
			} else {
				bob = bob + temp;
			}
			card[num] = -1;

			// 初期化
			temp = 0;
			num = -1;
		}
		System.out.println(alice - bob);

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int m,n,a[200005];
	long long s=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=0;i<m;i++)
	{
		a[i]=0;
	}
	for(int i=0;i<n;i++)
	{
		s+=a[i];
	}
	cout<<s<<'\n';
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define eb emplace_back
#define ep emplace
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const int INF=1e6;
const ll int MOD=998244353;

main(){
    ll n=in();
    int k=in(),r=in(),s=in(),p=in();
    string t;cin>>t;
    ll ans=0;
    vec mem(n);
    rep(i,n){
        if(!(i>=k && t[i]==t[i-k])||(i>=k*2 && mem[i-k])){
            if(t[i]=='r')ans+=p;
            else if(t[i]=='s')ans+=r;
            else ans+=s;
        }
        else mem[i]=1;
        
    }
    cout<<ans;
}

Measured memory_bytes: 896
m = [0] * 50
f = [0] * 50
r = [0] * 50
seiseki = ['S'] * 50

for i in range(50):
    m[i], f[i], r[i] = map(int, input().split())
    if m[i] == f[i] == r[i] == -1:
        break
    if m[i] == -1 or f[i] == -1:
        seiseki[i] = 'F'
    elif m[i] + f[i] >= 80:
        seiseki[i] = 'A'
    elif m[i] + f[i] >= 65:
        seiseki[i] = 'B'
    elif m[i] + f[i] >= 50:
        seiseki[i] = 'C'
    elif m[i] + f[i] >= 30 and r[i] >= 50:
        seiseki[i] = 'C'
    elif m[i] + f[i] >= 30:
            seiseki[i] = 'D'
    elif m[i] + f[i] < 30:
        seiseki[i] = 'F'

for i in range(50):
    if seiseki[i] == 'S':
        break
    print(seiseki[i])



Measured memory_bytes: 5608
N=int(input())
a=list(map(int,input().split()))
total=0
minloss=100000000000
zeroflag=0
minus=0
for i in range(N):
  total+=abs(a[i])
  if a[i]==0:
    zeroflag=1
  if a[i]<0:
    minus+=1
  if abs(a[i])<minloss:
    minloss=abs(a[i])
if minus%2==0 or zeroflag==1:
  print(total)
else:
  print(total-2*minloss)

Measured memory_bytes: 14412
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let s: String = read(&mut stdin_lock, &mut buf, b' ');
    let t: String = read(&mut stdin_lock, &mut buf, b'\n');
    let sv: Vec<char> = s.chars().collect();
    let tv: Vec<char> = t.chars().collect();

    for i in 0..n {
        print!("{}", sv[i]);
        print!("{}", tv[i]);
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  int n,a,i,min;long long ans;cin >> n;ans = 0;min = 1;
  for(i=0;i<n;i++){
    cin >> a;
    if (min==a) min = a+1;
    else ans += (a-1)/min;
    if(a != 1 && i == 0) min += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1<<21

int n;
int G[100][100];//重みを記録した隣接行列

int prim(){
  int i,sum=0,minv,u,v;
  int color[100];//訪問状態
  int d[100];//重みが最小の辺の重みを記録
  int p[100];//MSTにおける頂点vの親を記録
  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && G[u][v]!=INFTY){
	if(d[v]>G[u][v]){
	  d[v]=G[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=G[i][p[i]];
    }
  }
  return sum;
}


int main(){
  int i,j,e,count;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      G[i][j]=(e==-1)?INFTY:e;
      //e==-1ならINFTY(1<<21),それ以外ならe
    }
  }
  count=prim();
  printf("%d\n",count);
  return 0;
}   



Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;


int place[100100];
int Input[100100];

signed main() {
  int N; cin >> N;

  memset(Input, 0, sizeof(Input));
  
  for (int i = 1; i <= N; i++) {
    int a; cin >> a;
    Input[i] = a;
    place[a] = i;
  }

  Input[0] = INF;
  Input[N+1] = INF;
  
  int ans = 0;
  
  multiset<int> T;
  T.insert(0);
  T.insert(N+1);

  for (int i = 0; i <= N+1; i++) {
    T.insert(i);
  }
  
  for (int i = 1; i <= N; i++) {
    auto itr = T.find(place[i]);
    int right_1 = *(next(itr, 1));
    int right_2 = *(next(itr, 2));
    int left_1 = *(prev(itr, 1));
    int left_2 = *(prev(itr, 2));
    
    ans += i * ((right_2 - right_1) * (place[i] - left_1) + (left_1 - left_2) * (right_1 - place[i]));
    
    T.erase(itr);
  }

  cout << ans << endl;
}


Measured memory_bytes: 6528
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	LL N;
	cin >> N;
	map<LL, LL> m;
	REP(i, N){
		int a;
		cin >> a;
		m[a]++;
	}

	LL tmp1 = 0, tmp2 = 0;
	EACH(a, m){
		if(3 < a.second){
			tmp1 = tmp2 = a.first;
		}
		else if(1 < a.second){
			tmp1 = tmp2;
			tmp2 = a.first;
		}
	}

	cout << tmp1 * tmp2 << endl;



	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::string s; std::cin >> s;
    int cur = 0, mi = 0;
    for (int i = 0; i < n; i++) {
        cur += s[i] == '(' ? 1 : -1;
        mi = std::min(mi, cur);
    }
    std::string ans;
    for (int i = 0; i < -mi; i++) ans += '(', cur++;
    ans += s;
    for (int i = 0; i < cur; i++) ans += ')';
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
import math
n,m=map(int,input().split())
h=[0 for _ in range(n+1)]
dp=[0 for _ in range(n+1)]
for i in range(m):
	s=int(input())
	h[s]=1
dp[0]=1
if h[1]==1:
	dp[1]=0
else:
	dp[1]=1
for i in range(2,n+1):
	if h[i]==1:
		dp[i]==0
	else:
		dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%1000000007)


Measured memory_bytes: 466652
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int K = sc.nextInt();

		ArrayList<String> strlist = new ArrayList();
		int length =str.length();
		for(int from =0;from<=length;from++) {
				for(int to =from+1;to<=length && to<=from+K;to++) {
					String substr=str.substring(from, to);
					boolean match=false;
					for(String st : strlist) {
						if(st.equals(substr)) {
							match=true;
							break;
						}
					}
					if(!match) {
						strlist.add(substr);
					}
				}
		}
		Collections.sort(strlist);
		System.out.println(strlist.get(K-1));
	}
}


Measured memory_bytes: 25876
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, mut k) = get!(usize, usize);
    let mut ns = Vec::new();
    for _ in 0..n {
        ns.push(get!(usize, usize));
    }
    ns.sort();
    for (a, b) in ns.into_iter() {
        if k > b {
            k -= b;
        } else {
            println!("{}", a);
            return;
        }
    }
}

Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {

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

		int sunukeNum = Integer.parseInt(sc.next());
		int sweetsNum = Integer.parseInt(sc.next());
		int[] sunukeArr = new int[sunukeNum];
		for (int i = 0; i < sunukeNum; i++) {
			sunukeArr[i] = 0;
		}

		for (int i = 0; i < sweetsNum; i++) {
			int hasSweetsNum = Integer.parseInt(sc.next());
			for (int j = 0; j < hasSweetsNum; j++) {
				int sunukeIndex = Integer.parseInt(sc.next());
				sunukeArr[sunukeIndex - 1]++;
			}
		}
		int count = 0;
		for (int sweets : sunukeArr) {
			if (sweets == 0) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 41600
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__



void solve(void){
  
  ll A,B;
  cin >> A >> B;
  
  ll K = A+B;
  
  if(K%2!=0){
    cout << "IMPOSSIBLE" << endl;
  }
  else
  {
    cout << K/2 << endl;
  }
  
  return;
   
}

#define TESTCASES 1

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


    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,h,m,s;
    cin >> x;
    
    h = x/3600;
    m = ((x-(h*3600))/60);
    s = (x - h*3600 - m*60);
    
    cout << h << ":" << m << ":" << s << endl;
    return 0;
    
    
}


Measured memory_bytes: 3136
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void solve() {
	int n, k, r, s, p;
	int rc = 0, sc = 0, pc = 0;
	int ans = 0;
	bool ok = false;
	string t, a;
	cin >> n >> k >> r >> s >> p;
	cin >> t;

	for (int i = k; i < n; ++i) {
		if (t[i] == t[i - k])
			t[i] = ' ';
	}

	for (int i = 0; i < n; ++i) {
		if (t[i] == 'r') ans += p;
		else if (t[i] == 's') ans += r;
		else if(t[i] == 'p') ans += s;
	}

	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    ll MAX = 0, GCD = 0;
    rep(i,n){
        ll a;cin>>a;
        MAX=max(MAX,a);
        GCD=__gcd(GCD,a);
    }
    if(k%GCD==0&&k<=MAX)cout<<"POSSIBLE";
    else cout<<"IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 256
// +build ignore
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const D int = 60
const MAX_N int = 200005

var to [D][MAX_N]int

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()
	K := sc.i()
	for i := 0; i < N; i++ {
		to[0][i] = sc.i() - 1
	}

	for i := 1; i < D; i++ {
		for j := 0; j < N; j++ {
			to[i][j] = to[i-1][to[i-1][j]]
		}
	}

	p := 0
	for i := D; i >= 0; i-- {
		if K&(1<<i) != 0 {
			p = to[i][p]
		}
	}

	fmt.Println(p + 1)

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 96916
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> p(n), m(n);
    map<int, ll> cp,cm;
    rep(i,n){
        p[i] = i + a[i];
        cp[p[i]]++;
        m[i] = i - a[i];
        cm[m[i]]++;
    }
    ll ans = 0;
    for(auto x : cp){
        int val = x.first;
        ll num = x.second;
        ans += cm[val]*num;
    }
    cout << ans << endl;
}


Measured memory_bytes: 39828
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
  ll n,k;
  cin>>n>>k;
  string s;
  --k;
  cin>>s;
  if(s[k]=='A')
  s[k]='a';
  else if(s[k]=='B')
  s[k]='b';
  else
  s[k]='c';
  cout<<s;}

Measured memory_bytes: 3620
import java.util.Scanner;

class Main
{
    public static void main(String args[])
    {
        Scanner scn=new Scanner(System.in);
        int t=700;
        String s=scn.next();
        for (int i=0;i<s.length();i++)
        {
            if(s.charAt(i)=='o')
                t+=100;
        }
        System.out.println(t);
    }
}


Measured memory_bytes: 21844
n, capacity, wait = map(int, raw_input().split(' '))

v = []

for i in range(n):
	v.append(int(raw_input()))

v.sort()

last = 0
capacity_left = 0

res = 0

for i in range(n):
	if v[i] <= last and capacity_left > 0:
		capacity_left -= 1
	else:
		last = v[i] + wait
		capacity_left = capacity - 1
		res += 1
	
print res

Measured memory_bytes: 8964
import java.util.BitSet;
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - 1;
		}

		BitSet touched = new BitSet(N);
		int i = A[0];
		int result = 0;
		while (i != 1){
			if (touched.get(i)) {
				System.out.println(-1);
				return;
			}

			touched.set(i);
			result++;
			i = A[i];
		}
		System.out.println(result + 1);
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 52556
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,K = LMIIS()
    count = 0
    pre = 10**18+1

    x = N


    x = N % K
    while x >= K //2 and x!= 0:
        x = K % x

    print(x)



    

if __name__ == '__main__':
    main()

Measured memory_bytes: 66028
#include<bits/stdc++.h>
using namespace std;
double total_odd_number(int n)
{
    if(n%2==0) return n/2;
    else return (n/2)+1;
}
int main(void)
{
    double n;
    cin>>n;
    double s = total_odd_number(n);
    cout<<fixed<<setprecision(10)<<s/n<<endl;

    return 0;
}


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

using namespace std;
const int N = 1e5 + 5;
int head[N], nxt[N * 2], to[N * 2], ne = 0;

void addedge(int a, int b) {
    nxt[ne] = head[a];
    to[ne] = b;
    head[a] = ne++;
}

int dist[N][4];
int a, b;

int bfs(int s) {
    memset(dist, '?', sizeof dist);
    dist[s][0] = 0;
    queue<pair<int, int>> q;
    q.push({s, 0});
    while (q.size()) {
        int u = q.front().first, l = q.front().second;
        q.pop();
        int lv = dist[u][l];
        if (u == b && l == 0) return lv / 3;
        for (int i = head[u]; ~i; i = nxt[i]) {
            int v = to[i], vl = (l + 1) % 3;
            if (dist[v][vl] > lv + 1) {
                dist[v][vl] = lv + 1;
                q.push({v, vl});
            }
        }
    }
    return -1;
}

int main() {
 //   freopen("in.txt", "rt", stdin);
    int n, m;
    memset(head, -1, sizeof head);
    scanf("%d %d", &n, &m);
    while (m--) {
        scanf("%d %d", &a, &b);
        addedge(a, b);
    }
    scanf("%d %d", &a, &b);
    printf("%d\n", bfs(a));
}

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

int main(){
    string s, t;
    cin >> s >> t;
    if(s.size() < t.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    string ans = s;
    bool ok = false;
    for(int i = 0; i <= s.size() - t.size(); i++){
        bool flag = true;
        for(int j = 0; j < t.size(); j++){
            if(s[i + j] == '?') continue;
            if(s[i + j] != t[j]) flag = false;
        }
        if(!flag) continue;
        ok = true;
        for(int j = 0; j < s.size(); j++){
            ans[j] = (s[j] == '?' ? 'a' : s[j]);
        }
        for(int j = i; j < i + t.size(); j++){
            ans[j] = t[j - i];
        }
    }
    cout << (ok ? ans : "UNRESTORABLE") << endl;
    return 0;
}

Measured memory_bytes: 256
L = []
L.append((0,0))
L.append((1,0))
x = 1
y = 0
for _ in range(1000):
    dy = x /( (x**2 + y**2)**0.5 )
    dx = -y/( (x**2 + y**2)**0.5 )
    x += dx
    y += dy
    L.append((x,y))

while True:
    k = int(input())
    if k < 0:
        break
    print("{:.2f}".format(L[k][0]))
    print("{:.2f}".format(L[k][1]))




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

int main(void){
    long long int i, j, n, x, d, lengs=0, lengt=0, ans=1000, po=0;
    char s[1001], t[1001];
    memset(s, '\0', 1001);
    memset(t, '\0', 1001);
    scanf("%s %s", s, t);
    for(i=0; i<1001; i++){
        if(s[i]=='\0'&&lengs==0) lengs = i;
        if(t[i]=='\0'&&lengt==0) lengt = i;
    }
    for(i=0; i<lengs-lengt+1; i++){
        po = 0;
        for(j=0; j<lengt; j++){
            if(s[i+j] != t[j]) po++;
        }
        if(po<ans) ans = po;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323

int main() 
{
    FAST;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    bool x=1;
    while(a>0 && c>0)
    {
        if(x)
        {
            c=c-b;
            x=0;
            if(c<=0)
                cout<<"Yes";
        }
        else
        {
            a=a-d;
            x=1;
            if(a<=0)
                cout<<"No";
        }
    }
    return 0;
}

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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define all(v) v.begin() , v.end()
 
#define rep(i, a, b,r) for (ll i = a, to = b; i < to; i+=r)
#define ren(i, a, b,r) for (ll i = a, to = b; i > to; i-=r)	
 
#define rll(x) ll x;cin>>x;
#define rll2(x,y) ll x,y;cin>>x>>y;
#define rll3(x,y,z) ll x,y,z;cin>>x>>y>>z;
#define rll4(x,y,z,w) ll x,y,z,w;cin>>x>>y>>z>>w;
 
#define rs(s) string s;cin>>s;
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> pll;
const ll MOD=998244353;
 
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef deque<ll> dqll;
 
typedef set<ll> sll;
 
const long double PI = acos(-1);
 
const ll MX=2e5 + 10;
 
const ll MX2=9223372036854775806;
const ll MX3=100000+5;
 

/*PLANTILLA*/
vll vec(10000,0);

 
int main(){
	ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	rll2(x,n);
	
	rep(i,0,n,1){
		rll(a);
		vec[a+100]=1;
	}
	
	for(ll i=0;i<=100;i++){
		if(vec[x+100-i]==0){
			cout<<x-i;
			return 0;
		}
		if(vec[x+100+i]==0){
			cout<<x+i;
			return 0;
		}
	}
}

Measured memory_bytes: 3632
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG


//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}

int k;
string s;
signed main() {
	cin >> k >> s;
	int a = s.size();
	if (k <a) {
		rep(k)cout << s[i];
	}
	else {
		cout << s << endl;
		return 0;
	
	}cout << "..." << endl;
}

Measured memory_bytes: 3620