akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var Q = int.Parse(Console.ReadLine());
        var sorted = a.OrderBy(_ => _).ToArray();
        var ok = new bool[N];
        var diff = 0;
        for (int i = 0; i < N; i++)
        {
            ok[i] = a[i] == sorted[i];
            if (!ok[i])
            {
                diff++;
            }
        }
        if (diff == 0)
        {
            Console.WriteLine(0);
        }
        else
        {
            for (int i = 0; i < Q; i++)
            {
                var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var x = input[0] - 1;
                var y = input[1] - 1;
                var t = a[x];
                a[x] = a[y];
                a[y] = t;
                var z = new[] { x, y };
                foreach (var j in z)
                {
                    if (a[j] == sorted[j])
                    {
                        if (!ok[j])
                        {
                            ok[j] = true;
                            diff--;
                        }
                    }
                    else
                    {
                        if (ok[j])
                        {
                            ok[j] = false;
                            diff++;
                        }
                    }
                }
                if (diff == 0)
                {
                    Console.WriteLine(i + 1);
                    return;
                }
            }
            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 58900
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int[] a = new int[N];
        for(int i=0;i<N;i++){
            a[i] = int.Parse(str[i]);
        }
        Array.Sort(a);
        sb.Append((a[N-1]-a[0])+"\n");
    }
}

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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int k;
	cin >> k;
	queue<long long> q;
	for (int i = 1; i < 10; ++i){
		q.push(i);
	}
	while (1){
		long long u = q.front();
		q.pop();
		if (--k == 0){
			cout << u;
			return 0;
		}
		if ((10ll * u + u % 10) % 10 != 0){
			q.push(10ll * u + u % 10 - 1);
		}
		q.push(10ll * u + u % 10);
		if ((10ll * u + u % 10) % 10 != 9){
			q.push(10ll * u + u % 10 + 1);
		}
	}
	return 0;
}


Measured memory_bytes: 1792
import sys

retsu = int(input())

def dfs( s , n ):
    i = 0
    if len(s) == n:
        ans.append(s)
        return
    else:
        a = int(s[len(s)-1])
        for j in range(3):
            if a+j-1 >= 0 and a+j-1 <= 9:
                dfs( s + str(a+j-1) , n )
                
ans = []
for i in range(1,11):
    for j in range(10):
        a = str(j)
        dfs( a , i )
        
ans2 = []
for i in ans:
    if i[0] != "0":
        ans2.append(int(i))
        
print(ans2[retsu-1])

Measured memory_bytes: 26904
import sys
from collections import deque

input = sys.stdin.readline


def calc_group(N, G, group_id, group_cnt):
    g_id = 0
    for i in range(N):
        if group_id[i] != -1:
            continue
        cnt = 1
        group_id[i] = g_id
        stack = deque([i])
        while stack:
            v = stack.pop()
            for u in G[v]:
                if group_id[u] != -1:
                    continue
                cnt += 1
                group_id[u] = g_id
                stack.append(u)
        g_id += 1
        group_cnt.append(cnt)


