akhauriyash/Code-Regression huggingface dataset:
import sys
def side(p1,p2):
  global D
  y1,x1=p1
  y2,x2=p2
  dy=y2-y1
  dx=x2-x1
  for p3 in D:
    if p1==p3 or p2==p3:continue
    if (p3[1]-x1)*dy-dx*(p3[0]-y1)<0:return 0
  else:return 1
 
while 1:
  n=input()
  if n==0:break
  D=sorted([list(input()) for i in range(n)])
  p=p1=D[0]
  while 1:
    for p2 in D:
      if p1!=p2 and side(p1,p2):break
    p1=p2
    D.remove(p2)
    if p2==p:break
  print len(D)

Measured memory_bytes: 4268
#include "bits/stdc++.h"
#include <unordered_set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;

int main(){

    string s; cin >> s;
    ll x, y; cin >> x >> y;

    vector<ll > vec;
    if(s[0] == 'T'){
        vec.push_back(0);
    }
    for(ll i = 0; i < s.size();){
        ll j = i;
        //一緒の間ループを回し続けて，切れ目を探す
        if(s[j] == 'T'){
            if(s[j+1] == 'T'){
                vec.push_back(0);
            }
            j++;
            i = j;
            continue;
        }
        while(j < s.size() && s[j] == s[i]){
            j++;
        }
        vec.push_back(j - i);
        //次の始点へすっ飛ばす
        i = j;
    }

    //確認
    /*
    for(ll i = 0; i < vec.size(); i++){
        cout << vec[i] << endl;
    }
    */
    

    //xとy軸の移動しうる点を交互に求めていく(Tの数だけXまたはY軸に沿って移動するかが変化する)


    vector<unordered_set<ll > >x_dp(vec.size()+10);
    vector<unordered_set<ll > >y_dp(vec.size()+10);
    x_dp[0].insert(0);
    y_dp[0].insert(0);
    y_dp[1].insert(0);

    ll i = 0;
    
    while(i < vec.size()){
        
        if(i == 0){
            x_dp[1].insert(vec[i]);
            x_dp[2].insert(vec[i]);
        }else if(i != 0 && i % 2 == 1){
            //cout << i << " " <<  vec[i] << endl;
            for(auto y : y_dp[i]){
                y_dp[i + 1].insert(y + vec[i]); 
                y_dp[i + 1].insert(y - vec[i]); 
                //次の次は更新されないので
                y_dp[i + 2].insert(y + vec[i]); 
                y_dp[i + 2].insert(y - vec[i]); 
            }      
        }else if(i != 0 && i % 2 == 0){
            //cout << i << " " << vec[i] << endl;
            for(auto x : x_dp[i]){
                //cout << iter->first + vec[i] << " " << iter->first - vec[i] << endl;
                x_dp[i + 1].insert(x + vec[i]); 
                x_dp[i + 1].insert(x - vec[i]); 
                //次の次は更新されないので
                x_dp[i + 2].insert(x + vec[i]); 
                x_dp[i + 2].insert(x - vec[i]); 
            }    
        }

        i++;
    }

    ll posi = vec.size();
    if(x_dp[posi].find(x) != x_dp[posi].end() && y_dp[posi].find(y) != y_dp[posi].end() ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }



}

Measured memory_bytes: 408448
S = str(input())

N = len(S)

ans = "Yes"
for i in range(N):
  if S[i] != S[N-1-i]:
    ans = "No"
    break
N_1 = int((N-1)/2)
for i in range(N_1):
  if S[i] != S[N_1-1-i]:
    ans = "No"
    break
N_2 = int((N+1)/2)
for i in range(N_1):
  if S[N_2+i] != S[N-1-i]:
    ans = "No"
print(ans)

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

#define N 10000
#define X 100
#define Y 100
#define Z 100

int n, f[N+1]={0};

int main(void)
{
    cin >> n;

    for (int i = 1; i <= X; i++){
        for (int j = 1; j <= Y; j++){
            for (int k = 1; k <= Z; k++){
                int siki = i*i + j*j + k*k + i*j + j*k + k*i;
                if (siki <= N){
                    f[siki]++;
                }
            }
        }
    }
    
    for (int i = 1; i <= n; i++){
        cout << f[i] << endl;    
    }
    
    return 0;
}


Measured memory_bytes: 3572
N, A, B, C = map(int, input().split())
t = [int(input()) for i in range(N)]
INF = 10 ** 9

l = [[[], [], []]]  # [[[0, 2, 3], [1], [4]], [[0], [1, 2, 3], [4]]]
for i in range(N):
    l2 = l.copy()
    for li in l2:
        a = li[0]
        b = li[1]
        c = li[2]

        l.append([a, b, c])
        l.append([a + [t[i]], b, c])
        l.append([a, b + [t[i]], c])
        l.append([a, b, c + [t[i]]])

ll = []
for li in l:
    a = li[0]
    b = li[1]
    c = li[2]
    if not a or not b or not c:
        continue
    ll.append(li)


ans = 100000000
for li in ll:
    a = li[0]
    b = li[1]
    c = li[2]

    cost = 0
    len_a = len(a)
    len_b = len(b)
    len_c = len(c)
    
    tmp = sum(a)
    cost += 10 * (len_a - 1)
    cost += abs(A - tmp)

    tmp = sum(b)
    cost += 10 * (len_b - 1)
    cost += abs(B - tmp)

    tmp = sum(c)
    cost += 10 * (len_c - 1)
    cost += abs(C - tmp)

    ans = min(ans, cost)

