akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final long MOD = 998244353;

	public static void main(String[] args) {
		char[] S = sc.next().toCharArray();
		int N = S.length;
		long[] pow3 = new long[N + 1];
		pow3[0] = 1;
		for (int i = 0; i < N; i++) {
			pow3[i + 1] = pow3[i] * 3 % MOD;
		}
		Bits bsf1 = new Bits(N + 64);
		Bits bsf2 = new Bits(N + 64);
		Bits bsb1 = new Bits(N + 64);
		Bits bsb2 = new Bits(N + 64);
		int Q = 0;
		for (int i = 0; i < N; i++) {
			if (S[i] == 'G') {
				bsf1.set(i);
			} else if (S[i] == '?') {
				bsf2.set(i);
				Q++;
			}
			if (S[N - 1 - i] == 'U') {
				bsb1.set(i);
			} else if (S[N - 1 - i] == '?') {
				bsb2.set(i);
			}
		}
		long ans = 0;
		long[] buff1 = new long[bsf1.bits.length];
		long[] buff2 = new long[bsf1.bits.length];
		long[] bufb1 = new long[bsf2.bits.length];
		long[] bufb2 = new long[bsf2.bits.length];
		for (int i = 1; i < N - 1; i++) {
			if (S[i] == 'M' || S[i] == '?') {
				int q = S[i] == 'M' ? Q : Q - 1;
				bsf1.copy(buff1, i + 1);
				bsf2.copy(buff2, i + 1);
				bsb1.copy(bufb1, N - i);
				bsb2.copy(bufb2, N - i);
				int len = (Math.min(N - 1 - i, i) + 63) / 64;
				for (int j = 0; j < len; j++) {
					ans += Long.bitCount(buff1[j] & bufb1[j]) * pow3[q];
					if (q >= 1) {
						ans += Long.bitCount(buff1[j] & bufb2[j]) * pow3[q - 1];
						ans += Long.bitCount(buff2[j] & bufb1[j]) * pow3[q - 1];
					}
					if (q >= 2) {
						ans += Long.bitCount(buff2[j] & bufb2[j]) * pow3[q - 2];
					}
				}
				ans %= MOD;
			}
		}
		System.out.println(ans);
	}

	static class Bits {
		long[] bits;

		Bits(int size) {
			bits = new long[(size + 63) / 64];
		}

		void copy(long[] buf, int from) {
			int start = from >> 6;
			int rem = from & 63;
			if (rem == 0) {
				for (int i = start; i < bits.length; i++) {
					buf[i - start] = bits[i];
				}
			} else {
				for (int i = start; i < bits.length; i++) {
					buf[i - start] = bits[i] >>> rem;
					if (i < bits.length - 1) {
						buf[i - start] |= bits[i + 1] << (64 - rem);
					}
				}
			}
			if (start > 0) buf[bits.length - start] = 0;
		}

		void shiftLOr(int shift) {
			int m1 = shift >> 6;
			int m2 = shift & 63;
			if (m2 == 0) {
				for (int i = bits.length - 1 - m1; i >= 0; i--) {
					bits[i + m1] |= bits[i];
				}
			} else {
				for (int i = bits.length - 1 - m1; i >= 0; i--) {
					int p1 = i + m1 + 1;
					int p2 = i + m1;
					long v1 = bits[i] >>> (64 - m2);
					long v2 = bits[i] << m2;
					if (p1 < bits.length) {
						bits[p1] |= v1;
					}
					bits[p2] |= v2;
				}
			}
		}

		boolean get(int pos) {
			return ((bits[pos >> 6] >>> (pos & 63)) & 1) != 0;
		}

		void set(int pos) {
			bits[pos >> 6] |= (1L << (pos & 63));
		}

		public String toString() {
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < bits.length; i++) {
				sb.append(Long.toString(bits[i], 16));
				sb.append(',');
			}
			return sb.toString();
		}
	}
}



Measured memory_bytes: 37000
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int n;
string s;