def main():
    N, M, K = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        G[A].append(B)
        G[B].append(A)
    B = [[] for _ in range(N)]
    for i in range(K):
        C, D = map(int, input().split())
        C -= 1
        D -= 1
        B[C].append(D)
        B[D].append(C)

    group_id = [-1] * N
    group_cnt = []
    calc_group(N, G, group_id, group_cnt)

    ans = [0] * N
    for i in range(N):
        n_neighbor = len(G[i])
        n_block = sum(1 for j in B[i] if group_id[i] == group_id[j])
        ans[i] = (group_cnt[group_id[i]] - 1) - n_neighbor - n_block

    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 51828
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (500 * a >= b)
                System.out.println("Yes");
            else
                System.out.println("No");
        
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
long long n,p,lcm,tot;
long long arr[100001];
long long num[1000001];
long long power(long long a,long long b){
    long long res=1;
    while (b>0){
        if (b%2==1) res=(res*a)%p;
        b/=2;
        a=(a*a)%p;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    p=1e9+7;
    for (int i=1;i<=n;i++) cin>>arr[i];
    for (long long i=1;i<=n;i++){
        long long cur=arr[i];
        for (long long j=2;j*j<=arr[i];j++){
            long long res=0;
            while (cur%j==0){
                res++;
                cur/=j;;
            }
            num[j]=max(num[j],res);
        }
        if (cur!=1){
            num[cur]=max(num[cur],1LL);
        }
    }
    lcm=1;
    for (long long i=1;i<=1000000;i++){
        lcm*=power(i,num[i]);
        lcm%=p;
    }
    for (long long i=1;i<=n;i++){
        tot+=lcm*power(arr[i],p-2);
        tot%=p;
    }
    cout<<tot;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s,t;
    cin>>s>>t;
    ll a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(s==u){
        --a;
    }else{
        --b;
    }
    cout<<a<<" "<<b<<endl;
}

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

int n,ta,ao,ans;
vector<int> g[100005];
int dis[100005];

void dfs(int x,int p,int d){
    if(d>=dis[x]){//如果被抓到了就退出
        ans=max(ans,dis[x]);
        return;
    }
    for(int i=0;i<g[x].size();i++){
        int y=g[x][i];
        if(y!=p){
            dfs(y,x,d+1);
        }
    }
    if(g[x].size()==1){//是叶子结点，就特判一下之前做法中提到的情况
        ans=max(ans,dis[x]-1);
    }
}

int main(){

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

    cin>>n>>ta>>ao;
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    memset(dis,-1,sizeof(dis));
    dis[ao]=0;
    {//预处理青木到每个结点的距离dis
        queue<int> q;
        q.push(ao);
        while(!q.empty()){
            int x=q.front();q.pop();
            for(int i=0;i<g[x].size();i++){
                int &y=g[x][i];
                if(dis[y]==-1){
                    dis[y]=dis[x]+1;
                    q.push(y);
                }
            }
        }
    }
    dfs(ta,-1,0);
    cout<<ans<<endl;

    return 0;
}

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

#define MAX 100000

typedef struct Card{
	int number;
	char soot[10];
}card;

int partition(card A[], int p, int r){
	int x = A[r].number;
	card nu;
	int i = p - 1;
	for(int j = p; j < r; j++){
		if(A[j].number <= x){
			i = i + 1;
			nu = A[i];
			A[i] = A[j];
			A[j] = nu;
		}
	}
	nu = A[i + 1];
	A[i + 1] = A[r];
	A[r] = nu;
	return i + 1;
}

int quickSort(card A[], int p, int r){
	if(p < r){
		int q = partition(A, p, r);
		quickSort(A, p, q-1);
		quickSort(A, q+1, r);
	}
}

int isStable(card be_val[],card af_val[],int n){
	int lastNo = 0;
	int lastval = 0;
	for(int i = 0; i < n; i++){
		if(lastNo != af_val[i].number){
			lastNo = af_val[i].number;
			lastval = 0;
		}
		int u = lastval;
		for(; u < n;u++){
			if(af_val[i].number == be_val[u].number){
				if(strcmp(af_val[i].soot, be_val[u].soot) == 0){
					lastval = u + 1;
					u = n + 1000000;
				}else{
					return 0; //false
				}
			}
		}
		if(u < n + 1000000){
			return 0; //false
		}
	}
	return 1; //true
}


int main(){
	int n;
	card val[MAX];
	card valfirst[MAX];
	
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%s",val[i].soot);
		scanf("%d",&val[i].number);
		valfirst[i].number = val[i].number;
		strcpy(valfirst[i].soot,val[i].soot);
	}

	quickSort(val,0,n-1);
	
	if(isStable(valfirst,val,n)){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}
	
	for(int i = 0;i < n; i++){
		printf("%s %d\n",val[i].soot,val[i].number);
	}
	return 0;
}




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

main()
{
    int l,r;
    cin>>l>>r;
    int length=r-l+1;
    if(length>=2019){
        cout<<0<<"\n";
        return 0;
    }
    int ans=INT_MAX;
    for(int i=l;i<=r;i++)
    {
        for(int j=i+1;j<=r;j++)
        {
            ans=min((i*j)%2019,ans);
        }
    }
    cout<<ans<<"\n";
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	bool flag = 1;
	while (flag) {
		flag = 0;
		for (int j = n - 1; j >= 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				ans++;
				flag = 1;
			}
		}
	}
	for (int i = 0; i < n; i++)
		cout << a[i] << (i == n - 1 ? '\n' : ' ');
	cout << ans << endl;
}


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

int main() {
    int n,ans=0;cin>>n;
    
    for(int i=1;i<10;++i){
        for(int j=1;j<10;++j){
            if(n==i*j){
                ans=1;
                break;
            }
        }
    }
    if(ans==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,m,x,y=parseMap(split(readline()))
    xx=sort(parseMap(split(readline())))
    yy=sort(parseMap(split(readline())))
    ans="War"
    for i in x+1:y
        if xx[end]<i && yy[1]>=i
            ans="No War"
            break
        end
    end
    println(ans)
end
main()

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define modsum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define modsubtract(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define modmultiply(a, b) (((a) * (b)) % M)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)((a).size()))
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


inline void transpose(vector<string> &a) {

    int n = a.size();
    if (n == 0) return;
    int m = a[0].size();
    vector<string> b(m, string(n, ' '));
    fori (i, n) fori (j, m) b[j][i] = a[i][j];
    a = b;
}


template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "{";
    fori (i, SZ(a))
        out << a[i] << vector<string>{", ", "}"}[i + 1 == SZ(a)];
    return out;
}