print(ans)

Measured memory_bytes: 73840
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

#define ALL(v) (v).begin(),(v).end()
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{␣"; for(auto nth : list){ cout << nth << "␣"; } cout << "}" << endl;

using namespace std;

int main() {
    string S;
    cin >> S;
    vector<int> pos = {-1, -1};

    for (int i = 0; i < S.size(); ++i) {
        if (pos[0] == -1 && S[i] == 'C') pos[0] = i;
        if (S[i] == 'F') pos[1] = i;
    }

    cout << ((pos[0] != -1 && pos[1] != -1 && (pos[0] < pos[1])) ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

int main(){
    
    int i = 1;
    
    while(true){
        
    int a;
    cin >> a;
    
    if(a != 0){
        cout << "Case " << i << ": " << a << endl;
        i = i + 1;
    }
    else{
        break;
    }
    }
    return 0;
}




Measured memory_bytes: 3072
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy
import bisect


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

#X = str(input()).split()
#a = [int(x) for x in input().split()]
#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())

A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
A3 = [int(x) for x in input().split()]
A = ["x"]*9

N = int(input())
b = []
ans = "No"

for i in range(N):
  b.append(int(input()))
  for j in range(3):
    if(b[i]==A1[j]):
      A[j]="o"
    elif(b[i]==A2[j]):
      A[j+3]="o"
    elif(b[i]==A3[j]):
      A[j+6]="o"

for i in range(3):
  if(A[i*3]=="o" and A[i*3+1]=="o" and A[i*3+2]=="o"):
    ans = "Yes"
  if(A[i]=="o" and A[i+3]=="o" and A[i+6]=="o"):
    ans = "Yes"

if(A[0]=="o" and A[4]=="o" and A[8]=="o"):
  ans = "Yes"
if(A[2]=="o" and A[4]=="o" and A[6]=="o"):
  ans = "Yes"



print(ans)


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

const int MAXN = 1000010;
char buf[MAXN];
int bak, str[MAXN], C[3], tar[3] = {0, 1, 2}, src[3];
struct track { int be, tb; } li[MAXN];
int cnt;
void encode(int A, int B, int C) {
	cnt = 0;
	for (int i = 1; i <= bak; ++i) {
		li[++cnt].tb = 1;
		li[cnt].be = str[i];
		if (str[i] == B || str[i] == C)
			while (i < bak && str[i + 1] != A) ++i, ++li[cnt].tb;
	}
}
void decode(int A, int B, int C) {
	bak = 0;
	for (int i = 1; i <= cnt; ++i) if (li[i].tb) {
		if (li[i].be == A) str[++bak] = A;
		else {
			int now = li[i].be;
			while (li[i].tb --> 0)
				str[++bak] = now, now = now == B ? C : B;
		}
	}
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> buf; int slen = strlen(buf);
	*str = -1;
	for (int i = 1; i <= slen; ++i)
		if (buf[i - 1] != str[bak] + 'A')
			++C[str[++bak] = buf[i - 1] - 'A'];
	std::sort(tar, tar + 3, [] (int a, int b) { return C[a] < C[b]; });
	std::sort(C, C + 3);
	for (int i = 0; i < 3; ++i) src[tar[i]] = i;
	for (int i = 1; i <= bak; ++i) str[i] = src[str[i]];
	encode(0, 1, 2);
	for (int i = 1; i <= cnt; ++i) if (li[i].be)
		while (C[2] > C[1] && (li[i].tb > (i != 1 && i != cnt))) {
			if (li[i].be == 1 && (li[i].tb & 1)) break;
			if (li[i].be == 2) li[i].be = 1;
			--li[i].tb, --C[2];
		}
	decode(0, 1, 2);
	encode(1, 0, 2);
	for (int i = 1; i <= cnt && C[2] > C[1]; ++i)
		if (li[i].be != 1 && (i == 1 || i == cnt || li[i].tb > 1)) {
			int t = std::min(C[2] - C[1], li[i].tb - 1 >> 1);
			C[0] -= t, C[2] -= t, li[i].tb -= t << 1;
		}
	decode(1, 0, 2);
	encode(0, 1, 2);
	for (int i = 1; i <= cnt && C[1] > C[0]; ++i)
		if (li[i].be && (i == 1 || i == cnt || li[i].tb > 1)) {
			int dx = !(i == 1 || i == cnt);
			int t = std::min(C[1] - C[0], li[i].tb - dx >> 1);
			C[1] -= t, C[2] -= t, li[i].tb -= t << 1;
		}
	decode(0, 1, 2); slen = bak;
	for (int i = 1; i <= bak; ++i) buf[i - 1] = 'A' + tar[str[i]];
	buf[slen] = 0;
	std::cout << buf << std::endl;
	return 0;
}


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

int main ()
{
    string str;
    while((cin >> str) && str != "-")
    {
        int m;
        cin >> m;
        while(m--)
        {
            int len;
            cin >>len;
            char temp[202] = {'\0'};
            str.copy(temp, len, 0);
            str.erase(0,len);
            str += temp;
        }
        cout << str << endl;
		str.clear(); 
    }
    return 0;
}


Measured memory_bytes: 3148
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		int x = a/d, y = c/b;
		if(a%d != 0) {
			x++;
		}
		if(c%b != 0) {
			y++;
		}
		if(x >= y) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35772
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    let mut colors = vec![0; 9];
    for &num in a.iter() {
        if num < 400 {
            colors[0] = 1;
        } else if num < 800 {
            colors[1] = 1;
        } else if num < 1200 {
            colors[2] = 1;
        } else if num < 1600 {
            colors[3] = 1;
        } else if num < 2000 {
            colors[4] = 1;
        } else if num < 2400 {
            colors[5] = 1;
        } else if num < 2800 {
            colors[6] = 1;
        } else if num < 3200 {
            colors[7] = 1;
        } else {
            colors[8] += 1;
        }
    }
    println!(
        "{} {}",
        max(colors.iter().sum::<i32>() - colors[8], 1),
        colors.iter().sum::<i32>()
    );
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int aa,bb,mm;
int a[100100],b[100100],ans=999999999,mna=999999999,mnb=999999999;
int main()
{
	scanf("%d%d%d",&aa,&bb,&mm);
	int i=1;
	while(i<=aa)
	{
		scanf("%d",&a[i]);
		mna=min(mna,a[i]);
		++i;
	}
	i=1;
	while(i<=bb)
	{
		scanf("%d",&b[i]);
		mnb=min(mnb,b[i]);
		++i;
	}
	ans=mna+mnb;
	i=1;
	while(i<=mm)
	{
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		ans=min(ans,a[x]+b[y]-c);
		++i;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());
        double[][] Xnd = new double[N][D];
        for (int i = 0; i < N; i++) {

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

                Xnd[i][j] = Integer.parseInt(sc.next());
            }
        }

        sc.close();

        int ansCount = 0;

        //必要な計算量はNC2回,N個の座標のうちのi番目(1,2・・・N-1)
        for (int i = 0; i < N-1; i++) {

            //i番目に対してのj番目(i+1,2・・・N)の座標
            for (int j = i+1; j < N; j++) {

                double sum = 0;
                double distance = 0;

                //(Xnd[i][~]-Xnd[j][~])^2
                for (int Dindex = 0; Dindex < D; Dindex++) {

                    sum += Math.pow((Xnd[i][Dindex] - Xnd[j][Dindex]),2);
                }

                distance = Math.sqrt(sum);
                //i,j番目の座標の距離が整数ならカウント
                if (isNumber(distance)) {

                    ansCount++;
                }
            }
        }

        System.out.println(ansCount);
    }

    public static boolean isNumber(double val) {

        boolean retval = val == Math.floor(val) ? true : false;

        return retval;
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,sum;
  cin>>a>>b;
  sum=a+b;
  if(sum%2==0)
  {
    cout<<sum/2<<endl;
  }
  
  else
    cout<<"IMPOSSIBLE"<<endl;
return 0;  
}


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

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }  
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  string s;
  cin>>s;
  
  vector<vector<Int>> G(n);
  for(Int i=1;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  
  const Int INF = 1e15;
  Int ans=INF;
  vector<Int> cnt(n),dst(n),all(n);
  auto dfs=
    MFP([&](auto dfs,Int v,Int p)->void{         
          cnt[v]=s[v]=='1';
          dst[v]=0;
          all[v]=0;
          using P = pair<Int, Int>;          
          vector<P> res;
          for(Int u:G[v]){
            if(u==p) continue;
            dfs(u,v);
            cnt[v]+=cnt[u];
            all[v]+=cnt[u]+all[u];            
            res.emplace_back(cnt[u]+dst[u],u);            
          }
          if(res.empty()) return;
          
          sort(res.rbegin(),res.rend());
          Int sum=0,tmp=0;
          for(auto p:res){
            sum+=p.first;
            if(p==res[0]) continue;
            tmp+=cnt[p.second]+all[p.second];
          }
          if(res[0].first>tmp){
            dst[v]=res[0].first-tmp;            
          }else{
            dst[v]=sum&1;            
          }
          if(p==-1&&dst[v]==0) chmin(ans,all[v]/2);          
          
          if(0&&p==-1){
            cout<<v<<" "<<sum<<" "<<tmp<<":"<<all[v]<<" "<<dst[v]<<endl;
            cout<<v<<":"<<endl;
            for(auto p:res) cout<<p.first<<" "<<p.second<<endl;            
          }
        });
  
  for(Int i=0;i<n;i++) dfs(i,-1);
  
  if(ans==INF) ans=-1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 768
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] d = new int[n];
		for (int i = 0; i < n; i++)
			d[i] = scan.nextInt();
		int m = scan.nextInt();
		int[] t = new int[m];
		for (int i = 0; i < m; i++)
			t[i] = scan.nextInt();
		Arrays.sort(d);
		Arrays.sort(t);
		int index = 0;
		for (int i = 0; i < m;) {
			if (index == n) {
				System.out.println("NO");
				return;
			}
			if (t[i] == d[index]) {
				i++;
				index++;
			} else {
				index++;
			}
		}
		System.out.println("YES");
	}
	public static void main(String[] args) {
		new Main().run();
	}
}


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

