akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
// const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;

ll dx[] = {0,1,0,1};
ll dy[] = {0,0,1,1};

int main(){
	cin >> n;
	vector<ll> x(n),y(n),w(n);
	map<P,ll> m;
	rep(i,n){
		cin >> x[i] >> y[i] >> w[i];
		m[P(x[i],y[i])] = w[i];
	}
	ll ans = 0;
	rep(i,n){
		for(int j = -1;j <= 0;j++){
			for(int k = -1;k <= 0;k++){
				ll nx = x[i] + j;
				ll ny = y[i] + k;
				ll cnt = 0;
				rep(l,4)cnt += m[P(nx+dx[l],ny+dy[l])];
				ans = max(ans,cnt);
			}
		}
	}
	cout << ans << " / 1" << endl;
}


Measured memory_bytes: 61460
//半分全列挙
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)

bool flag[11];
int main(void){
	int n, k; cin >> n >> k;
	rep(i, 11) flag[i] = true;
	rep(i, k){
		int d; cin >> d;
		flag[d] = false;
	}
	// printf("ok\n");
	while(1){

		int now = n;
		// printf("%d\n", now);
		string s = to_string(now);
		rep(i, s.size()){
			// printf("%d\n", i);
			// printf("%d\n", s[i] - '0');
			if(flag[s[i] - '0'] == false)break;
			if(i == s.size() - 1){
				cout << s << endl;
				return 0;
			}
		}
		n++;
	}

	// printf("flag\n");


	return 0;
}

Measured memory_bytes: 256
Sp = input()
T = input()
S = ""
flag = True
for i in range(len(Sp)-len(T),-1,-1):
    if flag:
        for j in range(len(T)):
            if Sp[i+j] != "?" and T[j] != Sp[i+j]:
                break
            elif j == len(T)-1:
                S = Sp[:i] + T + Sp[i+j+1:]
                flag = False
if S == "":
    print("UNRESTORABLE")
else:
    print(S.replace("?", "a"))


Measured memory_bytes: 3060
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();
    int a[] = new int [N];
    
    for (int i=0; i<Q; i++){
      int b = sc.nextInt();
      a[b-1]++;
    }
    for (int i=0; i<N;i++) {
      if(K - (Q - a[i]) > 0) {
        System.out.println("Yes");
      }else {
        System.out.println("No");
      }
    }
  }
}

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