void smain();

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


#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#define cerr cout
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\n";
    cout << "TOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}


const int N = 1e5 + 9;
const int L = 1e4 + 9;
const ll oo = 1e18;


void smain() {


    int n;
    cin >> n;
    vl h(n + 1, 0), dp(n + 1, oo);
    fori (i, n) cin >> h[i + 1];
    dp[1] = 0;
    for (int i = 2; i <= n; ++i) {
        for (int step : {1, 2}) {
            if (i - step >= 1) inmin(dp[i], dp[i - step] + abs(h[i] - h[i - step]));
        }
    }
    cout << dp[n];
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b){
    return a < b ? a : b; 
}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for(int i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;
    tail = n + 1;
    
    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0){
            enqueue(u);
        }
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    
    return 0;
}


Measured memory_bytes: 12716
#include<stdio.h>

int main(){
  int n,m;
  int k[1000000];
 
  int sum=0;
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d",&k[i]);
    sum+=k[i];
  }
  
  if(n-sum<0) printf("-1");
  else printf("%d",n-sum);
  
  return 0;
}
  

Measured memory_bytes: 1780
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int h, int w) {

    long _calc(long h, long w) {
        long ans = long.max;

        for (int i = 1; i < w; i++) {
            long a = h * i;

            long hTop = h / 2;
            long hBtm = h - hTop;
            long b = hTop * (w - i);
            long c = hBtm * (w - i);
            ans = min(ans, max(a, b, c) - min(a, b, c));
        }

        for (int i = 1; i < w - 1; i++) {
            long a = h * i;

            long w2 = w - i;
            long wLeft = w2 / 2;
            long wRight = w2 - wLeft;
            long b = h * wLeft;
            long c = h * wRight;
            ans = min(ans, max(a, b, c) - min(a, b, c));
        }
        return ans;
    }

    return min(_calc(h, w), _calc(w, h));
}

void main() {
    auto hw = readints;
    int h = hw[0], w = hw[1];
    writeln(calc(h, w));
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define N 100005
int main()
{
    int n,m,i,j,k,l;
    int T,unit;
    int z,y,x1,y1;
    int ans1=0,ans2=0;
    int n1,n2;
    char x[20];
    scanf("%s",&x);
    if(strcmp(x,"Sunny")==0)
        printf("Cloudy\n");
    else if(strcmp(x,"Cloudy")==0)
        printf("Rainy\n");
    else
        printf("Sunny");
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int minm = 1e8;
  for(int i = 2; i < (int)s.size(); i++) {
    string tmp = ""s + s[i-2] + s[i-1] + s[i];
    int ans = stoi(tmp);
    minm = min(minm, abs(753-ans));
  }
  cout << minm << endl;
  return 0;
}
    

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,T; cin>>N>>T;
	vector<ll> t(N);
	rep(i,N) cin>>t[i];
	ll ans=0;
	rep(i,N-1){
		ans+=min(t[i+1]-t[i],T);
	}
	cout<<ans+T;
}

Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N, M, X;
	cin >> N >> M >> X;
	int left = 0, right = 0;
	int num;
	rep(i, M) {
		cin >> num;
		if (num < X)left++;
		else right++;
	}
	cout << min(left, right);
}

Measured memory_bytes: 256
n = int(input())
k = 26
p = 1
while (n > k):
	n -= k
	k *= 26
	p += 1