const int maxn = 210;
int n, ans, a[maxn], b[maxn], c[maxn], d[maxn], lnk[maxn], vis[maxn];
vector<int> G[maxn];

bool match(int v) {
    for (int i = 0, u; i < G[v].size(); i++) {
        if (vis[u = G[v][i]]) continue; vis[u] = 1;
        if (!lnk[u] || match(lnk[u])) { lnk[u] = v; return 1; }
    }
    return 0;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d %d", &a[i], &b[i]);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d %d", &c[i], &d[i]);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (a[i] < c[j] && b[i] < d[j]) G[i].push_back(j + n);
        }
    }
    for (int i = 1; i <= n; i++) {
        memset(vis, 0, sizeof(vis));
        if (match(i)) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)
#define pb push_back

const long long MOD = 1000000007;


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

    bool flag = true;
    rep(i, s.size()){
        if(i % 2 == 1){
            if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){}
            else{
                flag = false;
                break;
            }
        }else{
            if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){}
            else{
                flag = false;
                break;
            }
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
lenb=len(str(bin(b)))-2

#a=2、b=8とする
#0000 0
#0001 1
#0010 2
#0011 3
#0100 4
#0101 5 
#0110 6
#0111 7
#1000
#各桁の1の個数を数えればよさそう
#i桁目のX番目までの１の数
#(x+1)%(2**(i+1))-(2*(i))