int main()
{
  ll n;
  cin >> n;
  
  ll ans;
  for(int i = 1; i * i <= n; i++){
    ans = i*i;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 5003;
const ll MOD = 1000000007;

ll dp[MAXN*MAXN], n, p[3], q[3];

void build () {
    memset(dp, 0, sizeof(dp));
    REP (i, 3) {
        REP (j, MAXN*MAXN) {
            if (j >= p[i]) {
                dp[j] = max(dp[j-p[i]]+(q[i]-p[i]), dp[j]);
            }
        }
    }
}
/*********************GoodLuck***********************/
int main () {
    IOS();
    cin >> n;
    REP (j, 3) {
        cin >> p[j];
    }
    REP (j, 3) {
        cin >> q[j];
    }

    build();
    ll t = n + dp[n];
    swap(p, q);
    build();
    cout << t + dp[t] << endl;


}


Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A,B;
    cin >> A >> B;
  
  	int ANS;

  	ANS = A - B*2 ;

  	if (ANS<=0) {
    		ANS = 0;
    }
  cout << ANS << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>

#define PI 3.14159265359

#define INF 1000000;

using namespace std;


/*
class ElectronicPetEasy
{
public:
	string isDifficult(int st1, int p1, int t1, int st2, int p2, int t2)
	{
		
	}
};
*/






int main()
{
	int n, m;
	
	while (cin >> n >> m, n)
	{
		int t[n];
		int h[m];
		int tsum = 0, hsum = 0;
		
		for (int i=0; i<n; i++)
		{
			cin >> t[i];
			tsum += t[i];
		}
		for (int i=0; i<m; i++)
		{
			cin >> h[i];
			hsum += h[i];
		}
		
		int taro = 1000;
		int hanako = 1000;
		
		for (int i=0; i<n; i++)
		{
			for (int j=0; j<m; j++)
			{
				int tnow = tsum - t[i];
				int hnow = hsum - h[j];
				tnow += h[j];
				hnow += t[i];
				if (tnow == hnow && t[i]+h[j] < taro + hanako)
				{
					taro = t[i];
					hanako = h[j];
				}
			}
		}
		
		if (taro != 1000)
		{
			cout << taro << " " << hanako << endl;
		} else {
			cout << -1 << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int h, n;
int a[1000];
int b[1000];

int dp[10001];


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

	cin >> h >> n;
	rep(i,n) {
		cin >> a[i] >> b[i];
	}

	rep(i, h + 1)dp[i] = INF;
	dp[0] = 0;

	rep(i, n) {
		rep(j, h) {
			dp[min(h, j + a[i])] = min(dp[min(h, j + a[i])], dp[j] + b[i]);
		}
	}
	cout << dp[h] << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

int main(void) {
  int N,L;
  
  std::cin >> N >> L;
  std::vector<std::string> s(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> s[i];
  }
  
  std::sort(s.begin(), s.end());
  auto result = std::accumulate(s.begin(), s.end(), std::string());

  std::cout << result << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vi a(m);
	repz(i, m) cin >> a[i];

	int left = 0,right = 0;
	repz(i, m) {
		if (a[i] < x)left++;
		else right++;
	}
	
	int ans = min(left, right);
	cout << ans << endl;


	system("pause");
	return 0;
}

Measured memory_bytes: 504
n=int(input())
a = list(map(int,input().split()))
cnt=1
index=0
state=""
while index+1 < n:
    if state=="low" and a[index]<a[index+1]:
        state=""
        cnt+=1
        index+=1
    elif state=="high" and a[index]>a[index+1]:
        state=""
        cnt+=1
        index+=1
    elif a[index]<a[index+1]:
        state="high"
        index+=1
    elif a[index]>a[index+1]:
        state="low"
        index+=1
    else:
        index+=1
print(cnt)


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

int i, j, n, a[300005];
long long rs;

int main() {
  ios_base::sync_with_stdio(0);

  cin >> n; n *= 3;
  for(i = 1; i <= n; ++i) cin >> a[i];

  sort(a + 1, a + n + 1);

  for(i = 1, j = n; i <= n / 3; ++i) {
    rs += a[j - 1]; j -= 2;
  }

  cout << rs << '\n';

  return 0;
}

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

int main(){
    string s; cin>>s;
    int n = s.size() - 1;
    if(s[n]=='3'){
        cout << "bon" << endl;
    }
    else if(s[n]=='0' or s[n]=='1' or s[n]=='6' or s[n]=='8'){
        cout << "pon" << endl;
    }
    else cout << "hon" << endl;
}

Measured memory_bytes: 3556
import java.math.BigInteger;
import java.util.*;


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

        Long[] list = new Long[N];
        for (int i = 0; i < N; i++) {
            list[i] = sc.nextLong();
        }

        Arrays.sort(list, Collections.reverseOrder());

        BigInteger ans = new BigInteger("0");
        for (int i = K; i < N; i++) {
            ans = ans.add(new BigInteger(list[i].toString()));
        }

        System.out.println(ans);
    }

    static double pre (int x) {
        return ((double)x + 1) / 2;
    }
}

Measured memory_bytes: 97128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var input string
	fmt.Scan(&input)

	output := 0
	var last rune = 0
	for _, v := range input {
		if (last == v) {
			last = v
			continue
		}
		last = v
		output++
	}
	fmt.Println(output)
}


Measured memory_bytes: 1280
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x: u32 = read();
    let n: usize = read();
    let mut p: Vec<u32> = (0..n).map(|_| read()).collect();
    p.sort();
    let mut point: usize = 0;
    let mut flag = false;
    for (i, s) in p.iter().enumerate() {
        if *s == x {
            point = i;
            flag = true;
            break;
        }
    }
    
    if !flag { 
        print!("{}", x)
    } else {
        let mut counter = 0;
        // check under
        for i in (0..point+1).rev() {
            if  x - counter != p[i] {
                break
            }
            counter += 1;
        }   
        let under = counter;
        counter = 0;
        // check upper
        for i in point..n {
            if  x + counter != p[i] {
                break
            }
            counter += 1;
        }  
        print!("{}", if under > counter{
            x + counter
        }else{
            x - under
        }) 

    }
}

Measured memory_bytes: 2080
#include <stdio.h>
int main()
{
    int a,b;
    char op;
    while(1)
    {
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+')
    {
        printf("%d\n",a+b);
    }
    else if(op=='-')
    {
        printf("%d\n",a-b);
    }
    else if(op=='*')
    {
        printf("%d\n",a*b);
    }
    else if(op=='/')
    {
        printf("%d\n",a/b);
    }
    else if(op=='?')
        break;
    }
    return 0;
}

Measured memory_bytes: 2728
#include<stdio.h>
#include<math.h>
int main()
{
          double x1,x2,y1,y2,dis1,dis2,Dis;
          double dis;
          scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

          dis1=pow((x1-x2),2);
          dis2=pow((y1-y2),2);
          Dis=sqrt(dis1+dis2);
          printf("%.8lf",Dis);
          return 0;

}



Measured memory_bytes: 2120
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1<<18|3, maxn = 19, inf = 1e9;
int n,a[maxn],b[maxn],f[N][maxn],g[N][maxn];

int main(){
	n=read();
	For(i,1,n) a[i]=read();
	For(i,1,n) b[i]=read();
	FOR(i,1,1<<n) For(j,1,n) f[i][j]=g[i][j]=inf;
	For(i,1,n) f[1<<i-1][i]=0;
	FOR(i,1,n){
		FOR(j,1,1<<n) For(k,1,n) if (f[j][k]!=inf){
			int s=0;
			Dow(l,n,1) if (!(j&(1<<l-1))){
				int las=(abs(k-i)&1)?b[k]:a[k];
				int now=(abs(l-(i+1))&1)?b[l]:a[l];
				if (now>=las) g[j|(1<<l-1)][l]=min(g[j|(1<<l-1)][l],f[j][k]+s);
			} else s++;
		}
		FOR(j,1,1<<n) For(k,1,n) f[j][k]=g[j][k],g[j][k]=inf;
	}
	int ans=inf;
	FOR(i,1,1<<n) For(j,1,n) ans=min(ans,f[i][j]);
	printf("%d\n",ans==inf?-1:ans);
}

Measured memory_bytes: 42672
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        long n,k,con,tmp;
        n=scan.nextLong();
        k=scan.nextLong();
        con=0;
        tmp=1;
        while(tmp<=n){
            tmp*=k;
            con+=1;
        }
        System.out.println(con);
    }
}