k = 26 ** (p - 1)
s = ""
n -= 1
while (k):
	s += chr(ord('a') + n // k)
	n %= k
	k //= 26
print(s)
# print(p, n)

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

int main() 
{
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    q[i] = p[i];
  }
  int count = 0;
  sort(q.begin(), q.end());

  for (int i = 0; i < n; i++) {
    if (p[i] != q[i]) count++;
  } 
  if (count <= 2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

powof2 = lambda x: len("{:b}".format(x))

def f2(n, h, a):
    p = powof2(n)
    N = 2 ** p
    segt = [0] * (2 * N - 1)

    def getmax(a, b, i = 0, l = 0, r = N - 1):
        if r <= a or b <= l:
            return(0)
        if a <= l and r <= b:
            return(segt[i])
        i1 = 2 * i + 1
        i2 = i1 + 1
        lr = (l + r) // 2
        lmax = getmax(a, b, i1, l, lr)
        rmax = getmax(a, b, i2, lr, r)
        return(lmax if lmax > rmax else rmax)

    def setmax(i, v):
        si = i + N - 1
        segt[si] = v
        while si > 0:
            si = (si - 1) // 2
            si1 = 2 * si + 1
            si2 = si1 + 1
            segt[si] = segt[si1] if segt[si1] > segt[si2] else segt[si2]

    for i in range(1, n + 1):
        m = getmax(0, h[i])
        setmax(h[i], m + a[i])

    return(getmax(0, n))

n = int(input()) # 1 <= n <= 2 x 10^5
h = [0] + list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
print(f2(n, h, a))


Measured memory_bytes: 123088
void main() {
    int[] ab = readln.split.to!(int[]);
    writeln(ab.sum < 10 ? ab.sum.to!string : "error");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
program Touitsh
    implicit none
    integer(4):: n,i,ans
    character(:),allocatable:: a,b,c
    logical:: b1,b2,b3

    read*, n
    allocate(character(n):: a,b,c)
    read*, a
    read*, b
    read*, c

    ans=0
    do i=1,n
        b1 = a(i:i) == b(i:i)
        b2 = b(i:i) == c(i:i)
        b3 = a(i:i) == c(i:i)

        if (b1 .and. b2 .and. b3) then
            cycle
        else if (.not. (b1 .or. b2 .or. b3)) then
            ans=ans+2
        else
            ans=ans+1
        end if
    end do

    print*, ans
end program Touitsh

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

bool isPrime(int num)
{
  for (int i = 3; i*i <= num; i += 2)
    if (num % i == 0)
      return false;  
  
  // 素数である
  return true;
}

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

  if (X==2 || X==3) {
    cout << X << endl;
    return 0;
  }
  
  for (int x=X; ;) {
    if (x%2==0)
      ++x;

    if (isPrime(x)) {
      cout << x << endl;
      break;
    }
    
    x += 2;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(){
	char s;
	bool c = false,f = false;
	while(cin >>s){
		if (s =='C') c = true;
		else if(s == 'F'){
			if(c){
				f = true;
				cout << "Yes";
				return 0;
			}
		}
	}
	if(!f) cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  LL n,m,k; cin>>n>>m>>k;
  vector<LL> a(n),b(m);
  forn(i,n){
  	cin>>a[i];
  	if(i>=1) a[i]+=a[i-1];
  }
  forn(i,m){
  	cin>>b[i];
  	if(i>=1) b[i]+=b[i-1];
  }
  LL an = 0;
  forn(i,n){
  	LL cnt = 0;
  	if(a[i]<=k){
  		cnt = i+1;
  		cnt += upper_bound(all(b), k - a[i]) - b.begin();
  		an = max(an, cnt);
  	}
  	else break;
  }
  forn(i,m){
  	LL cnt = 0;
  	if(b[i]<=k){
  		cnt = i+1;
  		cnt += upper_bound(all(a), k - b[i]) - a.begin();
  		an = max(an, cnt);
  	}
  	else break;
  }
  cout<<an<<endl;
  return 0;
}

Measured memory_bytes: 6364
#include <iostream>

using namespace std;

int main(void){
  int i,n;
  int x[9] = {111,222,333,444,555,666,777,888,999};
  
  cin >> n;
  
  for(i = 0 ; i < 9 ; i++){
    if(n <= x[i]) break;
  }
  cout << x[i] << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
      if i+1 < b+1:
        A.append(s[i:i+1])
      if i+2 < b+1:
        A.append(s[i:i+2])
      if i+3 < b+1:
        A.append(s[i:i+3])
      if i+4 < b+1:
        A.append(s[i:i+4])
      if i+5 < b+1:
        A.append(s[i:i+5])
B = set(A)
B = list(B)
B = sorted(B)
print(B[K-1])

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

int main() {
  string T;
  cin >> T;
  int N = T.size();
  int cnt = 0;
  for(int i = 0; i < N; ++i){
    if(T.at(i) == '?'){
      T.at(i) = 'D';
    } 
  }

  cout << T << endl;
}


Measured memory_bytes: 3752
#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int rot[24][7] = {
	{ 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
	{ 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
	{ 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
	{ 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
	{ 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
	{ 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };

int  a[102][7];
char f[102];

int identical(int *a, int *b)
{
	int i, j;
	memset(f, 0, sizeof(f));
	for (i = 1; i <= 6; i++) f[a[i]]++;
	for (i = 1; i <= 6; i++) f[b[i]]--;
	for (i = 1; i <= 6; i++) if (f[b[i]]) return 0;

	for (j = 0; j < 24; j++) {
		if (b[1] == a[rot[j][1]]) {
			for (i = 2; ; i++) {
				if (i > 6) return 1;
				if (b[i] != a[rot[j][i]]) break;
			}
		}
	}
	return 0;
}

int main()
{
	int n, i, j, f;

	n = in();
	for (i = 0; i < n; i++) {
		for (j = 1; j <= 6; j++) a[i][j] = in();
	}
	f = 1;
	for (i = 0; i < n; i++) for (j = i+1; j < n; j++) {
		if (identical(a[i], a[j])) { f = 0; goto done; }
	}
done:
	puts(f? "Yes": "No");
	return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
char s[1002],p;
long long a,n,b,k,l,r;
int main(){
	cin>>s;
	cin>>n;
	if(s[0]==s[strlen(s)-1]){
		l=0;
		while(s[++l]==s[0]);
		r=strlen(s)-1;
		while(s[--r]==s[strlen(s)-1]);
		for(long long i=1;i<strlen(s);++i){
			if(s[i]==s[i-1]){
				k++;
				i++;
			}
		}
		if(l>r){
			if(strlen(s)%2==0){
				printf("%lld",k*n);
			}
			else{
				printf("%lld",k*n+n/2);
			}
		}
		else{
			for(register int i=l+1;i<=r;++i){
				if(s[i]==s[i-1]){
					b++;
					i++;
				}
			}
			printf("%lld",k+(b+(l+strlen(s)-1-r)/2)*(n-1));
		}

	}
	else{
		for(long long i=1;i<strlen(s);++i){
			if(s[i]==s[i-1]){
				k++;
				i++;
			}
		}
		printf("%lld",k*n);
	}
}

Measured memory_bytes: 256
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    string s; cin >> s;
    if(s == "RRR")cout << 3 << endl;
    else if (s == "RRS" || s == "SRR")cout << 2 << endl;
    else if(s == "SSS")cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3652
#import <stdio.h>

int main() {
    long N,x;
    scanf("%ld %ld", &N,&x);
    long cost = 0;
    long last;
    for (long i=0; i<N; i++){
        long a;
        scanf("%ld",&a);
        if (i==0) {
            if (a>x) {
                last = x;
                cost = a - x;
            } else {
                last = a;
            }
            continue;
        }
        if (last + a <= x) {
            last = a;
            continue;
        }
        last = x - last;
        cost += a - last;
    }
    
    printf("%ld", cost);
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision 
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
int lcm(int a,int b){//最小公倍数
  return (a*b)/gcd(a,b);
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);    
    int a,b,c=0;
    cin>>a>>b;
    if(a%b!=0)c++;
    cout<<a/b+c<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int k, s; cin>>k>>s;
    int ans=0;
    for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){
            if(0<=s-i-j && s-i-j<=k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, b, ca, cb, a[10005];
int main() {
	ll i;
	cin >> n;
	for(i=0; i<n; i++) scanf("%lld", &a[i]);
	for(i=0; i<n; i++) {
		scanf("%lld", &b);
		if(b < a[i]) ca += a[i]- b;
		else if(b > a[i]) cb += b-a[i] >> 1;
	}
	puts(cb>=ca ? "Yes" : "No");
	return 0;
}

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

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

    vector<int> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());

    int A = 0, B = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0) A += v[i];
        else B += v[i];
    }
    cout << A - B << endl;
}

Measured memory_bytes: 256
N = int(input())
ans = [0] * N
for i in range(1,101):
    for j in range(1,101):
        if i ** 2 + j ** 2 > N: break
        for k in range(1,101):
            if i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i <= N:
                ans[i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i - 1] += 1
for i in ans: print(i)


Measured memory_bytes: 69084
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

char s[600][600];
ll h,w;
int main(){
	scanf("%lld%lld\n",&h,&w);
	rep(i,0,h)scanf("%s",s+i);

	rep(i,0,h){
		rep(j,0,w)putchar(j==0||(i%2==0&&j!=w-1)||s[i][j]=='#'?'#':'.');
		putchar('\n');
	}
	putchar('\n');
	rep(i,0,h){
		rep(j,0,w)putchar(j==w-1||(i%2==1&&j!=0)||s[i][j]=='#'?'#':'.');
		putchar('\n');
	}
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  int need = n / 2;
  vector<int> v(2, 0);
  for(int i = 0; i < n; i++){
    if(a[i] % 4 == 0) v[0]++;
    if(a[i] % 4 != 0 && a[i] % 2 == 0) v[1]++;
  }
  need -= v[0];
  need -= v[1]/2;
  cout << (need <= 0 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	string S,T;
	cin >> S >> T;
	ll nS = S.size();
	ll nT = T.size();
	ll sameTS = 0;

	for(ll i = 0; i<=nS-nT; i++){
		ll sam = 0;
		for(ll j = 0; j<nT; j++){
			if(S[i+j]==T[j])
				sam++;
		}
		if(sameTS<sam)
			sameTS = sam;
	} 

	cout << nT - sameTS;

	cin >> S;
	
	return 0;	
}


Measured memory_bytes: 3608
#include <string>
#include <iostream>
#include <vector>
#include <algorithm> 
using namespace std;
int main()
{
	string s;
	int n;
	cin>>n;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		s[i]=((s[i]-'A')+n)%26+'A';
	}
	for(int i=0;i<s.length();i++)
		cout<<s[i];
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    vector<int> v(3);
    for(int i=0; i<n; ++i){
        int p;
        cin >> p;
        if(p <= a)
            ++ v[0];
        else if(p <= b)
            ++ v[1];
        else
            ++ v[2];
    }
    int ans = *min_element(v.begin(), v.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque



# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
from bisect import bisect_left as bl
from math import log2,ceil
from heapq import heappush, heappop
from itertools import permutations 
def main():
    # for t in range(int(input())):
        n = int(input())
        x = (n+1000)//1000*1000-n
        if x==1000:
            print(0)
        else:
            print(x)

            # heappush(h, l[i])

        


        
        




# endregion

if __name__ == "__main__":
    main()



Measured memory_bytes: 66116
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, x, v[100005], respa=0, respw=0, testa[100005];
    string deu;
    memset(v, 0, sizeof(v));
    memset(testa, 0, sizeof(testa));
    cin >> n >> m;
    for(int i=0; i<m; i++){
        cin >> x >> deu;
        if(deu=="WA" && testa[x]==0){
            v[x]++;
        }
        if(deu=="AC" && testa[x]==0){
            respw+=v[x];
            respa++;
            testa[x]=1;
        }
    }
    cout << respa << " " << respw << endl;
    return 0;
}

Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

struct P {
    ll x, y;
    char ty;
};
ostream& operator<<(ostream& os, const P& p) {
    return os << p.ty << "(" << p.x << ", " << p.y << ")";
}

V<ll> v;
ll dfs(int l, int r, ll a, ll b) {
    if (l > r) return 0;
    ll ans = TEN(18);
    for (int k = l; k <= r; k++) {
        ans = min(ans, (a + b) * v[k] + dfs(l, k - 1, a, a + b) + dfs(k + 1, r, a + b, b));
    }
    return ans;
}


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


    int n;
    cin >> n;
    v = V<ll>(n);
    for (int i = 0; i < n; i++) cin >> v[i];

    cout << v[0] + v[n - 1] + dfs(1, n - 2, 1, 1) << endl;
    // set<V<int>> st;
    // st.insert({1, 1});

    // for (int ph = 3; ph <= 18; ph++) {
    //     set<V<int>> nst;
    //     for (auto v: st) {
    //         int n = int(v.size());
    //         for (int i = 1; i <= n - 1; i++) {
    //             auto w = v;
    //             w.insert(w.begin() + i, {v[i - 1] + v[i]});
    //             nst.insert(w);
    //         }
    //     }
    //     st = nst;
    //     cout << "PH " << ph << " : " << st.size() << endl;
    // }
    return 0;
}



Measured memory_bytes: 256
n = gets.to_s.to_i
a = gets.to_s.split.map{|i|i.to_i}

c = Array.new(2*10**5+1,0)
a.each do |k|
  c[k] += 1
end

s = 1
c.each{|k| s += k * (k-1)/2 if k > 0}.inject(:+)

a.each do |k|
  puts s - c[k]
end

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
string A[202];
int dp[200][200];

short R[190][190][190][18]; //y1,y2,x,n
short D[190][190][190][18]; //x1,x2,y,n

int ok(int y1,int y2,int x1,int x2) {
	if(y2>H || x2>W) return 0;
	int num=dp[y2][x2]-dp[y1][x2]-dp[y2][x1]+dp[y1][x1];
	return num==0 || num==(y2-y1)*(x2-x1);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) {
		cin>>A[y];
		FOR(x,W) {
			dp[y+1][x+1]=dp[y+1][x]+dp[y][x+1]-dp[y][x];
			if(A[y][x]=='#') dp[y+1][x+1]++;
		}
	}
	
	int y1,y2,x1,x2;
	FOR(y1,H) for(y2=y1+1;y2<=H;y2++) {
		FOR(x,W) {
			R[y1][y2][x][0]=x;
			for(i=8;i>=0;i--) if(ok(y1,y2,x,R[y1][y2][x][0]+(1<<i))) R[y1][y2][x][0]+=1<<i;
		}
		FOR(i,17) R[y1][y2][W][i]=W;
	}
	FOR(x1,W) for(x2=x1+1;x2<=W;x2++) {
		FOR(y,H) {
			D[x1][x2][y][0]=y;
			for(i=8;i>=0;i--) if(ok(y,D[x1][x2][y][0]+(1<<i),x1,x2)) D[x1][x2][y][0]+=1<<i;
		}
		FOR(i,17) D[x1][x2][H][i]=H;
	}
	
	if(R[0][H][0][0]==W) return _P("0\n");
	for(i=1;i<=17;i++) {
		FOR(y1,H) for(y2=y1+1;y2<=H;y2++) FOR(x,W) R[y1][y2][x][i]=R[y1][y2][R[y1][y2][x][i-1]][i-1];
		FOR(x1,W) for(x2=x1+1;x2<=W;x2++) FOR(y,H) D[x1][x2][y][i]=D[x1][x2][D[x1][x2][y][i-1]][i-1];
		FOR(y1,H) FOR(x1,W) {
			for(y2=y1+1;y2<=H;y2++) {
				x=R[y1][y2][x1][i];
				D[x1][x][y1][i]=max(D[x1][x][y1][i],(short)y2);
			}
			for(x2=x1+1;x2<=W;x2++) {
				y=D[x1][x2][y1][i];
				R[y1][y][x1][i]=max(R[y1][y][x1][i],(short)x2);
			}
			for(y=H-1;y>y1;y--) R[y1][y][x1][i]=max(R[y1][y][x1][i],R[y1][y+1][x1][i]);
			for(x=W-1;x>x1;x--) D[x1][x][y1][i]=max(D[x1][x][y1][i],D[x1][x+1][y1][i]);
		}
		if(R[0][H][0][i]==W) return _P("%d\n",i);
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 473472
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<P> v;
	int cnt = 0;
	if (n % 2 == 0){
		for(int i = 1; i < n; i++) {
			for(int j = i + 1; j <= n; j++) {
				if (i + j != n + 1){
					v.pb(mp(i,j));
					cnt++;
				}
			}
		}
	}
	else{
		for(int i = 1; i < n; i++) {
			for(int j = i + 1; j <= n; j++) {
				if (i + j != n){
					v.pb(mp(i,j));
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
	for(int i = 0; i < cnt; i++) {
		cout << v[i].fs << " " << v[i].sc << endl;
	}
	return 0;
}

Measured memory_bytes: 512
n, a, b = map(int, input().split())
X = list(map(int, input().split()))
cost = [0]*n
for i in range(n-1):
    if (X[i+1] - X[i])*a > b:
        cost[i+1] = b
        continue
    cost[i+1] = (X[i+1] - X[i])*a
ans = sum(cost)
print(ans)


Measured memory_bytes: 14252
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {

            int a, b, A, B, C, max;

            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            A = a + b;
            B = a - b;
            C = a * b;

            if (A >= B)
                if (A > C) max = A;
                else max = C;

            else if (B > A)
                if (B > C) max = B;
                else max = C;
            else
                max = C;


            Console.WriteLine(max);

            Console.ReadKey();
        }
    }
}


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

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n;
    cin >> n;
    ll res = 0;
    for(int i = 1; i <= n; ++i) {
        if(i%3 != 0 && i%5 != 0)
            res += i;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3652
function main(input){
  var line = input[0].split(' ');
  var n = parseInt(line[0]);
  var a = parseInt(line[1]);
  var b = parseInt(line[2]);
  
  console.log(Math.min(a, b) + ' ' + Math.max(0, a+b -n));
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


Measured memory_bytes: 7500
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    int n;
    string s;
    cin>>n;
    cin>>s;
    char ans[114514]={};
    for(int i=0;i<2;i++){
        if(i==0){
            ans[0]='S';
        }else{
            ans[0]='W';
        }
        for(int j=0;j<2;j++){
            if(j==0){
                ans[1]='S';
            }else{
                ans[1]='W';
            }
            bool f=true;
            for(int k=2;k<n;k++){
                if(ans[k-1]=='S'){
                    if(ans[k-2]=='W'){
                        if(s[k-1]=='o'){
                            ans[k]='W';
                        }else{
                            ans[k]='S';
                        }
                    }else{
                        if(s[k-1]=='o'){
                            ans[k]='S';
                        }else{
                            ans[k]='W';
                        }
                    }
                }else{
                    if(ans[k-2]=='W'){
                        if(s[k-1]=='o'){
                            ans[k]='S';
                        }else{
                            ans[k]='W';
                        }
                    }else{
                        if(s[k-1]=='o'){
                            ans[k]='W';
                        }else{
                            ans[k]='S';
                        }
                    }
                }
            }
            for(int i=0;i<n;i++){
                int l,r;
                if(i==0){
                    l=n-1;
                    r=1;
                }else if(i==n-1){
                    l=n-2;
                    r=0;
                }else{
                    l=i-1;
                    r=i+1;
                }
                if(s[i]=='o'){
                    if(ans[i]=='S'){
                        if(ans[l]!=ans[r]){
                            f=false;
                        }
                    }else{
                        if(ans[l]==ans[r]){
                            f=false;
                        }
                    }
                }else{
                    if(ans[i]=='W'){
                        if(ans[l]!=ans[r]){
                            f=false;
                        }
                    }else{
                        if(ans[l]==ans[r]){
                            f=false;
                        }
                    }
                }
            }
            if(f==true){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String Alphabet = "abcdefghijklmnopqrstuvwxyz";
//		System.out.println(a.charAt(index));
		String ans = "";
		Scanner kb = new Scanner(System.in);
		String s = kb.next();
		for (int i = 0; i < s.length(); i++) {
			if (Alphabet.contains(String.valueOf(s.charAt(i)))) {
				ans += 'x';
			}
		}
		System.out.println(ans);
		kb.close();
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N, K; cin >> N >> K;
    vll A(N); rep(i, N) cin >> A[i];

    vll cnt(60);
    rep(i, 60) {
        // i桁目に注目
        rep(j, A.size()) {
            cnt[i] += ((A[j] >> i) & 1ll);
        }
    }

    //for (auto elem : cnt) cout << elem << " "; cout << endl;

    ll sum = 0;
    ll x = 0;
    for (ll i = 59; i >= 0; i--) {
        if (x + (1ll << i) <= K && (N - cnt[i]) >= cnt[i]) {
            x += (1ll << i);
            sum += (N - cnt[i]) * (1ll << i);
        } else {
            sum += cnt[i] * (1ll << i);
        }
        //cout << "x: " << x << endl;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>c(n);
    for(lint&x:c){std::cin>>x;x--;}
    std::vector<std::vector<lint>>g(n);
    for(lint i=0;i<n-1;i++){
        lint u,v;std::cin>>u>>v;u--,v--;
        g.at(u).push_back(v);
        g.at(v).push_back(u);
    }
    std::vector<lint>sz(n,1),prt(n),ord;
    auto dfs=[&](auto&&f,lint x,lint p)->void{
        ord.push_back(x);
        auto&&v=g.at(x);
        if(x!=p)v.erase(std::find(ALL(v),p));
        for(lint&y:v){
            f(f,y,x);
            prt.at(y)=x;
            sz.at(x)+=sz.at(y);
            if(sz.at(v.front())<sz.at(y))std::swap(v.front(),y);
        }
    };
    dfs(dfs,0,0);
    std::vector<lint>dp(n);
    auto efs=[&](auto&&f,lint x)->std::map<lint,lint>{
        auto&&v=g.at(x);
        if(v.empty()){
            dp.at(x)=c.at(x)!=c.at(prt.at(x));
            return {{c.at(x),1}};
        }
        lint head=v.front();
        auto ans=f(f,head);
        for(lint y:g.at(x)){
            if(head==y)continue;
            auto now=f(f,y);
            for(auto[key,val]:now)ans[key]+=val;
        }
        ans[c.at(x)]=sz.at(x);
        dp.at(x)=sz.at(x)-ans[c.at(prt.at(x))];
        return ans;
    };
    efs(efs,0);
    std::vector<std::vector<lint>>cmp(n);
    std::vector<lint>count(n);
    for(lint i=0;i<n;i++){
        count.at(c.at(i))++;
        if(i==0)continue;
        lint k=c.at(prt.at(i));
        cmp.at(k).push_back(dp.at(i));
    }
    for(lint i=0;i<n;i++){
        lint sum=std::accumulate(ALL(cmp.at(i)),0ll);
        cmp.at(i).push_back(n-count.at(i)-sum);
    }
    for(auto&&v:cmp){
        lint ans=n*(n+1)/2;
        for(lint x:v){
            ans-=x*(x+1)/2;
        }
        std::cout<<ans<<'\n';
    }
}



Measured memory_bytes: 92936