result=""

if a!=0:
    a-=1
if a%4 in [1,2]:
    a4="1"
else:
    a4="0"
if b%4 in [1,2]:
    b4="1"
else:
    b4="0"

if a4==b4:
    result="0"
else:
    result="1"

for i in range(1,lenb):
    a4=(max(0,(a+1)%(2**(i+1))-(2**(i))))%2
    b4=(max(0,(b+1)%(2**(i+1))-(2**(i))))%2
    if a4==b4:
        result="0"+result
    else:
        result="1"+result


print(int(result,2))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    // 1は未定, 0は減少, 2は増加
    int flag = 1;
    int ans = 0;
    rep(i, n) {
        if (i == 0) continue;
        if (flag == 1) {
            if (a[i-1] < a[i]) {
                flag = 2;
            } else if (a[i-1] > a[i]) {
                flag = 0;
            }
        } else if (flag == 0) {
            if (a[i-1] < a[i]) {
                ans++;
                flag = 1;
            }
        } else {
            if (a[i-1] > a[i]) {
                ans++;
                flag = 1;
            }
        }
    }
    ans++;
    cout << ans << endl;
}

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


int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n;
	cin >> n;
	vector<int> divcnt(n + 1);
	for(int x = 1; x <= n; ++ x){
		for(int y = x; y <= n; y += x){
			++ divcnt[y];
		}
	}
	int res = 0;
	for(auto c = 1; c < n; ++ c){
		res += divcnt[n - c];
	}
	cout << res << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 7140
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int max = 0;
		int maxValue = m / n;
		for (int i = 1; i <= maxValue; i++) {
		    if (m % i == 0) {
		        int ans = m / i;
		        if (ans <= maxValue) {
		            max = ans;
		            break;
		        }
		        max = i;
		    }
		}
		System.out.println(max);
	}
	
}


Measured memory_bytes: 23252
x1,y1,x2,y2 = map(int, input().split())


dx = y1 - y2
dy = x2 - x1

x3 = x2 + dx
y3 = y2 + dy

x4 = x3 + (x1-x2)
y4 = y3 + (y1-y2)

print("{} {} {} {}".format(x3,y3, x4, y4))



Measured memory_bytes: 9040
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;


//=============segment_tree============================
const int MAX_N = 1 << 17;
int nn;
vector<ll> dat(2 * MAX_N - 1, INF);

void init(ll n_) {
  nn = 1;
  while (nn < n_) {
    nn *= 2;
  }
}

void update(ll k, ll a) {
  k += nn - 1;
  dat.at(k) = a;
  while (k > 0) {
    k = (k - 1) / 2;
    dat.at(k) = min(dat.at(k * 2 + 1), dat.at(k * 2 + 2));
  }
}