signed main(){
    cin >> n;
    cin >> s;

    int ans = 1;
    char c = s[0];
    rep(i, 1, n) if(c != s[i]) ans++, c = s[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
using namespace std;
const int MaxN = 1e5 + 5;
int box[MaxN];
int cnt, c, n, k;
int main(){
	while(~scanf("%d %d %d", &n, &c, &k)){
		for(int i = 1; i <= n; i++)
			scanf("%d", &box[i]);
		sort(box + 1, box + 1 + n);
		int l, r;
		l = r = 1;
		cnt = 0;
		while(l <= n){
			int temp = box[l] + k;
			while(box[r + 1] <= temp && r - l < c - 1 && r < n)
				r++;
			cnt++;
			l = r + 1;
		}
		printf("%d\n", cnt);
	}
	return 0;
}


Measured memory_bytes: 512
n = int(input())
p = [float(i) for i in input().split()]
#i枚目までのコインでj枚表が出ている確率
dp = [[0] * i for i in range(2,n+2)]

dp[0][1] = p[0]
dp[0][0] = 1-p[0]
ans = 0
if n != 1:
    for i in range(1,n):
        for j in range(len(dp[i])-1):
            #i枚目で裏が出る確率
            dp[i][j] += dp[i-1][j] * (1-p[i])
            #i枚目で表が出る確率
            dp[i][j+1] += dp[i-1][j] * p[i]
    for i in range(1,(n+1)//2+1):
        ans += dp[n-1][-i]
    print(ans)
else:
    print(p[0])


Measured memory_bytes: 147592
def is_correct(grids):
    for a1 in range(min(101, grids[0][0]+1)):
        b_list = grids[0][0] - a1, grids[0][1] - a1, grids[0][2] - a1
        a2, a3 = grids[1][0] - b_list[0], grids[2][0] - b_list[0]
        a_list = [a1, a2, a3]
        temp_grids = []
        for an in a_list:
            row = []
            for bn in b_list:
                row.append(an+bn)
            temp_grids.append(row)
        if grids == temp_grids:
            return True

    return False


grids = []
for _ in range(3):
    grids.append(list(map(int, input().split())))

print("Yes" if is_correct(grids) else "No")


Measured memory_bytes: 3064
import sys

def rotate90(ptn):
    ptn = zip(ptn[0], ptn[1], ptn[2], ptn[3],\
              ptn[4], ptn[5], ptn[6], ptn[7])
    for i in range(8): ptn[i] = list(ptn[i])
    for i in range(8): ptn[i].reverse()
    return ptn

def print_ptn(ptn):
    for i in range(8):
        for j in range(8):
            sys.stdout.write(ptn[i][j])
        print

ptn = []
for i in range(8):
    ptn.append(list(raw_input()))
for i in range(3):
    print 90 * (i + 1)
    ptn = rotate90(ptn)
    print_ptn(ptn)

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

public class Main {	
	private static void solve(){
		//Implement solution here.
		long N = nl();
		long A = nl();
		long B = nl();
		long result = 0;
		result += (N / (A + B)) * A;
		result += Math.min((N % (A + B)), A);
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>
 
using namespace std;

const int N=100010;

// factorial and inverse
ll f[N];
ll finv[N];

// quick power
ll qp(ll x,ll n) {
    ll ret=1;
    while (n) {
        if (n&1) ret=(ret*x)%MOD;
        n=n>>1;
        x=(x*x)%MOD;
    }
    return ret;
}

int pos[N];
int n,a,p1,p2;

ll cal(int k) {
	ll x=(((f[n+1]*finv[k])%MOD)*finv[n+1-k])%MOD;
	ll y=0;
	ll tmp=p1-1+n+1-p2;
	if (k-1<=tmp) {
		y=(((f[tmp]*finv[k-1])%MOD)*finv[tmp-k+1])%MOD;
	}
	return (x-y+MOD)%MOD;
}

int main() {
	f[0]=finv[0]=1;
	for (int i=1;i<=100005;i++) {
   	 	f[i]=(f[i-1]*i)%MOD;
    	finv[i]=qp(f[i],MOD-2);
	}
	scanf("%d",&n);
	for (int i=1;i<=n+1;i++) {
		scanf("%d",&a);
		if (pos[a]!=0) {
			p1=pos[a];
			p2=i;
		} else pos[a]=i;
	}
	for (int i=1;i<=n+1;i++) {
		printf("%lld\n",cal(i));
	}
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

bool isPrime(long long x) {
    if (x == 1) return true;
    for (long long i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

vector<long long> common_divisors(long long a, long long b) {
    long long n = gcd(a, b);
    vector<long long> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    return ans;
}

int main() {
    string s;
    cin >> s;
    bool ok = true;
    for (int i = 0; i < (int)s.length(); i++) {
        if (i % 2 == 0) {
            if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') ok = false;
        }
        else {
            if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') ok = false;
        }
    }
    if (ok) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <map>

using namespace std;

int main(){
    int n;
    cin>>n;
    map<string,long long>ans;
    for (int i = 0;i < n;i++){
        string St;
        cin>>St;
        sort(St.begin(),St.end());
        ans[St]++;
    }
    long long result = 0;
    map<string, long long>::iterator iter;
    for (iter = ans.begin();iter != ans.end();iter++){
        result += iter->second*(iter->second-1)/2;
    }
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    rep(i,ty-sy){
        cout << "U";
    }
    rep(i,tx-sx){
        cout << "R";
    }
    rep(i,ty-sy){
        cout << "D";
    }
    rep(i,tx-sx){
        cout << "L";
    }
    cout << "L";
    rep(i,ty-sy+1){
        cout << "U";
    }
    rep(i,tx-sx+1){
        cout << "R";
    }
    cout << "D";
    cout << "R";
    rep(i,ty-sy+1){
        cout << "D";
    }
    rep(i,tx-sx+1){
        cout << "L";
    }
    cout << "U";
    cout << endl;
}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    vector<vector<int>> a(s.size() + 1, vector<int>(26));
    for(int i = 0; i < s.size(); ++i){
        for(int j = 0; j < 26; ++j){
            if(s[i] == j + 'a') a[i+1][j] = a[i][j] + 1;
            else a[i+1][j] = a[i][j] - 1;
        }
    }
    for(int i = 0; i < 26; ++i){
        int m = 0, m_index = -1; // 今見ているものより2つ以上後ろであることが保証されている
        int m2 = 0, m_index2 = 0; // 
        for(int j = 1; j <= s.size(); ++j){
            if(m_index >= 0 && a[j][i] - m > 0) {
                cout << m_index + 1 << " " << j << "\n";
                return 0;
            }
            if(m2 > a[j][i]) {
                m = m2;
                m_index = m_index2;
                m2 = a[j][i];
                m_index2 = j;
            }
            else{
                m = m2;
                m_index = m_index2;
            }
        }
    }

    cout << "-1 -1\n";
    return 0;
}

Measured memory_bytes: 13648
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,K;
int A[100010];

signed main(){
	cin>>N>>K;
	REP(i,N){
		cin>>A[i];
	}
	int ans=0;
	REP(i,N){
		if(A[i]>=K){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] P = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int min = int.MaxValue;
            int count = 0;
            for (int i = 0; i < P.Length; i++)
            {
                if (P[i] < min)
                {
                    min = P[i];
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 33628
n,m = map(int,input().split())
a = [] # 1 → x
z = [] # x → n
an = 0
zn = 0
for i in range(m):
    x,y = map(int,input().split())
    if x == 1:
        zn += 1
        z.append(y)
    elif y == n:
        an += 1
        a.append(x)
    else:
        pass
a.sort()
z.sort()
i = 0
j = 0
while i < an and j < zn:
    if a[i] == z[j]:
        print('POSSIBLE')
        exit(0)
    else:
        if a[i] > z[j]:
            j += 1
        else:
            i += 1
print('IMPOSSIBLE')

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

int N, A[1 << 18], B[1 << 18];

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

	for (int i = N; i >= 1; i--) {
		B[i] = A[i];
		if (B[i] == 1) {
			for (int j = 1; j*j <= i; j++) {
				if (i%j != 0) continue;
				A[j] ^= 1;
				if (j != i / j) A[i / j] ^= 1;
			}
		}
	}
	vector<int> vec;
	for (int i = 1; i <= N; i++) { if (B[i] == 1) vec.push_back(i); }
	cout << vec.size() << endl;
	for (int i = 0; i < vec.size(); i++) { if (i) cout << " "; cout << vec[i]; } cout << endl;
	return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

//char型のポインタ(=配列と意味は同じ)をString型と定義([0]から数える)
typedef char* String;

//S[0]から始まる文字列の長さを求める関数
int string_len(String str){
    int len=0;
    while(str[len]!=0){
        len++;
    }
    return len;
}

//文字列を標準入力から読み込み、それをString型のメモリを確保し直してくれる関数
//S[0]~S[n-1]までが入力で、S[n]は0になる
//文字列長さの上限は1000まで

String string_input(void){
    int i,len;
    char buf[1000];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    
    len=string_len(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}

int main(void){
    String S=string_input(); //入力文字列

    int N=string_len(S);

    int count; //Yesなら1,Noなら0にする
    for(int i=0;i<N;i++){
        if(i%2==0){
            if(S[i]=='L'){
                count=0;
                break;
            }
            else{
                count=1;
            }
        }
        else{
            if(S[i]=='R'){
                count=0;
                break;
            }
            else{
                count=1;
            }
        }
    }

    if(count==1){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

//文字列をS[0]から始めるときは、問題文と偶奇がずれるので気をつける

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

struct Point{
  double s,t;};
void koch(int,struct Point,struct Point);

int main(){
  struct Point x,y;
  int n;
  scanf("%d",&n);
  x.s=0;
  x.t=0;
  y.s=100;
  y.t=0;

  printf("%.8f %.8f\n",x.s,x.t);
  koch(n,x,y);
  printf("%.8f %.8f\n",y.s,y.t);
  return 0;
}
void koch(int n,struct Point x,struct Point y){
  struct Point a,b,c;
  double ch;
  if(n==0)
    return;
  ch=M_PI*60.0/180.0;
  a.s=(2.0*x.s+1.0*y.s)/3.0;
  a.t=(2.0*x.t+1.0*y.t)/3.0;
  b.s=(1.0*x.s+2.0*y.s)/3.0;
  b.t=(1.0*x.t+2.0*y.t)/3.0;
  c.s=(b.s-a.s)*cos(ch)-(b.t-a.t)*sin(ch)+a.s;
  c.t=(b.s-a.s)*sin(ch)+(b.t-a.t)*cos(ch)+a.t;
  
 
  koch(n-1,x,a);
  printf("%.8f %.8f\n",a.s,a.t);
  koch(n-1,a,c);
  printf("%.8f %.8f\n",c.s,c.t);
  koch(n-1,c,b);
  printf("%.8f %.8f\n",b.s,b.t);
  koch(n-1,b,y);
}



Measured memory_bytes: 2700
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;

  using M = Mint<int>;
  vector<M> dp(n+2,0);
  dp[0]=1;
  for(int i=0;i<n;i++){
    vector<M> nx(n+2,0);
    for(int j=0;j<=n;j++){
      nx[j+1]+=dp[j]*M(2);
      nx[max(0,j-1)]+=dp[j];
    }
    swap(dp,nx);
  }

  cout<<dp[s.size()]*M(2).inv().pow(s.size())<<endl;
  return 0;
}


Measured memory_bytes: 256
#保証されている
#分解するとa<10**3となる...はずだが

x=int(input())

for b in range(10**3):
    a = int((x+b**5)**(1/5))
    for i in range(a-1000,a+1000):#小さい数でも漏れが出ている
        if i**5+b**5==x:
            print(i,-b)
            exit()
for b in range(10**3):
    a2=(x-b**5)
    if a2<0:
        continue
    a = int(a2**(1/5))
    
    for i in range(a-1000,a+1000):
        if i**5-b**5==x:
            print(i,b)
            exit()
    


Measured memory_bytes: 67804
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m;
ll p[100000],y[100000];
vector<ll> yd[100001];
int main(){
  cin>>n>>m;
  rep(i,m){
    cin>>p[i]>>y[i];
    yd[p[i]].push_back(y[i]);
  }
  rep(i,n){
    sort(ALL(yd[i+1]));
  }
  rep(i,m){
    printf("%012lld\n",ll(p[i])*1000000+(ll)(lower_bound(ALL(yd[p[i]]),y[i])-yd[p[i]].begin())+1);
	}
	
	return 0;
  }


Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
    ios::sync_with_stdio(false);
	string s,alpha="abcdefghijklmnopqrstuvwxyz";
	int k;
	cin>>s>>k;
	for(int i=0;i<s.length();i++){
		if(s[i]=='a') continue;
		if('z'-s[i]+1<=k){
			k-=('z'-s[i]+1);
			s[i]='a';
		}
	}
	for(int i=0;i<26;i++){
		if(alpha[i]==s[s.length()-1]){
			i+=k%26;
			if(i>=26) s[s.length()-1]=alpha[i-26];
			else s[s.length()-1]=alpha[i];
		}
	}
	cout<<s<<endl;
	return 0;
}



Measured memory_bytes: 592
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>

using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007

int main() {

	int n;
	int flag = 0;
	cin >> n;

	vector<int>num(n);
	rep(i, 0, n)cin >> num[i];

	rep(i, 0, n) {
		if (num[i] != i + 1)flag++;
	}
	
	if (flag <= 2)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}



Measured memory_bytes: 256
# AtCoder Beginner Contest 147 - B
# -*- encoding: UTF-8 -*-

s = input()
la = len(s)

lf = la // 2

slist =list(s)

flist = slist[:lf]
slist.reverse()
#print(flist)
#print(slist)
count = 0
for i in range(lf) :
  if flist[i] != slist[i] :
    count = count + 1

print(count)


Measured memory_bytes: 2940
N, M = list(map(int, input().split()))
a_list = sorted(list(map(int, input().split())))
b_c_list = []
for _ in range(M):
    b, c = list(map(int, input().split()))
    b_c_list.append((b, c))
b_c_list = sorted(b_c_list, key=lambda x: x[1], reverse=True)

def b_c_gen():
    for b, c in b_c_list:
        for _ in range(b):
            yield c

total = 0
for i, c in enumerate(b_c_gen()):
    if i >= N:
        break
    if a_list[i] >= c:
        i -= 1
        break
    total += c
i += 1

if i < N:
    total += sum(a_list[i:])
print(total)


Measured memory_bytes: 23288
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];

fn main() {
    input!(S: Chars);
    input!(T: Chars);

    let N = S.len();
    let M = T.len();
    let mut ans = 1_001;
    for i in 0..N - M + 1 {
        let mut cnt = 0;
        for j in 0..M {
            if T[j] != S[i + j] {
                cnt += 1;
            }
        }
        ans = min(ans, cnt);
    }
    println!("{}", ans);
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++){
    int A, B;
    cin >> A >> B;
    sum = sum + B - A + 1;
  }
  cout << sum;
}



Measured memory_bytes: 3644
#include <stdio.h>

int main(){
    while (1) {
        int n,p,stone,i;
        scanf("%d %d",&n,&p);
        stone=p;
        if (n==0&&stone==0) return 0;
        int player[n];
        for (i=0; i<n; i++) {
            player[i]=0;
        }
        i=0;
        while (player[i%n]!=p) {
            if (stone==0) {
                stone=player[i%n];
                player[i%n]=0;
            }else{
                player[i%n]++;
                stone--;
            }
            i++;
        }
        printf("%d\n",i%n);
    }
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


int main()
{
    int n,m,R;
    cin >> n >> m >> R;
    vi r(R);
    rep(i,R) {
        cin >> r[i];
        r[i]--;
    }
    sort(all(r));
    vvi dist(n,vi(n,INF));
    rep(i,n) dist[i][i] = 0;
    rep(i,m) {
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    rep(k,n) {
        rep(i,n) {
            rep(j,n) {
                chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int res = INF;
    do {
        int sum = 0;
        rep(i,R-1) {
            sum += dist[r[i]][r[i+1]];
        }
        chmin(res, sum);
    } while(next_permutation(all(r)));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int n;
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	cout<<(n+1)/2<<endl;
	return 0;
}


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

int main() {
	
    int n, l;
	cin >> n >> l;
	int max = l + n - 1;
    int min = max - (n - 1);
    int ans = 0;

    
    if (min <= 0 && max >= 0) {
		for (int m = max; m >= min; m--) {
 			ans += m;
		}
		cout << ans << endl;
		return 0;
	}
	else if (min > 0 && max > 0) {
		for (int m = max; m >= min; m--) {
 			ans += m;
		}
		ans -= min;
		cout << ans << endl;
		return 0;
 	}
	else if (max < 0 && max < 0) {
		for (int m = max; m >= min; m--) {
			ans += m;
		}
		ans -= max;
		cout << ans << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define P pair<int,int>
const LL N=1e6+10;
const LL mod=998244353;
using namespace std;
template<typename tp> inline void read(tp &x)
{
    x=0; char c=getchar(); bool f=0;
    for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());
    for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());
}
LL a,b,c,k;
int main()
{
	read(a),read(b),read(c),read(k);
	if(k%2) printf("%lld\n",b-a);
	else printf("%lld\n",a-b);
	return 0;
}

Measured memory_bytes: 256
// Problem : B - I miss you...
// Contest : AtCoder Beginner Contest 154
// URL : https://atcoder.jp/contests/abc154/tasks/abc154_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);
#define endl "\n"

int32_t main()
{
	IOS;
	int t = 1;
	//cin >> t;	
	for(int msi = 1; msi <= t; msi++)
	{
		string s;
		cin >> s;
		int n = (int)s.size();
		while(n--)
			cout << 'x';
	}	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

int main() {
  string S;
  string T;
  cin >> S >> T;
  int s = S.length(), t = T.length();
  if (s >= t) {
    for (int i = s-t; i >= 0; --i) {
      bool flag = true;
      for (int j = 0; j != t; ++j) {
        if (S[i+j] != '?' && S[i+j] != T[j]) {
          flag = false;
          break;
        }
      }
      if (flag) {
        for (int j = 0; j != s; ++j) {
          if (S[j] == '?') {
            if (j >= i && j < i + t) S[j] = T[j-i];
            else S[j] = 'a'; 
          }
        }
        cout << S << endl;
        return 0;
      }
    }
  }
  cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,m,a[1000],b[1000],ans=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
    }
    sort(a,a+m,greater<int>());
    for(int i=0;i<m-1;i++){
        if(a[i]<n)ans=ans+(n-a[i]);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3176
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    int t = sc.nextInt();
    int s = sc.nextInt();
    sc.close();
    if( (s * t) < d){
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 35640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map> 
using namespace std;

#define LL long long
#define MOD (1000000007)

//�ő����
LL GCD(LL a, LL b) {
	if (a < b) {
		LL temp = a;
		a = b;
		b = temp;
	}

	LL r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

//�ŏ����{��
LL LCM(LL a, LL b) {
	return a * b / GCD(a, b);
}


//131
int main() {
	LL A, B, C, D;

	scanf("%lld %lld %lld %lld", &A, &B, &C, &D);

	LL result = 0;

	LL lcm = LCM(C, D);

	A -= 1;

	result += B - (B / C) - (B / D) + (B / lcm);
	result -= A - (A / C) - (A / D) + (A / lcm);

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

	return 0;
}


//130
/*
int main() {
	LL W, H, x, y;

	scanf("%lld %lld", &W, &H);
	scanf("%lld %lld", &x, &y);

	double result = 1.0 * W * H / 2.0;

	int sub = 0;

	if (x * 2 == W && y * 2 == H) {
		sub = 1;
	}

	printf("%0.6f %d\n", result, sub);

	return 0;
}
*/

//129
/*
int main() {
	LL N, M;

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

	static LL dp[100010];
	memset(dp, 0, sizeof(dp));

	for (int i = 0; i < M; i++) {
		LL a;
		scanf("%lld", &a);

		dp[a] = -1;
	}

	dp[0] = 1;
	for (int i = 1; i <= N; i++) {
		if (dp[i] < 0) {
			continue;
		}

		if (dp[i - 1] > 0) {
			dp[i] += dp[i - 1]; //1step
		}
		
		if (i > 1 && dp[i - 2] > 0) {
			dp[i] += dp[i - 2]; //2step
		}

		dp[i] = dp[i] % MOD;
	}

	printf("%lld\n", dp[N]);

}
*/

//128
/*
int main() {
	LL N, M;

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

	unsigned int relation[11]; //index->switch No.
	memset(relation, 0, sizeof(relation));

	for (int i = 1; i <= M; i++) {
		LL k;
		scanf("%lld", &k);

		for (int j = 1; j <= k; j++) {
			unsigned int s;
			scanf("%d", &s);

			relation[s] |= (1 << (i - 1));
		}
	}

	unsigned int P = 0;
	for (int i = 1; i <= M; i++) {
		unsigned p;
		scanf("%d", &p);

		if (p > 0) {
			P |= (1 << (i - 1));
		}
	}

	LL result = 0;

	for (unsigned int pattern = 0; pattern < (unsigned int)pow(2, N); pattern++) {
		unsigned int on_off = 0; //bit��0�Ȃ�_��

		for (int i = 1; i <= N; i++) {
			if (((1 << (i - 1)) & pattern) != 0) {
				on_off ^= relation[i];
			}
		}

		on_off ^= P;

		if (on_off == 0) {
			result++;
		}
	}

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

}
*/

//127
/*
int main() {
	LL N, M;

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

	LL pass_count[100010];
	memset(pass_count, 0, sizeof(pass_count));

	for (int i = 1; i <= M; i++) {
		LL L, R;

		scanf("%lld %lld", &L, &R);

		pass_count[L]++;
		pass_count[R + 1]--;
	}

	LL result = 0;
	for (int i = 1; i <= N; i++) {
		pass_count[i] += pass_count[i - 1];
		if (pass_count[i] == M) {
			result++;
		}
	}

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

	return 0;
}
*/


//126
/*
int main() {
	LL N, K;

	cin >> N >> K;

	static double dp[200100];
	memset(dp, 0, sizeof(dp));

	for (int i = 1; i <= N; i++) {
		dp[i] = 1.0 / (double)N;
	}

	for (LL i = 1; i < K; i++) {
		dp[i * 2] += dp[i] * 0.5;
	}

	double result = 0;

	for (LL i = K; i < 200100; i++) {
		result += dp[i];
	}

	printf("%0.11f\n", result);

	return 0;
}
*/

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp;
    auto T = readln.chomp;
    int[27] ss, ts;
    foreach (i; 0..S.length) {
        int s = S[i] - 'a' + 1;
        int t = T[i] - 'a' + 1;
        if (ts[s] == 0 || ts[s] == t) {
            ts[s] = t;
        } else {
            writeln("No");
            return;
        }
        if (ss[t] == 0 || ss[t] == s) {
            ss[t] = s;
        } else {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}

Measured memory_bytes: 840
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"


#define MAX LLONG_MAX

#define MIN LLONG_MIN

using namespace std;

int main()
{
  ll n,l;
  cin >> n >> l;
  
  string *a = new string[n];
  
  for01(0,n)
    cin >> a[i];
  
  sort(a,a+n);
  
  for01(0,n)
    cout << a[i];
  
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

typedef long long ll;

using namespace std;


int main() {
    int N; cin >> N;
    int count = 0;
    long long mina = 1LL << 60;
    long long a[N]; 

    for (int i = 0 ; i < N; ++i) {
        long long x; cin >> x;
        a[i] = x;
        if (x < 0) ++count;
        mina = min(mina, abs(x));
    }

    long long sum = 0;
    for (int i = 0 ; i < N; ++i) sum += abs(a[i]);
    if (count % 2) sum -= 2 * abs(mina);
    cout << sum << endl;
}


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

const int INF=1001001001;
const int MX=100010;
int dp[MX][3],x[MX][3];

int main(){
    int n;
    cin>>n;
    rep(i,n){
        int a,b,c; cin>>a>>b>>c;
        x[i][0]=a;
        x[i][1]=b;
        x[i][2]=c;
    }
    rep(i,MX)rep(j,3)dp[i][j]=-INF;
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    rep(i,n){
        rep(j,3)rep(k,3){
            if(j==k)continue;
            dp[i+1][j]=max(dp[i+1][j],dp[i][k]+x[i][j]);
        }
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<long long> x(N);
  rep(i, 0, N){
    cin >> x[i];
  }
  
  long long answer = LLONG_MAX;
  rep(i, 0, N-K+1){
    long long smaller = x[i], bigger = x[i + K - 1], steps;
    steps = bigger - smaller + min(abs(smaller), abs(bigger));
    if (steps < answer){
      answer = steps;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int a,b,c,i,j;
    scanf("%d%d%d",&a,&b,&c);
    i=a;
    a=b;
    b=i;
    j=a;
    a=c;
    c=j;
    printf("%d %d %d\n",a,b,c);
    return 0;
}



Measured memory_bytes: 128
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    int ans = 0;
    rep(i, n - 2){
        if(s.substr(i, 3) == "ABC"){
            ++ans;
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count = [0] * 200005
for a in A:
    count[a] += 1

s = 0
for c in count:
    s += c * (c - 1) // 2

for a in A:
    c = count[a]
    x = c * (c - 1) // 2
    c -= 1
    y = c * (c - 1) // 2

    print(s - x + y)


Measured memory_bytes: 26268
from collections import Counter
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
s = [readline().decode().rstrip() for _ in range(n)]
m = int(readline())
t = [readline().decode().rstrip() for _ in range(m)]

sc = Counter(s)
tc = Counter(t)
ans = 0
for k, v in sc.items():
    if k in tc.keys():
        ans = max(ans, v-tc[k])
    else:
        ans = max(ans, v)
print(ans)

Measured memory_bytes: 3316
n, x, y = map(int, input().split())

ans = [0]*n

x = x-1
y = y-1

def search(i, j):
    if j <= x or y <= i:
        ans[j-i] += 1
    elif i <= x and x <= j and j <= y:
        d = min(j-i, x-i+y-j+1)
        ans[d] += 1
    elif x <= i and j <= y:
        d = min(j-i, i-x+y-j+1)
        ans[d] += 1
    elif x <= i and i <= y and y <= j:
        d = min(j-i, i-x+j-y+1)
        ans[d] += 1
    elif i <= x and y <= j:
        ans[x-i+j-y+1] += 1
    
    
for i in range(0, n-1, 1):
    for j in range(i+1, n, 1):
        search(i,j)
        
for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 49628
#include <iostream>
#include <string>

std::string zreverse(std::string s, int i, int j)
{
	while (i < j)
	{
		std::swap(s[i], s[j]);
		++i; --j;
	}
	return s;
}
int main()
{
	std::string str;
	int q;
	std::cin >> str >> q;
	int len = str.length();
	for (int i = 0; i < q; ++i)
	{
		std::string command, p;
		int a, b;
		std::cin >> command >> a >> b;
		if (command == "replace")
		{
			std::cin >> p;
			str = str.substr(0, a) + p + str.substr(b + 1, len - b - 1);
		}
		else if (command == "reverse")
			str = zreverse(str, a, b);
		else
			std::cout << str.substr(a, (b - a + 1)) << '\n';
	}

	return 0;
}


Measured memory_bytes: 3208
package main

import (
	"fmt"
	"math"
)

type zahyo struct {
	x float64
	y float64
}

func main() {
	var n int
	fmt.Scan(&n)
	list := make([]zahyo, n)
	for i :=0; i<n ; i++ {
		fmt.Scan(&list[i].x,&list[i].y)
	}
	cnt := 0.0

	chohuku := 2.0 * factorial(n-1)
	//N!通り全部の距離合計（あとでansでｎで割って平均値を算出）
	for i:=0; i<n-1; i++ {
		for j :=i+1; j<n; j++ {
			cnt += math.Sqrt(squa(list[i].x-list[j].x) + squa(list[i].y - list[j].y))*float64(chohuku)
		}
	}
	fmt.Println(cnt/(float64(factorial(n))))
}

func factorial(n int) int {
	return permutation(n, n - 1)
}
func permutation(n int, k int) int {
	v := 1
	if 0 < k && k <= n {
		for i := 0; i < k; i++ {
			v *= (n - i)
		}
	} else if k > n {
		v = 0
	}
	return v
}

func squa (a float64)float64 {
	return a*a
}

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

typedef long long ll;
typedef tuple<ll, ll, ll> mytuple;
const ll INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589793238;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) { if (b == 0) {return a;} else {return GCD(b, a % b);} }
// a と b の最小公倍数を返す関数
long long LCM(long long a, long long b) { return a/GCD(a,b)*b; }

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

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

  // for(int64_t x = 0; x <= N; x++) {
  //   int64_t t = (A*x)/B - A*(x/B);
  //   cout << t << endl;
  // }

  int64_t a = min(B-1, N);
  cout << (A*a)/B - A*(a/B) << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>


#define NMAX 100002
using namespace std;

vector<int> v;
int H,N,A[NMAX],B[NMAX];

bool judge(int a){
	long long sum = 0;
	for (int i = 0; i < a; ++i)
	{
		if(i < v.size()){
			sum += v[i];
		}else{
			sum += v[v.size()-1]*(a-v.size());
			break;
		}
	}
	return (H <= sum);
}

int main(){
	cin >> N >> H;
	int a = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i] >> B[i];
		a = max(A[i],a);
	}
	v.push_back(a);
	for (int i = 0; i < N; ++i)
	{
		if(B[i] > a){
			v.push_back(B[i]);
		}
	}
	sort(v.begin(), v.end(),greater<int>());
	int r = 0,l = H/A[0] + (H%A[0] != 0);
	while(l - r > 1){
		int m = (l-r)/2+r;
		if(judge(m)) l = m;
		else r = m;
	}
	// for (int i = 0; i < v.size(); ++i)
	// {
	// 	cout << v[i] << " ";
	// }
	// cout << endl;
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll N; cin >> N;
    vector<string> str(N);
    rep(i, N) cin >> str[i];

    ll a = 0, b = 0, c = 0, d = 0;

    rep(i, N) {
        if (str[i] == "AC") { ++a; }
        else if (str[i] == "WA") { ++b; }
        else if (str[i] == "TLE") { ++c; }
        else if (str[i] == "RE") { ++d; }
    }

    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;

}

Measured memory_bytes: 5260
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long int N;
    long int A,B;
    long int S=0;
    long int Y=0;
    long int T=0;
    scanf("%ld %ld %ld",&N,&A,&B);


        S=N/(A+B);
        Y=N%(A+B);
        if(Y>A)
            T=(S*A)+A;
        else
            T=(S*A)+Y;

    printf("%ld",T);
    return 0;
}

Measured memory_bytes: 128