Measured memory_bytes: 23380
/*#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;*/
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define s second
# define vll vector<ll> 
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);   cout.tie(NULL);
#define mod (ll)1e18
#define pb push_back
#define N 100000 + 5
#define N 100000 + 5
  //cout << fixed << setprecision(12);
# define deb(x) cout<<#x<<" "<<x<<endl;
#define forab(i, a, b, c) for (ll(i) = a; (i) <= (b); (i) += (c))
#define forabr(i, a, b, c) for (ll(i) = a; (i) >= (b); (i) -= (c))
void arrinitialize(ll n,ll a[],ll x){
    forab(i,0,n-1,1){
        a[i]=x;
    }
}
void start(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
ll gcd(ll a,ll b){

if(b==0)return a;
gcd(b,a%b);
}
ll prime[100000+3],prod[100000+3];
void seive(){
    arrinitialize(100001,prod,1);
forab(i,2,100000,1){
    
        forab(j,2*i,100000,i){
            if(!prime[j]){
                prime[j]=i;
            }
            else{
                prod[j]*=i;
            }
        }
}
}
int main(){
    //start();
    fastio;
    ll n,w;cin>>n>>w;
    vll a(n,0),b(n,0);
    ll dp[n+1][w+1]={0};ll x;
    forab(i,0,n-1,1)cin>>x,a[i]=x,cin>>x,b[i]=x;
    
    forab(i,0,n,1){
        forab(j,0,w,1){
            if(i==0)dp[i][j]=0;
           else if(j==0)dp[i][j]=0;
           else{
            ll x=0;
            if(a[i-1]<=j)
            x=(dp[i-1][j-a[i-1]])+b[i-1];
            dp[i][j]=max(x,dp[i-1][j]);
           }
        }
        
    }
    cout<<dp[n][w];
}

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

int main(){
  string O,E;
  cin>>O;
  cin>>E;

  for(int i=0;i<(int)E.size();i++)
    cout<<O[i]<<E[i];
  
  if((int)O.size()>(int)E.size()) cout<<O[(int)O.size()-1];
  cout<<endl;
  return 0;
}
  


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        while(true)
        {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if(m == -1 && f == -1 && r == -1)
            {
                break;
            }

            if(m == -1 || f == -1)
            {
                System.out.println("F");
                continue;
            }
            int sum = m+f;
            if(sum >= 80)
            {
                System.out.println("A");
            } 
            else if(sum >= 65){
                System.out.println("B");
            }
            else if(sum >= 50 || (sum >=30 && r >= 50))
            {
                System.out.println("C");
            }
            else if(sum >= 30)
            {
                System.out.println("D");
            }
            else {
                System.out.println("F");
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26384
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
#include<string>
#include<map>
typedef long long ll;
using namespace std;
const double pi=4*atan(1.0);
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;

string a[15]={"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};
int main()
{
	int n;cin>>n;
	n=n%10;
	cout<<a[n];
	return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define  fuckit(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
int main()
{
	fuckit();
	string s;
	cin>>s;
	int i,n=s.size(),cnt=0;

		for(i=0;i<n;i++){
			if(s[i]!=s[i+1]){
				cnt++;
			}
		}
	cout<<cnt-1<<endl;
	return 0;	
}


Measured memory_bytes: 512
N,x=map(int, input().split())
A=sorted(list(map(int, input().split())))
cnt=0
for i in range(N):
  if i == N-1 and x > A[i]:
    break
  if x >= A[i]:
    x -= A[i]
    cnt+=1
  else:
    break
print(cnt)


Measured memory_bytes: 2940
N, A, B, C, D = map(int, input().split())

S = '.' + input() + '#'

# S[A,C],S[B,D]には'##'が存在してはいけない
if '##' in S[A: C + 1] or '##' in S[B: D + 1]:
    print('No')
    exit()

# 追い越さなければいけないとき
# S[B,D]に'...'が存在する必要がある
if D < C:
    if not '...' in S[B - 1 : D + 2]:

        print('No')
        exit()

print('Yes')


Measured memory_bytes: 3572
from itertools import permutations
a = list(map(int, input().split()))

comb = permutations(a)

def cost(a1, a2, a3):
    return abs(a1 -a2) + abs(a2 - a3)

min_sum = -1
for i in comb:
    tmp_sum = cost(i[0], i[1], i[2])
    if min_sum == -1 or tmp_sum < min_sum:
        min_sum = tmp_sum

print(min_sum)


Measured memory_bytes: 3060
package main

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

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

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

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

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

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

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

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

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	V := sc.nextIntSlice(N)
	ans := 0
	for a := 0; a <= min(K, N); a++ {
		for b := 0; b <= min(K-a, N); b++ {
			A := []int{}
			l, r := 0, N-1
			for l < a {
				A = append(A, V[l])
				l++
			}
			for r >= N-b && l <= r {
				A = append(A, V[r])
				r--
			}
			total := 0
			for i := 0; i < len(A); i++ {
				total += A[i]
			}
			sort.Ints(A)
			rest := K - (a + b)
			for k := 0; k < len(A) && k < rest; k++ {
				if A[k] < 0 {
					total -= A[k]
				} else {
					break
				}
			}
			ans = max(ans, total)
		}
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N, M;
string S;

string solve(){
    int index = N, next = 0;
    string ret;
    while(index > 0){
        next = max(0, index - M);
        while(S[next] == '1') next++;
        if(index == next) break;
        ret = to_string(index - next) + " " + ret;
        index = next;
    }
    if(index != 0) return "-1";
    ret.pop_back();
    return ret;
}

signed main(){
    cin >> N >> M >> S;
    PRINT(solve());
    return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long ans=1;  
  for(int i=0; i<N; i++){
    long long a;
    cin >>a;
    long long b=ans, c=a, d;
    do{
      d=b%c;
      b=c, c=d;
    }
    while(d!=0);
    ans=ans/b*a;
  }    
  cout << ans << endl;      
}

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

#define MOD 998244353LL

long long K, N;
vector<long long> R;

#define LIMIT 4000
long long I[LIMIT], P[LIMIT], IP[LIMIT];

long long choose(long long n, long long k) {
  return P[n] * IP[k] % MOD * IP[n - k] % MOD;
}

int main() {
  cin >> K >> N;
  I[1] = P[0] = P[1] = IP[0] = IP[1] = 1;
  for(long long i = 2; i < LIMIT; ++i) {
    I[i] = MOD - I[MOD % i] * (MOD / i) % MOD;
    P[i] = i * P[i - 1] % MOD;
    IP[i] = I[i] * IP[i - 1] % MOD;
  }
  for(long long i = 0; i < K; ++i) {
    long long j = i / 2 + 1;
    R.push_back(0);
    for(long long r = 0; r <= min(j, N / 2); ++r) {
      long long a =
        choose(N - 2 * r + K - 1, K - 1) *
        choose(j, r) % MOD;
      (R.back() +=
        (r % 2 == 0 ? 1 : MOD - 1) * a % MOD)
      %= MOD;
    }
  }
  for(long long i = 0; i < K; ++i) {
    cout << R[i] << endl;
  }
  for(long long i = K - 2; i >= 0; --i) {
    cout << R[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
template <typename T>
#define all(v) v.begin(),v.end()
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc;
    tc = 1;  
    while (tc--)
    {
       int n;
        cin >> n;
        long double f = n;
        f = f / 3;
        f = f * f * f;
        cout << fixed<<setprecision(20)<<f << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<b+1;i++){
        if(i*a%b==c){
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ITP1_2_C
{
    class Program
    {
        static void Main(string[] args)
        {
            //??\???
            int a, b, c;
            Inputs.Read(out a, out b, out c);

            compare(ref a,ref b,ref c);

            //??????
            Console.WriteLine(a + " " + b + " " + c);
        }

        private static void compare(ref int a, ref int b,ref int c)
        {
            int[] array = { a, b, c };
            for(int i = 0; i < array.Length - 1; i++)
            {
                for (int j = array.Length - 1;j > i; j--) {
                    if (array[j] < array[j - 1])
                    {
                        int buf = array[j];
                        array[j] = array[j - 1];
                        array[j - 1] = buf;
                    }
                }
            }
            a = array[0];
            b = array[1];
            c = array[2];
        }
    }
}


namespace ITP1_2_C
{
    class Inputs
    {
        // ?????????????????\??????????????????????????????
        public static void Read(out int a,out int b, out int c)
        {
            string line = Console.ReadLine();
            var inputs = line.Split(' ');
            a = int.Parse(inputs[0]);
            b = int.Parse(inputs[1]);
            c = int.Parse(inputs[2]);
        }
    }
}

Measured memory_bytes: 9088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long x = sc.nextLong(), k = sc.nextLong(), d = sc.nextLong();
		x = Math.abs(x);
		long min1 = x%d, min2 = Math.abs(min1-d);
		long mov1 = x/d, mov2 = mov1 + 1;
		long ans = 0;
		if(k < mov1) {
			ans = x - k*d;
		}else {
			if(k == mov1) {
				ans = min1;
			}else if(k == mov2) {
				ans = min2;
			}else{
				long c1 = k - mov1, c2 = k - mov2;
				if(c1%2 == 0) {
					ans = min1;
				}else {
					ans = min2;
				}
			}
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 32728
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define mul(a,b) a=a*b%mod;
ll ma(ll a,ll k){
    if(a+1<=k){
	ll sum=a+1+k;
	ll x=sum/2,y=sum-x;
	return x*y;
    }
    return k*(a+1);
}
void solve(){
    ll a,b; cin>>a>>b;
    if(a>b)swap(a,b);
    ll l=0,r=1e10,mid;
    while(l<r-1){
	mid=(l+r)>>1;
	if(ma(a,mid)<a*b)l=mid;
	else r=mid;
    }
    cout<<a+l-1<<endl;
}
int main(){
  ll q; cin>>q;
  while(q--)solve();
  return 0;
}


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

using namespace std;

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

    int N = S.size();
    int ans = N;
    for(int i=1; i<ans; i++) {
        if(S[i-1] != S[i]) {
            ans = min(ans, max(i, N-i));
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

n = int(input())
ch = [[0,i] for i in range(n)]
graph = [[] for i in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ch[a][0] += 1
    ch[b][0] += 1
    graph[a].append(b)
    graph[b].append(a)

use =[0 for i in range(n)]

c = list(map(int,input().split()))
c.sort(reverse=True)
ch.sort()

ans = [0 for i in range(n)]

stack = [ch[0][1]]
count = 1
use[ch[0][1]] = 1
ans[ch[0][1]] = c[0]
while len(stack) > 0:
    now = stack.pop()
    data = graph[now]
    for i in data:
        if use[i] == 0:
            use[i] = 1
            ans[i] = c[count]
            count += 1
            stack.append(i)




print(sum(c)-c[0])
for i in ans:
    print(i,end=' ')

print()

Measured memory_bytes: 49896
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<vector<int>> adj;
vector<int> vs;
vector<int> lis;
vector<int> ans;
int n;

int get_index(int u){
  int lo = 0, hi = n - 1;
  while(lo < hi){
    int mid = (lo + hi) / 2;
    if(lis[mid] >= vs[u])
      hi = mid;
    else
      lo = mid + 1;
  }
  return lo;
}

void dfs(int u, int p = -1){
//cout << u << endl;
  int lis_in = get_index(u);
  int old_v = lis[lis_in];
  lis[lis_in] = vs[u];
  ans[u] = lis_in + 1;
  if(p != -1)
    ans[u] = max(ans[u], ans[p]);
  for(auto el : adj[u]){
    if(el == p)continue;
    dfs(el, u);
  }
  lis[lis_in] = old_v;
}

int main()
{
  cin >> n;
  adj.resize(n);
  vs.resize(n);
  ans.resize(n);
  lis.resize(n + 1, 1e9 + 1);
  for(int i = 0;i < n;i++)
    cin >> vs[i];
  for(int i = 0;i < n - 1;i++){
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  dfs(0);
  for(auto el : ans)
    cout << el << endl;
  return 0;
}


Measured memory_bytes: 27984
def put(i, x, y):
    if x == 0:
        on_top.append((y, i))
    elif x == r:
        on_bottom.append((y, i))
    elif y == 0:
        on_left.append((x, i))
    else:
        on_right.append((x, i))


on_top, on_bottom, on_left, on_right = [], [], [], []

r, c, n = map(int, input().split())
for i in range(n):
    x1, y1, x2, y2 = map(int, input().split())
    if 0 < x1 < r and 0 < y1 < c:
        continue
    if 0 < x2 < r and 0 < y2 < c:
        continue
    put(i, x1, y1)
    put(i, x2, y2)
on_top.sort()
on_bottom.sort(reverse=True)
on_left.sort(reverse=True)
on_right.sort()
stack = []
for on_edge in [on_top, on_right, on_bottom, on_left]:
    for p, i in on_edge:
        if stack and stack[-1] == i:
            stack.pop()
        else:
            stack.append(i)

print('NO' if stack else 'YES')


Measured memory_bytes: 27996
N,M = map(int,input().split())

lis = [list(map(int,input().split())) for i in range(M)]

Ans = 0

for k in range(1,N+1):
	for i in range(0,M):
		for j in range(0,2):
			if lis[i][j] == k:
				Ans += 1
	print(Ans)
	Ans = 0


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cstdlib>
#include <climits>
using namespace std;

int main(){
    while(true){
        int m, n_min, n_max;
        cin >> m >> n_min >> n_max;
        if(m == 0) break;
        vector<int> p(m, 0);

        for(int i = 0; i < m; ++i)
            cin >> p[i];

        int gap = INT_MIN;
        int ans = -1;
        for(int i = n_min-1; i < n_max; ++i){
            int gap_ = p[i] - p[i+1];
            if(gap <= gap_){
                gap = gap_;
                ans = i+1;
            }
        }

        cout << ans << endl;
    }

    return EXIT_SUCCESS;
}

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

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    cout << (isupper(s[0]) ? 'A' : 'a') << '\n';

    return 0;
}


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

#define ll long long

void chmin(ll&a, int b) {
  if (a > b) a = b;
}

const ll INF = 10000000000;

int main() {
  int N, K;
  cin >> N >> K;
  
  int h[N+K+10] = {0};
  for (int i = 0; i < N; i++) cin >> h[i+1];

  vector<ll> s(N+K+10, INF);
  
  s[0] = 0; s[1] = 0;
  
  for (int i = 1; i < N+2; i++) {
    for (int j = 1; j < K+1; j++) {
      chmin(s[i+j], s[i] + abs(h[i+j] - h[i]));
    }
  }
  
  cout << s[N] << endl;
  
  
  
  
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define vi vector<ll>
#define vivi vector<vector<ll>> 
#define vipa vector<pair<ll,ll>>
#define F first
#define S second
#define M 1000000007
#define kl endl

typedef long long ll;
void solve()
{
  ll k,n;
  cin>>k>>n;
  ll arr[n];
  vi v;
  for(ll i=0;i<n;i++) cin>>arr[i];
  for(ll i=1;i<n;i++)
  {
      v.pb(arr[i]-arr[i-1]);
  }
  v.pb(k-arr[n-1]+arr[0]);
  sort(v.begin(),v.end());
  ll sum=0;
  for(ll i=0;i<v.size()-1;i++) sum+=v[i];
  cout<<sum;   
}
int  main() 
{ 
    ios;
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {   
        solve();
    }
	
	return 0; 
} 




Measured memory_bytes: 3956
package main

import (
	"fmt"
	"sort"
)

//const pi = math.Pi

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[string]int, n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		_, ok := m[s]
		if ok {
			m[s]++
		} else {
			m[s] = 1
		}
	}
	var l int
	fmt.Scan(&l)
	for i := 0; i < l; i++ {
		var s string
		fmt.Scan(&s)
		_, ok := m[s]
		if ok {
			m[s]--
		}
	}
	//sortして最大値。最大値マイナスなら０
	a := List{}
	for k, v := range m {
		e := Entry{k, v}
		a = append(a, e)
	}
	sort.Sort(a)
	if a[0].value <= 0 {
		fmt.Println(0)
	} else {
		fmt.Println(a[0].value)
	}
}

type Entry struct {
	name  string
	value int
}
type List []Entry

func (l List) Len() int {
	return len(l)
}
func (l List) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}
func (l List) Less(i, j int) bool {
	return (l[i].value > l[j].value)

}

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

typedef long long ll;

const int N  = 200010;
ll t[N];

int main()
{
    int n,T;
    cin >> n >> T;
    for (int i = 0; i < n; i ++ )
    {
        cin >> t[i];
    }

    ll sum = 0;
    for (int i = 1; i < n; i ++ )
    {
        if(t[i] - t[i-1] >= T) sum += T;
        else sum += (t[i]-t[i-1]);
    }
    cout << sum+T << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
  long long int n;
  cin >> n;
  long long int cnt = 0;
  for(long long int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0) cnt += i;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
  int c;
  int size;
  cin>>c;
  string s[c]={};
  for(int i=0;i<c;i++)
    cin>>s[i];
  bool x=true;
  for(int j=1;j<c;j++)
  {
    size=s[j-1].size();
    if(s[j][0]!=s[j-1][size-1])
      x=false;
    for(int k=j;k<c;k++)
      if(s[j-1]==s[k])
        x=false;
  }
  if(x)
  cout << "Yes" <<endl;
  else
  cout << "No" <<endl;
  return 0;
}


Measured memory_bytes: 256
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let a:usize = read();
    let b:usize = read();
    println!("{}",if a <= 5{
        0
    }else if 5 < a && a < 13{
        b / 2
    }else{
        b
    });
}

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

#define int long long
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define moduloP 1e9 + 7

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

    int n;
    cin>>n;

    string s = "ACL";
    for(int i=0;i<n;i++){
        cout<<s;
    }

    return 0;
}


Measured memory_bytes: 3640
N = int(input())
lis = [int(i) for i in input().split()]
i = 0
a = {}
b = {}
for nums in lis:
  if i%2==0:
    if nums in a.keys():
      a[nums] += 1
    else:
      a[nums] = 1
  else:
    if nums in b.keys():
      b[nums] += 1
    else:
      b[nums] = 1
  i += 1
a1 = sorted(a.items(), key=lambda x: -x[1])
b1 = sorted(b.items(), key=lambda x: -x[1])
if a1[0][0]!=b1[0][0]:
  print(N-a1[0][1]-b1[0][1])
else:
  if len(a1)>=2 and len(b1)>=2:
    print(min(N-a1[1][1]-b1[0][1],N-a1[0][1]-b1[1][1]))
  elif len(a1)==1 and len(b1)==1:
    print(min(N-a1[0][1],N-b1[0][1]))
  elif len(a1)==1:
    print(min(N-a1[0][1]-b1[1][1],N-b1[0][1]))
  else:
    print(min(N-b1[0][1]-a1[1][1],N-a1[0][1]))

Measured memory_bytes: 22368
loop {
m,f,r=gets.split(" ").map(&:to_i)
break if m==-1 && f==-1 && r==-1

grade="F"
if m == -1 or f == -1

elsif (m + f) >=80 
    grade= "A"
elsif (m + f) >=65
    grade= "B"
elsif (m + f)>=50
    grade="C"
elsif (m + f)>=30
    if r >= 50
        grade= "C"
    else
        grade= "D"
    end
end

puts grade


}








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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int x;
  cin >> x;

  cout << lcm(x, 360) / x << '\n';
  return 0;
}

Measured memory_bytes: 3636
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

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

ll dp[3][1000001];

int main(int argc, char const* argv[])
{
  int n;
  string s;
  int q;
  cin >> n >> s >> q;
  rep(i, q){
    int k;
    cin >> k;
    rep(j, 3)fill(dp[j], dp[j] + n + 1, 0);
    ll res = 0;
    rep(j, s.size()){
      if(j > 0)rep(l, 3)dp[l][j] = dp[l][j-1];
      if(s[j] == 'D')dp[0][j]++;
      else if(s[j] == 'M'){
        dp[1][j]++;
        dp[2][j] += dp[0][j];
      }else if(s[j] == 'C'){
        res += dp[2][j];
      }
      //cout << j << " " << dp[0][j] << " " << dp[1][j] << " " << dp[2][j] << endl;
      if(j-k+1 >= 0){
        if(s[j-k+1] == 'D'){
          dp[0][j]--;
          dp[2][j] -= dp[1][j];
        }
        else if(s[j-k+1] == 'M'){
          dp[1][j]--;
        }
      }
    }
    cout << res << endl;
  }
	return 0;
}


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

int main()
{
    long long N, X, M;
    cin >> N >> X >> M;

    vector<pair<long long, long long>> first(M, make_pair(0, -1));

    long long current = 0;
    for (long long i = 1; i <= N; i++)
    {
        X %= M;
        current += X;
        if (first[X].second == -1)
        {
            first[X] = make_pair(current, i);
        }
        else
        {
            long long diff = i - first[X].second;
            long long loop = max(0ll, (N - i) / diff - 1);
            current += loop * (current - first[X].first);
            i += loop * diff;
        }
        X *= X;
    }
    cout << current << endl;
}


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

#define MAX 2000001
#define VMAX 10000

int main(){

  unsigned short *A,*B;


  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);

  A=malloc(sizeof(short) * n + 1);
  B=malloc(sizeof(short) * n + 1);

  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }

  for(i=0;i<n;i++){
    scanf("%hu", &A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i] = C[i] + C[i-1];
  }


  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}

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


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

  ll tmp=1;
  for(int i=0;i<k;++i) tmp*=a[i];

  ll mae=tmp;
  for(int i=k;i<n;++i){
    if(a[i-k]<a[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


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

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

		while (true) {
			String str[] = br.readLine().split(" ");
			int T = Integer.parseInt(str[0]);
			int D = Integer.parseInt(str[1]);
			int L = Integer.parseInt(str[2]);
			if (T == 0 && D == 0 && L == 0)
				break;

			int x[] = new int[T];
			for (int i = 0; i < T; i++) {
				x[i] = Integer.parseInt(br.readLine());
			}

			int dCount = 0;
			int ans = 0;
			for (int i = 0; i < T - 1; i++) {
				if (x[i] >= L) {
					dCount = D - 1;
					ans++;
				} else if (dCount != 0) {
					dCount--;
					ans++;
				}
			}
			System.out.println(ans);
		}
	}
}



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

typedef long long ll;
const int TOF = 3;

ll q, a, b;

bool ok(int cnt, int a, int b) {
	ll s = 1LL * a * b - 1;
	for (int i = max(1, (cnt >> 1) - TOF); i <= min(cnt + 1, (cnt >> 1) + TOF); i++) {
		ll x = i < a? i: i + 1;
		ll y;
		if(cnt < b)
			y = b - i;
		else if(i <= cnt + 1 - b)
			y = cnt + 1 - i + 1;
		else
			y = cnt + 1 - i + 1 - 1;
		if(x * y > s)
			return false;
	}
	return true;
}

int solve(int a, int b) {
	ll l = 0, r = a + b - 1;
	while(r - l > 1) {
		ll c = (l + r) >> 1;
		if(ok(c, a, b))
			l = c;
		else
			r = c;
	}
	return l;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> q;
	while(q--) {
		cin >> a >> b;
		cout << max(solve(a, b), solve(b, a)) << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

s = input()
counter = Counter(s)
mc = counter.most_common()
max_c = mc[0][1]
ret = len(s)
# print(mc)

for t in mc:
    # if t[1] < max_c: break
    # print(s.split(t[0]))
    sp = max(map(len, s.split(t[0])))
    
    if ret > sp:
        ret = sp
        
print(ret)

Measured memory_bytes: 3316