ll query(ll a, ll b, ll k = 0, ll l = 0, ll r = nn) {
  if (r <= a || b <= l) {
    return INF;
  }
  if (a <= l && r <= b) {
    return dat.at(k);
  }
  else {
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
}
//=================================================

ll N;

ll get(ll l, ll x) {
  ll r = l + x + 1;
  ll res = INF;
  if (r >= N) {
    res = min(res, query(l, N));
    res = min(res, query(0, r % N));
  }
  else {
    res = min(res, query(l, r));
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll x;
  cin >> N >> x;
  init(N);
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    update(i, a);
  }
  ll ans = INF;
  for (ll i = 0; i < N; ++i) {
    ll temp = i * x;
    for (ll j = 0; j < N; ++j) {
      temp += get(j, i);
    }
    ans = min(ans, temp);
  }
  cout << ans << "\n";
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    long long N, P, ans = 1;
    cin >> N >> P;

    vector<pair<long long, long long> > ress;

    for(long long i = 2; i * i <= P; ++i) {
        if (P % i != 0) {
            continue;
        }

        long long ex = 0; // 指数
        while (P % i == 0) {
            ++ex;
            P /= i;
        }
        // 結果を保存
        ress.push_back({i, ex});
    }
    // 残った数字の処理
    if (P != 0) {
        ress.push_back({P, 1});
    }

    // 各素因数の指数を均等にN個に分ける(int/int = int)
    for (pair<long long, long long> res : ress) {
        if (res.second >= N ) {
            ans *= pow(res.first, (res.second / N));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4072
N = int(input())
D = list(map(int, input().split()))

def minGap(hour):
    ret = float('inf')
    for i in range(len(hour)):
        for j in range(len(hour)):
            if i == j:
                continue
            h1 = hour[i]
            h2 = hour[j]
            gap = max(h1, h2) - min(h1, h2)
            ret = min(ret, gap, 24 - gap)
    return ret

D.sort()
hour = [0]
for i, d in enumerate(D):
    if i % 2 == 0:
        hour.append(d)
    else:
        hour.append(24 - d)

print(minGap(hour))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
 
#define rep(i,n) for(ll i=0;i<(n;i++)
typedef long long ll;
using namespace std;

int main(void){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    while(B<=A){
        B *= 2;
        K--;
    }
    while(C<=B){
        C *= 2;
        K--;
    }
    if(K<0){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}
    

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	ull mod = pow(10, 9) + 7;
	uint N;
	cin >> N;

	vector<ull> bcnt(60);
	
	for(uint i=0; i<N; i++) {
		ull A;
		cin >> A;
	
		uint l = 0;
		while(A > 0) {
			bcnt[l++] += A & 1;
			A /= 2;
		}
	}
	
	ull ans = 0;
	for(uint i=0; i<60; i++) {
		ans = ((((((ull)pow(2, i) % mod) * bcnt[i]) % mod) * (N - bcnt[i])) + ans) % mod;
	}
	
	cout << ans % mod;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
i = 0
j = 0
k = 0
while k < 100:
    while k < 100:
        k = i * 4 + j * 7
        if k == n:
            print("Yes")
            exit()
        j += 1
    j = 0
    k = i * 4 + j * 7
    i += 1
print("No")

Measured memory_bytes: 3060
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
A2 = [0]*(N+1)
for i in range(K):
    for j in range(N):
        g = math.ceil(j+1-A[j]-0.5)
        if g<1:
            g=1
        h = math.floor(j+1+A[j]+0.5)
        if h>N:
            h=N
        A2[g-1]+=1
        A2[h]-=1
    A[0]=A2[0]
    for j in range(1, N):
        A[j]=A[j-1]+A2[j]
    A2 = [0]*(N+1)
    c = 0
    for p in range(N):
        c+=A[p]
    if c >= N*N:
        break

print(*A)

Measured memory_bytes: 159300
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  ll n,b,c=0,ans=0;
  cin>>n;
  ll a[n+1];
  a[0]=0;
  rep(i,0,n){
    cin>>b;
    a[i+1]=b+c;
    c=a[i+1];
  }
  c=1;
  sort(a,a+n+1);
  rep(i,1,n+1){
    if(a[i]!=a[i-1]){
      ans+=c*(c-1)/2;
      c=1;
    }
    else c++;
  }
  ans+=c*(c-1)/2;
  co(ans);
    
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
const int MAXN = (1 << 20);

int n;
int64_t a[MAXN];

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

void solve()
{
	sort(a, a + n);

    int64_t sum = 0;
	for(int i = 0; i < n - 1; i++)
		sum += a[i];

	int ans = 1;
	for(int j = n - 2; j >= 0; j--)
	{
		if(2 * sum < a[j + 1]) break;
		ans++;
		sum -= a[j];
	}

	cout << ans << endl;
}

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

	read();
	solve();
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

int main(){
  ll H,W;
  cin >> H >> W;
  vec A(H),B(H);
  rep(i,H){
    cin >> A.at(i) >> B.at(i);
  }
  set<P> C,D;
  rep(i,W){
    C.insert(P(i+1,0));
    D.insert(P(0,i+1));
  }
  rep(i,H){
    if(C.empty()){
      cout << -1 << endl;
    }else{
      P x=P(0,0);
      while(C.lower_bound(P(A.at(i),0))!=C.end()&&*C.lower_bound(P(A.at(i),0))<P(B.at(i)+1,0)){
        P a=*C.lower_bound(P(A.at(i),0));
        C.erase(a);
        D.erase(P(a.second,a.first));
        if(x==P(0,0)){
          x=a;
        }else{
          if(a.first-x.first>a.second-x.second){
            x=a;
          }
        }
        if(C.lower_bound(P(A.at(i),0))==C.end()||*C.lower_bound(P(A.at(i),0))>=P(B.at(i)+1,0)){
          if(B.at(i)!=W){
            C.insert(P(B.at(i)+1,x.second+B.at(i)+1-x.first));
            D.insert(P(x.second+B.at(i)+1-x.first,B.at(i)+1));
          }
        }
      }
      if(C.empty()){
        cout << -1 << endl;
      }else{
        P a=*begin(D);
        cout << a.first+i+1 << endl;
      }
    }
  }
}

Measured memory_bytes: 31392
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 H1, M1, H2, M2, K;
  std::cin >> H1 >> M1 >> H2 >> M2 >> K;
  std::cout << (H2 * 60 + M2 - K) - (H1 * 60 + M1) << std::endl;
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
	int a,b,c,d,e,k;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
	int max,min;
	max=a;min=a;
	if(max<b) max=b;
	if(max<c) max=c;
	if(max<d) max=d;
	if(max<e) max=e;
	if(min>b) min=b;
	if(min>c) min=c;
	if(min>d) min=d;
	if(min>e) min=e;
	if(max-min<=k)
        printf("Yay!");
    else
        printf(":(");
	return 0;
}




Measured memory_bytes: 128
A,B=gets.split.map(&:to_i)
require "prime"
class Integer
    def divisor_list
        return [1] if self == 1
        (1..Math.sqrt(self).to_i).select do |i|
            self%i == 0
        end.map {|e| [e, self/e]}.flatten.uniq.sort
    end

    def prime?
        s=prime**(1/2.0).to_i+1
        for i in 2..s
            if self%i == 0
                return false
            end
        end
        return true
    end
end
list=(A.divisor_list & B.divisor_list)
list.delete_if{|e|e!=1 && !Prime.prime?(e)}
p list.size


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; i++) cin >> h[i];
  vector<int> DP(N, 0);
  DP[1] = abs(h[1] - h[0]);
  int cost, min_cost;
  for(int i = 2; i < N; i++) {
    min_cost = DP[i - 1] + abs(h[i] - h[i - 1]);
    for(int j = 2; j <= K; j++) {
      if(i - j < 0) break;
      cost = DP[i - j] + abs(h[i] - h[i - j]);
      if(cost < min_cost) min_cost = cost;
    }
    DP[i] = min_cost;
  }
  cout << DP[N - 1] << endl;
}

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

#define ll long long

int a[110] , f[110];

int main()
{
    int c , n , m;
    cin >> n >> m >> c;

    for (int i = 1 ; i <= m ; i++)   scanf("%d",&a[i]);

    int x;
    for (int i = 1 ; i <= n ; i++)
    {
        f[i] = 0;
        for (int j = 1 ; j <= m ; j++)
            scanf("%d",&x) , f[i] += a[j] * x;
    }
    int res = 0;
    for (int i = 1 ; i <= n ; i++)
        if (f[i] + c > 0 ) res++;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool vis[3][3];
int main(){
	bool flag=false;
	int st[9],a,k[100];
	for(int i=0;i<9;i++)
		cin>>st[i];
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>k[i];
		for(int j=0;j<9;j++)
			if(k[i]==st[j]){
				int x=j/3,y=j%3;
				vis[x][y]=true; 
			}
	}
	for(int i=0;i<3;i++){
		if(vis[i][0]==vis[i][1]&&vis[i][1]==vis[i][2]&&vis[i][0]==true)
			flag=true;
		if(vis[0][i]==vis[1][i]&&vis[1][i]==vis[2][i]&&vis[0][i]==true)
			flag=true;
	}
	if(vis[0][0]==vis[1][1]&&vis[1][1]==vis[2][2]&&vis[0][0]==true)
		flag=true;
	if(vis[2][0]==vis[1][1]&&vis[1][1]==vis[0][2]&&vis[2][0]==true)
		flag=true;
	if(flag==true)
		cout<<"Yes";
	else
		cout<<"No";
	return 0; 
}

Measured memory_bytes: 256
// while( !(succeed == try()) );

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

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha
vector<vector<int>> adj(100001);
int n;
int x, y;

int dist[2001];
int ans[2001];

void djikstra(int src){

	loop(i,0,2001)	dist[i] = inf;

	dist[src] = 0;
	set<pair<int, int>> s;

	s.insert({0, src});

	while(!s.empty()){

		set<pair<int, int>>::iterator itr = s.begin();
		int v = (*itr).ss;
		s.erase(s.begin());

		loop(i, 0, adj[v].size()){
			if(dist[adj[v][i]] > dist[v]+1){

				if(dist[adj[v][i]]!=inf){
					s.erase({dist[adj[v][i]], adj[v][i]});
				}

				dist[adj[v][i]] = dist[v]+1;
				s.insert({dist[adj[v][i]], adj[v][i]});
			}
		}

	}
}


void alpha()
{	
	cin>>n;

	loop(i,1,n+1){
		if(i<n) adj[i].pb(i+1);
		if(i<n) adj[i+1].pb(i);
	}

	cin>>x>>y;
	adj[x].pb(y);
	adj[y].pb(x);

	// loop(i,1,n+1){
	// 	cout<<i<<" -> ";
	// 	loop(j,0,adj[i].size()){
	// 		cout<<adj[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	// cout<<endl;

	loop(i,1,n+1) {
		djikstra(i);
		loop(j,i,n+1) ans[dist[j]]++;
	}


	loop(i,1,n) cout<<ans[i]<<endl;
	cout<<endl;
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 2688
N, Q = map(int, input().split())
childrens = [[] for i in range(0, N)]
for i in range(0, N-1):
    a, b = map(int, input().split())
    childrens[a-1].append(b-1)
results = [0 for i in range(0, N)]
for i in range(0, Q):
    p, x = map(int, input().split())
    results[p-1] += x

for i in range(0, N):
    for child in childrens[i]:
        results[child] += results[i]

print(' '.join(map(str, results)))


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

int main()
{

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

       cin>>a[i];
   }
   int dp[n+1];
   dp[1]=0;
   dp[2]=abs(a[2]-a[1]);

   for(int i=3;i<=n;i++)
   {

       dp[i]  = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
   }

   cout<<dp[n];


}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



void dfs(int on, int par, vector<int> &ans, vector<vector<int>> &E){
    for(int to:E[on]){
        if(to == par) continue;
        ans[to] += ans[on];
        dfs(to, on, ans, E);
    }
    return;
}

int main(){
    int N, Q; cin >> N >> Q;
    vector<vector<int>> E(N);
    
    
    for(int i=0; i<N-1; i++){
        int a, b; cin >> a >> b;
        a--;
        b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    
    vector<int> ans(N);
    for(int i=0; i<Q; i++){
        int p, x; cin >> p >> x;
        p--;
        ans[p] += x;
    }
    
    dfs(0, 0, ans, E);
    for(int i=0; i<N; i++){
        cout << ans[i] << endl;
    }
    
    return 0;
}





Measured memory_bytes: 29696
n,m,X,Y=map(int,input().split( ))
x_l=list(map(int,input().split( )))
y_l=list(map(int,input().split( )))
z_l=list(range(X+1,Y+1))
ans='War'
for z in z_l:
    x=list(filter(lambda x: x<z, x_l))
    y=list(filter(lambda y: y>=z, y_l))
    if len(x)==n and len(y)==m:
        ans=('No War')
print(ans)

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

int main() {
  int N;
  cin >>N;
 
  if (N/10%111==0) {
    cout << "Yes" << endl;
  }
  
  else if (N%1000%111==0) {
    cout<<"Yes"<<endl;
  }
    
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
      int y = sc.nextInt();
      int count = 0;
      boolean hit = false;
      for(int i = 0;i<=x;i++){
         if(4*(x-i)+2*i==y){
             hit = true;
         }
      }
      if(hit){
         System.out.println("Yes");
      }else{
         System.out.println("No");
      }
   }
}

Measured memory_bytes: 35776
#include <bits/stdc++.h>
using namespace std;
 
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long
 
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >>d;
    cout << max(a * b, c * d) << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    for (int i = 0; i < (1 << 3); i++) {
        int sum = S.at(0) - '0';
        for (int j = 0; j < 3; j++) {
            if ((i >> j) & 1) {
                sum += S.at(j+1) - '0';
            }
            else {
                sum -= S.at(j+1) - '0';
            }
        }
        if (sum == 7) {
            cout << S.at(0) << (i >> 0 & 1 ? '+' : '-') << S.at(1) << (i >> 1 & 1 ? '+' : '-') << S.at(2) << (i >> 2 & 1 ? '+' : '-') << S.at(3) << "=7" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	long long n, town[5] = {0}, min = -1;
	scanf("%lld", &n);getchar();
	for(int i = 0; i < 5; i++){
		scanf("%lld", &town[i]);getchar();
		if(min == -1 || town[i] < town[min]){
			min = i;
		}
	}
  	if(n <= town[min]){
    	printf("5\n");
      	return 0;
    }
	printf("%lld\n", n % town[min] == 0 ? n / town[min] + 4 : n / town[min] + 5);
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a,b,ans = 0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try{
        String line = reader.readLine();
        String[] splitted = line.split(" ");
          if(Integer.parseInt(splitted[0]) > Integer.parseInt(splitted[1])){
            a = Integer.parseInt(splitted[0]);
            b = Integer.parseInt(splitted[1]);
          }else{
            a = Integer.parseInt(splitted[1]);
            b = Integer.parseInt(splitted[0]);
          }
      
		}catch(Exception e){
      a = 0;
      b = 0;
    }

    while(true){
      ans = b;
      b = a % b;
      a = ans;
      if (b == 0) break;
    }

    System.out.println(ans);

	}
}


Measured memory_bytes: 24464
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> v(n);
    rep(i,n){
        cin >> v[i];
    }
    ll ans=0;
    for(int a=0;a<=k;a++){
        for(int b=0;b<=k-a;b++){
            if(a+b>n) continue;
            int d = k-a-b;
            ll sum=0;
            vector<ll> s;
            for(int i=0;i<a;i++){
                sum += v[i];
                s.push_back(v[i]);
            }
            for(int j=n-b;j<n;j++){
                sum += v[j];
                s.push_back(v[j]);
            }
            sort(s.begin(),s.end());
            for(int m=0;m<d;m++){
                if(m>=s.size()) break;
                if(s[m]>0) break;
                sum -= s[m];
            }
            ans = max(ans,sum);
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  int A;
  cin >> N;
  cin >> A;
  
  int r = N % 500;
  
  if (r <= A) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n, m, i;
	string str, chr = "ABC";
	cin >> n >> m;
	cin >> str;
	for(i = 0; i < 3; i++){
		if(str[m-1]==chr[i]){
			str[m-1] = chr[i]+(int)('a'-'A');
		}
	}
	cout << str << endl;
	return 0;
} 

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

using namespace std;
using ll = long long;

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int solve() {
  unordered_map<string, int> cnt;
  int N; // N blue + 1, M red - 1
  cin >> N;
  while (N--) {
    string str;
    cin >> str;
    cnt[str] += 1;
  }
  int M;
  cin >> M;
  while (M--) {
    string str;
    cin >> str;
    cnt[str] -= 1;
  }
  int ans {0};
  for (const pair<string, int>& s : cnt) {
    ans = max(ans, s.second);
  }
  return ans; 
}

int main(int argc, char* argv[]) {
  cout << solve() << '\n';
  return 0;
}

Measured memory_bytes: 256
from math import *
a,b,h,m = map(int, input().split())
h = h + m/60
theta_h = (h / 12) * 2 * pi
theta_m = (m / 60) * 2 * pi

distance = (a * cos(theta_h) - b * cos(theta_m))**2 + (a * sin(theta_h) - b * sin(theta_m))**2
print(sqrt(distance))


Measured memory_bytes: 62660
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <cstring>
using namespace std;
typedef long long ll;
ll INF=1<<29;

int main(){
	ios::sync_with_stdio(false);
	int n,k;
	string s;
	cin>>n>>s>>k;
	char a=s[k-1];
	for(int i=0;i<n;i++){
		if(s[i]!=a){
			cout<<"*";
		}else{
			cout<<s[i];
		}
	}
	return 0;
}


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

int main(void){
    int n, q, c = 0, s[10001], t[501];
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> s[i];
    cin >> q;
    for(int i = 0; i < q; ++i) cin >> t[i];

    for(int i = 0; i < q; ++i){
        int j = 0;
        s[n] = t[i];
        while(s[j] != t[i]) j++;
        if(j == n) continue;
        c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3120
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void task()
{
    //code here...
    
    int n;
    cin >> n;
    
    string s;
    set<string> ss;
    
    while(n--){
		cin >> s;
		ss.insert(s);
	}
	
	cout << (int)ss.size() << "\n";
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}




Measured memory_bytes: 19188
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>    // for pair
using namespace std;

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i, n) for(ll i = 1; i < (n); ++i)
#define rep4(i, start, end, step) for (ll i = (start); i < (end); i += (step))

#define BIG_PRIME 1000000007
#define BP_remainder(x) ((x) % BIG_PRIME)

#define INF 0x3fffFFFF
#define INF_NEG (INF * -1)
#define INF_LONG (INF << 32)
#define INF_LONG_NEG (INF_LONG * -1L)

typedef long long ll;
typedef pair<ll, ll> lpair;
typedef char str255[256];
// char *用、strlen の ll 版
ll StrLen(char *s) { for(ll ptr = 0L;; ++ptr) if(!s[ptr]) return ptr; } 
// char * の後ろから n 文字削除, 削除後の文字数を返す
ll StrDel(char *s, int n) { ll l = StrLen(s); s[l - n + 1L] = '\0'; return l - n; }
// 正の整数の桁数
ll NumDigits(ll l){ char s[30]; sprintf(s, "%lld", l); return StrLen(s); }

int isFirst = 1;
template <class T> 
void print(T t) { if (isFirst) cout << t, isFirst = 0; else cout << " " << t; }

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

ll gcd(ll a, ll b){ if (a % b) return (gcd(b, a % b)); else return b; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

void swap(int *a, int *b)
{ int tmp = *a; *a = *b; *b = tmp; }

signed main()
{
    int X, Y, Z; cin >> X >> Y >> Z;

    int A = X, B = Y, C = Z;
    swap(&A, &B);
    swap(&A, &C);

    print(A); print(B); print(C);
    puts("");

    return 0;
}


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

int64_t FormulaSum(int64_t Num){
  if(Num < 10){
    return Num;
  }
  
  int64_t sum = Num;
  int64_t exp2 = 1;
  int64_t exp10 = 1;
  while (Num / 10 >= exp10) {
    exp10 *= 10;
    sum += Num / exp10 * exp2;
    sum += FormulaSum(Num % exp10);
    exp2 *= 2;
  }

  return sum;
}

int main() {
  int64_t S;
  cin >> S;
  
  cout << FormulaSum(S) <<endl;
  
  return 0;
}


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

int main() {
	for(int n, m; cin >> n >> m && (n | m);) {
		vector<int> players(n);
		iota(players.begin(), players.end(), 1);

		int idx = m - 1;
		while(players.size() > 1) {
			players.erase(players.begin() + idx);
			idx = (idx + m - 1) % players.size();
		}

		cout << players.front() << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	string mae, usiro;
	int t, f;
	char c;
	int i, j, k, q;
	bool muki = true;

	cin >> s;
	cin >> q;
	for (j = 0; j < q; j++) {
		cin >> t;
		if (t == 1) {
			if (muki == true) {
				muki = false;
			}
			else {
				muki = true;
			}
		}
		else {
			cin >> f >> c;
			if (f == 1 && muki == true) {
				mae.push_back(c);
			}
			else if (f == 2 && muki == false) {
				mae.push_back(c);
			}
			else {
				usiro.push_back(c);
			}
		}

	}

	if (muki == true) {
		for (i = mae.length() - 1; i >= 0; i--) {
			cout << mae[i];
		}
		cout << s;
		for (i = 0; i < usiro.length(); i++) {
			cout << usiro[i];
		}
		cout << endl;
	}
	else {
		for (i = usiro.length() - 1; i >= 0; i--) {
			cout << usiro[i];
		}
		for (i = s.length() - 1; i >= 0; i--) {
			cout << s[i];
		}
		for (i = 0; i < mae.length(); i++) {
			cout << mae[i];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 1088